3 #include <qpainterpath.h> 6 static QPolygonF qwtBasisUniformKnots(
const QPolygonF& points )
8 const int n = points.size();
18 kx[n-3] = 6.0 * points[n-2].x() - points[n-1].x();
19 ky[n-3] = 6.0 * points[n-2].y() - points[n-1].y();
21 for (
int i = n - 4; i >= 0; i-- )
23 u[i] = 4.0 - 1.0 / u[i+1];
24 kx[i] = 6.0 * points[i+1].x() - kx[i+1] / u[i+1];
25 ky[i] = 6.0 * points[i+1].y() - ky[i+1] / u[i+1];
32 for (
int i = 1; i < n - 1; i++ )
34 knots[i].rx() = ( kx[i-1] - knots[i-1].x() ) / u[i-1];
35 knots[i].ry() = ( ky[i-1] - knots[i-1].y() ) / u[i-1];
38 knots[n-1] = points[n-1];
46 const QPointF &p1,
const QPointF &p2,
const QPointF &p3,
const QPointF &p4,
47 QPointF &cp1, QPointF &cp2 )
53 const double t123 = t1 + t2 + t3;
55 cp1 = ( t2 + t3 ) / t123 * p2 + t1 / t123 * p3;
56 cp2 = ( t3 * p2 + ( t1 + t2 ) * p3 ) / t123;
63 const int n = points.size();
64 const QPointF *pd = points.constData();
68 QPointF cp1 = ( 2.0 * pd[0] + pd[1] ) / 3.0;;
76 const QPointF cpN = ( pd[n-1] + 2.0 * pd[0] ) / 3.0;
77 path.moveTo( 0.5 * ( cpN + cp1 ) );
80 for (
int i = 1; i < n - 1; i++ )
82 const QPointF cp2 = ( pd[i-1] + 2.0 * pd[i] ) / 3.0;
83 const QPointF cp3 = ( 2.0 * pd[i] + pd[i+1] ) / 3.0;
85 path.cubicTo( cp1, cp2, 0.5 * ( cp2 + cp3 ) );
92 const QPointF cp2 = ( pd[n-2] + 2.0 * pd[n-1] ) / 3.0;
93 path.cubicTo( cp1, cp2, pd[n-1] );
97 const QPointF cp2 = ( pd[n-2] + 2.0 * pd[n-1] ) / 3.0;
98 const QPointF cp3 = ( 2.0 * pd[n-1] + pd[0] ) / 3.0;
100 path.cubicTo( cp1, cp2, 0.5 * ( cp2 + cp3 ) );
104 const QPointF cp4 = ( pd[n-1] + 2.0 * pd[0] ) / 3.0;
105 const QPointF cp5 = ( 2.0 * pd[0] + pd[1] ) / 3.0;
107 path.cubicTo( cp3, cp4, 0.5 * ( cp4 + cp5 ) );
118 const int n = points.size();
119 const QPointF *pd = points.constData();
132 double t012 = t0 + t1 + t2;
133 QPointF cp1 = ( ( t1 + t2 ) * pd[0] + t0 * pd[1] ) / t012;
142 const QPointF cpN = ( t1 * pd[n-1] + ( tN + t0 ) * pd[0] ) / ( tN + t0 + t1 );
144 p0 = ( t1 * cpN + t0 * cp1 ) / ( t0 + t1 );
150 for (
int i = 1; i < n - 2; i++ )
153 const double t123 = t1 + t2 + t3;
155 const QPointF cp2 = ( t2 * pd[i-1] + ( t0 + t1 ) * pd[i] ) / t012;
156 const QPointF cp3 = ( ( t2 + t3 ) * pd[i] + t1 * pd[i+1] ) / t123;
158 const QPointF p2 = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 );
160 path.cubicTo( cp1, cp2, p2 );
177 const double t123 = t1 + t2 + t3;
179 const QPointF cp2 = ( t2 * pd[n-3] + ( t0 + t1 ) * pd[n-2] ) / t012;
180 const QPointF cp3 = ( ( t2 + t3 ) * pd[n-2] + t1 * pd[n-1] ) / t123;
182 const QPointF p2 = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 );
184 path.cubicTo( cp1, cp2, p2 );
194 const QPointF cp2 = ( t2 * pd[n-2] + ( t0 + t1 ) * pd[n-1] ) / t012;
198 path.cubicTo( cp1, cp2, pd[n-1] );
203 const double t123 = t1 + t2 + t3;
205 const QPointF cp3 = ( t2 + t3 ) / t123 * pd[n-1] + t1 / t123 * pd[0];
206 const QPointF cp4 = ( t3 * pd[n-1] + ( t1 + t2 ) * pd[0] ) / t123;
208 const QPointF pN = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 );
210 path.cubicTo( cp1, cp2, pN );
211 path.cubicTo( cp3, cp4, p0 );
242 if ( points.size() < 4 )
243 return QPainterPath();
Curve parametrization used for a spline interpolation.
virtual uint locality() const QWT_OVERRIDE
The locality is always 2.
const QwtSplineParametrization * parametrization() const
virtual double valueIncrement(const QPointF &, const QPointF &) const
Calculate the parameter value increment for 2 points.
virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE
static QPainterPath qwtSplineBasisPath(const QPolygonF &points, const QwtSplineParametrization *param, QwtSpline::BoundaryType boundaryType)
static QPainterPath qwtSplineBasisPathUniform(const QPolygonF &points, QwtSpline::BoundaryType boundaryType)
BoundaryType boundaryType() const
QwtSplineBasis()
Constructor.
virtual ~QwtSplineBasis()
Destructor.