PDA

View Full Version : plotting a binary file by using Qwt



Alex22
13th November 2015, 08:59
Hi all,

I have a data that includes two columns that each columns has 5 points. first column is "time" and second column is related value of the time for a signal. But because of being in binary format, the protocol is : odd data is time and even data is value. for example I have below numbers in my binary file:

0001000300020002000300040004000700050001

green color is time. and it means:

time | value
0001 | 0003
0002 | 0002
0003 | 0004
0004 | 0007
0005 | 0001

please help me how can I plot this binary file by Qwt?

Sintegrial
13th November 2015, 11:09
You have to "parse" your file first, so you become two arrays, one with time and second with values.
Then it is easy to pass these data to a Qwt curve object.

Alex22
13th November 2015, 11:38
You have to "parse" your file first, so you become two arrays, one with time and second with values.
Then it is easy to pass these data to a Qwt curve object.

no i need my project to work fast whit out any parseing or converting


You have to "parse" your file first, so you become two arrays, one with time and second with values.
Then it is easy to pass these data to a Qwt curve object.

no i need my project to work fast whit out any parseing or converting

Sintegrial
15th November 2015, 20:35
But you have to read the data from the file somehow.
Do it by 4 bytes (quint32 for example), pack them into two arrays and pass to the plot curve.

Alex22
16th November 2015, 14:37
But you have to read the data from the file somehow.
Do it by 4 bytes (quint32 for example), pack them into two arrays and pass to the plot curve.


thanks, but 4 bytes are little. i need put them binary data) from file in "char c[1024]" and then cast each byte (each cell) of "c" to float and then plot all. please help me in this way.

HappyCoder
17th November 2015, 07:36
I have below numbers in my binary file:

0001000300020002000300040004000700050001

green color is time. and it means:

time | value
0001 | 0003
0002 | 0002
0003 | 0004
0004 | 0007
0005 | 0001


You have 4 Byte time, 4 Byte value and so on.
Read them and append each to a QVector<double> and use
QwtPlotCurve::setSamples (const QVector< double > &xData, const QVector< double > &yData)
to plot it.

Alex22
18th November 2015, 16:50
You have 4 Byte time, 4 Byte value and so on.
Read them and append each to a QVector<double> and use
QwtPlotCurve::setSamples (const QVector< double > &xData, const QVector< double > &yData)
to plot it.

thanks for your answer. i have 1000 kB data in file. please help me how i can read and append?

HappyCoder
20th November 2015, 09:40
thanks for your answer. i have 1000 kB data in file. please help me how i can read and append?

I don't know your file format, but you should. How could i help you with that.

RTM QVector: http://doc.qt.io/qt-5/qvector.html