plotting a binary file by using Qwt
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?
Re: plotting a binary file by using Qwt
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.
Re: plotting a binary file by using Qwt
Quote:
Originally Posted by
Sintegrial
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
Quote:
Originally Posted by
Sintegrial
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
Re: plotting a binary file by using Qwt
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.
Re: plotting a binary file by using Qwt
Quote:
Originally Posted by
Sintegrial
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.
Re: plotting a binary file by using Qwt
Quote:
Originally Posted by
Alex22
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.
Re: plotting a binary file by using Qwt
Quote:
Originally Posted by
HappyCoder
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?
Re: plotting a binary file by using Qwt
Quote:
Originally Posted by
Alex22
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