QwtPlotMagnifier is about connecting key and mouse events to rescale operations. In your case only the rescale operation is left, what is only some code around setAxisScale:
void rescale
( QwtPlot* plot,
double factor
) {
factor = qAbs( factor );
if ( factor == 1.0 || factor == 0.0 )
return;
bool doReplot = false;
const bool autoReplot = plot->autoReplot();
plot->setAutoReplot( false );
for ( int axisId
= 0; axisId <
QwtPlot::axisCnt; axisId
++ ) {
const QwtScaleDiv &scaleDiv
= plot
->axisScaleDiv
( axisId
);
const double center = scaleDiv.lowerBound() + scaleDiv.range() / 2;
const double width_2 = scaleDiv.range() / 2 * factor;
plot->setAxisScale( axisId, center - width_2, center + width_2 );
doReplot = true;
}
plot->setAutoReplot( autoReplot );
if ( doReplot )
plot->replot();
}
void rescale( QwtPlot* plot, double factor )
{
factor = qAbs( factor );
if ( factor == 1.0 || factor == 0.0 )
return;
bool doReplot = false;
const bool autoReplot = plot->autoReplot();
plot->setAutoReplot( false );
for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
{
const QwtScaleDiv &scaleDiv = plot->axisScaleDiv( axisId );
const double center = scaleDiv.lowerBound() + scaleDiv.range() / 2;
const double width_2 = scaleDiv.range() / 2 * factor;
plot->setAxisScale( axisId, center - width_2, center + width_2 );
doReplot = true;
}
plot->setAutoReplot( autoReplot );
if ( doReplot )
plot->replot();
}
To copy to clipboard, switch view to plain text mode
Bookmarks