PDA

View Full Version : Updating QwtPlot from QThread



atzengin
5th April 2011, 11:04
Hi everybody, this is my first post to this forum. I'm noob to both Qt and C++.

I'm trying to implement a gui for my hardware which takes analog data by a PCI AD card and processes all those data and visualize by using QwtPlot. Besides it does some other control by using a PCI DA and PCI Counter boards.

What I'm doing now in visualization part is, acquiring the data by a QThread then showing them as QwtPlotCurve objects in the main thread. Since I have too much data (getting 12 channels simultaneously) I have 12 curve objects. Storing the data in a QVector<QVector<double>> which is 13 x 2000 (may change) and updating all those curve data in the main thread takes too much of cpu time. This makes the gui less responsive (pressing the stop button responses after 5 seconds or sometimes never)

What I want to do is, updating the QwtPlotCurves in a new QThread like the other QThread acquiring data. But when I tried this, I could not reach the Qwt objects from inside of the thread.

I've checked both the forum and the Qt4 book I have. The way to communicate between threads is using signal/slot, I know. But when I use this way, main thread will still be busy when the slot is called to update the curves.

I'm asking some ideas, how to overcome this? Most probably I'm missing something since I'm totally a noob. All your comments are welcome.
Thanks

boudie
5th April 2011, 13:33
Stick to one thread and call processEvents in the loop.
That will make your gui responsive again.

JohannesMunk
5th April 2011, 13:54
I'm having the exact same situation here. Real-Time-Data-Acquisition-Oscilloscope !

You should leave the acquisition in a separate thread with higher priority. To reduce the load for the gui thread you could prepare a QwtSeriesData and pass it through a signal to your gui thread. There you use a QwtPlotDirectPainter to plot only the data that just arrived and avoid replotting everything.

If that is still not fast enough, qwt provides the QwtWeedingCurveFitter. With it you can subsample your data to make plotting faster. http://www.qtcentre.org/threads/28435-Implimentation-advice-for-a-large-data-plotting-application

Let me know if you need more details,

HIH

Johannes

lamle
5th April 2012, 08:05
I'm having the exact same situation here. Real-Time-Data-Acquisition-Oscilloscope !

You should leave the acquisition in a separate thread with higher priority. To reduce the load for the gui thread you could prepare a QwtSeriesData and pass it through a signal to your gui thread. There you use a QwtPlotDirectPainter to plot only the data that just arrived and avoid replotting everything.

If that is still not fast enough, qwt provides the QwtWeedingCurveFitter. With it you can subsample your data to make plotting faster. http://www.qtcentre.org/threads/28435-Implimentation-advice-for-a-large-data-plotting-application

Let me know if you need more details,

HIH

Johannes

Hi Johannes,
I am having exactly the same issue, can you provide more details please
Thanks,Lam