PDA

View Full Version : Linking QwtPlot panners



psk
3rd July 2013, 08:39
Hi,
Firstly thanks for offering a great library. I am impressed with the features and community!

Now to my problem, I have created an application where I have added multiple QwtPlots.
I've been able to follow the rasterview example to allow panning of the plot. I've been trying to link the panners so that If I pan one plot, the other plots are moved as well.

I've been able to connect the panned signal to the movedCanvas slot, but this only updates each plot after mouse release. To get the realtime movement (as I hold and drag the mouse) I've tried to install an eventFilter on the parent widget containing the multiple plots and send forward the mouseEvents to the multiple plots but it does not seem to do anything.

I'm also hoping to link a scrollbar to the parent widget containing the plots as another way to all pan the plots

I'm looking for any guidance on how I should achieve this.
Thanks
psk

Nicho
4th July 2013, 02:37
psk,
What you want may cause performance problem . Is that necessary ?

Uwe
4th July 2013, 07:06
I've been able to follow the rasterview example to allow panning of the plot. I've been trying to link the panners so that If I pan one plot, the other plots are moved as well.
The panner grabs the current content of the plot to a pixmap and creates a widget overlay, that is moving this pixmap without modifying the plot. The reason for this implementation is that that a user has a visual feedback without having to replot, what is often too slow for operations like panning.

If your application has plots, where replots are fast enough you might want to modify the real plot while scrolling/panning. F.e the eventFilter example shows how to scroll a plot with a QwtWheel - the code for several plots should be more or less the same.
If you want to implement "real" panning I would implement a event filter ( QObject::installEventFilter() ) for the plot canvas, that translates the mouse events into setAxisScale() calls. If you want to sync other plots according to scale changes of a plot you can connect to the QwtScaleWidget::scaleDivChanged() signal ( see QwtPlot::axisWidget() ).

HTH,
Uwe

psk
4th July 2013, 08:15
Thanks Nicho and Uwe for the clear explanation about the panner.
I'm having a go at what you've suggested Uwe. Update once I'm done (or stuck again)
Cheers,