OpenCurves  0.9
PlotZoomer Class Reference

Custom zoom handler for Plot objects. More...

#include <plotzoomer.h>

Inheritance diagram for PlotZoomer:

Public Types

enum  ZoomMode { ZoomBoth, ZoomX, ZoomY, ZoomModeCount }
 Zooming mode. More...
 
typedef QwtPlotZoomer Super
 Parent class.
 

Public Slots

void setZoomMode (ZoomMode mode)
 Set the active ZoomMode. More...
 
void setZoomModeBoth ()
 Set the zoom mode to ZoomBoth.
 
void setZoomModeX ()
 Set the zoom mode to ZoomX.
 
void setZoomModeY ()
 Set the zoom mode to ZoomY.
 
void zoomSync (const QRectF &rect)
 Event for zoom synchronisation. More...
 

Signals

void zoomModeChanged (int mode)
 Notifies changes in zoomMode().
 
void zoomModeBoth (bool isset)
 Signal for changes to/from ZoomBoth. More...
 
void zoomModeX (bool isset)
 Signal for changes to/from ZoomX. More...
 
void zoomModeY (bool isset)
 Signal for changes to/from ZoomY. More...
 

Public Member Functions

 PlotZoomer (QwtPlotCanvas *plot, bool doReplot=true)
 Constructor, operating on the given plot. More...
 
 ~PlotZoomer ()
 Destructor.
 
ZoomMode zoomMode () const
 Access the current ZoomMode. More...
 
QAction * zoomBothAction () const
 Fetch the action used to select the ZoomBoth mode. More...
 
QAction * zoomXAction () const
 Fetch the action used to select the ZoomX mode. More...
 
QAction * zoomYAction () const
 Fetch the action used to select the ZoomY mode. More...
 
void loadSettings (QSettings &settings)
 Load zoom settings stored by saveSettings(). More...
 
void saveSettings (QSettings &settings)
 Save zoom settings to settings. More...
 
void fitIfAutoScaling ()
 Set current zoom to fit if auto scaling is enabled.
 
void zoomToFit (bool replot=true)
 Zoom to fit even if auto-scaling is off. More...
 
void zoom (const QRectF &rect) override
 Override to prevent catastrophic event propagation on synchronised zoom response. More...
 
void zoom (int up) override
 Override to set auto scaling when reaching zoom level zero. More...
 

Static Public Attributes

static const unsigned int AxisY = 0
 YAxis reference within QwtPlot.
 
static const unsigned int AxisX = 2
 XAxis reference within QwtPlot.
 

Protected Slots

void zoomActionToggled (bool checked)
 Bound to zoom actions simply to ensure one is kept active.
 

Protected Member Functions

void widgetMousePressEvent (QMouseEvent *event) override
 End panning or reset the zoom level on right mouse button. More...
 
void widgetMouseReleaseEvent (QMouseEvent *event) override
 Ignore middle click - handled by panner - resolve right click zoom restore or context menu. More...
 
void widgetWheelEvent (QWheelEvent *event) override
 Cycle zoom levels on wheel. More...
 
bool end (bool ok=true) override
 Overload to handle ZoomMode.
 

Detailed Description

Custom zoom handler for Plot objects.

Extends zoom functionality to handle mouse wheel cycling through zoom levels, middle mouse panning and right mouse reset.

Member Enumeration Documentation

Zooming mode.

Enumerator
ZoomBoth 

Zoom both axes.

ZoomX 

Zoom only X axis.

ZoomY 

Zoom only Y axis.

Constructor & Destructor Documentation

PlotZoomer::PlotZoomer ( QwtPlotCanvas *  plot,
bool  doReplot = true 
)
explicit

Constructor, operating on the given plot.

Parameters
plotThe plot to operate on.
doReplotCall 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.

Member Function Documentation

void PlotZoomer::loadSettings ( QSettings &  settings)

Load zoom settings stored by saveSettings().

Note: zoomToFit() is called if the stack size is 1 or empty. This enforces auto scaling when there is no active stack.

Parameters
settingsThe object to load from.
See also
saveSettings()
void PlotZoomer::saveSettings ( QSettings &  settings)

Save zoom settings to settings.

Settings are stored in a group labelled "zoom". The following settings are stored:

Key Description
mode The zoomMode()
index The current zoomRectIndex() in the zoomStack()
stack The zoomStack() as a array of rectangles (see below)

Each zoom rectangle is written as:

Key Description
x The X position
y The Y position
w The rectangle width
h The rectangle height
Parameters
settingsThe object to save to.
void PlotZoomer::setZoomMode ( ZoomMode  mode)
slot

Set the active ZoomMode.

Raises the zoomModeChanged() signal if the mode differs from the current mode.

Parameters
modeThe mode to set.

Referenced by setZoomModeBoth(), setZoomModeX(), and setZoomModeY().

void PlotZoomer::widgetMousePressEvent ( QMouseEvent *  event)
overrideprotected

End panning or reset the zoom level on right mouse button.

Parameters
eventThe mouse event.
void PlotZoomer::widgetMouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Ignore middle click - handled by panner - resolve right click zoom restore or context menu.

Parameters
eventThe mouse event.
void PlotZoomer::widgetWheelEvent ( QWheelEvent *  event)
overrideprotected

Cycle zoom levels on wheel.

Parameters
eventThe mouse event.
void PlotZoomer::zoom ( const QRectF &  rect)
override

Override to prevent catastrophic event propagation on synchronised zoom response.

Parameters
rectThe zoom rectangle.
void PlotZoomer::zoom ( int  up)
override

Override to set auto scaling when reaching zoom level zero.

Parameters
upThe number of zoom steps to make.
QAction* PlotZoomer::zoomBothAction ( ) const
inline

Fetch the action used to select the ZoomBoth mode.

Returns
The ZoomBoth action.

References ZoomBoth.

ZoomMode PlotZoomer::zoomMode ( ) const
inline

Access the current ZoomMode.

Returns
The current ZoomMode.
void PlotZoomer::zoomModeBoth ( bool  isset)
signal

Signal for changes to/from ZoomBoth.

Parameters
issetTrue if ZoomBoth is the new zoom mode.
void PlotZoomer::zoomModeX ( bool  isset)
signal

Signal for changes to/from ZoomX.

Parameters
issetTrue if ZoomX is the new zoom mode.
void PlotZoomer::zoomModeY ( bool  isset)
signal

Signal for changes to/from ZoomY.

Parameters
issetTrue if ZoomY is the new zoom mode.
void PlotZoomer::zoomSync ( const QRectF &  rect)
slot

Event for zoom synchronisation.

The whole zoom stack is synchronised if the sender is a QwtPlotZoomer.

void PlotZoomer::zoomToFit ( bool  replot = true)

Zoom to fit even if auto-scaling is off.

Parameters
replotForce replot after the zoom?
QAction* PlotZoomer::zoomXAction ( ) const
inline

Fetch the action used to select the ZoomX mode.

Returns
The ZoomX action.

References ZoomX.

QAction* PlotZoomer::zoomYAction ( ) const
inline

Fetch the action used to select the ZoomY mode.

Returns
The ZoomY action.

References ZoomY.


The documentation for this class was generated from the following file: