Results 1 to 5 of 5

Thread: Problem with QwtCurveFitter

  1. #1
    Join Date
    Oct 2012
    Posts
    12
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Problem with QwtCurveFitter

    Hello,

    I derived my own fitter class from QwtCurveFitter and implemented the abstract method fitCurve. When I debugged the program, I noticed that the points that are passed to that method are in screen coordinates. The problem is now, that I want to implement a proportional fit to my data and I need to add the point (0.0, 0.0) to the result data. However, that point is of course not in screen coordinates, but in coordinates of my data points. Since I have no access to the curve or the plot in my derived class, I wondered if there is any way to translate the origin point to screen coordinates in the method MyCurveFitterClass:fitCurve.

    (A bad way would be to translate the coordinates before the fitter is appended to the curve and pass it to the instance of my class... I'd rather avoid that.)

    Some code:

    Qt Code:
    1. QPolygonF MyCurveFitterClass::fitCurve(const QPolygonF &polygon) const
    2. {
    3. // Do some calculation...
    4. QPolygonF result;
    5. // Add some calculated points.
    6. result.append(QPointF(0.0, 0.0));
    7. return result;
    8. }
    To copy to clipboard, switch view to plain text mode 

  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: Problem with QwtCurveFitter

    Quote Originally Posted by Crowley View Post
    (A bad way would be to translate the coordinates before the fitter is appended to the curve and pass it to the instance of my class... I'd rather avoid that.)
    There is nothing bad about it - it depends.

    When you add the fitter to a curve it is intended to make it visually nicer ( that's why fitting is done for the translated points ). But f.e. QwtWeedingCurveFitter is an expensive algorithm ( too expensive to do it for every replot ) and you would usually use it to reduce the number of points once ( or depending on a zoom level ) and pass the fitted points to the curve.

    But if you really want to apply your fitting algorithm each time it is painted you might implement it inside of a QwtSeriesData<QPointF> object that you can insert between the curve and your samples.

    Uwe

  3. #3
    Join Date
    Oct 2012
    Posts
    12
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Problem with QwtCurveFitter

    Hm, I do not quite understand what you mean. Of course I need to re-plot the fitted curve every time it needs to be re-plottet: when the zoom changes, when the plot is paned or when the data changes. While I could control the latter event, I find it quite convenient that the fitter functionality takes care not only about the first two events, but of all three of them.

    But if you really want to apply your fitting algorithm each time it is painted you might implement it inside of a QwtSeriesData<QPointF> object that you can insert between the curve and your samples.
    Sounds promising. Can you perhaps give a quick example? (I am still quite new to QT and qwt.) Thanx.

  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: Problem with QwtCurveFitter

    Of course I need to re-plot the fitted curve every time it needs to be re-plottet: when the zoom changes, when the plot is paned or when the data changes..
    But you don't need to apply an expensive fitting algorithm each time the plot is resized or for scale changes ( f.e panning ) - when fitting is done with the untranslated points. Basically you don't need to recalculate any fitting, when none of the parameters going into your algo have changed !

    You slow down the replot operation with a heavy calculation where you always get the same result !

    Uwe

  5. #5
    Join Date
    Oct 2012
    Posts
    12
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Problem with QwtCurveFitter

    You are right about slowing down the replot operation. I reorganized my code and it works well now. Thanx. :-)

Similar Threads

  1. Replies: 20
    Last Post: 22nd July 2010, 07:35

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.