Results 1 to 8 of 8

Thread: plotting a binary file by using Qwt

  1. #1
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default 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?
    Last edited by Alex22; 13th November 2015 at 10:06.

  2. #2
    Join Date
    Mar 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: plotting a binary file by using Qwt

    Quote Originally Posted by Sintegrial View Post
    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 View Post
    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

  4. #4
    Join Date
    Mar 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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.

  5. #5
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: plotting a binary file by using Qwt

    Quote Originally Posted by Sintegrial View Post
    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.

  6. #6
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: plotting a binary file by using Qwt

    Quote Originally Posted by Alex22 View Post
    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.

  7. The following user says thank you to HappyCoder for this useful post:

    Alex22 (18th November 2015)

  8. #7
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: plotting a binary file by using Qwt

    Quote Originally Posted by HappyCoder View Post
    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?

  9. #8
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: plotting a binary file by using Qwt

    Quote Originally Posted by Alex22 View Post
    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

Similar Threads

  1. plotting a binary file
    By Alex22 in forum Newbie
    Replies: 1
    Last Post: 7th November 2015, 21:41
  2. Qwtplot3d Plotting file containing 3D points.
    By spikestar in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2012, 00:08
  3. Replies: 19
    Last Post: 11th May 2012, 22:06
  4. Replies: 0
    Last Post: 4th August 2009, 16:24
  5. How to Print a doc file (or binary file) to printer
    By rmagro in forum Qt Programming
    Replies: 15
    Last Post: 5th September 2008, 16:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.