QwtPlotZoomer provides stacked zooming for a plot widget. More...
#include <qwt_plot_zoomer.h>
Classes | |
class | PrivateData |
Public Slots | |
void | moveBy (double dx, double dy) |
virtual void | moveTo (const QPointF &) |
virtual void | zoom (const QRectF &) |
Zoom in. More... | |
virtual void | zoom (int offset) |
Zoom in or out. More... | |
Public Slots inherited from QwtPicker | |
void | setEnabled (bool) |
En/disable the picker. More... | |
Signals | |
void | zoomed (const QRectF &rect) |
Signals inherited from QwtPlotPicker | |
void | appended (const QPointF &pos) |
void | moved (const QPointF &pos) |
void | selected (const QPointF &pos) |
void | selected (const QRectF &rect) |
void | selected (const QVector< QPointF > &pa) |
Signals inherited from QwtPicker | |
void | activated (bool on) |
void | appended (const QPoint &pos) |
void | changed (const QPolygon &selection) |
void | moved (const QPoint &pos) |
void | removed (const QPoint &pos) |
void | selected (const QPolygon &polygon) |
Public Member Functions | |
int | maxStackDepth () const |
QwtPlotZoomer (QWidget *, bool doReplot=true) | |
Create a zoomer for a plot canvas. More... | |
QwtPlotZoomer (int xAxis, int yAxis, QWidget *, bool doReplot=true) | |
Create a zoomer for a plot canvas. More... | |
virtual void | setAxis (int xAxis, int yAxis) override |
void | setMaxStackDepth (int) |
Limit the number of recursive zoom operations to depth. More... | |
virtual void | setZoomBase (bool doReplot=true) |
virtual void | setZoomBase (const QRectF &) |
Set the initial size of the zoomer. More... | |
void | setZoomStack (const QStack< QRectF > &, int zoomRectIndex=-1) |
Assign a zoom stack. More... | |
QRectF | zoomBase () const |
QRectF | zoomRect () const |
uint | zoomRectIndex () const |
const QStack< QRectF > & | zoomStack () const |
virtual | ~QwtPlotZoomer () |
Public Member Functions inherited from QwtPlotPicker | |
QWidget * | canvas () |
const QWidget * | canvas () const |
QwtPlot * | plot () |
const QwtPlot * | plot () const |
QwtPlotPicker (QWidget *canvas) | |
Create a plot picker. More... | |
QwtPlotPicker (int xAxis, int yAxis, QWidget *) | |
QwtPlotPicker (int xAxis, int yAxis, RubberBand rubberBand, DisplayMode trackerMode, QWidget *) | |
int | xAxis () const |
Return x axis. More... | |
int | yAxis () const |
Return y axis. More... | |
virtual | ~QwtPlotPicker () |
Destructor. More... | |
Public Member Functions inherited from QwtPicker | |
virtual void | drawRubberBand (QPainter *) const |
virtual void | drawTracker (QPainter *) const |
virtual bool | eventFilter (QObject *, QEvent *) |
Event filter. More... | |
bool | isActive () const |
bool | isEnabled () const |
QWidget * | parentWidget () |
Return the parent widget, where the selection happens. More... | |
const QWidget * | parentWidget () const |
Return the parent widget, where the selection happens. More... | |
virtual QPainterPath | pickArea () const |
QwtPicker (QWidget *parent) | |
QwtPicker (RubberBand rubberBand, DisplayMode trackerMode, QWidget *) | |
ResizeMode | resizeMode () const |
RubberBand | rubberBand () const |
virtual QRegion | rubberBandMask () const |
QPen | rubberBandPen () const |
QPolygon | selection () const |
void | setResizeMode (ResizeMode) |
Set the resize mode. More... | |
void | setRubberBand (RubberBand) |
void | setRubberBandPen (const QPen &) |
void | setStateMachine (QwtPickerMachine *) |
void | setTrackerFont (const QFont &) |
void | setTrackerMode (DisplayMode) |
Set the display mode of the tracker. More... | |
void | setTrackerPen (const QPen &) |
const QwtPickerMachine * | stateMachine () const |
QwtPickerMachine * | stateMachine () |
QFont | trackerFont () const |
virtual QRegion | trackerMask () const |
DisplayMode | trackerMode () const |
QPen | trackerPen () const |
QPoint | trackerPosition () const |
virtual QRect | trackerRect (const QFont &) const |
virtual | ~QwtPicker () |
Destructor. More... | |
Public Member Functions inherited from QwtEventPattern | |
void | initKeyPattern () |
void | initMousePattern (int numButtons) |
bool | keyMatch (KeyPatternCode, const QKeyEvent *) const |
Compare a key event with an event pattern. More... | |
const QVector< KeyPattern > & | keyPattern () const |
QVector< KeyPattern > & | keyPattern () |
bool | mouseMatch (MousePatternCode, const QMouseEvent *) const |
Compare a mouse event with an event pattern. More... | |
const QVector< MousePattern > & | mousePattern () const |
QVector< MousePattern > & | mousePattern () |
QwtEventPattern () | |
void | setKeyPattern (KeyPatternCode, int keyCode, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier) |
void | setKeyPattern (const QVector< KeyPattern > &) |
Change the key event patterns. More... | |
void | setMousePattern (MousePatternCode, Qt::MouseButton button, Qt::KeyboardModifiers=Qt::NoModifier) |
void | setMousePattern (const QVector< MousePattern > &) |
Change the mouse event patterns. More... | |
virtual | ~QwtEventPattern () |
Destructor. More... | |
Protected Member Functions | |
virtual bool | accept (QPolygon &) const override |
Check and correct a selected rectangle. More... | |
virtual void | begin () override |
virtual bool | end (bool ok=true) override |
virtual QSizeF | minZoomSize () const |
Limit zooming by a minimum rectangle. More... | |
virtual void | rescale () |
virtual void | widgetKeyPressEvent (QKeyEvent *) override |
virtual void | widgetMouseReleaseEvent (QMouseEvent *) override |
Protected Member Functions inherited from QwtPlotPicker | |
virtual void | append (const QPoint &) |
QRectF | invTransform (const QRect &) const |
QPointF | invTransform (const QPoint &) const |
virtual void | move (const QPoint &) |
QRectF | scaleRect () const |
virtual QwtText | trackerText (const QPoint &) const |
virtual QwtText | trackerTextF (const QPointF &) const |
Translate a position into a position string. More... | |
QRect | transform (const QRectF &) const |
QPoint | transform (const QPointF &) const |
Protected Member Functions inherited from QwtPicker | |
virtual QPolygon | adjustedPoints (const QPolygon &) const |
Map the pickedPoints() into a selection() More... | |
const QPolygon & | pickedPoints () const |
virtual void | remove () |
virtual void | reset () |
const QwtWidgetOverlay * | rubberBandOverlay () const |
virtual void | stretchSelection (const QSize &oldSize, const QSize &newSize) |
const QwtWidgetOverlay * | trackerOverlay () const |
virtual void | transition (const QEvent *) |
virtual void | updateDisplay () |
Update the state of rubber band and tracker label. More... | |
virtual void | widgetEnterEvent (QEvent *) |
virtual void | widgetKeyReleaseEvent (QKeyEvent *) |
virtual void | widgetLeaveEvent (QEvent *) |
virtual void | widgetMouseDoubleClickEvent (QMouseEvent *) |
virtual void | widgetMouseMoveEvent (QMouseEvent *) |
virtual void | widgetMousePressEvent (QMouseEvent *) |
virtual void | widgetWheelEvent (QWheelEvent *) |
Protected Member Functions inherited from QwtEventPattern | |
virtual bool | keyMatch (const KeyPattern &, const QKeyEvent *) const |
Compare a key event with an event pattern. More... | |
virtual bool | mouseMatch (const MousePattern &, const QMouseEvent *) const |
Compare a mouse event with an event pattern. More... | |
Private Member Functions | |
void | init (bool doReplot) |
Init the zoomer, used by the constructors. More... | |
Private Attributes | |
PrivateData * | d_data |
Additional Inherited Members | |
Public Types inherited from QwtPicker | |
enum | DisplayMode { AlwaysOff, AlwaysOn, ActiveOnly } |
Display mode. More... | |
enum | ResizeMode { Stretch, KeepSize } |
enum | RubberBand { NoRubberBand = 0, HLineRubberBand, VLineRubberBand, CrossRubberBand, RectRubberBand, EllipseRubberBand, PolygonRubberBand, UserRubberBand = 100 } |
Public Types inherited from QwtEventPattern | |
enum | KeyPatternCode { KeySelect1, KeySelect2, KeyAbort, KeyLeft, KeyRight, KeyUp, KeyDown, KeyRedo, KeyUndo, KeyHome, KeyPatternCount } |
Symbolic keyboard input codes. More... | |
enum | MousePatternCode { MouseSelect1, MouseSelect2, MouseSelect3, MouseSelect4, MouseSelect5, MouseSelect6, MousePatternCount } |
Symbolic mouse input codes. More... | |
Properties inherited from QwtPicker | |
bool | isEnabled |
ResizeMode | resizeMode |
RubberBand | rubberBand |
QPen | rubberBandPen |
QFont | trackerFont |
DisplayMode | trackerMode |
QPen | trackerPen |
QwtPlotZoomer provides stacked zooming for a plot widget.
QwtPlotZoomer selects rectangles from user inputs ( mouse or keyboard ) translates them into plot coordinates and adjusts the axes to them. The selection is supported by a rubber band and optionally by displaying the coordinates of the current mouse position.
Zooming can be repeated as often as possible, limited only by maxStackDepth() or minZoomSize(). Each rectangle is pushed on a stack.
The default setting how to select rectangles is a QwtPickerDragRectMachine with the following bindings:
To traverse the zoom stack the following bindings are used:
The setKeyPattern() and setMousePattern() functions can be used to configure the zoomer actions. The following example shows, how to configure the 'I' and 'O' keys for zooming in and out one position on the zoom stack. The "Home" key is used to "unzoom" the plot.
QwtPlotZoomer is tailored for plots with one x and y axis, but it is allowed to attach a second QwtPlotZoomer ( without rubber band and tracker ) for the other axes.
Definition at line 79 of file qwt_plot_zoomer.h.
|
explicit |
Create a zoomer for a plot canvas.
The zoomer is set to those x- and y-axis of the parent plot of the canvas that are enabled. If both or no x-axis are enabled, the picker is set to QwtPlot::xBottom. If both or no y-axis are enabled, it is set to QwtPlot::yLeft.
The zoomer is initialized with a QwtPickerDragRectMachine, the tracker mode is set to QwtPicker::ActiveOnly and the rubber band is set to QwtPicker::RectRubberBand
canvas | Plot canvas to observe, also the parent object |
doReplot | Call QwtPlot::replot() for the attached plot before initializing the zoomer with its scales. This might be necessary, when the plot is in a state with pending scale changes. |
Definition at line 109 of file qwt_plot_zoomer.cpp.
|
explicit |
Create a zoomer for a plot canvas.
The zoomer is initialized with a QwtPickerDragRectMachine, the tracker mode is set to QwtPicker::ActiveOnly and the rubber band is set to QwtPicker;;RectRubberBand
xAxis | X axis of the zoomer |
yAxis | Y axis of the zoomer |
canvas | Plot canvas to observe, also the parent object |
doReplot | Call QwtPlot::replot() for the attached plot before initializing the zoomer with its scales. This might be necessary, when the plot is in a state with pending scale changes. |
Definition at line 133 of file qwt_plot_zoomer.cpp.
|
virtual |
Definition at line 158 of file qwt_plot_zoomer.cpp.
|
overrideprotectedvirtual |
Check and correct a selected rectangle.
Reject rectangles with a height or width < 2, otherwise expand the selected rectangle to a minimum size of 11x11 and accept it.
Reimplemented from QwtPicker.
Reimplemented in PlotZoomer.
Definition at line 567 of file qwt_plot_zoomer.cpp.
|
overrideprotectedvirtual |
Rejects selections, when the stack depth is too deep, or the zoomed rectangle is minZoomSize().
Reimplemented from QwtPicker.
Definition at line 609 of file qwt_plot_zoomer.cpp.
Expand the selected rectangle to minZoomSize() and zoom in if accepted.
ok | If true, complete the selection and emit selected signals otherwise discard the selection. |
Reimplemented from QwtPlotPicker.
Definition at line 643 of file qwt_plot_zoomer.cpp.
|
private |
Init the zoomer, used by the constructors.
Definition at line 142 of file qwt_plot_zoomer.cpp.
int QwtPlotZoomer::maxStackDepth | ( | ) | const |
Definition at line 201 of file qwt_plot_zoomer.cpp.
|
protectedvirtual |
Limit zooming by a minimum rectangle.
Reimplemented in PlotZoomer.
Definition at line 597 of file qwt_plot_zoomer.cpp.
|
slot |
Move the current zoom rectangle.
dx | X offset |
dy | Y offset |
Definition at line 520 of file qwt_plot_zoomer.cpp.
|
virtualslot |
Move the the current zoom rectangle.
pos | New position |
Definition at line 534 of file qwt_plot_zoomer.cpp.
|
protectedvirtual |
Adjust the observed plot to zoomRect()
Definition at line 416 of file qwt_plot_zoomer.cpp.
|
overridevirtual |
Reinitialize the axes, and set the zoom base to their scales.
xAxis | X axis |
yAxis | Y axis |
Reimplemented from QwtPlotPicker.
Definition at line 455 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::setMaxStackDepth | ( | int | depth | ) |
Limit the number of recursive zoom operations to depth.
A value of -1 set the depth to unlimited, 0 disables zooming. If the current zoom rectangle is below depth, the plot is unzoomed.
depth | Maximum for the stack depth |
Definition at line 174 of file qwt_plot_zoomer.cpp.
|
virtual |
Reinitialized the zoom stack with scaleRect() as base.
doReplot | Call QwtPlot::replot() for the attached plot before initializing the zoomer with its scales. This might be necessary, when the plot is in a state with pending scale changes. |
Definition at line 235 of file qwt_plot_zoomer.cpp.
|
virtual |
Set the initial size of the zoomer.
base is united with the current scaleRect() and the zoom stack is reinitialized with it as zoom base. plot is zoomed to scaleRect().
base | Zoom base |
Definition at line 261 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::setZoomStack | ( | const QStack< QRectF > & | zoomStack, |
int | zoomRectIndex = -1 |
||
) |
Assign a zoom stack.
In combination with other types of navigation it might be useful to modify to manipulate the complete zoom stack.
zoomStack | New zoom stack |
zoomRectIndex | Index of the current position of zoom stack. In case of -1 the current position is at the top of the stack. |
Definition at line 383 of file qwt_plot_zoomer.cpp.
|
overrideprotectedvirtual |
Qt::Key_Plus zooms in, Qt::Key_Minus zooms out one position on the zoom stack, Qt::Key_Escape zooms out to the zoom base.
Changes the current position on the stack, but doesn't pop any rectangle.
Reimplemented from QwtPicker.
Definition at line 497 of file qwt_plot_zoomer.cpp.
|
overrideprotectedvirtual |
Qt::MidButton zooms out one position on the zoom stack, Qt::RightButton to the zoom base.
Changes the current position on the stack, but doesn't pop any rectangle.
Reimplemented from QwtPicker.
Reimplemented in PlotZoomer.
Definition at line 474 of file qwt_plot_zoomer.cpp.
|
virtualslot |
Zoom in.
Clears all rectangles above the current position of the zoom stack and pushes the normalized rectangle on it.
Reimplemented in PlotZoomer.
Definition at line 310 of file qwt_plot_zoomer.cpp.
|
virtualslot |
Zoom in or out.
Activate a rectangle on the zoom stack with an offset relative to the current position. Negative values of offset will zoom out, positive zoom in. A value of 0 zooms out to the zoom base.
offset | Offset relative to the current position of the zoom stack. |
Definition at line 347 of file qwt_plot_zoomer.cpp.
QRectF QwtPlotZoomer::zoomBase | ( | ) | const |
Definition at line 221 of file qwt_plot_zoomer.cpp.
|
signal |
A signal emitting the zoomRect(), when the plot has been zoomed in or out.
rect | Current zoom rectangle. |
QRectF QwtPlotZoomer::zoomRect | ( | ) | const |
Definition at line 287 of file qwt_plot_zoomer.cpp.
uint QwtPlotZoomer::zoomRectIndex | ( | ) | const |
Definition at line 295 of file qwt_plot_zoomer.cpp.
const QStack< QRectF > & QwtPlotZoomer::zoomStack | ( | ) | const |
Definition at line 212 of file qwt_plot_zoomer.cpp.
|
private |
Definition at line 138 of file qwt_plot_zoomer.h.