5 static QPolygonF qwtBasisUniformKnots(
const QPolygonF& points )
7 const int n = points.size();
12 QVector<double> u( n - 2 );
13 QVector<double> kx( n - 2 );
14 QVector<double> ky( n - 2 );
17 kx[n-3] = 6.0 * points[n-2].x() - points[n-1].x();
18 ky[n-3] = 6.0 * points[n-2].y() - points[n-1].y();
20 for (
int i = n - 4;
i >= 0;
i-- )
22 u[
i] = 4.0 - 1.0 / u[
i+1];
23 kx[
i] = 6.0 * points[
i+1].x() - kx[
i+1] / u[
i+1];
24 ky[
i] = 6.0 * points[
i+1].y() - ky[
i+1] / u[
i+1];
27 QVector<QPointF> knots( n );
31 for (
int i = 1;
i < n - 1;
i++ )
33 knots[
i].rx() = ( kx[
i-1] - knots[
i-1].x() ) / u[i-1];
34 knots[
i].ry() = ( ky[
i-1] - knots[
i-1].y() ) / u[i-1];
37 knots[n-1] = points[n-1];
44 const QPointF &p1,
const QPointF &p2,
const QPointF &p3,
const QPointF &p4,
45 QPointF &cp1, QPointF &cp2 )
51 const double t123 = t1 + t2 + t3;
53 cp1 = ( t2 + t3 ) / t123 * p2 + t1 / t123 * p3;
54 cp2 = ( t3 * p2 + ( t1 + t2 ) * p3 ) / t123;
60 const int n = points.size();
61 const QPointF *pd = points.constData();
65 QPointF cp1 = ( 2.0 * pd[0] + pd[1] ) / 3.0;;
73 const QPointF cpN = ( pd[n-1] + 2.0 * pd[0] ) / 3.0;
74 path.moveTo( 0.5 * ( cpN + cp1 ) );
77 for (
int i = 1;
i < n - 1;
i++ )
79 const QPointF cp2 = ( pd[
i-1] + 2.0 * pd[
i] ) / 3.0;
80 const QPointF cp3 = ( 2.0 * pd[
i] + pd[
i+1] ) / 3.0;
82 path.cubicTo( cp1, cp2, 0.5 * ( cp2 + cp3 ) );
89 const QPointF cp2 = ( pd[n-2] + 2.0 * pd[n-1] ) / 3.0;
90 path.cubicTo( cp1, cp2, pd[n-1] );
94 const QPointF cp2 = ( pd[n-2] + 2.0 * pd[n-1] ) / 3.0;
95 const QPointF cp3 = ( 2.0 * pd[n-1] + pd[0] ) / 3.0;
97 path.cubicTo( cp1, cp2, 0.5 * ( cp2 + cp3 ) );
101 const QPointF cp4 = ( pd[n-1] + 2.0 * pd[0] ) / 3.0;
102 const QPointF cp5 = ( 2.0 * pd[0] + pd[1] ) / 3.0;
104 path.cubicTo( cp3, cp4, 0.5 * ( cp4 + cp5 ) );
115 const int n = points.size();
116 const QPointF *pd = points.constData();
129 double t012 = t0 + t1 + t2;
130 QPointF cp1 = ( ( t1 + t2 ) * pd[0] + t0 * pd[1] ) / t012;
139 const QPointF cpN = ( t1 * pd[n-1] + ( tN + t0 ) * pd[0] ) / ( tN + t0 + t1 );
141 p0 = ( t1 * cpN + t0 * cp1 ) / ( t0 + t1 );
147 for (
int i = 1;
i < n - 2;
i++ )
150 const double t123 = t1 + t2 + t3;
152 const QPointF cp2 = ( t2 * pd[
i-1] + ( t0 + t1 ) * pd[
i] ) / t012;
153 const QPointF cp3 = ( ( t2 + t3 ) * pd[i] + t1 * pd[i+1] ) / t123;
155 const QPointF p2 = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 );
157 path.cubicTo( cp1, cp2, p2 );
174 const double t123 = t1 + t2 + t3;
176 const QPointF cp2 = ( t2 * pd[n-3] + ( t0 + t1 ) * pd[n-2] ) / t012;
177 const QPointF cp3 = ( ( t2 + t3 ) * pd[n-2] + t1 * pd[n-1] ) / t123;
179 const QPointF p2 = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 );
181 path.cubicTo( cp1, cp2, p2 );
191 const QPointF cp2 = ( t2 * pd[n-2] + ( t0 + t1 ) * pd[n-1] ) / t012;
195 path.cubicTo( cp1, cp2, pd[n-1] );
200 const double t123 = t1 + t2 + t3;
202 const QPointF cp3 = ( t2 + t3 ) / t123 * pd[n-1] + t1 / t123 * pd[0];
203 const QPointF cp4 = ( t3 * pd[n-1] + ( t1 + t2 ) * pd[0] ) / t123;
205 const QPointF pN = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 );
207 path.cubicTo( cp1, cp2, pN );
208 path.cubicTo( cp3, cp4, p0 );
239 if ( points.size() < 4 )
240 return QPainterPath();
virtual uint locality() const
The locality is always 2.
Curve parametrization used for a spline interpolation.
const QwtSplineParametrization * parametrization() const
static void qwtSplineBezierControlPoints(const QwtSplineParametrization *param, const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4, QPointF &cp1, QPointF &cp2)
virtual double valueIncrement(const QPointF &, const QPointF &) const
Calculate the parameter value increment for 2 points.
static QPainterPath qwtSplineBasisPath(const QPolygonF &points, const QwtSplineParametrization *param, QwtSpline::BoundaryType boundaryType)
GraphId path[kMaxDeadlockPathLen]
static QPainterPath qwtSplineBasisPathUniform(const QPolygonF &points, QwtSpline::BoundaryType boundaryType)
BoundaryType boundaryType() const
QwtSplineBasis()
Constructor.
virtual QPainterPath painterPath(const QPolygonF &) const
virtual ~QwtSplineBasis()
Destructor.