libs/flake
KoPathShape.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
00021
00022 #ifndef KOPATHSHAPE_H
00023 #define KOPATHSHAPE_H
00024
00025 #include "flake_export.h"
00026
00027 #include <QMap>
00028
00029 #include "KoShape.h"
00030 #include "KoPathSegment.h"
00031
00032 #define KoPathShapeId "KoPathShape"
00033
00034 class KoPathShape;
00035 class KoPathPoint;
00036 class KoPathShapePrivate;
00037
00038 typedef QPair<int, int> KoPathPointIndex;
00039 typedef QMap<KoPathShape *, QSet<KoPathPointIndex> > KoPathShapePointIndexMap;
00040
00042 typedef QList<KoPathPoint *> KoSubpath;
00043 typedef QList<KoSubpath *> KoSubpathList;
00045 typedef QPair<KoSubpath*, int> KoPointPosition;
00074 class FLAKE_EXPORT KoPathShape : public KoShape
00075 {
00076 public:
00080 KoPathShape();
00081
00085 virtual ~KoPathShape();
00086
00088 virtual void paint(QPainter &painter, const KoViewConverter &converter);
00089 virtual void paintPoints(QPainter &painter, const KoViewConverter &converter, int handleRadius);
00091 virtual QPainterPath outline() const;
00093 virtual QRectF boundingRect() const;
00095 virtual QSizeF size() const;
00107 virtual void setSize(const QSizeF &size);
00109 virtual bool hitTest(const QPointF &position) const;
00110
00111
00112 virtual void saveOdf(KoShapeSavingContext & context) const;
00113
00114 virtual bool loadOdf(const KoXmlElement & element, KoShapeLoadingContext &context);
00115
00117 void clear();
00125 KoPathPoint * moveTo(const QPointF &p);
00126
00134 KoPathPoint * lineTo(const QPointF &p);
00135
00148 KoPathPoint * curveTo(const QPointF &c1, const QPointF &c2, const QPointF &p);
00149
00161 KoPathPoint * curveTo(const QPointF &c, const QPointF &p);
00162
00176 KoPathPoint * arcTo(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle);
00177
00178
00182 void close();
00183
00193 void closeMerge();
00194
00204 virtual QPointF normalize();
00205
00211 QList<KoPathPoint*> pointsAt(const QRectF &r);
00212
00218 QList<KoPathSegment> segmentsAt(const QRectF &r);
00219
00227 KoPathPointIndex pathPointIndex(const KoPathPoint *point) const;
00228
00236 KoPathPoint * pointByIndex(const KoPathPointIndex &pointIndex) const;
00237
00250 KoPathSegment segmentByIndex(const KoPathPointIndex &pointIndex) const;
00251
00257 int pointCount() const;
00258
00264 int subpathCount() const;
00265
00271 int pointCountSubpath(int subpathIndex) const;
00272
00280 bool isClosedSubpath(int subpathIndex);
00281
00296 bool insertPoint(KoPathPoint* point, const KoPathPointIndex &pointIndex);
00297
00308 KoPathPoint * removePoint(const KoPathPointIndex &pointIndex);
00309
00324 bool breakAfter(const KoPathPointIndex &pointIndex);
00325
00338 bool join(int subpathIndex);
00339
00348 bool moveSubpath(int oldSubpathIndex, int newSubpathIndex);
00349
00360 KoPathPointIndex openSubpath(const KoPathPointIndex &pointIndex);
00361
00371 KoPathPointIndex closeSubpath(const KoPathPointIndex &pointIndex);
00372
00380 bool reverseSubpath(int subpathIndex);
00381
00387 KoSubpath * removeSubpath(int subpathIndex);
00388
00395 bool addSubpath(KoSubpath * subpath, int subpathIndex);
00396
00402 bool combine(KoPathShape *path);
00403
00409 bool separate(QList<KoPathShape*> & separatedPaths);
00410
00411 #ifndef NDEBUG
00412
00415 void debugPath();
00416 #endif
00417
00431 virtual QString pathShapeId() const;
00432
00434 QString toString(const QMatrix &matrix) const;
00435
00437 Qt::FillRule fillRule() const;
00438
00440 void setFillRule(Qt::FillRule fillRule);
00441
00443 static KoPathShape * fromQPainterPath(const QPainterPath &path);
00444
00445 protected:
00447 KoPathShape(KoPathShapePrivate &);
00448
00449 private:
00450
00451 void map(const QMatrix &matrix);
00452
00453 void updateLast(KoPathPoint ** lastPoint);
00454
00456 void closeSubpath(KoSubpath *subpath);
00458 void closeMergeSubpath(KoSubpath *subpath);
00459
00465 KoSubpath * subPath(int subpathIndex) const;
00466 #ifndef NDEBUG
00467 void paintDebug(QPainter &painter);
00468 #endif
00470 virtual QString saveStyle(KoGenStyle &style, KoShapeSavingContext &context) const;
00472 virtual void loadStyle(const KoXmlElement & element, KoShapeLoadingContext &context);
00473
00474 protected:
00475 QRectF handleRect(const QPointF &p, qreal radius) const;
00490 int arcToCurve(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle, const QPointF & offset, QPointF * curvePoints) const;
00491
00493 QRectF loadOdfViewbox(const KoXmlElement & element) const;
00495 void applyViewboxTransformation(const KoXmlElement & element);
00496
00520 QString nodeTypes() const;
00521
00525 void loadNodeTypes(const KoXmlElement & element);
00526
00533 QMatrix resizeMatrix( const QSizeF & newSize ) const;
00534
00535 KoSubpathList m_subpaths;
00536
00537 private:
00538 Q_DECLARE_PRIVATE(KoPathShape)
00539 };
00540
00541 #endif
|