fcona (9th May 2018)
Thank you very much! I'll surely have a look at that.
Bests,
Filippo
I managed to implement the plot update using the QwtDirectPainter::drawSeries(), but now I have another problem.
When the trace reaches the end of the screen it restarts from the left side, but the new points instead of replacing old ones are plotted over them.
This does not happen if I call replot() after drawing the series, but using replot again increases the CPU usage to a condition worse than the initial one, while not calling replot actually improves the CPU usage even if the screen gets cluttered with points after the trace reaches the right end a bunch of times.
I see that in the oscilloscope example the window is moved to the right when the trace reaches the right end, while in my case I keep the origin of time axis at 0 seconds (I do want one trace to be visible until the following one "eats" it away). Is there a way to configure the painter to work this way?
Bests,
Filippo
Ok, I just read this warning in QwtDirectPainter documentation:
"Incremental painting will only help when no replot is triggered by another operation ( like changing scales ) and nothing needs to be erased."
So I guess I should give up this development branch...
Any other trick for improving performance is very welcome. I need to handle both the case in which there's only one trace that "eats" its own tail after reaching the right end of the screen and the case in which the last N traces are kept on the monitor (at the moment I have N QwtPlotCurve which I update circularly with new traces with setRawSamples method). The problem in the end is that in case 2 the N traces create quite a lot of points for replot to handle and while on my development desktop the application runs almost smoothly, it will crash on a typical notebook as soon as I increase the sampling rate a bit. Moreover, my actual implementation is completely non scalable: the CPU usage depends on the number of traces which I simply cannot increase too much, no matter how powerful my pc is.
Bests,
Filippo
Well this one should be doable with using QwtDirectPainter. All you need to do is to call replot manually once, when the curve restarts - like it is done in the oscilloscope example.
In this case all previous points have a different position, what means you always have to replot. Then it depends on how many points you have and of course on the specific attributes being used for drawing the curve.and the case in which the last N traces are kept on the monitor (at the moment I have N QwtPlotCurve which I update circularly with new traces with setRawSamples method).
For reducing the number of points I again recommend to have a look at the QwtPlotCurve::FilterPointsAggressive flag. It is useful for line plots being monotonic in x or y direction. The effect is, that it limits the number of points to be rendered in the worst case to 4 * the canvas width ( or height ).
Concerning the attributes: antialiasing or a pen width > 1 slow down rendering. You could also try a OpenGL canvas ( better use trunk then ) - or Qt4/X11 ( graphicssystem=native ), what is the best choice for hardware acceleration. Guess you don't use symbols - as this doesn't make too much sense for your type of plot.
And of course always decouple the refresh rate of the plot from the sample rate. 10 fps should be by far good enough for oscilloscopes as only few pixels on screen are changing, but often less frequent updates are fine as well.
Uwe
The oscilloscope example is a bit different because it completely clears the old trace, while in my case it'd need to disappear gradually as the new trace is plotted over it (For some odd reason which I haven't figured out yet in my case calling the replot when the curve restarts as you suggest doesn't even clear the plot, but that's most probably due to something stupid I did...)
Maybe these images can clear what I mean:
oscilloscope:
oscilloscope.png
my application:
my application.jpg
This is my application with the 10 traces overlapped (the more saturated the color the more recent the trace):
10 traces.jpg
Not sure what you mean byIn this case all previous points have a different positionI checked it and it is very interesting because I already do something similar to reduce the amount of points when there are just too many to plot compared to the available widht in pixels, so I might switch to using QwtPlotCurve::FilterPointsAggressive that seems much more optimized!For reducing the number of points I again recommend to have a look at the QwtPlotCurve::FilterPointsAggressive flag.
When I inherited the software it had a pen width of 2 and actually it was much more demanding. Fortunately I read on a forum that it could be a good idea to use thin curves and corrected them.Concerning the attributes: antialiasing or a pen width > 1 slow down rendering
Is there any example of how I can use OpenGL canvas?You could also try a OpenGL canvas
That's exactly my refresh rate10 fps should be by far good enough for oscilloscopes
Thanks again for the great support!
Filippo
Bookmarks