QwtPlotPanner provides panning of a plot canvas. More...
#include <qwt_plot_panner.h>


Classes | |
| class | PrivateData |
Public Member Functions | |
| QwtPlotPanner (QwtPlotCanvas *) | |
| Create a plot panner. | |
| virtual | ~QwtPlotPanner () |
| Destructor. | |
| 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. | |
| void | setAxisEnabled (int axis, bool on) |
| En/Disable an axis. | |
| bool | isAxisEnabled (int axis) const |
Protected Slots | |
| virtual void | moveCanvas (int dx, int dy) |
QwtPlotPanner provides panning of a plot canvas.
QwtPlotPanner is a panner for a QwtPlotCanvas, that adjusts the scales of the axes after dropping the canvas on its new position.
Together with QwtPlotZoomer and QwtPlotMagnifier powerful ways of navigating on a QwtPlot widget can be implemented easily.
Definition at line 32 of file qwt_plot_panner.h.
| QwtPlotPanner::QwtPlotPanner | ( | QwtPlotCanvas * | canvas ) | [explicit] |
Create a plot panner.
The panner is enabled for all axes
| canvas | Plot canvas to pan, also the parent object |
Definition at line 38 of file qwt_plot_panner.cpp.
References moveCanvas(), and QwtPanner::panned().
:
QwtPanner(canvas)
{
d_data = new PrivateData();
connect(this, SIGNAL(panned(int, int)),
SLOT(moveCanvas(int, int)));
}
| QwtPlotPanner::~QwtPlotPanner | ( | ) | [virtual] |
| QwtPlotCanvas * QwtPlotPanner::canvas | ( | ) |
Return observed plot canvas.
Definition at line 87 of file qwt_plot_panner.cpp.
Referenced by plot().
{
QWidget *w = parentWidget();
if ( w && w->inherits("QwtPlotCanvas") )
return (QwtPlotCanvas *)w;
return NULL;
}
| const QwtPlotCanvas * QwtPlotPanner::canvas | ( | ) | const |
Return Observed plot canvas.
Definition at line 97 of file qwt_plot_panner.cpp.
{
return ((QwtPlotPanner *)this)->canvas();
}
| bool QwtPlotPanner::isAxisEnabled | ( | int | axis ) | const |
Test if an axis is enabled
| axis | Axis, see QwtPlot::Axis |
Definition at line 78 of file qwt_plot_panner.cpp.
References QwtPlot::axisCnt, and QwtPlotPanner::PrivateData::isAxisEnabled.
{
if ( axis >= 0 && axis < QwtPlot::axisCnt )
return d_data->isAxisEnabled[axis];
return true;
}
| void QwtPlotPanner::moveCanvas | ( | int | dx, |
| int | dy | ||
| ) | [protected, virtual, slot] |
Adjust the enabled axes according to dx/dy
| dx | Pixel offset in x direction |
| dy | Pixel offset in y direction |
Definition at line 130 of file qwt_plot_panner.cpp.
References QwtPlot::autoReplot(), QwtPlot::axisCnt, QwtPlot::axisScaleDiv(), QwtPlot::canvasMap(), QwtScaleMap::invTransform(), QwtPlotPanner::PrivateData::isAxisEnabled, QwtScaleDiv::lowerBound(), plot(), QwtPlot::replot(), QwtPlot::setAutoReplot(), QwtPlot::setAxisScale(), QwtScaleMap::transform(), QwtScaleDiv::upperBound(), QwtPlot::xBottom, and QwtPlot::xTop.
Referenced by QwtPlotPanner().
{
if ( dx == 0 && dy == 0 )
return;
QwtPlot *plot = QwtPlotPanner::plot();
if ( plot == NULL )
return;
const bool doAutoReplot = plot->autoReplot();
plot->setAutoReplot(false);
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( !d_data->isAxisEnabled[axis] )
continue;
const QwtScaleMap map = plot->canvasMap(axis);
const int i1 = map.transform(plot->axisScaleDiv(axis)->lowerBound());
const int i2 = map.transform(plot->axisScaleDiv(axis)->upperBound());
double d1, d2;
if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
{
d1 = map.invTransform(i1 - dx);
d2 = map.invTransform(i2 - dx);
}
else
{
d1 = map.invTransform(i1 - dy);
d2 = map.invTransform(i2 - dy);
}
plot->setAxisScale(axis, d1, d2);
}
plot->setAutoReplot(doAutoReplot);
plot->replot();
}
| const QwtPlot * QwtPlotPanner::plot | ( | ) | const |
Return plot widget, containing the observed plot canvas.
Definition at line 117 of file qwt_plot_panner.cpp.
{
return ((QwtPlotPanner *)this)->plot();
}
| QwtPlot * QwtPlotPanner::plot | ( | ) |
Return plot widget, containing the observed plot canvas.
Definition at line 103 of file qwt_plot_panner.cpp.
References canvas().
Referenced by moveCanvas().
| void QwtPlotPanner::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 64 of file qwt_plot_panner.cpp.
References QwtPlot::axisCnt, and QwtPlotPanner::PrivateData::isAxisEnabled.
{
if ( axis >= 0 && axis < QwtPlot::axisCnt )
d_data->isAxisEnabled[axis] = on;
}
1.7.2