15 const double dx = point2.x() - point1.x();
16 const double dy = point2.y() - point1.y();
18 return qSqrt( dx * dx + dy * dy );
21 template<
class Param >
23 const QPointF &p1,
const QPointF &p2 )
25 return ( p2 - p1 ) / param( p1, p2 );
28 template<
class Param >
30 const QPointF &p1,
const QPointF &p2,
const QPointF &p3 )
32 const double t1 = param( p1, p2 );
33 const double t2 = param( p2, p3 );
35 return t2 * ( p3 - p1 ) / ( t1 + t2 );
53 inline double operator()(
const QPointF &p1,
const QPointF &p2 )
const 55 return parameter->valueIncrement( p1, p2 );
63 inline double operator()(
const QPointF &p1,
const QPointF &p2 )
const 76 inline void start(
const QPointF &p0 )
82 const QPointF &cp2,
const QPointF &p2 )
84 path.cubicTo( cp1, cp2, p2 );
98 inline void init(
int size )
100 controlPoints.resize( size );
101 d_cp = controlPoints.data();
104 inline void start(
const QPointF & )
109 const QPointF &cp2,
const QPointF & )
112 l.setPoints( cp1, cp2 );
123 double d13,
double d23,
double d24,
124 const QPointF &p1,
const QPointF &p2,
125 const QPointF &p3,
const QPointF &p4 )
129 const bool b1 = ( d13 / 3.0 ) < d23;
130 const bool b2 = ( d24 / 3.0 ) < d23;
136 tension.
t1 = ( p1 != p2 ) ? ( 1.0 / 3.0 ) : ( 2.0 / 3.0 );
137 tension.
t2 = ( p3 != p4 ) ? ( 1.0 / 3.0 ) : ( 2.0 / 3.0 );
141 tension.
t1 = tension.
t2 = d23 / d24;
148 tension.
t1 = tension.
t2 = d23 / d13;
152 tension.
t1 = d23 / d13;
153 tension.
t2 = d23 / d24;
160 template<
class SplineStore,
class Param >
162 bool isClosed, Param param )
166 const int size = points.size();
168 const QPointF *p = points.constData();
171 store.init( isClosed ? size : size - 1 );
183 d13, p[size-1], p[0], p[1], p[2] );
185 const QPointF vec0 = qwtVectorCardinal<Param>( param, p[size-1], p[0], p[1] );
186 vec1 = qwtVectorCardinal<Param>( param, p[0], p[1], p[2] );
188 store.addCubic( p[0] + vec0 * t0.
t1, p[1] - vec1 * t0.
t2, p[1] );
196 d13, p[0], p[0], p[1], p[2] );
198 const QPointF vec0 = 0.5 * qwtVector<Param>( param, p[0], p[1] );
199 vec1 = qwtVectorCardinal<Param>( param, p[0], p[1], p[2] );
201 store.addCubic( p[0] + vec0 * t0.
t1, p[1] - vec1 * t0.
t2, p[1] );
204 for (
int i = 1;
i < size - 2;
i++ )
209 const QPointF vec2 = qwtVectorCardinal<Param>( param, p[i], p[i+1], p[i+2] );
212 d13, d23, d24, p[i-1], p[i], p[i+1], p[i+2] );
214 store.addCubic( p[i] + vec1 * t.t1, p[i+1] - vec2 * t.t2, p[i+1] );
226 p[size-3], p[size-2], p[size-1], p[0] );
228 const QPointF vec2 = qwtVectorCardinal<Param>( param, p[size-2], p[size-1], p[0] );
229 store.addCubic( p[size-2] + vec1 * tn.
t1, p[size-1] - vec2 * tn.
t2, p[size-1] );
236 const QPointF vec3 = qwtVectorCardinal<Param>( param, p[size-1], p[0], p[1] );
238 store.addCubic( p[size-1] + vec2 * tc.
t1, p[0] - vec3 * tc.
t2, p[0] );
246 p[size-3], p[size-2], p[size-1], p[size-1] );
248 const QPointF vec2 = 0.5 * qwtVector<Param>( param, p[size-2], p[size-1] );
249 store.addCubic( p[size-2] + vec1 * tn.
t1, p[size-1] - vec2 * tn.
t2, p[size-1] );
290 const int size = points.size();
301 store = qwtSplinePathPleasing<PathStore>( points,
306 store = qwtSplinePathPleasing<PathStore>( points,
307 isClosing,
param( parametrization() ) );
311 store.
path.closeSubpath();
326 const QPolygonF &points )
const 328 const int size = points.size();
330 return QVector<QLineF>();
339 store = qwtSplinePathPleasing<ControlPointsStore>( points,
344 store = qwtSplinePathPleasing<ControlPointsStore>( points,
345 isClosing,
param( parametrization() ) );
Curve parametrization used for a spline interpolation.
QwtSplinePleasing()
Constructor.
virtual QPainterPath painterPath(const QPolygonF &) const
Interpolate a curve with Bezier curves.
static QPointF qwtVectorCardinal(Param param, const QPointF &p1, const QPointF &p2, const QPointF &p3)
virtual QVector< QLineF > bezierControlLines(const QPolygonF &points) const
Interpolate a curve with Bezier curves.
static SplineStore qwtSplinePathPleasing(const QPolygonF &points, bool isClosed, Param param)
QVector< QLineF > controlPoints
double operator()(const QPointF &p1, const QPointF &p2) const
const QwtSplineParametrization * parameter
virtual uint locality() const
static QPointF qwtVector(Param param, const QPointF &p1, const QPointF &p2)
GraphId path[kMaxDeadlockPathLen]
void start(const QPointF &p0)
virtual QPainterPath painterPath(const QPolygonF &) const
Interpolate a curve with Bezier curves.
void addCubic(const QPointF &cp1, const QPointF &cp2, const QPointF &)
static double valueIncrementUniform(const QPointF &, const QPointF &)
Calculate the ParameterUniform value increment.
void addCubic(const QPointF &cp1, const QPointF &cp2, const QPointF &p2)
static QwtSplinePleasingP::Tension qwtTensionPleasing(double d13, double d23, double d24, const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
void start(const QPointF &)
virtual ~QwtSplinePleasing()
Destructor.
param(const QwtSplineParametrization *p)
static double qwtChordalLength(const QPointF &point1, const QPointF &point2)