PDA

View Full Version : How to directly plot 'short' type data rather than 'double' type in QwtPlotCurve



songx6688
26th November 2013, 13:27
Hello everybody,
I come from china, hope my expression is not too bad:p.
Currenty I am in a project and my job is programming a software to show and analyze data collected from one 14 bits AD converter.The software is done with
qt5.1.0 and qwt6.1.0.
The type of data received from AD converter is 'short', two bytes long. But now I find that when I trying to plot the data with QwtPlotCurve, I must transfer the
data from 'short' to 'double'. Because all the interfaces I can find in QwtPlotCurve to plot data are only working with 'double' type. So this process is really memory consuming. For example , When I receive one megabytes data from AD converter, I need extra four megabytes memory to transfer data from short
to double and then plot the data with the transtered double type data.
In extreme case, I need to receive eighty megabytes data one time. So with this transfer process, my software often faces memory allocation failure bacause I
also have other memory consuming work to do in other place in the software.
I tried my best to find a way to directly plot 'short' type data but I failed.So cound anybody to tell me how to directly plot 'short' type data?

Thank you
Ben

Uwe
26th November 2013, 13:50
You can store your samples however you like, all you need to do is to implement a bridge for QwtPlotCurve how to iterate over them by deriving a class from QwtSeriesData<QPointF>.
So for example you could store your samples in 2 vectors of shorts, returning a temporary QPointF in the implementation of "YourData::sample (size_t i) const".

When you are low on memory you might also want to play with the paint attributes of the curve ( QwtPlotCurve::PaintAttribute ) - f.e QwtPlotCurve::MinimizeMemory - to avoid that too much memory is used for the temporary buffers during rendering.

Uwe

songx6688
27th November 2013, 00:56
Thank you Uwe, it works.