source: ntrip/branches/BNC_2.11.0/qwt/qwt_curve_fitter.h@ 10110

Last change on this file since 10110 was 4271, checked in by mervart, 13 years ago
File size: 3.2 KB
Line 
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 <qpolygon.h>
15#include <qrect.h>
16
17class QwtSpline;
18
19/*!
20 \brief Abstract base class for a curve fitter
21*/
22class QWT_EXPORT QwtCurveFitter
23{
24public:
25 virtual ~QwtCurveFitter();
26
27 /*!
28 Find a curve which has the best fit to a series of data points
29
30 \param polygon Series of data points
31 \return Curve points
32 */
33 virtual QPolygonF fitCurve( const QPolygonF &polygon ) const = 0;
34
35protected:
36 QwtCurveFitter();
37
38private:
39 QwtCurveFitter( const QwtCurveFitter & );
40 QwtCurveFitter &operator=( const QwtCurveFitter & );
41};
42
43/*!
44 \brief A curve fitter using cubic splines
45*/
46class QWT_EXPORT QwtSplineCurveFitter: public QwtCurveFitter
47{
48public:
49 /*!
50 Spline type
51 The default setting is Auto
52 \sa setFitMode(), FitMode()
53 */
54 enum FitMode
55 {
56 /*!
57 Use the default spline algorithm for polygons with
58 increasing x values ( p[i-1] < p[i] ), otherwise use
59 a parametric spline algorithm.
60 */
61 Auto,
62
63 //! Use a default spline algorithm
64 Spline,
65
66 //! Use a parametric spline algorithm
67 ParametricSpline
68 };
69
70 QwtSplineCurveFitter();
71 virtual ~QwtSplineCurveFitter();
72
73 void setFitMode( FitMode );
74 FitMode fitMode() const;
75
76 void setSpline( const QwtSpline& );
77 const QwtSpline &spline() const;
78 QwtSpline &spline();
79
80 void setSplineSize( int size );
81 int splineSize() const;
82
83 virtual QPolygonF fitCurve( const QPolygonF & ) const;
84
85private:
86 QPolygonF fitSpline( const QPolygonF & ) const;
87 QPolygonF fitParametric( const QPolygonF & ) const;
88
89 class PrivateData;
90 PrivateData *d_data;
91};
92
93/*!
94 \brief A curve fitter implementing Douglas and Peucker algorithm
95
96 The purpose of the Douglas and Peucker algorithm is that given a 'curve'
97 composed of line segments to find a curve not too dissimilar but that
98 has fewer points. The algorithm defines 'too dissimilar' based on the
99 maximum distance (tolerance) between the original curve and the
100 smoothed curve.
101
102 The smoothed curve consists of a subset of the points that defined the
103 original curve.
104
105 In opposite to QwtSplineCurveFitter the Douglas and Peucker algorithm reduces
106 the number of points. By adjusting the tolerance parameter according to the
107 axis scales QwtSplineCurveFitter can be used to implement different
108 level of details to speed up painting of curves of many points.
109*/
110class QWT_EXPORT QwtWeedingCurveFitter: public QwtCurveFitter
111{
112public:
113 QwtWeedingCurveFitter( double tolerance = 1.0 );
114 virtual ~QwtWeedingCurveFitter();
115
116 void setTolerance( double );
117 double tolerance() const;
118
119 virtual QPolygonF fitCurve( const QPolygonF & ) const;
120
121private:
122 class Line;
123
124 class PrivateData;
125 PrivateData *d_data;
126};
127
128#endif
Note: See TracBrowser for help on using the repository browser.