[Qt-interest] real time strip chart
Ross Bencina
rossb-lists at audiomulch.com
Sat May 21 03:33:36 CEST 2011
Hi Giovanni
Some thoughts:
I don't know exactly how X works but I imagine you need to avoid transferring data back and forth between your App and the X server as much as possible. I'm not sure if Qt on X does all rendering using a software renderer or if some painting is done in the X server -- based on your experience it sounds like scrolling is at least done on the server -- ideally you want as much as possible done on the server.. perhaps you'll need to go lower-level than Qt for this.
How about something like this:
For each timer call, render a new "strip" in a new QPixmap. Keep a history of the strips and implement scrolling by repainting all the old strips in moved positions, and the new strip in its new position.
In theory (if my assuption above is correct) that should mean each QPixmap is only sent to the X server once.
You could experiment with reusing pixmaps but I'm not sure if it's a good idea.
Other ideas:
- If you can use OpenGL, use GL textures for the strips. Then they'll be cached on the graphics card.
- Investigate whether you can disable Qt's double-buffering for your widget, and try to make sure minimal scroll/copy operations are performed on the X server.
Just some ideas
Ross
----- Original Message -----
From: giovanni drogo
To: qt-interest at qt.nokia.com
Sent: Saturday, May 21, 2011 2:06 AM
Subject: [Qt-interest] real time strip chart
Hi All,
I'm developing a QT application which includes a real time chart (with several (8 or more) traces), similar to an ECG monitor. Traces should move on the monitor with a speed of about 5cm/sec. The active window is, in principle almost the whole screen. Target operating system is Linux.
Do somebody has some suggestion about the best approach?
I try to look in the archive, but all the messages I found are now too old.
The approach I'm taking now is the following:
I have a timer, clocking at about 50Hz. When the timer expires I compute the scrolling amount using the effective elapsed time, and I scroll the widget using the QWidget::scroll() function. Then I paint the traces in the empty space.
The algorithm is fine, but visual aspect is very bad. Traces run very unsmooth, unless the widget is made very small.
After some profiling I found that the QT program run quite fast: it takes only few milliseconds to scroll the widget and to paint the traces, however the X server is *really* busy. My impression is that, at the end of my PaintEvent, Qt simply tell X to repaint the whole widget, and this is clearly too much.
Before that I tried the classical canvas approach, scrolling and painting a QImage or a Qpixmaps, and drawing them to the widget. Results are even worst: computer and X server are so busy that timer event are lost!
Any suggestion?
Thanks in advance,
G. Drogo
------------------------------------------------------------------------------
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110521/02d784dd/attachment.html
More information about the Qt-interest-old
mailing list