Results 1 to 10 of 10

Thread: Qwt spline fitter - it doesn't work as expected

Threaded View

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

    Default Re: Qwt spline fitter - it doesn't work as expected

    I tried your points with the following code:

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qwt_plot.h>
    3. #include <qwt_plot_curve.h>
    4. #include <qwt_curve_fitter.h>
    5. #include <qwt_symbol.h>
    6.  
    7. int main(int argc, char **argv)
    8. {
    9. const QColor color(35, 70, 106);
    10.  
    11. QApplication a(argc, argv);
    12.  
    13. QwtPlot plot;
    14. plot.setCanvasBackground(Qt::white);
    15. plot.resize(600,400);
    16. plot.show();
    17.  
    18. const double x[] = { 0, 1, 2, 4, 5, 8 };
    19. const double y[] = { 17, 16.5, 8, 3, 12, 14.5 };
    20.  
    21. // Insert new curves
    22. QwtPlotCurve *curve = new QwtPlotCurve();
    23. curve->setStyle(QwtPlotCurve::Lines);
    24. curve->setCurveAttribute(QwtPlotCurve::Fitted, true);
    25.  
    26. QwtSymbol symbol;
    27. symbol.setStyle(QwtSymbol::Rect);
    28. symbol.setSize(10, 10);
    29. symbol.setBrush(color);
    30.  
    31. curve->setSymbol(symbol);
    32.  
    33. fitter->setFitMode(QwtSplineCurveFitter::ParametricSpline);
    34. fitter->setSplineSize(100);
    35. curve->setCurveFitter(fitter);
    36.  
    37. curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    38. curve->setPen(QPen(color, 3));
    39.  
    40. curve->setData(x, y, 6);
    41. curve->attach(&plot);
    42.  
    43. return a.exec();
    44. }
    To copy to clipboard, switch view to plain text mode 

    The result is different compared to the OpenOffice curve, but what exactly makes you so unhappy with it ?

    Uwe

    PS: You can play with the spline size parameter. IMHO the curve looks better with a value of 50.
    Attached Images Attached Images

Similar Threads

  1. Can qwt work on Windows 7 x64?
    By RavenS in forum Qwt
    Replies: 0
    Last Post: 28th March 2009, 09:37
  2. QHTTP::GET doesn't work as expected !
    By tuthmosis in forum Qt Programming
    Replies: 1
    Last Post: 27th July 2008, 15:45

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.