NAME
QwtPlotZoomer -
SYNOPSIS
Inherits QwtPlotPicker.
Detailed Description
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.
Definition at line 59 of file qwt_plot_zoomer.h.
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
void zoomed (const QwtDoubleRect &rect)
Public Member Functions
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)
Protected Member Functions
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
Constructor & Destructor Documentation
QwtPlotZoomer::QwtPlotZoomer (QwtPlotCanvas * canvas, const char * name =
0)
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 selectionFlags() are set to QwtPicker::RectSelection &
QwtPicker::ClickSelection, the cursor label mode to
QwtPicker::ActiveOnly.
Parameters:
canvas Plot canvas to observe, also the parent object
name Object name
Warning:
Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is
FALSE leaves the axis in an ’intermediate’ state. In this case, to
prevent buggy behaviour, you must call QwtPlot::replot() before
calling QwtPlotZoomer(). This quirk will be removed in a future
release.
See also:
QwtPlot::autoReplot(), QwtPlot::replot(),
QwtPlotPicker::setZoomBase()
Definition at line 40 of file qwt_plot_zoomer.cpp.
QwtPlotZoomer::QwtPlotZoomer (int xAxis, int yAxis, QwtPlotCanvas * canvas,
const char * name = 0)
Create a zoomer for a plot canvas.
The selectionFlags() are set to QwtPicker::RectSelection &
QwtPicker::ClickSelection, the cursor label mode to
QwtPicker::ActiveOnly.
Parameters:
xAxis X axis of the zoomer
yAxis Y axis of the zoomer
canvas Plot canvas to observe, also the parent object
name Object name
Warning:
Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is
FALSE leaves the axis in an ’intermediate’ state. In this case, to
prevent buggy behaviour, you must call QwtPlot::replot() before
calling QwtPlotZoomer(). This quirk will be removed in a future
release.
See also:
QwtPlot::autoReplot(), QwtPlot::replot(),
QwtPlotPicker::setZoomBase()
Definition at line 68 of file qwt_plot_zoomer.cpp.
QwtPlotZoomer::QwtPlotZoomer (int xAxis, int yAxis, int selectionFlags,
DisplayMode cursorLabelMode, QwtPlotCanvas * canvas, const char * name
= 0)
Create a zoomer for a plot canvas.
Parameters:
xAxis X axis of the zoomer
yAxis Y axis of the zoomer
selectionFlags Or´d value of QwtPicker::RectSelectionType and
QwtPicker::SelectionMode. QwtPicker::RectSelection will be auto
added.
cursorLabelMode Cursor label mode
canvas Plot canvas to observe, also the parent object
name Object name
See also:
QwtPicker, QwtPicker::setSelectionFlags(),
QwtPicker::setRubberBand(), QwtPicker::setCursorLabelMode
Warning:
Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is
FALSE leaves the axis in an ’intermediate’ state. In this case, to
prevent buggy behaviour, you must call QwtPlot::replot() before
calling QwtPlotZoomer(). This quirk will be removed in a future
release.
See also:
QwtPlot::autoReplot(), QwtPlot::replot(),
QwtPlotPicker::setZoomBase()
Definition at line 102 of file qwt_plot_zoomer.cpp.
Member Function Documentation
bool QwtPlotZoomer::accept (QPointArray & pa) const [protected, virtual]
Check and correct a selected rectangle.
Reject rectangles with a hight or width < 2, otherwise expand the
selected rectangle to a minimum size of 11x11 and accept it.
Returns:
TRUE If rect is accepted, or has been changed to a accepted
rectangle.
Reimplemented from QwtPicker.
Definition at line 456 of file qwt_plot_zoomer.cpp.
References minZoomSize().
void QwtPlotZoomer::begin () [protected, virtual]
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 508 of file qwt_plot_zoomer.cpp.
References QwtPicker::begin(), QwtDoubleSize::height(),
QwtDoubleSize::isValid(), minZoomSize(), and QwtDoubleSize::width().
bool QwtPlotZoomer::end (bool ok = TRUE) [protected, virtual]
Expand the selected rectangle to minZoomSize() and zoom in if accepted.
Note:
The zoomed signal is emitted.
See also:
QwtPlotZoomer::accept()a, QwtPlotZoomer::minZoomSize()
Reimplemented from QwtPlotPicker.
Definition at line 539 of file qwt_plot_zoomer.cpp.
References QwtDoubleRect::center(), QwtPlotPicker::end(),
QwtDoubleSize::expandedTo(), QwtPlotPicker::invTransform(),
minZoomSize(), QwtDoubleRect::moveCenter(), QwtDoubleRect::normalize(),
QwtPlotPicker::plot(), QwtPicker::selection(),
QwtDoubleRect::setSize(), QwtDoubleRect::size(), zoom(), zoomed(), and
zoomRect().
int QwtPlotZoomer::maxStackDepth () const
Returns:
Maximal depth of the zoom stack.
See also:
setMaxStackDepth()
Definition at line 159 of file qwt_plot_zoomer.cpp.
QwtDoubleSize QwtPlotZoomer::minZoomSize () const [protected, virtual]
Limit zooming by a minimum rectangle.
Tries to stop zooming, when the precision of the axes label string
conversion leads to identical values.
Returns:
minimum rectangle
Definition at line 488 of file qwt_plot_zoomer.cpp.
References QwtPlot::axisLabelFormat(), QwtPlotPicker::plot(),
QwtPlotPicker::xAxis(), and QwtPlotPicker::yAxis().
Referenced by accept(), begin(), and end().
void QwtPlotZoomer::move (double x, double y) [virtual, slot]
Move the the current zoom rectangle.
Parameters:
x X value
y value
See also:
QwtDoubleRect::move
Note:
The changed rectangle is limited by the zoom base
Definition at line 430 of file qwt_plot_zoomer.cpp.
References rescale(), QwtDoubleRect::x1(), QwtDoubleRect::y1(),
zoomBase(), and zoomRect().
Referenced by moveBy().
void QwtPlotZoomer::moveBy (double dx, double dy) [slot]
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 415 of file qwt_plot_zoomer.cpp.
References move(), QwtDoubleRect::x1(), and QwtDoubleRect::y1().
void QwtPlotZoomer::rescale () [protected, virtual]
Adjust the observed plot to zoomRect()
Note:
Initiates QwtPlot::replot
Definition at line 327 of file qwt_plot_zoomer.cpp.
References QwtPlotPicker::plot(), QwtPlot::replot(),
QwtPlotPicker::scaleRect(), QwtPlot::setAxisScale(),
QwtDoubleRect::x1(), QwtDoubleRect::x2(), QwtPlotPicker::xAxis(),
QwtDoubleRect::y1(), QwtDoubleRect::y2(), and QwtPlotPicker::yAxis().
Referenced by move(), setZoomBase(), and zoom().
void QwtPlotZoomer::setAxis (int xAxis, int yAxis) [virtual]
Reinitialize the axes, and set the zoom base to their scales.
Parameters:
xAxis X axis
yAxis Y axis
Reimplemented from QwtPlotPicker.
Definition at line 350 of file qwt_plot_zoomer.cpp.
References QwtPlotPicker::scaleRect(), QwtPlotPicker::setAxis(),
setZoomBase(), QwtPlotPicker::xAxis(), and QwtPlotPicker::yAxis().
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.
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 135 of file qwt_plot_zoomer.cpp.
References zoom().
void QwtPlotZoomer::setSelectionFlags (int flags) [virtual]
Set the selection flags
Parameters:
flags Or´d value of QwtPicker::RectSelectionType and
QwtPicker::SelectionMode. The default value is
QwtPicker::RectSelection & QwtPicker::ClickSelection.
See also:
selectionFlags(), SelectionType, RectSelectionType, SelectionMode
Note:
QwtPicker::RectSelection will be auto added.
Reimplemented from QwtPicker.
Definition at line 578 of file qwt_plot_zoomer.cpp.
References QwtPicker::setSelectionFlags().
void QwtPlotZoomer::setZoomBase (const QwtDoubleRect & base) [virtual]
Set the initial size of the zoomer.
base is united with the current scaleRect() and the zoom stack is
reinitalized with it as zoom base. plot is zoomed to scaleRect().
Parameters:
base Zoom base
See also:
zoomBase(), scaleRect()
Definition at line 227 of file qwt_plot_zoomer.cpp.
References QwtPlotPicker::plot(), rescale(), and
QwtPlotPicker::scaleRect().
void QwtPlotZoomer::setZoomBase () [virtual]
Reinitialized the zoom stack with scaleRect() as base.
See also:
zoomBase(), scaleRect()
Warning:
Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is
FALSE leaves the axis in an ’intermediate’ state. In this case, to
prevent buggy behaviour, you must call QwtPlot::replot() before
calling QwtPlotZoomer::setZoomBase(). This quirk will be removed in
a future release.
See also:
QwtPlot::autoReplot(), QwtPlot::replot().
Definition at line 204 of file qwt_plot_zoomer.cpp.
References QwtPlotPicker::plot(), rescale(), and
QwtPlotPicker::scaleRect().
Referenced by setAxis().
void QwtPlotZoomer::widgetKeyPressEvent (QKeyEvent * ke) [protected,
virtual]
Qt::Key_Plus zooms out, Qt::Key_Minus zooms in 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 392 of file qwt_plot_zoomer.cpp.
References QwtPicker::isActive(), QwtEventPattern::keyMatch(),
QwtPicker::widgetKeyPressEvent(), and zoom().
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.
Note:
The mouse events can be changed, using
QwtEventPattern::setMousePattern: 2, 1
Reimplemented from QwtPicker.
Definition at line 369 of file qwt_plot_zoomer.cpp.
References QwtEventPattern::mouseMatch(),
QwtPicker::widgetMouseReleaseEvent(), and zoom().
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 offest 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.
See also:
zoomRectIndex()
Definition at line 305 of file qwt_plot_zoomer.cpp.
References rescale().
void QwtPlotZoomer::zoom (const QwtDoubleRect & rect) [virtual, slot]
Zoom in.
Clears all rectangles above the current position of the zoom stack and
pushs the intersection of zoomRect() and the normalized rect on it.
Note:
If the maximal stack depth is reached, zoom is ignored.
Definition at line 277 of file qwt_plot_zoomer.cpp.
References QwtDoubleRect::normalize(), rescale(), and zoomRect().
Referenced by end(), setMaxStackDepth(), widgetKeyPressEvent(), and
widgetMouseReleaseEvent().
QwtDoubleRect QwtPlotZoomer::zoomBase () const
Returns:
Initial rectangle of the zoomer
See also:
setZoomBase(), zoomRect()
Definition at line 186 of file qwt_plot_zoomer.cpp.
Referenced by move().
void QwtPlotZoomer::zoomed (const QwtDoubleRect & rect) [signal]
A signal emitting the zoomRect(), when the plot has been zoomed in or
out.
Parameters:
rect Current zoom rectangle.
Warning:
zoomed() is only emitted after selections in end(), but never in
zoom().
Referenced by end().
QwtDoubleRect QwtPlotZoomer::zoomRect () const
Rectangle at the current position on the zoom stack.
See also:
QwtPlotZoomer::zoomRectIndex(), QwtPlotZoomer::scaleRect().
Definition at line 254 of file qwt_plot_zoomer.cpp.
Referenced by end(), move(), and zoom().
uint QwtPlotZoomer::zoomRectIndex () const
Returns:
Index of current position of zoom stack.
Definition at line 262 of file qwt_plot_zoomer.cpp.
QValueStack< QwtDoubleRect > & QwtPlotZoomer::zoomStack () [protected]
Return the zoom stack. zoomStack()[0] is the zoom base, zoomStack()[1]
the first zoomed rectangle. Definition at line 177 of file
qwt_plot_zoomer.cpp.
const QValueStack< QwtDoubleRect > & QwtPlotZoomer::zoomStack () const
Return the zoom stack. zoomStack()[0] is the zoom base, zoomStack()[1]
the first zoomed rectangle. Definition at line 168 of file
qwt_plot_zoomer.cpp.
Author
Generated automatically by Doxygen for Qwt User’s Guide from the source
code.