libs/flake
KoPathSegment.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KOPATHSEGMENT_H
00021 #define KOPATHSEGMENT_H
00022
00023 #include "flake_export.h"
00024 #include <QtCore/QPointF>
00025 #include <QtCore/QList>
00026 #include <QtCore/QPair>
00027 #include <QtCore/QRectF>
00028
00029 class KoPathPoint;
00030 class QMatrix;
00031
00033 class FLAKE_EXPORT KoPathSegment
00034 {
00035 public:
00041 explicit KoPathSegment(KoPathPoint * first = 0, KoPathPoint * second = 0);
00042
00044 KoPathSegment(const KoPathSegment & segment);
00045
00047 KoPathSegment(const QPointF &p0, const QPointF &p1);
00049 KoPathSegment(const QPointF &p0, const QPointF &p1, const QPointF &p2);
00051 KoPathSegment(const QPointF &p0, const QPointF &p1, const QPointF &p2, const QPointF &p3);
00052
00054 KoPathSegment& operator=(const KoPathSegment &rhs);
00055
00057 ~KoPathSegment();
00058
00060 KoPathPoint * first() const;
00061
00063 void setFirst(KoPathPoint * first);
00064
00066 KoPathPoint * second() const;
00067
00069 void setSecond(KoPathPoint * second);
00070
00072 bool isValid() const;
00073
00075 bool operator == (const KoPathSegment &rhs) const;
00076
00078 int degree() const;
00079
00081 QList<QPointF> intersections(const KoPathSegment &segment) const;
00082
00084 QList<QPointF> convexHull() const;
00085
00087 QPair<KoPathSegment, KoPathSegment> splitAt(qreal t) const;
00088
00090 QPointF pointAt(qreal t) const;
00091
00093 QRectF boundingRect() const;
00094
00096 QRectF controlPointRect() const;
00097
00099 KoPathSegment mapped(const QMatrix & matrix) const;
00100
00102 KoPathSegment toCubic() const;
00103
00108 qreal length(qreal error = 0.005) const;
00109
00119 qreal lengthAt(qreal t, qreal error = 0.005) const;
00120
00126 qreal paramAtLength(qreal length, qreal tolerance = 0.001) const;
00127
00132 bool isFlat(qreal tolerance = 0.01) const;
00133
00139 qreal nearestPoint( const QPointF &point ) const;
00140
00142 QList<QPointF> controlPoints() const;
00143
00148 static KoPathSegment interpolate( const QPointF &p0, const QPointF &p1, const QPointF &p2, qreal t );
00149
00151 KoPathSegment convertToCubic() const;
00152
00153 void printDebug() const;
00154
00155 private:
00156
00158 qreal distanceFromChord(const QPointF &point) const;
00159
00161 qreal chordLength() const;
00162
00164 QList<QPointF> linesIntersection(const KoPathSegment &segment) const;
00165
00167 QList<qreal> extrema() const;
00168
00170 QList<qreal> roots() const;
00171
00181 void deCasteljau(qreal t, QPointF *p1, QPointF *p2, QPointF *p3, QPointF *p4, QPointF *p5) const;
00182
00183 class Private;
00184 Private * const d;
00185 };
00186
00187 #endif // KOPATHSEGMENT_H
|