Results 1 to 7 of 7

Thread: Plotting part of a curve

  1. #1
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Plotting part of a curve

    Hello,

    I am new to Qwt and I do not find a way to draw only a part of a curve.
    Let me explain more precisely.

    I have huge data (multiple curves of 1 million points) to be plotted. To avoid duplicating data (which can be edited through a QTableView), I have a class inheriting QwtData for each Curve. These Curve objects are used by my table model linked with the QTableView.

    Then I have created a QwtPlotCurve object for each curve, and call setData with my own QwtData.

    Next, I call setAxisScale (and replot) regularly on my plot to display my curves with a "slidding window".

    The problem is that 100000 points curves works quite well, but 1 millions ones are really not.
    I have noticed that all the data are browsed even if only data between 30 to 100 (in X index) have to be displayed. I think that is the problem but I do not find a way to avoid that.

    I have notice the draw function which take two parameters (from and to) but I do not know how to use it.

    Any hint ? How can I boost all this stuff ?

    Thanks in advance

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

    Default Re: Plotting part of a curve

    With QwtPlotCurve::PaintFiltered or QwtPlotCurve::ClipPolygon you can reduce the number of points, that are painted.

    But the best way to optimize your performance is to implement level of details in your derived Data class: whenever the scales are changing ( f.e. QwtScaleWidget::scaleDivChanged() ) you adjust your data class, so that it returns less points to the curve object.

    Uwe

  3. The following 2 users say thank you to Uwe for this useful post:

    Kok (23rd September 2010), viridis (9th June 2008)

  4. #3
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plotting part of a curve

    Thanks a lot, it works just as I want and it allow me to do clever things !

  5. #4
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Plotting part of a curve

    Hi virdis,

    I think i have the same problem right now . If you don't mind can you give me a snippet of your "drived data class".

    It seems that you need to connect the QwtScaleWidget::scaleDivChanged() into your data class. Is that what you did?

    baray98

  6. #5
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plotting part of a curve

    Well,

    I will try to send you a snippet next week since all the stuff is at work !

  7. #6
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Plotting part of a curve

    thank you very much It will help me a lot...

    baray98

  8. #7
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plotting part of a curve

    Here we are :

    I have connected the scaleDivChanged signal of the xBottom axis to a slot.
    In this slot, I get the xBottom ScaleDiv :
    QwtScaleDiv* div = my_plot->axisScaleDiv(QwtPlot::xBottom);
    Then, for each of my curves :
    ((MyDataType&)my_curve->data()).updateScale(div->lBound(), div->hBound());

    MyDataType inherits QwtData and stores the current lower bound et higher bound which are changed by the updateScale method just used.
    Then, in the x and y methods, I just add the lower bound to the requested index and returns the corresponding value.
    The "size" function must be redefined too and it just returns (highBound-lowBound+1).

    To be noticed that I have just made a "proof of concept". There is maybe a clever way to do that but it works.

    Hope this help.

  9. The following 2 users say thank you to viridis for this useful post:

    baray98 (22nd July 2008), Kok (23rd September 2010)

Similar Threads

  1. Multi curves plotting issue
    By fallen in forum Qwt
    Replies: 5
    Last Post: 6th May 2008, 05:47

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.