QwtPlotZoomer(3)

NAME
QwtPlotZoomer -

SYNOPSIS

#include <qwt_plot_zoomer.h>

Inherits QwtPlotPicker.

  Public Slots
void moveBy (double x, double y)
virtual void moveTo (const QPointF &)
virtual void zoom (const QRectF &)
virtual void zoom (int up)

  Signals
void zoomed (const QRectF &rect)

  Public Member Functions
QwtPlotZoomer (QwtPlotCanvas *, bool doReplot=true)
QwtPlotZoomer (int xAxis, int yAxis, QwtPlotCanvas *, bool doReplot=true)
int maxStackDepth () const
virtual void setAxis (int xAxis, int yAxis)
void setMaxStackDepth (int)
virtual void setZoomBase (bool doReplot=true)
virtual void setZoomBase (const QRectF &)
void setZoomStack (const QStack< QRectF > &, int zoomRectIndex=-1)
QRectF zoomBase () const
QRectF zoomRect () const
uint zoomRectIndex () const
const QStack< QRectF > & zoomStack () const

  Protected Member Functions
virtual bool accept (QPolygon &) const
virtual void begin ()
virtual bool end (bool ok=true)
virtual QSizeF minZoomSize () const
virtual void rescale ()
virtual void widgetKeyPressEvent (QKeyEvent *)
virtual void widgetMouseReleaseEvent (QMouseEvent *)

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.

Note:
    The realtime example includes an derived zoomer class that adds scrollbars to the plot canvas.

Constructor & Destructor Documentation

  QwtPlotZoomer::QwtPlotZoomer (QwtPlotCanvas *canvas, booldoReplot = 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 rubberband is set to QwtPicker::RectRubberBand

Parameters:
    canvas Plot canvas to observe, also the parent object
    doReplot Call 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()

  QwtPlotZoomer::QwtPlotZoomer (intxAxis, intyAxis, QwtPlotCanvas *canvas, booldoReplot = 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 rubberband is set to QwtPicker;;RectRubberBand

Parameters:
    xAxis X axis of the zoomer
    yAxis Y axis of the zoomer
    canvas Plot canvas to observe, also the parent object
    doReplot Call 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()

Member Function Documentation

  bool QwtPlotZoomer::accept (QPolygon &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.

  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.

  bool QwtPlotZoomer::end (boolok = true) [protected], [virtual]
Expand the selected rectangle to minZoomSize() and zoom in if accepted.

See also:
    accept(), minZoomSize()

Reimplemented from QwtPlotPicker.

  int QwtPlotZoomer::maxStackDepth () const
Returns:
    Maximal depth of the zoom stack.

See also:
    setMaxStackDepth()

  QSizeF QwtPlotZoomer::minZoomSize () const [protected], [virtual]

Limit zooming by a minimum rectangle. Returns:
    zoomBase().width() / 10e4, zoomBase().height() / 10e4

  void QwtPlotZoomer::moveBy (doubledx, doubledy) [slot]
Move the current zoom rectangle.

Parameters:
    dx X offset
    dy Y offset

Note:
    The changed rectangle is limited by the zoom base

  void QwtPlotZoomer::moveTo (const QPointF &pos) [virtual], [slot]
Move the the current zoom rectangle.

Parameters:
    pos New position

See also:
    QRectF::moveTo()

Note:
    The changed rectangle is limited by the zoom base

  void QwtPlotZoomer::rescale () [protected], [virtual]
Adjust the observed plot to zoomRect()

Note:
    Initiates QwtPlot::replot

  void QwtPlotZoomer::setAxis (intxAxis, intyAxis) [virtual]
Reinitialize the axes, and set the zoom base to their scales.

Parameters:
    xAxis X axis
    yAxis Y axis

Reimplemented from QwtPlotPicker.

  void QwtPlotZoomer::setMaxStackDepth (intdepth)

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.

  void QwtPlotZoomer::setZoomBase (booldoReplot = true) [virtual]
Reinitialized the zoom stack with scaleRect() as base.

Parameters:
    doReplot Call 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().

  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 reinitalized with it as zoom base. plot is zoomed to scaleRect().

Parameters:
    base Zoom base

See also:
    zoomBase(), scaleRect()

  void QwtPlotZoomer::setZoomStack (const QStack< QRectF > &zoomStack, intzoomRectIndex = -1)

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()

  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.

Note:
    The keys codes can be changed, using QwtEventPattern::setKeyPattern: 3, 4, 5

Reimplemented from QwtPicker.

  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.

  void QwtPlotZoomer::zoom (const QRectF &rect) [virtual], [slot]

Zoom in. Clears all rectangles above the current position of the zoom stack and pushs the normalized rect on it.

Note:
    If the maximal stack depth is reached, zoom is ignored.

    The zoomed signal is emitted.

  void QwtPlotZoomer::zoom (intoffset) [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.

Note:
    The zoomed signal is emitted.

See also:
    zoomRectIndex()

  QRectF QwtPlotZoomer::zoomBase () const
Returns:
    Initial rectangle of the zoomer

See also:
    setZoomBase(), zoomRect()

  void QwtPlotZoomer::zoomed (const QRectF &rect) [signal]
A signal emitting the zoomRect(), when the plot has been zoomed in or out.

Parameters:
    rect Current zoom rectangle.

  QRectF QwtPlotZoomer::zoomRect () const
Rectangle at the current position on the zoom stack.

See also:
    zoomRectIndex(), scaleRect().

  uint QwtPlotZoomer::zoomRectIndex () const
Returns:
    Index of current position of zoom stack.

  const QStack< QRectF > & QwtPlotZoomer::zoomStack () const
Return the zoom stack. zoomStack()[0] is the zoom base, zoomStack()[1] the first zoomed rectangle.

See also:
    setZoomStack(), zoomRectIndex()

Author

Generated automatically by Doxygen for Qwt User's Guide from the source code.