QwtPlotZoomer provides stacked zooming for a plot widget. More...
#include <qwt_plot_zoomer.h>
Classes | |
class | PrivateData |
Public Slots | |
void | moveBy (double x, double y) |
virtual void | moveTo (const QPointF &) |
virtual void | zoom (const QRectF &) |
Zoom in. | |
virtual void | zoom (int up) |
Zoom in or out. | |
Signals | |
void | zoomed (const QRectF &rect) |
Public Member Functions | |
int | maxStackDepth () const |
QwtPlotZoomer (QWidget *, bool doReplot=true) | |
Create a zoomer for a plot canvas. | |
QwtPlotZoomer (int xAxis, int yAxis, QWidget *, bool doReplot=true) | |
Create a zoomer for a plot canvas. | |
virtual void | setAxis (int xAxis, int yAxis) |
void | setMaxStackDepth (int) |
Limit the number of recursive zoom operations to depth. | |
virtual void | setZoomBase (bool doReplot=true) |
virtual void | setZoomBase (const QRectF &) |
Set the initial size of the zoomer. | |
void | setZoomStack (const QStack< QRectF > &, int zoomRectIndex=-1) |
Assign a zoom stack. | |
QRectF | zoomBase () const |
QRectF | zoomRect () const |
uint | zoomRectIndex () const |
const QStack< QRectF > & | zoomStack () const |
virtual | ~QwtPlotZoomer () |
Protected Member Functions | |
virtual bool | accept (QPolygon &) const |
Check and correct a selected rectangle. | |
virtual void | begin () |
virtual bool | end (bool ok=true) |
virtual QSizeF | minZoomSize () const |
Limit zooming by a minimum rectangle. | |
virtual void | rescale () |
virtual void | widgetKeyPressEvent (QKeyEvent *) |
virtual void | widgetMouseReleaseEvent (QMouseEvent *) |
Private Member Functions | |
void | init (bool doReplot) |
Init the zoomer, used by the constructors. | |
Private Attributes | |
PrivateData * | d_data |
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.
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.
Definition at line 77 of file qwt_plot_zoomer.h.
QwtPlotZoomer::QwtPlotZoomer | ( | QWidget * | canvas, |
bool | doReplot = true |
||
) | [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 106 of file qwt_plot_zoomer.cpp.
QwtPlotZoomer::QwtPlotZoomer | ( | int | xAxis, |
int | yAxis, | ||
QWidget * | canvas, | ||
bool | doReplot = true |
||
) | [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 130 of file qwt_plot_zoomer.cpp.
QwtPlotZoomer::~QwtPlotZoomer | ( | ) | [virtual] |
Definition at line 155 of file qwt_plot_zoomer.cpp.
bool QwtPlotZoomer::accept | ( | QPolygon & | pa | ) | const [protected, virtual] |
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 564 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::begin | ( | ) | [protected, virtual] |
Rejects selections, when the stack depth is too deep, or the zoomed rectangle is minZoomSize().
Reimplemented from QwtPicker.
Definition at line 606 of file qwt_plot_zoomer.cpp.
bool QwtPlotZoomer::end | ( | bool | ok = true | ) | [protected, virtual] |
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 640 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::init | ( | bool | doReplot | ) | [private] |
Init the zoomer, used by the constructors.
Definition at line 139 of file qwt_plot_zoomer.cpp.
int QwtPlotZoomer::maxStackDepth | ( | ) | const |
Definition at line 198 of file qwt_plot_zoomer.cpp.
QSizeF QwtPlotZoomer::minZoomSize | ( | ) | const [protected, virtual] |
Limit zooming by a minimum rectangle.
Reimplemented in PlotZoomer.
Definition at line 594 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::moveBy | ( | double | dx, |
double | dy | ||
) | [slot] |
Move the current zoom rectangle.
dx | X offset |
dy | Y offset |
Definition at line 517 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::moveTo | ( | const QPointF & | pos | ) | [virtual, slot] |
Move the the current zoom rectangle.
pos | New position |
Definition at line 531 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::rescale | ( | ) | [protected, virtual] |
Adjust the observed plot to zoomRect()
Definition at line 413 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::setAxis | ( | int | xAxis, |
int | yAxis | ||
) | [virtual] |
Reinitialize the axes, and set the zoom base to their scales.
xAxis | X axis |
yAxis | Y axis |
Reimplemented from QwtPlotPicker.
Definition at line 452 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 171 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::setZoomBase | ( | bool | doReplot = true | ) | [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 232 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. plot is zoomed to scaleRect().
base | Zoom base |
Definition at line 258 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 380 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::widgetKeyPressEvent | ( | QKeyEvent * | ke | ) | [protected, virtual] |
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 494 of file qwt_plot_zoomer.cpp.
void QwtPlotZoomer::widgetMouseReleaseEvent | ( | QMouseEvent * | me | ) | [protected, virtual] |
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 471 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.
Definition at line 307 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.
offset | Offset relative to the current position of the zoom stack. |
Definition at line 344 of file qwt_plot_zoomer.cpp.
QRectF QwtPlotZoomer::zoomBase | ( | ) | const |
Definition at line 218 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.
rect | Current zoom rectangle. |
QRectF QwtPlotZoomer::zoomRect | ( | ) | const |
Definition at line 284 of file qwt_plot_zoomer.cpp.
uint QwtPlotZoomer::zoomRectIndex | ( | ) | const |
Definition at line 292 of file qwt_plot_zoomer.cpp.
const QStack< QRectF > & QwtPlotZoomer::zoomStack | ( | ) | const |
Definition at line 209 of file qwt_plot_zoomer.cpp.
PrivateData* QwtPlotZoomer::d_data [private] |
Reimplemented from QwtPicker.
Definition at line 136 of file qwt_plot_zoomer.h.