Results 1 to 4 of 4

Thread: plot only subset of the data

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default plot only subset of the data

    I have data with >1e6 entries. I want from these arrays howeve only a subset to be plotted. For example only the last 1000 entries.
    To assign the data fast I use 'setRawData'

    But what needs to be done to let qwt know that it shall only work with the last 1000 entries?

    Matthias

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: plot only subset of the data

    Derive from QwtData and implement your filters there.

    Uwe

  3. #3
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: plot only subset of the data

    Quote Originally Posted by Uwe View Post
    Derive from QwtData and implement your filters there.
    Could you direct me to an example, I could not figure out how this could be implemented.

    In the meanwhile I implented the following
    Qt Code:
    1. void QCurvePlot::setData(const unsigned int number, const double * xData, const double * yData, int start, int size)
    2. {
    3. if (number <= m_data.size())
    4. {
    5. int arraynumber = number - 1;
    6. if (m_data[arraynumber].x != NULL )
    7. delete [] m_data[arraynumber].x;
    8. if (m_data[arraynumber].y != NULL )
    9. delete [] m_data[arraynumber].y;
    10. m_data[arraynumber].x = new double [size];
    11. m_data[arraynumber].y = new double [size];
    12. memcpy(m_data[arraynumber].x, xData + start, size * sizeof(double));
    13. memcpy(m_data[arraynumber].y, yData + start, size * sizeof(double));
    14. Curve[number].setRawData(m_data[arraynumber].x, m_data[arraynumber].y, size);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    which however does not use any qwt code at all.

    Matthias

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: plot only subset of the data

    Quote Originally Posted by pospiech View Post
    Could you direct me to an example, I could not figure out how this could be implemented.
    Qwt itsself is full of examples. Look at the classes in qwt_data.h, or in the simple example. ( Passing double arrays also creates an internal QwtData object ).

    If I were in your shoes I would implement a data object, that has a pointer to your original data structure holding your samples. Then you can add filters like "every 10th point" or whatever, and implement these filters easily in the virtual methods of QwtData.
    In my example YourData::x(i) would return the x value from the sample 10*i from your structure.

    Note, that you have to implement YourData::copy(). Here you have to copy the API - not the data itsself!

    Uwe

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 03:59
  2. Replies: 4
    Last Post: 19th October 2007, 19:47
  3. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 12:14
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.