QwtPlotZoomer::zoom( rect ) also sets the scale and does a replot - so your code above has no effect beside that it slows down the operation significantly. Why don't you listen to me: QwtPlotZoomer has nothing to do with your use case.
Instead this is your code:
void zoomAxis
( QwtPlot* plot,
int axis,
double factor
) {
const QwtScaleDiv &scaleDiv
= plot
->axisScaleDiv
( axis
);
const double center =
scaleDiv.lowerBound() + scaleDiv.range() / 2;
const double width_2 = scaleDiv.range() / 2 * factor;
plot->setAxisScale( axis, center - width_2, center + width_2 );
plot->replot();
}
void zoomAxis( QwtPlot* plot, int axis, double factor )
{
const QwtScaleDiv &scaleDiv = plot->axisScaleDiv( axis );
const double center =
scaleDiv.lowerBound() + scaleDiv.range() / 2;
const double width_2 = scaleDiv.range() / 2 * factor;
plot->setAxisScale( axis, center - width_2, center + width_2 );
plot->replot();
}
To copy to clipboard, switch view to plain text mode
When you want to zoom in/out more than one axis don't use the code above unmodified and take care that the replot is done only once.
Uwe
Bookmarks