File: qwt_plot_zoomer.h

package info (click to toggle)
libqwt 4.2.0-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,856 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 59
file content (134 lines) | stat: -rw-r--r-- 4,194 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

// vim: expandtab

#ifndef QWT_PLOT_ZOOMER
#define QWT_PLOT_ZOOMER

#include <qvaluestack.h>
#include "qwt_double_rect.h"
#include "qwt_plot_picker.h"

#if defined(QWT_TEMPLATEDLL)
// MOC_SKIP_BEGIN
template class QWT_EXPORT QValueStack<QwtDoubleRect>;
// MOC_SKIP_END
#endif

/*!
  \brief QwtPlotZoomer provides stacked zooming for a plot widget

  QwtPlotZoomer offers rubberband selections on the plot canvas, 
  translating the selected rectangles into plot coordinates and
  adjusting the axes to them. Zooming can repeated as often as 
  possible, limited only by maxStackDepth() or minZoomSize(). 
  Each rectangle is pushed on a stack. 

  Zoom rectangles can be selected depending on selectionFlags() using the
  mouse or keyboard (QwtEventPattern, QwtPickerMachine).
  QwtEventPattern::MouseSelect3/QwtEventPattern::KeyUndo, 
  or QwtEventPattern::MouseSelect6/QwtEventPattern::KeyRedo 
  walk up and down the zoom stack.
  QwtEventPattern::MouseSelect2 or QwtEventPattern::KeyHome unzoom to
  the initial size. 
  
  QwtPlotZoomer is tailored for plots with one x and y axis, but it is
  allowed to attach a second QwtPlotZoomer for the other axes, even when
  one or both of them are disabled. In most situations it is 
  recommended to disable rubber band and cursor label for one of the zoomers.

  \note The realtime example includes an derived zoomer class that adds 
        scrollbars to the plot canvas.

  \warning Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is FALSE
           leaves the axis in an 'intermediate' state.
           In this case, to prevent buggy behaviour, your must call
       QwtPlot::replot() before calling QwtPlotPicker::scaleRect(),
       QwtPlotZoomer::scaleRect(), QwtPlotPicker::QwtPlotPicker() or
       QwtPlotZoomer::QwtPlotZoomer().
           This quirk will be removed in a future release.
*/

class QWT_EXPORT QwtPlotZoomer: public QwtPlotPicker
{
    Q_OBJECT
public:
    QwtPlotZoomer(QwtPlotCanvas *, const char *name = 0);
    QwtPlotZoomer(int xAxis, int yAxis, 
        QwtPlotCanvas *, const char *name = 0);
    QwtPlotZoomer(int xAxis, int yAxis, int selectionFlags,
        DisplayMode cursorLabelMode, QwtPlotCanvas *, const char *name = 0);

    virtual void setZoomBase();
    virtual void setZoomBase(const QwtDoubleRect &);

    QwtDoubleRect zoomBase() const;
    QwtDoubleRect zoomRect() const;

    virtual void setAxis(int xAxis, int yAxis);

    void setMaxStackDepth(int);
    int maxStackDepth() const;

    const QValueStack<QwtDoubleRect> &zoomStack() const;
    uint zoomRectIndex() const;

    virtual void setSelectionFlags(int);

public slots:
    void moveBy(double x, double y);
    virtual void move(double x, double y);

    virtual void zoom(const QwtDoubleRect &);
    virtual void zoom(int up);

signals:
    /*!
      A signal emitting the zoomRect(), when the plot has been 
      zoomed in or out.

      \param rect Current zoom rectangle.
      \warning zoomed() is only emitted after selections in end(), but never
               in zoom().
    */

    void zoomed(const QwtDoubleRect &rect);

protected:
    QValueStack<QwtDoubleRect> &zoomStack();

    virtual void rescale();

    virtual QwtDoubleSize minZoomSize() const;

    virtual void widgetMouseReleaseEvent(QMouseEvent *);
    virtual void widgetKeyPressEvent(QKeyEvent *);

    virtual void begin();
    virtual bool end(bool ok = TRUE);
    virtual bool accept(QPointArray &) const;

private:
    void init(int selectionFlags = RectSelection & ClickSelection, 
        DisplayMode cursorLabelMode = ActiveOnly);

    uint d_zoomRectIndex;
    QValueStack<QwtDoubleRect> d_zoomStack;

    int d_maxStackDepth;
};
            
#endif

// Local Variables:
// mode: C++
// c-file-style: "stroustrup"
// indent-tabs-mode: nil
// End: