QwtPlotZoomer(3)
β¨ QwtPlotZoomer β¨
ok so this is from the Library Functions Manual bestie, and it's literally the QwtPlotZoomer(3) page β the zoom-stacking icon of the Qwt plot world π
π NAME π
QwtPlotZoomer β gives you stacked zooming for a plot widget. That's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <qwt_plot_zoomer.h>
Inherits QwtPlotPicker (so like, it's the picker's cooler younger sister π
).
π«Ά Public Slots
void moveBy (double dx, double dy)virtual void moveTo (const QPointF &)virtual void zoom (const QRectF &)β zoom in, periodt πvirtual void zoom (int offset)β zoom in or out, your call bestie
π Public Slots inherited from QwtPicker
void setEnabled (bool)β en/disable the picker (on/off switch energy β‘)
π¦ Signals
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)
π Public Member Functions
QwtPlotZoomer (QWidget *, bool doReplot=true)β create a zoomer for a plot canvas β¨QwtPlotZoomer (QwtAxisId xAxis, QwtAxisId yAxis, QWidget *, bool doReplot=true)β also creating a zoomer for a plot canvas, but you get to say which axes πvirtual void setZoomBase (bool doReplot=true)virtual void setZoomBase (const QRectF &)β set the initial size of the zoomerQRectF zoomBase () constQRectF zoomRect () constvirtual void setAxes (QwtAxisId xAxis, QwtAxisId yAxis) overridevoid setMaxStackDepth (int)β cap the number of recursive zoom operations at depth (no infinite zoom spiral bestie π)int maxStackDepth () constconst QStack< QRectF > & zoomStack () constvoid setZoomStack (const QStack< QRectF > &, int zoomRectIndex=-1)β assign a zoom stackuint zoomRectIndex () const
π§ Public Member Functions inherited from QwtPlotPicker
QwtPlotPicker (QWidget *canvas)β create a plot pickervirtual ~QwtPlotPicker ()β destructor, bye bye πQwtPlotPicker (QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget *)QwtPlotPicker (QwtAxisId xAxisId, QwtAxisId yAxisId, RubberBand rubberBand, DisplayMode trackerMode, QWidget *)QwtAxisId xAxis () constβ return x axisQwtAxisId yAxis () constβ return y axisQwtPlot * plot ()const QwtPlot * plot () constQWidget * canvas ()const QWidget * canvas () const
π Public Member Functions inherited from QwtPicker
QwtPicker (QWidget *parent)QwtPicker (RubberBand rubberBand, DisplayMode trackerMode, QWidget *)virtual ~QwtPicker ()β destructorvoid setStateMachine (QwtPickerMachine *)const QwtPickerMachine * stateMachine () constQwtPickerMachine * stateMachine ()void setRubberBand (RubberBand)RubberBand rubberBand () constvoid setTrackerMode (DisplayMode)β set the display mode of the trackerDisplayMode trackerMode () constvoid setResizeMode (ResizeMode)β set the resize modeResizeMode resizeMode () constvoid setRubberBandPen (const QPen &)QPen rubberBandPen () constvoid setTrackerPen (const QPen &)QPen trackerPen () constvoid setTrackerFont (const QFont &)QFont trackerFont () constbool isEnabled () constbool isActive () constvirtual bool eventFilter (QObject *, QEvent *) overrideβ event filterQWidget * parentWidget ()β return the parent widget, where the selection happensconst QWidget * parentWidget () constβ same thing but const, still the parent widget where the selection happens π«Άvirtual QPainterPath pickArea () constvirtual void drawRubberBand (QPainter *) constvirtual void drawTracker (QPainter *) constvirtual QRegion trackerMask () constvirtual QRegion rubberBandMask () constQPoint trackerPosition () constvirtual QRect trackerRect (const QFont &) constQPolygon selection () const
β Public Member Functions inherited from QwtEventPattern
QwtEventPattern ()virtual ~QwtEventPattern ()β destructorvoid 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 patternsvoid setKeyPattern (const QVector< KeyPattern > &)β change the key event patternsconst QVector< MousePattern > & mousePattern () constconst QVector< KeyPattern > & keyPattern () constQVector< MousePattern > & mousePattern ()QVector< KeyPattern > & keyPattern ()bool mouseMatch (MousePatternCode, const QMouseEvent *) constβ compare a mouse event with an event patternbool keyMatch (KeyPatternCode, const QKeyEvent *) constβ compare a key event with an event pattern
π Protected Member Functions
virtual void rescale ()virtual QSizeF minZoomSize () constβ limit zooming by a minimum rectangle (so you can't zoom into a crumb bestie π)virtual void widgetMouseReleaseEvent (QMouseEvent *) overridevirtual void widgetKeyPressEvent (QKeyEvent *) overridevirtual void begin () overridevirtual bool end (bool ok=true) overridevirtual bool accept (QPolygon &) const overrideβ check and correct a selected rectangle β
π Protected Member Functions inherited from QwtPlotPicker
QRectF scaleRect () constQRectF invTransform (const QRect &) constQRect transform (const QRectF &) constQPointF invTransform (const QPoint &) constQPoint transform (const QPointF &) constvirtual QwtText trackerText (const QPoint &) const overridevirtual QwtText trackerTextF (const QPointF &) constβ translate a position into a position stringvirtual void move (const QPoint &) overridevirtual void append (const QPoint &) override
πΈ Protected Member Functions inherited from QwtPicker
virtual QPolygon adjustedPoints (const QPolygon &) constβ map thepickedPoints()into aselection()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 labelconst QwtWidgetOverlay * rubberBandOverlay () constconst QwtWidgetOverlay * trackerOverlay () constconst QPolygon & pickedPoints () constQRect 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 patternvirtual bool keyMatch (const KeyPattern &, const QKeyEvent *) constβ compare a key event with an event pattern
π Additional Inherited Members π
π Public Types inherited from QwtPicker
enum RubberBand { NoRubberBand = 0, HLineRubberBand, VLineRubberBand, CrossRubberBand, RectRubberBand, EllipseRubberBand, PolygonRubberBand, UserRubberBand = 100 }enum DisplayMode { AlwaysOff, AlwaysOn, ActiveOnly }β display modeenum ResizeMode { Stretch, KeepSize }
π₯ Public Types inherited from QwtEventPattern
enum MousePatternCode { MouseSelect1, MouseSelect2, MouseSelect3, MouseSelect4, MouseSelect5, MouseSelect6, MousePatternCount }β symbolic mouse input codesenum KeyPatternCode { KeySelect1, KeySelect2, KeyAbort, KeyLeft, KeyRight, KeyUp, KeyDown, KeyRedo, KeyUndo, KeyHome, KeyPatternCount }β symbolic keyboard input codes
π DETAILED DESCRIPTION π
QwtPlotZoomer provides stacked zooming for a plot widget. Obsessed. π«Ά
So here's the tea: 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. Iconic behaviour honestly. β¨
Zooming can be repeated as often as possible, limited only by maxStackDepth() or minZoomSize(). Each rectangle is pushed on a stack. Stacked like your iced coffee orders, bestie π§
The default setting for 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. No cap, this is the good stuff π
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. Two zoomers, one plot, main character energy π
Note β the realtime example includes a derived zoomer class that adds scrollbars to the plot canvas. π
See also QwtPlotPanner, QwtPlotMagnifier β the whole squad honestly π§
Definition at line 79 of file qwt_plot_zoomer.h. π
π Constructor & Destructor Documentation π
π QwtPlotZoomer::QwtPlotZoomer (QWidget * canvas, bool doReplot = true) [explicit]
Okay so this one builds you a zoomer for a plot canvas, periodt. And listen β the zoomer gets 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's set to QwtAxis::YLeft. iykyk π
It comes pre-loaded with a QwtPickerDragRectMachine, the tracker mode is set to QwtPicker::ActiveOnly, and the rubber band is set to QwtPicker::RectRubberBand. Iconic defaults, honestly.
Parameters
canvasβ plot canvas to observe, also the parent objectdoReplotβ callQwtPlot::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.
πΈ QwtPlotZoomer::QwtPlotZoomer (QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget * canvas, bool doReplot = true) [explicit]
Same vibe, but now you pick the axes bestie. Create a zoomer for a plot canvas β initialized with a QwtPickerDragRectMachine, tracker mode QwtPicker::ActiveOnly, rubber band QwtPicker::RectRubberBand. Chef's kiss π§
Parameters
xAxisIdβ X axis of the zoomeryAxisIdβ Y axis of the zoomercanvasβ plot canvas to observe, also the parent objectdoReplotβ callQwtPlot::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.
π QwtPlotZoomer::~QwtPlotZoomer () [virtual]
The destructor. She's leaving the group chat π«Ά (no description given for this one, so that's literally it)
Definition at line 158 of file qwt_plot_zoomer.cpp.
β¨ Member Function Documentation β¨
π bool QwtPlotZoomer::accept (QPolygon & pa) const [override] [protected] [virtual]
Check and correct a selected rectangle. Rectangles with a height or width < 2 get rejected β nope, not valid β otherwise the selected rectangle gets expanded to a minimum size of 11x11 and accepted. So tiny selections get glow-upped into something usable π
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.
π¦ void QwtPlotZoomer::begin () [override] [protected] [virtual]
Rejects selections when the stack depth is too deep, or when the zoomed rectangle is minZoomSize(). Like, we're full, no more zooming, sorry babe π
See also: minZoomSize(), maxStackDepth()
Reimplemented from QwtPicker.
Definition at line 609 of file qwt_plot_zoomer.cpp.
π bool QwtPlotZoomer::end (bool ok = true) [override] [protected] [virtual]
Expand the selected rectangle to minZoomSize() and zoom in if it's accepted. This is the moment fr fr β¨
Parameters
okβ iftrue, 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.
π int QwtPlotZoomer::maxStackDepth () const
Returns: maximal depth of the zoom stack.
See also: setMaxStackDepth()
Definition at line 201 of file qwt_plot_zoomer.cpp.
π§ QSizeF QwtPlotZoomer::minZoomSize () const [protected] [virtual]
Limit zooming by a minimum rectangle β keeps you from zooming into literal dust π
Returns: zoomBase().width() / 10e4, zoomBase().height() / 10e4
Definition at line 597 of file qwt_plot_zoomer.cpp.
πΈ void QwtPlotZoomer::moveBy (double dx, double dy) [slot]
Move the current zoom rectangle.
Parameters
dxβ X offsetdyβ Y offset
Note: the changed rectangle is limited by the zoom base.
Definition at line 520 of file qwt_plot_zoomer.cpp.
π void QwtPlotZoomer::moveTo (const QPointF & pos) [virtual] [slot]
Move the the current zoom rectangle. (Yes, "the the" β we don't gatekeep typos, we celebrate them π«Ά)
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.
π void QwtPlotZoomer::rescale () [protected] [virtual]
Adjust the observed plot to zoomRect() β syncing the vibe check between what's selected and what's shown β¨
Note: initiates QwtPlot::replot()
Definition at line 416 of file qwt_plot_zoomer.cpp.
π¦ void QwtPlotZoomer::setAxes (QwtAxisId xAxisId, QwtAxisId yAxisId) [override] [virtual]
Reinitialize the axes, and set the zoom base to their scales. Fresh start, main character energy π
Parameters
xAxisIdβ X axisyAxisIdβ 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 sets the depth to unlimited, 0 disables zooming entirely. If the current zoom rectangle is below depth, the plot is unzoomed. So -1 = endless slay, 0 = touch grass π
Parameters
depthβ maximum for the stack depth
See also: maxStackDepth()
Note:depthdoesn't include the zoom base, sozoomStack().count()might bemaxStackDepth() + 1. Sneaky, I know π
Definition at line 174 of file qwt_plot_zoomer.cpp.
π void QwtPlotZoomer::setZoomBase (bool doReplot = true) [virtual]
Reinitialized the zoom stack with scaleRect() as base. Reset era π
Parameters
doReplotβ callQwtPlot::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.
π void QwtPlotZoomer::setZoomBase (const QRectF & base) [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. The plot is zoomed to scaleRect(). Union of two vibes, one zoom base π«Ά
Parameters
baseβ zoom base
See also: zoomBase(), scaleRect()
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. Like redecorating the whole stack bestie π
Parameters
zoomStackβ new zoom stackzoomRectIndexβ index of the current position ofzoomStack. In case of-1the 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.
πΈ void QwtPlotZoomer::widgetKeyPressEvent (QKeyEvent * ke) [override] [protected] [virtual]
Keys doing keys things, no cap:
Qt::Key_Plusβ zooms inQt::Key_Minusβ zooms out one position on the zoom stackQt::Key_Escapeβ zooms out to the zoom base
Changes the current position on the stack, but doesn't pop any rectangle. Nothing leaves the stack, she just moves π
Note: the keys codes can be changed, usingQwtEventPattern::setKeyPattern:3,4,5
Reimplemented from QwtPicker.
Definition at line 497 of file qwt_plot_zoomer.cpp.
π±οΈ void QwtPlotZoomer::widgetMouseReleaseEvent (QMouseEvent * me) [override] [protected] [virtual]
Clicks that matter:
Qt::MidButtonβ zooms out one position on the zoom stackQt::RightButtonβ zooms out to the zoom base
Changes the current position on the stack, but doesn't pop any rectangle.
Note: the mouse events can be changed, usingQwtEventPattern::setMousePattern:2,1
Reimplemented from QwtPicker.
Definition at line 474 of file qwt_plot_zoomer.cpp.
π₯ void QwtPlotZoomer::zoom (const QRectF & rect) [virtual] [slot]
Zoom in. Clears all rectangles above the current position of the zoom stack and pushes the normalized rectangle on it. Out with the old, in with the new πβ¨
Note: if the maximal stack depth is reached, zoom is ignored. Also: the zoomed signal is emitted.
Definition at line 310 of file qwt_plot_zoomer.cpp.
π¦ void QwtPlotZoomer::zoom (int offset) [virtual] [slot]
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. Literally the "take me back" button π«Ά
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.
π QRectF QwtPlotZoomer::zoomBase () const
Returns: initial rectangle of the zoomer β the og rectangle, iconic π
See also: setZoomBase(), zoomRect()
Definition at line 221 of file qwt_plot_zoomer.cpp.
β void QwtPlotZoomer::zoomed (const QRectF & rect) [signal]
A signal emitting the zoomRect(), when the plot has been zoomed in or out. She's telling everyone in the chat what just happened π£
Parameters
rectβ current zoom rectangle.
π QRectF QwtPlotZoomer::zoomRect () const
Returns: rectangle at the current position on the zoom stack.
See also: zoomRectIndex(), scaleRect().
Definition at line 287 of file qwt_plot_zoomer.cpp.
π uint QwtPlotZoomer::zoomRectIndex () const
Returns: index of current position of zoom stack. Just a number but she's important π
Definition at line 295 of file qwt_plot_zoomer.cpp.
π const QStack< QRectF > & QwtPlotZoomer::zoomStack () const
Returns: the zoom stack. zoomStack()[0] is the zoom base, zoomStack()[1] the first zoomed rectangle. Index 0 is the mom of the group chat, periodt.
See also: setZoomStack(), zoomRectIndex()
Definition at line 212 of file qwt_plot_zoomer.cpp.
π«Ά Author π«Ά
Generated automatically by Doxygen for Qwt User's Guide from the source code. No human wrote this one β the robot did it, and honestly? She ate π€β¨
And that's the whole page, bestie! Big kiss from the Qwt User's Guide (that's the source + version vibe π), dated whenever this manual page got its little moment in the sun, and filed neatly under QwtPlotZoomer(3) π¦π Go forth and zoom responsibly π
π¦ where this page comes from
- alpine 3.24: qwt-doc 6.3.0-r0 Β· custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms