Qwt User's Guide  5.2.3
Public Slots | Signals | Public Member Functions | Protected Member Functions
QwtPlotZoomer Class Reference

#include <qwt_plot_zoomer.h>

Inheritance diagram for QwtPlotZoomer:
Inheritance graph
[legend]

List of all members.

Public Slots

virtual void move (double x, double y)
void moveBy (double x, double y)
virtual void zoom (const QwtDoubleRect &)
virtual void zoom (int up)

Signals

void zoomed (const QwtDoubleRect &rect)
- Signals inherited from QwtPlotPicker
void appended (const QwtDoublePoint &pos)
void moved (const QwtDoublePoint &pos)
void selected (const QwtDoublePoint &pos)
void selected (const QwtDoubleRect &rect)
void selected (const QwtArray< QwtDoublePoint > &pa)
- Signals inherited from QwtPicker
void appended (const QPoint &pos)
void changed (const QwtPolygon &pa)
void moved (const QPoint &pos)
void selected (const QwtPolygon &pa)

Public Member Functions

 QwtPlotZoomer (QwtPlotCanvas *, bool doReplot=true)
 QwtPlotZoomer (int xAxis, int yAxis, QwtPlotCanvas *, bool doReplot=true)
 QwtPlotZoomer (int xAxis, int yAxis, int selectionFlags, DisplayMode trackerMode, QwtPlotCanvas *, bool doReplot=true)
int maxStackDepth () const
virtual void setAxis (int xAxis, int yAxis)
void setMaxStackDepth (int)
virtual void setSelectionFlags (int)
virtual void setZoomBase (bool doReplot=true)
virtual void setZoomBase (const QwtDoubleRect &)
void setZoomStack (const QStack< QwtDoubleRect > &, int zoomRectIndex=-1)
QwtDoubleRect zoomBase () const
QwtDoubleRect zoomRect () const
uint zoomRectIndex () const
const QStack< QwtDoubleRect > & zoomStack () const
- Public Member Functions inherited from QwtPlotPicker
 QwtPlotPicker (QwtPlotCanvas *)
 QwtPlotPicker (int xAxis, int yAxis, QwtPlotCanvas *)
 QwtPlotPicker (int xAxis, int yAxis, int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QwtPlotCanvas *)
virtual ~QwtPlotPicker ()
QwtPlotCanvascanvas ()
const QwtPlotCanvascanvas () const
QwtPlotplot ()
const QwtPlotplot () const
int xAxis () const
int yAxis () const
- Public Member Functions inherited from QwtPicker
 QwtPicker (QWidget *parent)
 QwtPicker (int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QWidget *)
virtual ~QwtPicker ()
virtual void drawRubberBand (QPainter *) const
virtual void drawTracker (QPainter *) const
virtual bool eventFilter (QObject *, QEvent *)
bool isActive () const
bool isEnabled () const
QWidget * parentWidget ()
const QWidget * parentWidget () const
virtual QRect pickRect () const
ResizeMode resizeMode () const
RubberBand rubberBand () const
QPen rubberBandPen () const
const QwtPolygon & selection () const
int selectionFlags () const
virtual void setEnabled (bool)
virtual void setResizeMode (ResizeMode)
virtual void setRubberBand (RubberBand)
virtual void setRubberBandPen (const QPen &)
virtual void setTrackerFont (const QFont &)
virtual void setTrackerMode (DisplayMode)
virtual void setTrackerPen (const QPen &)
QFont trackerFont () const
DisplayMode trackerMode () const
QPen trackerPen () const
QPoint trackerPosition () const
QRect trackerRect (const QFont &) const
- Public Member Functions inherited from QwtEventPattern
 QwtEventPattern ()
virtual ~QwtEventPattern ()
void initKeyPattern ()
void initMousePattern (int numButtons)
bool keyMatch (uint pattern, const QKeyEvent *) const
const QwtArray< KeyPattern > & keyPattern () const
QwtArray< KeyPattern > & keyPattern ()
bool mouseMatch (uint pattern, const QMouseEvent *) const
const QwtArray< MousePattern > & mousePattern () const
QwtArray< MousePattern > & mousePattern ()
void setKeyPattern (uint pattern, int key, int state=Qt::NoButton)
void setKeyPattern (const QwtArray< KeyPattern > &)
void setMousePattern (uint pattern, int button, int state=Qt::NoButton)
void setMousePattern (const QwtArray< MousePattern > &)

Protected Member Functions

