PDA

View Full Version : Need advice or how to increase drawing perfomance



dkoryagin
16th November 2011, 15:21
Hello all!

I'm making diagnostic program for my embedded project. Program connects with device over usb and recieve some data, but it's not important. Important thing is that recieved data have many discrete signals which i must show.
Here is screenshot of my program:
7108
(sorry for russian text on screenshot :) )
On the left and right sides of program you can see rectangles with discrete signals(58 signals)...I'm drawing them by redefinition of paint method and painter.
Main problem in update :( They must be updated every 500-1000 msec.

So, here is question...what is the best way of solving this problem? Make timer and connect it to repaint method? But in this case perfomance will be very bad....
Maybe exists other way?

Oleg
16th November 2011, 18:00
First of all, are you sure it's really needed to update visible data with such interval? Even 1 second is very fast when there's lots of info.

The second question is, are you redrawing all rectangles with text labels every update? Or only squares near labels should be updated?

You can improve repainting performance using OpenGL, but I'm really not sure that it's the best solution for you.

dkoryagin
17th November 2011, 03:58
yep, i'm sure. Some discrete signals are pretty fast and i need to catch them =(
Only rectangles need to be repainted, text near them is static.

I thought about opengl, but i think it's like shooting a cannon at sparrows :) Using opengl for 58 rectangles....is bad idia i think :)
I think, that best way is to make rectangles as widgets and update only them...

ecanela
17th November 2011, 05:10
i dont know the spec of your project, but whit the info provided. maybe this solution are good.
one possible solution are store the value of each signal every 500-1000 msec, but ONLY update the display every one or two second.


sorry my poor english.

Santosh Reddy
17th November 2011, 07:16
You can connect a timer to update() (instead of paint method), this would more optimized way. What was the reason for redefining the paint method, where as it looks like simple QCheckBox(s) in a vertical layout could have done the job.

I don't think you will have performance issue with 58 signals (data), though care must to taken to update the complete widget / window at once in 500/1000 ms (don't paint the UI for each signal / data individually). If you use Qt standard widgets (like QCheckBox) and connect timer to update() slot, refreshing of widget is optimized internally (multiple update() in individual widgets will cause a single repaint on each widget, provided update() on all the widgets is called in same event exec cycle, i.e. inside the slot connected to timer).

Also if you are expecting data over USB to arrive at ~500ms, I suggest to used some kind to queuing mechanism between the USB interface and UI component, this will ensure that you have a consistent UI performance. Also data queuing will be an option when you feel the response of UI is not upto the expected mark, generally the timer method should work.

dkoryagin
17th November 2011, 12:49
What was the reason for redefining the paint method, where as it looks like simple QCheckBox(s) in a vertical layout could have done the job.
Handmade rectangles more beautiful :D

Thanks all, i will try those methods today...

Santosh Reddy
17th November 2011, 23:55
Just FYI you can use handmade rectangles in QCheckBox also. Refer Qt Style Sheets

d_stranz
18th November 2011, 00:22
I agree with Santosh and ecanela - break the connection between the rate at which you collect data, and the rate at which you update the display. No human can see the changes to 58 signals several times each second, so you really should update the display at the rate a human can process. Using a QTimer connected to an update() slot is a good way to go, I think.