There are only two ways how an axis scale can be set:
- explicitly by setAxisScale or setAxisScaleDiv
- implicitely by the auto scaler
Autoscaling is enabled in the default setting of QwtPlot and executed each time replot ( updateAxes ) is called. As soon as you explicitly assign a scale autoscaling gets disabled until you re-enable it with setAxisAutoScale().
The zoomer doesn't have a different API for setting the scales - all it can do is to use setAxisScale. So whenever the zoomer changes a scale autoscaling gets disabled.
When you add a new curve and want to run the autoscaler again you have to do:
plot->setAxisAutoScale( axisId, true );
plot->replot();
plot->setAxisAutoScale( axisId, true );
plot->replot();
To copy to clipboard, switch view to plain text mode
Usually you don't want to keep a zoom stack ( the history of the zoom rectangles ) starting with the scales from your previous
run of the autoscaler. To reinitialize the zoomer with the new scales you have to do:
doReplot = false;
zoomer->setZoomBase( doReplot );
doReplot = false;
zoomer->setZoomBase( doReplot );
To copy to clipboard, switch view to plain text mode
The mystery behind the doReplot flag is, that setAxisScale/setAxisAutoScale only assign the parameters for the calculation of the new scale, but the scales are calculated later ( replot/updateAxes ). So you have to do a replot before you reinitialize the zoomer to avoid, that it gets initialized with the previous scales.
In the code snippet above doReplot is set to false. This is only done because you already did the the replot above and you don't need to do it twice.
Uwe
Bookmarks