QwtPlotMagnifier provides zooming, by magnifying in steps. More...
#include <qwt_plot_magnifier.h>
Classes | |
class | PrivateData |
Public Member Functions | |
QwtPlotMagnifier (QwtPlotCanvas *) | |
virtual | ~QwtPlotMagnifier () |
Destructor. | |
void | setAxisEnabled (int axis, bool on) |
En/Disable an axis. | |
bool | isAxisEnabled (int axis) const |
QwtPlotCanvas * | canvas () |
Return observed plot canvas. | |
const QwtPlotCanvas * | canvas () const |
Return Observed plot canvas. | |
QwtPlot * | plot () |
Return plot widget, containing the observed plot canvas. | |
const QwtPlot * | plot () const |
Return plot widget, containing the observed plot canvas. | |
Protected Member Functions | |
virtual void | rescale (double factor) |
QwtPlotMagnifier provides zooming, by magnifying in steps.
Using QwtPlotMagnifier a plot can be zoomed in/out in steps using keys, the mouse wheel or moving a mouse button in vertical direction.
Together with QwtPlotZoomer and QwtPlotPanner it is possible to implement individual and powerful navigation of the plot canvas.
Definition at line 30 of file qwt_plot_magnifier.h.
QwtPlotMagnifier::QwtPlotMagnifier | ( | QwtPlotCanvas * | canvas ) | [explicit] |
Constructor
canvas | Plot canvas to be magnified |
Definition at line 35 of file qwt_plot_magnifier.cpp.
: QwtMagnifier(canvas) { d_data = new PrivateData(); }
QwtPlotMagnifier::~QwtPlotMagnifier | ( | ) | [virtual] |
QwtPlotCanvas * QwtPlotMagnifier::canvas | ( | ) |
Return observed plot canvas.
Definition at line 81 of file qwt_plot_magnifier.cpp.
Referenced by plot().
{ QObject *w = parent(); if ( w && w->inherits("QwtPlotCanvas") ) return (QwtPlotCanvas *)w; return NULL; }
const QwtPlotCanvas * QwtPlotMagnifier::canvas | ( | ) | const |
Return Observed plot canvas.
Definition at line 91 of file qwt_plot_magnifier.cpp.
{ return ((QwtPlotMagnifier *)this)->canvas(); }
bool QwtPlotMagnifier::isAxisEnabled | ( | int | axis ) | const |
Test if an axis is enabled
axis | Axis, see QwtPlot::Axis |
Definition at line 72 of file qwt_plot_magnifier.cpp.
References QwtPlot::axisCnt, and QwtPlotMagnifier::PrivateData::isAxisEnabled.
Referenced by rescale().
{ if ( axis >= 0 && axis < QwtPlot::axisCnt ) return d_data->isAxisEnabled[axis]; return true; }
QwtPlot * QwtPlotMagnifier::plot | ( | ) |
const QwtPlot * QwtPlotMagnifier::plot | ( | ) | const |
Return plot widget, containing the observed plot canvas.
Definition at line 111 of file qwt_plot_magnifier.cpp.
{ return ((QwtPlotMagnifier *)this)->plot(); }
void QwtPlotMagnifier::rescale | ( | double | factor ) | [protected, virtual] |
Zoom in/out the axes scales
factor | A value < 1.0 zooms in, a value > 1.0 zooms out. |
Implements QwtMagnifier.
Definition at line 120 of file qwt_plot_magnifier.cpp.
References QwtPlot::autoReplot(), QwtPlot::axisCnt, QwtPlot::axisScaleDiv(), isAxisEnabled(), QwtScaleDiv::isValid(), QwtScaleDiv::lowerBound(), plot(), qwtAbs, QwtScaleDiv::range(), QwtPlot::replot(), QwtPlot::setAutoReplot(), and QwtPlot::setAxisScale().
{ factor = qwtAbs(factor); if ( factor == 1.0 || factor == 0.0 ) return; bool doReplot = false; QwtPlot* plt = plot(); const bool autoReplot = plt->autoReplot(); plt->setAutoReplot(false); for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) { const QwtScaleDiv *scaleDiv = plt->axisScaleDiv(axisId); if ( isAxisEnabled(axisId) && scaleDiv->isValid() ) { const double center = scaleDiv->lowerBound() + scaleDiv->range() / 2; const double width_2 = scaleDiv->range() / 2 * factor; plt->setAxisScale(axisId, center - width_2, center + width_2); doReplot = true; } } plt->setAutoReplot(autoReplot); if ( doReplot ) plt->replot(); }
void QwtPlotMagnifier::setAxisEnabled | ( | int | axis, |
bool | on | ||
) |
En/Disable an axis.
Axes that are enabled will be synchronized to the result of panning. All other axes will remain unchanged.
axis | Axis, see QwtPlot::Axis |
on | On/Off |
Definition at line 58 of file qwt_plot_magnifier.cpp.
References QwtPlot::axisCnt, and QwtPlotMagnifier::PrivateData::isAxisEnabled.
{ if ( axis >= 0 && axis < QwtPlot::axisCnt ) d_data->isAxisEnabled[axis] = on; }