QwtPlotZoomer − QwtPlotZoomer provides stacked zooming for a plot widget.
#include <qwt_plot_zoomer.h>
Inherits QwtPlotPicker.
void
moveBy (double dx, double dy)
virtual void moveTo (const QPointF &)
virtual void zoom (const QRectF &)
Zoom in.
virtual void zoom (int offset)
Zoom in or out.
Public Slots inherited from QwtPicker
void setEnabled (bool)
En/disable the picker.
void zoomed (const QRectF &rect)
Signals inherited from QwtPlotPicker
void selected (const
QPointF &pos)
void selected (const QRectF &rect)
void selected (const QVector< QPointF >
&pa)
void appended (const QPointF &pos)
void moved (const QPointF &pos)
Signals inherited from QwtPicker
void activated (bool on)
void selected (const QPolygon &polygon)
void appended (const QPoint &pos)
void moved (const QPoint &pos)
void removed (const QPoint &pos)
void changed (const QPolygon
&selection)
QwtPlotZoomer
(QWidget *, bool doReplot=true)
Create a zoomer for a plot canvas.
QwtPlotZoomer (QwtAxisId xAxis, QwtAxisId
yAxis, QWidget *, bool doReplot=true)
Create a zoomer for a plot canvas.
virtual void setZoomBase (bool doReplot=true)
virtual void setZoomBase (const QRectF &)
Set the initial size of the zoomer.
QRectF zoomBase () const
QRectF zoomRect () const
virtual void setAxes (QwtAxisId xAxis,
QwtAxisId yAxis) override
void setMaxStackDepth (int)
Limit the number of recursive zoom operations to depth.
int maxStackDepth () const
const QStack< QRectF > & zoomStack
() const
void setZoomStack (const QStack< QRectF
> &, int zoomRectIndex=−1)
Assign a zoom stack.
uint zoomRectIndex () const
Public Member Functions inherited from QwtPlotPicker
QwtPlotPicker (QWidget
*canvas)
Create a plot picker.
virtual ˜QwtPlotPicker ()
Destructor.
QwtPlotPicker (QwtAxisId xAxisId, QwtAxisId yAxisId,
QWidget *)
QwtPlotPicker (QwtAxisId xAxisId, QwtAxisId yAxisId,
RubberBand rubberBand, DisplayMode
trackerMode, QWidget *)
QwtAxisId xAxis () const
Return x axis.
QwtAxisId yAxis () const
Return y axis.
QwtPlot * plot ()
const QwtPlot * plot () const
QWidget * canvas ()
const QWidget * canvas () const
Public Member Functions inherited from QwtPicker
QwtPicker (QWidget
*parent)
QwtPicker (RubberBand rubberBand, DisplayMode
trackerMode, QWidget *)
virtual ˜QwtPicker ()
Destructor.
void setStateMachine (QwtPickerMachine *)
const QwtPickerMachine * stateMachine () const
QwtPickerMachine * stateMachine ()
void setRubberBand (RubberBand)
RubberBand rubberBand () const
void setTrackerMode (DisplayMode)
Set the display mode of the tracker.
DisplayMode trackerMode () const
void setResizeMode (ResizeMode)
Set the resize mode.
ResizeMode resizeMode () const
void setRubberBandPen (const QPen &)
QPen rubberBandPen () const
void setTrackerPen (const QPen &)
QPen trackerPen () const
void setTrackerFont (const QFont &)
QFont trackerFont () const
bool isEnabled () const
bool isActive () const
virtual bool eventFilter (QObject *, QEvent *)
override
Event filter.
QWidget * parentWidget ()
Return the parent widget, where the selection happens.
const QWidget * parentWidget () const
Return the parent widget, where the selection happens.
virtual QPainterPath pickArea () const
virtual void drawRubberBand (QPainter *) const
virtual void drawTracker (QPainter *) const
virtual QRegion trackerMask () const
virtual QRegion rubberBandMask () const
QPoint trackerPosition () const
virtual QRect trackerRect (const QFont &) const
QPolygon selection () const
Public Member Functions inherited from QwtEventPattern
QwtEventPattern ()
virtual ˜QwtEventPattern ()
Destructor.
void initMousePattern (int numButtons)
void initKeyPattern ()
void setMousePattern (MousePatternCode,
Qt::MouseButton button,
Qt::KeyboardModifiers=Qt::NoModifier)
void setKeyPattern (KeyPatternCode, int key,
Qt::KeyboardModifiers modifiers=Qt::NoModifier)
void setMousePattern (const QVector<
MousePattern > &)
Change the mouse event patterns.
void setKeyPattern (const QVector<
KeyPattern > &)
Change the key event patterns.
const QVector< MousePattern > &
mousePattern () const
const QVector< KeyPattern > &
keyPattern () const
QVector< MousePattern > &
mousePattern ()
QVector< KeyPattern > &
keyPattern ()
bool mouseMatch (MousePatternCode, const
QMouseEvent *) const
Compare a mouse event with an event pattern.
bool keyMatch (KeyPatternCode, const QKeyEvent
*) const
Compare a key event with an event pattern.
virtual void
rescale ()
virtual QSizeF minZoomSize () const
Limit zooming by a minimum rectangle.
virtual void widgetMouseReleaseEvent (QMouseEvent *)
override
virtual void widgetKeyPressEvent (QKeyEvent *)
override
virtual void begin () override
virtual bool end (bool ok=true) override
virtual bool accept (QPolygon &) const override
Check and correct a selected rectangle.
Protected Member Functions inherited from QwtPlotPicker
QRectF scaleRect ()
const
QRectF invTransform (const QRect &) const
QRect transform (const QRectF &) const
QPointF invTransform (const QPoint &) const
QPoint transform (const QPointF &) const
virtual QwtText trackerText (const QPoint &)
const override
virtual QwtText trackerTextF (const QPointF &)
const
Translate a position into a position string.
virtual void move (const QPoint &) override
virtual void append (const QPoint &) override
Protected Member Functions inherited from QwtPicker
virtual QPolygon
adjustedPoints (const QPolygon &) const
Map the pickedPoints() into a selection()
virtual void transition (const QEvent *)
virtual void remove ()
virtual void reset ()
virtual void widgetMousePressEvent (QMouseEvent *)
virtual void widgetMouseDoubleClickEvent (QMouseEvent
*)
virtual void widgetMouseMoveEvent (QMouseEvent *)
virtual void widgetWheelEvent (QWheelEvent *)
virtual void widgetKeyReleaseEvent (QKeyEvent *)
virtual void widgetEnterEvent (QEvent *)
virtual void widgetLeaveEvent (QEvent *)
virtual void stretchSelection (const QSize
&oldSize, const QSize &newSize)
virtual void updateDisplay ()
Update the state of rubber band and tracker label.
const QwtWidgetOverlay * rubberBandOverlay ()
const
const QwtWidgetOverlay * trackerOverlay ()
const
const QPolygon & pickedPoints () const
QRect trackerRect (const QSize &) const
Protected Member Functions inherited from QwtEventPattern
virtual bool mouseMatch
(const MousePattern &, const QMouseEvent *) const
Compare a mouse event with an event pattern.
virtual bool keyMatch (const KeyPattern &,
const QKeyEvent *) const
Compare a key event with an event pattern.
Public Types inherited from QwtPicker
enum RubberBand {
NoRubberBand = 0, HLineRubberBand,
VLineRubberBand, CrossRubberBand,
RectRubberBand, EllipseRubberBand,
PolygonRubberBand, UserRubberBand = 100 }
enum DisplayMode { AlwaysOff, AlwaysOn,
ActiveOnly }
Display mode.
enum ResizeMode { Stretch, KeepSize
}
Public Types inherited from QwtEventPattern
enum MousePatternCode {
MouseSelect1, MouseSelect2,
MouseSelect3, MouseSelect4,
MouseSelect5, MouseSelect6,
MousePatternCount }
Symbolic mouse input codes.
enum KeyPatternCode { KeySelect1,
KeySelect2, KeyAbort, KeyLeft,
KeyRight, KeyUp, KeyDown,
KeyRedo, KeyUndo, KeyHome,
KeyPatternCount }
Symbolic keyboard input codes.
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:
|
• |
QwtEventPattern::MouseSelect1 |
The first point of the zoom rectangle is selected by a mouse press, the second point from the position, where the mouse is released.
|
• |
QwtEventPattern::KeySelect1 |
The first key press selects the first, the second key press selects the second point.
|
• |
QwtEventPattern::KeyAbort |
Discard the selection in the state, where the first point is selected.
To traverse the zoom stack the following bindings are used:
|
• |
QwtEventPattern::MouseSelect3, QwtEventPattern::KeyUndo |
Zoom out one position on the zoom stack
|
• |
QwtEventPattern::MouseSelect6, QwtEventPattern::KeyRedo |
Zoom in one position on the zoom stack
|
• |
QwtEventPattern::MouseSelect2, QwtEventPattern::KeyHome |
Zoom to the zoom base
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.
zoomer = new
QwtPlotZoomer( plot );
zoomer−>setKeyPattern( QwtEventPattern::KeyRedo,
Qt::Key_I, Qt::ShiftModifier );
zoomer−>setKeyPattern( QwtEventPattern::KeyUndo,
Qt::Key_O, Qt::ShiftModifier );
zoomer−>setKeyPattern( QwtEventPattern::KeyHome,
Qt::Key_Home );
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.
Note
The realtime example includes an derived zoomer class that adds scrollbars to the plot canvas.
See also
QwtPlotPanner, QwtPlotMagnifier
Definition at line 79 of file qwt_plot_zoomer.h.
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 QwtAxis::XBottom. If both or no y-axis are enabled, it is set to QwtAxis::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
Parameters
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.
See also
QwtPlot::autoReplot(), QwtPlot::replot(), setZoomBase()
Definition at line 109 of file qwt_plot_zoomer.cpp.
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
Parameters
xAxisId X axis of the
zoomer
yAxisId 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.
See also
QwtPlot::autoReplot(), QwtPlot::replot(), setZoomBase()
Definition at line 133 of file qwt_plot_zoomer.cpp.
Definition at line 158 of file qwt_plot_zoomer.cpp.
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.
Returns
true If the rectangle is accepted, or has been changed to an accepted one.
Reimplemented from QwtPicker.
Definition at line 567 of file qwt_plot_zoomer.cpp.
Rejects selections, when the stack depth is too deep, or the zoomed rectangle is minZoomSize().
See also
minZoomSize(), maxStackDepth()
Reimplemented from QwtPicker.
Definition at line 609 of file qwt_plot_zoomer.cpp.
Expand the selected rectangle to minZoomSize() and zoom in if accepted.
Parameters
ok If true, complete the selection and emit selected signals otherwise discard the selection.
See also
accept(), minZoomSize()
Returns
True if the selection has been accepted, false otherwise
Reimplemented from QwtPlotPicker.
Definition at line 643 of file qwt_plot_zoomer.cpp.
Returns
Maximal depth of the zoom stack.
See also
setMaxStackDepth()
Definition at line 201 of file qwt_plot_zoomer.cpp.
Limit zooming by a minimum rectangle.
Returns
zoomBase().width() / 10e4, zoomBase().height() / 10e4
Definition at line 597 of file qwt_plot_zoomer.cpp.
Move the current zoom rectangle.
Parameters
dx X offset
dy Y offset
Note
The changed rectangle is limited by the zoom base
Definition at line 520 of file qwt_plot_zoomer.cpp.
Move the the current zoom rectangle.
Parameters
pos New position
See also
QRectF::moveTo()
Note
The changed rectangle is limited by the zoom base
Definition at line 534 of file qwt_plot_zoomer.cpp.
Adjust the observed plot to zoomRect()
Note
Initiates QwtPlot::replot()
Definition at line 416 of file qwt_plot_zoomer.cpp.
Reinitialize the axes, and set the zoom base to their scales.
Parameters
xAxisId X axis
yAxisId Y axis
Reimplemented from QwtPlotPicker.
Definition at line 455 of file qwt_plot_zoomer.cpp.
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.
Parameters
depth Maximum for the stack depth
See also
maxStackDepth()
Note
depth doesn’t include the zoom base, so zoomStack().count() might be maxStackDepth() + 1.
Definition at line 174 of file qwt_plot_zoomer.cpp.
Reinitialized the zoom stack with scaleRect() as base.
Parameters
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.
See also
zoomBase(), scaleRect() QwtPlot::autoReplot(), QwtPlot::replot().
Definition at line 235 of file qwt_plot_zoomer.cpp.
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().
Parameters
base Zoom base
See also
zoomBase(), scaleRect()
Definition at line 261 of file qwt_plot_zoomer.cpp.
Assign a zoom stack. In combination with other types of navigation it might be useful to modify to manipulate the complete zoom stack.
Parameters
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.
Note
The zoomed signal might be emitted.
See also
zoomStack(), zoomRectIndex()
Definition at line 383 of file qwt_plot_zoomer.cpp.
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.
Note
The keys codes can be changed, using QwtEventPattern::setKeyPattern: 3, 4, 5
Reimplemented from QwtPicker.
Definition at line 497 of file qwt_plot_zoomer.cpp.
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.
Note
The mouse events can be changed, using QwtEventPattern::setMousePattern: 2, 1
Reimplemented from QwtPicker.
Definition at line 474 of file qwt_plot_zoomer.cpp.
Zoom in. Clears all rectangles above the current position of the zoom stack and pushes the normalized rectangle on it.
Note
If the maximal stack depth is reached, zoom is ignored.
The zoomed signal is emitted.
Definition at line 310 of file qwt_plot_zoomer.cpp.
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.
Parameters
offset Offset relative to the current position of the zoom stack.
Note
The zoomed signal is emitted.
See also
zoomRectIndex()
Definition at line 347 of file qwt_plot_zoomer.cpp.
Returns
Initial rectangle of the zoomer
See also
setZoomBase(), zoomRect()
Definition at line 221 of file qwt_plot_zoomer.cpp.
A signal emitting the zoomRect(), when the plot has been zoomed in or out.
Parameters
rect Current zoom rectangle.
Returns
Rectangle at the current position on the zoom stack.
See also
zoomRectIndex(), scaleRect().
Definition at line 287 of file qwt_plot_zoomer.cpp.
Returns
Index of current position of zoom stack.
Definition at line 295 of file qwt_plot_zoomer.cpp.
Returns
The zoom stack. zoomStack()[0] is the zoom base, zoomStack()[1] the first zoomed rectangle.
See also
setZoomStack(), zoomRectIndex()
Definition at line 212 of file qwt_plot_zoomer.cpp.
Generated automatically by Doxygen for Qwt User’s Guide from the source code.