PDA

View Full Version : Smartest way of efficiently replot with Qwt



Momergil
6th May 2014, 14:40
Hello!

As some older posts show, I'm trying to plot some graphs in a embedded linux environment which requires very efficient plotting using Qwt. For now I'm looking how to do this considering Qwt alone, and with this respect I noticed that use replot() constantly wasn't a good idea, so I decided to move towards a way of higher plot efficiency and I came about using QwtPlotDirectPainter.

Here comes my first question: is there another way of improve plotting efficiency than by using QwtPlotDirectPainter instead of QwtPlot::replot()? Is there somewhere, btw, a manual with all tips and tricks of Qwt including those related to plot efficiency?

Now considering this method (using QwtPlotDirectPainter). As the manual states, it draws only the desired, new data (if so configured) without erasing the background. Now this is a little bit inconvenient, for I'll need to repaint only the part of a curve that has new data, but obviously erasing the paintings related to a older value. If one wants to use a invariable points vector for drawing (so when the new data reaches the last point in the vector, it starts populating from 0 again), I wouldn't know how to use QwtPlotDirectPainter for this, leading either to call QwtPlot::replot() each time the points vector is completely changed (such as in the code posted here¹) or having to abandon a fixed sized QVector in favor of a continuously growing QwtPlot.

Second question: is there a way to come around this problem with QwtPlotDirectPainter?



Thanks,

Momergil



¹: http://www.qtcentre.org/threads/59028-QwtPlotDirectPainter-not-plotting-correctly?p=262506

Uwe
7th May 2014, 07:13
First of all I would always decouple the sample rate from the refresh rate of the plot. F.e by using a timer that updates the plot in fixed intervals ( of course only when new samples have arrived ). Then you can avoid that the plot updates kill your system by reducing the refresh rate.

Next you have to accept, that the only way to erase parts of the plot is by repainting it - this is a general limitation since Qt 4 ( Qt3 was the last version offering painting in XOR mode ). So you can try to avoid, hat you have to repaint something ( like it is done in the oscilloscope example ) or you can try to speed up repainting of the area to be erased. What exactly can be done heavily depends on the individual characteristics of a plot, but the second option usually means to have a stable part that can be cached in a pixmap.

Uwe

Momergil
7th May 2014, 13:08
Hello Uwe and thanks for the reply.


First of all I would always decouple the sample rate from the refresh rate of the plot. F.e by using a timer that updates the plot in fixed intervals ( of course only when new samples have arrived ). Then you can avoid that the plot updates kill your system by reducing the refresh rate.

No problem; already done.



you can try to speed up repainting of the area to be erased. What exactly can be done heavily depends on the individual characteristics of a plot, but the second option usually means to have a stable part that can be cached in a pixmap.
Uwe

I'm not familiar with this solution. Is there any example of this in Qwt's examples or somewhere you know?

Finally, a new question: QwtPlot::replot() performs a repaint of all the area. Isn't there a way to re-implement replot (or create another method) that does the same, but for a limited, defined area? If that can be done, than I probably will use this tactic.


Thanks,

Momergil