PDA

View Full Version : QwtPlotMagnifier zooming around the mouse pointer



cesroc
8th August 2014, 14:29
Hello,

I have a qwtPlot with 8 QwtPlotCurve, each one has a QwtPlotMagnifier to perform the zoom in/out on my y axes. I would like to change the behaviour and zoom in and out around my mouse position.

It is working fine now, but when I zoom in it can happen that my curve goes out of the screen and the user needs to scroll to bring it back, and then I wanted to zoom around the mouse position to avoid this kind of behaviour.
Is there any way with QwtPlotMagnifier to do that? I didn't find anything in documentation that make possible to consider mouse position.

I hope someone can help me.
Thanks in advance.
Best Regards.

Uwe
9th August 2014, 11:02
Such a mode is not implemented, but isn't very hard to implement. You could derive from QwtPlotMagnifier overloading the following 2 methods:

widgetWheelEvent to store the mouse position
rescale, where you implement zooming around the mouse poistion

Starting with the code from QwtPlotMagnifier ::rescale should help.

Uwe

cesroc
12th August 2014, 08:32
Hello Uwe,

Thanks a lot. I found a different way of doing. I install an event filter in my axis and I handle the wheel event.
It works fine for a normal zooming in and out, but I didn't find the right calculation to have it around the mouse pointer.
I have the mouse position and everything I need but I didn't figure out yet how to calculate to have the zoom around the pointer.
Can you help me on that? Do you have an example?

Thanks in advance.
Best Regards.

Uwe
12th August 2014, 19:09
Using the maps from QwtPlot::canvasMap() you can translate between widget ( canvas ) and plot coordinates.

Uwe

Using the maps from QwtPlot::canvasMap() you can translate between widget ( canvas ) and plot coordinates.

Uwe