virtual bool accept (QwtPolygon &) const
virtual void begin ()
virtual bool end (bool ok=true)
virtual QwtDoubleSize minZoomSize () const
virtual void rescale ()
virtual void widgetKeyPressEvent (QKeyEvent *)
virtual void widgetMouseReleaseEvent (QMouseEvent *)
- Protected Member Functions inherited from QwtPlotPicker
virtual void append (const QPoint &)
QwtDoubleRect invTransform (const QRect &) const
QwtDoublePoint invTransform (const QPoint &) const
virtual void move (const QPoint &)
QwtDoubleRect scaleRect () const
virtual QwtText trackerText (const QPoint &) const
virtual QwtText trackerText (const QwtDoublePoint &) const
QRect transform (const QwtDoubleRect &) const
QPoint transform (const QwtDoublePoint &) const
- Protected Member Functions inherited from QwtPicker
virtual void reset ()
const QWidget * rubberBandWidget () const
virtual QwtPickerMachinestateMachine (int) const
virtual void stretchSelection (const QSize &oldSize, const QSize &newSize)
const QWidget * trackerWidget () const
virtual void transition (const QEvent *)
virtual void updateDisplay ()
virtual void widgetKeyReleaseEvent (QKeyEvent *)
virtual void widgetLeaveEvent (QEvent *)
virtual void widgetMouseDoubleClickEvent (QMouseEvent *)
virtual void widgetMouseMoveEvent (QMouseEvent *)
virtual void widgetMousePressEvent (QMouseEvent *)
virtual void widgetWheelEvent (QWheelEvent *)
- Protected Member Functions inherited from QwtEventPattern
virtual bool keyMatch (const KeyPattern &, const QKeyEvent *) const
virtual bool mouseMatch (const MousePattern &, const QMouseEvent *) const

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,
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 selectionFlags() are set to QwtPicker::RectSelection | QwtPicker::ClickSelection, the tracker mode to QwtPicker::ActiveOnly.

Parameters:
canvasPlot canvas to observe, also the parent object
doReplotCall 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 ( int  xAxis,
int  yAxis,
QwtPlotCanvas canvas,
bool  doReplot = true 
)
explicit

Create a zoomer for a plot canvas.

The selectionFlags() are set to QwtPicker::RectSelection | QwtPicker::ClickSelection, the tracker mode to QwtPicker::ActiveOnly.

Parameters:
xAxisX axis of the zoomer
yAxisY axis of the zoomer
canvasPlot canvas to observe, also the parent object
doReplotCall 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 ( int  xAxis,
int  yAxis,
int  selectionFlags,
DisplayMode  trackerMode,
QwtPlotCanvas canvas,
bool  doReplot = true 
)
explicit

Create a zoomer for a plot canvas.

Parameters:
xAxisX axis of the zoomer
yAxisY axis of the zoomer
selectionFlagsOr'd value of QwtPicker::RectSelectionType and QwtPicker::SelectionMode. QwtPicker::RectSelection will be auto added.
trackerModeTracker mode
canvasPlot canvas to observe, also the parent object
doReplotCall 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:
QwtPicker, QwtPicker::setSelectionFlags(), QwtPicker::setRubberBand(), QwtPicker::setTrackerMode()
QwtPlot::autoReplot(), QwtPlot::replot(), setZoomBase()

Member Function Documentation

bool QwtPlotZoomer::accept ( QwtPolygon &  pa) const
protectedvirtual

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

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 ( bool  ok = true)
protectedvirtual

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()
QwtDoubleSize QwtPlotZoomer::minZoomSize ( ) const
protectedvirtual

Limit zooming by a minimum rectangle.

Returns:
zoomBase().width() / 10e4, zoomBase().height() / 10e4
void QwtPlotZoomer::move ( double  x,
double  y 
)
virtualslot

Move the the current zoom rectangle.

Parameters:
xX value
yY value
See also:
QwtDoubleRect::move()
Note:
The changed rectangle is limited by the zoom base
void QwtPlotZoomer::moveBy ( double  dx,
double  dy 
)
slot

Move the current zoom rectangle.

Parameters:
dxX offset
dyY offset
Note:
The changed rectangle is limited by the zoom base
void QwtPlotZoomer::rescale ( )
protectedvirtual

Adjust the observed plot to zoomRect()

Note:
Initiates QwtPlot::replot
void QwtPlotZoomer::setAxis ( int  xAxis,
int  yAxis 
)
virtual

Reinitialize the axes, and set the zoom base to their scales.

Parameters:
xAxisX axis
yAxisY axis

Reimplemented from QwtPlotPicker.

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:
depthMaximum for the stack depth
See also:
maxStackDepth()
Note:
depth doesn't include the zoom base, so zoomStack().count() might be maxStackDepth() + 1.
void QwtPlotZoomer::setSelectionFlags ( int  flags)
virtual

Set the selection flags

Parameters:
flagsOr'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.

void QwtPlotZoomer::setZoomBase ( bool  doReplot = true)
virtual

Reinitialized the zoom stack with scaleRect() as base.

Parameters:
doReplotCall 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 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:
baseZoom base
See also:
zoomBase(), scaleRect()
void QwtPlotZoomer::setZoomStack ( const QStack< QwtDoubleRect > &  ,
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.

Parameters:
zoomStackNew zoom stack
zoomRectIndexIndex 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)
protectedvirtual

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

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 QwtDoubleRect &  rect)
virtualslot

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.
The zoomed signal is emitted.
void QwtPlotZoomer::zoom ( int  offset)
virtualslot

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:
offsetOffset relative to the current position of the zoom stack.
Note:
The zoomed signal is emitted.
See also:
zoomRectIndex()
QwtDoubleRect QwtPlotZoomer::zoomBase ( ) const
Returns:
Initial rectangle of the zoomer
See also:
setZoomBase(), zoomRect()
void QwtPlotZoomer::zoomed ( const QwtDoubleRect &  rect)
signal

A signal emitting the zoomRect(), when the plot has been zoomed in or out.

Parameters:
rectCurrent zoom rectangle.
QwtDoubleRect 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 QwtZoomStack & QwtPlotZoomer::zoomStack ( ) const

Return the zoom stack. zoomStack()[0] is the zoom base, zoomStack()[1] the first zoomed rectangle.

See also:
setZoomStack(), zoomRectIndex()