Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_BEZIER_H
00011 #define QWT_BEZIER_H 1
00012
00013 #include "qwt_global.h"
00014 #include <qpolygon.h>
00015
00027 class QWT_EXPORT QwtBezier
00028 {
00029 public:
00030 QwtBezier( double tolerance = 0.5 );
00031 ~QwtBezier();
00032
00033 void setTolerance( double tolerance );
00034 double tolerance() const;
00035
00036 QPolygonF toPolygon( const QPointF &p1, const QPointF &cp1,
00037 const QPointF &cp2, const QPointF &p2 ) const;
00038
00039 void appendToPolygon( const QPointF &p1, const QPointF &cp1,
00040 const QPointF &cp2, const QPointF &p2, QPolygonF &polygon ) const;
00041
00042 static QPointF pointAt( const QPointF &p1, const QPointF &cp1,
00043 const QPointF &cp2, const QPointF &p2, double t );
00044
00045 private:
00046 double m_tolerance;
00047 double m_flatness;
00048 };
00049
00054 inline double QwtBezier::tolerance() const
00055 {
00056 return m_tolerance;
00057 }
00058
00070 inline QPointF QwtBezier::pointAt( const QPointF &p1,
00071 const QPointF &cp1, const QPointF &cp2, const QPointF &p2, double t )
00072 {
00073 const double d1 = 3.0 * t;
00074 const double d2 = 3.0 * t * t;
00075 const double d3 = t * t * t;
00076 const double s = 1.0 - t;
00077
00078 const double x = (( s * p1.x() + d1 * cp1.x() ) * s + d2 * cp2.x() ) * s + d3 * p2.x();
00079 const double y = (( s * p1.y() + d1 * cp1.y() ) * s + d2 * cp2.y() ) * s + d3 * p2.y();
00080
00081 return QPointF( x, y );
00082 }
00083
00084 #endif