PDA

View Full Version : Zooming on PushButton Press event



KosyakOFF
10th April 2008, 09:52
Hi there. I looked through QWT docs but didn't find good example of how I can perform zooming: idea is simple - make zooming on QPushbutton pressEvent like one, which perform when I use a mousewheel.

Right now I use some buggy code like this:

Zoom in example

if (myPlot->axisEnabled(QwtPlot::yLeft))
{
QwtDoubleRect tempQwtRect(myPlotZoomer[0]->zoomRect());
tempQwtRect.setWidth(tempQwtRect.width()/1.1);
tempQwtRect.setHeight(tempQwtRect.height()/1.1);
myPlotZoomer[0]->zoom(tempQwtRect);
}
if (myPlot->axisEnabled(QwtPlot::yRight))
{
QwtDoubleRect tempQwtRect2(myPlotZoomer[1]->zoomRect());
tempQwtRect2.setWidth(tempQwtRect2.width()/1.1);
tempQwtRect2.setHeight(tempQwtRect2.height()/1.1);
myPlotZoomer[1]->zoom(tempQwtRect2);
}

but it goes downward and left form centre. Thanks for your answers beforehand.

Uwe
10th April 2008, 11:20
Hi there. I looked through QWT docs but didn't find good example of how I can perform zooming:
Have a look at QwtPlotZoomer, QwtPlotPanner and QwtPlotMagnifier. These classes should offer all, what you need to implement your own flavour of navigation.


idea is simple - make zooming on QPushbutton pressEvent like one, which perform when I use a mousewheel.

QwtPlotMagnifier::rescale handles wheel events. If you don't want to use the Qwt navigation helpers, you can simply copy + adopt the code into the slot, that is connected to your pushbutton.

Uwe

KosyakOFF
10th April 2008, 14:56
Thanks Uwe, copying + adopting the code into the slot helped to solve the problem :cool:.

KosyakOFF
11th April 2008, 08:55
I will ask another question in this thread, because it's connected with previous one - I perform some smoothing algorithm on data, which is used to form a curve.

After updating curbve data and doing the plot->replot() QWT automaticly recalculates scales and in some occasions changes the zoom.

So it looks like this: I set a smoothing parameter in new dialog window and press Apply button (dialog not closing so I can press Apply many times to observe recent changes in curve structure). But rezooming of the plot spoils the proccess, because it's becoming not so clear what effect was after I pressed Apply last time.

Sorry if I described situation not so well. =(

Uwe
11th April 2008, 09:53
After updating curve data and doing the plot->replot() QWT automaticly recalculates scales ...
Only, when autoscaling is enabled. As soon as you assign specific scales ( f.e when zooming) autoscaling gets disabled.

Uwe

KosyakOFF
11th April 2008, 10:12
Thank you very much, gee... I forgot to turn autoscaling off :crying: