[89] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
| 5 | *
|
---|
| 6 | * This library is free software; you can redistribute it and/or
|
---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
| 8 | *****************************************************************************/
|
---|
| 9 |
|
---|
| 10 | #ifndef QWT_CURVE_FITTER_H
|
---|
| 11 | #define QWT_CURVE_FITTER_H
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include "qwt_double_rect.h"
|
---|
| 15 |
|
---|
| 16 | class QwtSpline;
|
---|
| 17 |
|
---|
| 18 | #if QT_VERSION >= 0x040000
|
---|
| 19 | #include <QPolygonF>
|
---|
| 20 | #else
|
---|
| 21 | #include "qwt_array.h"
|
---|
| 22 | #endif
|
---|
| 23 |
|
---|
| 24 | // MOC_SKIP_BEGIN
|
---|
| 25 |
|
---|
| 26 | #if defined(QWT_TEMPLATEDLL)
|
---|
| 27 |
|
---|
| 28 | #if QT_VERSION < 0x040000
|
---|
| 29 | #ifndef QWTARRAY_TEMPLATE_QWTDOUBLEPOINT // by mjo3
|
---|
| 30 | #define QWTARRAY_TEMPLATE_QWTDOUBLEPOINT
|
---|
| 31 | template class QWT_EXPORT QwtArray<QwtDoublePoint>;
|
---|
| 32 | #endif //end of QWTARRAY_TEMPLATE_QWTDOUBLEPOINT
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | #endif
|
---|
| 36 |
|
---|
| 37 | // MOC_SKIP_END
|
---|
| 38 |
|
---|
| 39 | /*!
|
---|
| 40 | \brief Abstract base class for a curve fitter
|
---|
| 41 | */
|
---|
| 42 | class QWT_EXPORT QwtCurveFitter
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 | virtual ~QwtCurveFitter();
|
---|
| 46 |
|
---|
| 47 | #if QT_VERSION < 0x040000
|
---|
| 48 | virtual QwtArray<QwtDoublePoint> fitCurve(
|
---|
| 49 | const QwtArray<QwtDoublePoint>&) const = 0;
|
---|
| 50 | #else
|
---|
| 51 | /*!
|
---|
| 52 | Find a curve which has the best fit to a series of data points
|
---|
| 53 |
|
---|
| 54 | \param polygon Series of data points
|
---|
| 55 | \return Curve points
|
---|
| 56 | */
|
---|
| 57 | virtual QPolygonF fitCurve(const QPolygonF &polygon) const = 0;
|
---|
| 58 | #endif
|
---|
| 59 |
|
---|
| 60 | protected:
|
---|
| 61 | QwtCurveFitter();
|
---|
| 62 |
|
---|
| 63 | private:
|
---|
| 64 | QwtCurveFitter( const QwtCurveFitter & );
|
---|
| 65 | QwtCurveFitter &operator=( const QwtCurveFitter & );
|
---|
| 66 | };
|
---|
| 67 |
|
---|
| 68 | /*!
|
---|
| 69 | \brief A curve fitter using cubic splines
|
---|
| 70 | */
|
---|
| 71 | class QWT_EXPORT QwtSplineCurveFitter: public QwtCurveFitter
|
---|
| 72 | {
|
---|
| 73 | public:
|
---|
| 74 | enum FitMode
|
---|
| 75 | {
|
---|
| 76 | Auto,
|
---|
| 77 | Spline,
|
---|
| 78 | ParametricSpline
|
---|
| 79 | };
|
---|
| 80 |
|
---|
| 81 | QwtSplineCurveFitter();
|
---|
| 82 | virtual ~QwtSplineCurveFitter();
|
---|
| 83 |
|
---|
| 84 | void setFitMode(FitMode);
|
---|
| 85 | FitMode fitMode() const;
|
---|
| 86 |
|
---|
| 87 | void setSpline(const QwtSpline&);
|
---|
| 88 | const QwtSpline &spline() const;
|
---|
| 89 | QwtSpline &spline();
|
---|
| 90 |
|
---|
| 91 | void setSplineSize(int size);
|
---|
| 92 | int splineSize() const;
|
---|
| 93 |
|
---|
| 94 | #if QT_VERSION < 0x040000
|
---|
| 95 | virtual QwtArray<QwtDoublePoint> fitCurve(
|
---|
| 96 | const QwtArray<QwtDoublePoint> &) const;
|
---|
| 97 | #else
|
---|
| 98 | virtual QPolygonF fitCurve(const QPolygonF &) const;
|
---|
| 99 | #endif
|
---|
| 100 |
|
---|
| 101 | private:
|
---|
| 102 | #if QT_VERSION < 0x040000
|
---|
| 103 | QwtArray<QwtDoublePoint> fitSpline(
|
---|
| 104 | const QwtArray<QwtDoublePoint> &) const;
|
---|
| 105 | QwtArray<QwtDoublePoint> fitParametric(
|
---|
| 106 | const QwtArray<QwtDoublePoint> &) const;
|
---|
| 107 | #else
|
---|
| 108 | QPolygonF fitSpline(const QPolygonF &) const;
|
---|
| 109 | QPolygonF fitParametric(const QPolygonF &) const;
|
---|
| 110 | #endif
|
---|
| 111 |
|
---|
| 112 | class PrivateData;
|
---|
| 113 | PrivateData *d_data;
|
---|
| 114 | };
|
---|
| 115 |
|
---|
| 116 | #endif
|
---|