PDA

View Full Version : autorescale a plot



mastupristi
3rd May 2011, 16:43
I'm using Qwt 5.2.2

starting from bode axample I had write a simplified version (6352).

once started it shows this dialog windows:
http://img690.imageshack.us/img690/8681/justlounched.png (http://img690.imageshack.us/i/justlounched.png/)

data are taken fron two constant vectors plus random number.

zoom button has the same behaviour of original bode example

clicking refresh button data are "recalculated" by adding another random number and multiplied by random factor.
If you try to click refresh button several times it happens that the graph is correclty rescaled:
http://img849.imageshack.us/img849/686/afterseveralrefresh.png (http://img849.imageshack.us/i/afterseveralrefresh.png/)

but clicking zoom button the scale decreases back to what was at the beginning:
http://img860.imageshack.us/img860/5096/onceclickzoom.png (http://img860.imageshack.us/i/onceclickzoom.png/)

and at this point no rescale happens even clicking refresh button.

there seems to be something destructive in zoom enabling.

How can I make it correctly rescale?

You can try with the attached project. Just modify .pro file to match your system path to qwt.

thanks

Uwe
3rd May 2011, 21:21
Assigning a scale disables autoscaling and zooming in/out explicitly does this.

See: QwtPlot::setAxisScale() ( implicitely called by the zoomer ) and QwtPlot::setAxisAutoScale().

Uwe

mastupristi
4th May 2011, 08:49
I added setAxisAutoScale() lines to enableZoomMode() slot as follow (lines 13-15):

void MainWin::enableZoomMode(bool on)
{
d_panner->setEnabled(on);

d_zoomer[0]->setEnabled(on);
d_zoomer[0]->zoom(0);

d_zoomer[1]->setEnabled(on);
d_zoomer[1]->zoom(0);

d_picker->setEnabled(!on);

d_plot->setAxisAutoScale(QwtPlot::yLeft);
d_plot->setAxisAutoScale(QwtPlot::yRight);
d_plot->setAxisAutoScale(QwtPlot::xBottom);
d_plot->replot();
}


now when I click zoom button the plot is not rescaled:
http://img838.imageshack.us/img838/2315/zoomenabled.png (http://imageshack.us/photo/my-images/838/zoomenabled.png/)

I can zoom correctly, but on mouse right-click to zoom out the scale decreases back to what was at the beginning, once again:
http://img3.imageshack.us/img3/6369/rightclick.png (http://imageshack.us/photo/my-images/3/rightclick.png/)

how to avoid this behaviour?

thanks