Results 1 to 9 of 9

Thread: How to do asynchronous points loading.?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: How to do asynchronous points loading.?

    Quote Originally Posted by kuzulis View Post
    The problem is in access to the "low-level" QwtSeriesData from the parent Plot.
    Should I do it like this (pseudo code)
    The idea of QwtSeriesData is to have abstract API for the curve to retrieve data, but the application is free to organize the data itself according to what is best for the use case.
    So why not simply load your data into some buffer - an operation unrelated to Qwt. Once this is done connect your curve data object to this buffer and call replot.

    Uwe

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 43 Times in 42 Posts

    Default Re: How to do asynchronous points loading.?

    Once this is done connect your curve data object to this buffer and call replot.
    Do you mean to use the set of setSamples() methods?

    If so, then it is not an optionn for me, because it causes an overheads:
    it copies and re-creates the internal QwtSeriesData objects each time when calls setSamples() (as I can see).

    The "right" way for me - it is to call the Curve::setData() once.

    Let's me explain:

    let's assume that an initial interval of interests data is: 2 second - 10 second (width is 8 second).

    The next interval will be: 3 second - 11 second (width is 8 second too)..

    So, I do not need to re-fill the whole buffer for 3 second - 11 second.
    I need just to append to the buffer the points between 10-11 seconds,
    and to remove the points from 2-3 second (to keep the width same 8 second).

    But, of course, in case of changing of the width of interval, I will re-fill whole buffer with new points
    (because in this case the detail level is changed, its like the zoom changed).

    So, as I understand, it is better for me to have an *one* custom QwtSeriesData object with
    "tricks", related to re-implementing of the setRectOfInterest() (where I will my buffer what I need).

    UPD:

    Maybe, even I can do not use the QwtSeriesData at all, and just override the dataSize(), dataRect() and
    setRectOfInterest() of QwtPlotCurve class... But, I'm afraid that it is wrong..
    Last edited by kuzulis; 24th November 2016 at 13:12.

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: How to do asynchronous points loading.?

    Quote Originally Posted by kuzulis View Post
    Do you mean to use the set of setSamples() methods?
    No:

    Qt Code:
    1. class YourData: public QwtSeriesData<QPointF>
    2. {
    3. virtual size_t size() const override
    4. {
    5. return ...;
    6. }
    7.  
    8. virtual QPointF sample( size_t i ) const override
    9. {
    10. return ...;
    11. }
    12.  
    13. virtual QRectF boundingRect() const override
    14. {
    15. // be careful with not introdicing a performance bottleneck here
    16. // better calculate it in advance an cache it
    17. return ...;
    18. }
    19. };
    20.  
    21. curve->setData( new YourData() );
    To copy to clipboard, switch view to plain text mode 

    It's totally up to you how these methods are implemented, but I guess they return values from some custom buffer. How these values come to this buffer is up the the application, Qwt does not see it.

    setSamples()
    Qt containers are implicitly shared: see http://doc.qt.io/qt-5/implicit-sharing.html.

    So if you load your values only for the purpose of displaying it on the plot using a QPolygonF + setSamples is just fine. The only thing you could consider is to call setSamples( QPolygonF() ) before loading a new set of samples. Otherwise you need memory for 2 buffers until you can pass the new one in.

    Uwe

  4. #4
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 43 Times in 42 Posts

    Default Re: How to do asynchronous points loading.?

    Ok, many thanks for your help. I will think...

Similar Threads

  1. Replies: 3
    Last Post: 16th December 2015, 20:39
  2. Why isn't QTimer asynchronous?
    By Hossein in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2015, 20:02
  3. Asynchronous loading from HTTP (as data stream)
    By shestero in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2012, 11:45
  4. Replies: 2
    Last Post: 2nd May 2012, 10:49
  5. asynchronous vs. synchroneous
    By timmu in forum Qt Programming
    Replies: 4
    Last Post: 28th August 2009, 11:48

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
  •  
Qt is a trademark of The Qt Company.