PDA

View Full Version : Zoom and pan with two y-axes



mjfj
30th June 2010, 15:00
Hello,
I've seen a lot of questions about QwtPlotZoomer already that are related to my question. I combined some of the hints from the answers, but still haven't worked it out, yet.

We have a QwtPlot with two y axes (showing different units) and one x -axis. We want to zoom and pan over the x and both y axes. I've copied the source code for the ScrollZoomer from the "realtime_plot" example to get zoom and pan working. Then I looked at the "bode" example to get zooming work for two axes, by adding a second QwtPlotZoomer for the right y-axis. Now, the zooming seems to work for the left y-axis and the right scale also responds to the zooming. But, when scrolling the vertical scrollbar, the window only pans for the left axis, not the right. Also the zoom area doesn't seem to completely be the area that I zoomed in on.
I assume, because the scrollbars are only connected to the left y-axis. So somehow the scrollbars have to synchronize the left and right y-axis. And maybe because both axes have different scales, they interfere with each other.

Am I on the right path by installing a second QwtPlotZoomer for the right y-axis? Or should I stay with one ScrollZoomer and modify it to synchronize the two y-axes? Or even use two ScrollZoomers for both axes that share the same scrollbars?

Thanks,
Michiel

FelixB
19th October 2010, 10:39
Hi Michiel,

I had the same problem and found a very simple solution:


connect(zoomer1, SIGNAL(zoomed(const QwtDoubleRect &)), zoomer2, SLOT(zoom(const QwtDoubleRect &)) );
since the "zoomed" signal is also emitted when you move the scrollbars, the second zoomer always gets synchronized :)

Felix