Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathShape.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2006, 2011 Thorsten Zachmann <zachmann@kde.org>
3 SPDX-FileCopyrightText: 2007, 2009 Thomas Zander <zander@kde.org>
4 SPDX-FileCopyrightText: 2006-2008 Jan Hambrecht <jaham@gmx.net>
5 SPDX-FileCopyrightText: 2011 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KOPATHSHAPE_H
11#define KOPATHSHAPE_H
12
13#include "kritaflake_export.h"
14
15#include <QMetaType>
16#include <QTransform>
17
18#include "KoTosContainer.h"
19
20#define KoPathShapeId "KoPathShape"
21
22class KoPathSegment;
23class KoPathPoint;
24class KoPathShapePrivate;
25class KoMarker;
27
28typedef QPair<int, int> KoPathPointIndex;
29
34
62class KRITAFLAKE_EXPORT KoPathShape : public KoTosContainer
63{
64public:
69
73 ~KoPathShape() override;
74
75 KoShape *cloneShape() const override;
76
78 void paint(QPainter &painter) const override;
79 virtual void paintPoints(KisHandlePainterHelper &handlesHelper);
80
82 QRectF outlineRect() const override;
84 QPainterPath outline() const override;
86 QRectF boundingRect() const override;
88 QSizeF size() const override;
89
90 QPainterPath pathStroke(const QPen &pen) const;
102 void setSize(const QSizeF &size) override;
103
105 bool hitTest(const QPointF &position) const override;
106
108 void clear();
116 KoPathPoint *moveTo(const QPointF &p);
117
125 KoPathPoint *lineTo(const QPointF &p);
126
139 KoPathPoint *curveTo(const QPointF &c1, const QPointF &c2, const QPointF &p);
140
152 KoPathPoint *curveTo(const QPointF &c, const QPointF &p);
153
167 KoPathPoint *arcTo(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle);
168
169
173 void close();
174
184 void closeMerge();
185
195 virtual QPointF normalize();
196
203 QList<KoPathPoint*> pointsAt(const QRectF &rect, const bool useControlPoints = false) const;
204
210 QList<KoPathSegment> segmentsAt(const QRectF &rect) const;
211
219 KoPathPointIndex pathPointIndex(const KoPathPoint *point) const;
220
228 KoPathPoint *pointByIndex(const KoPathPointIndex &pointIndex) const;
229
242 KoPathSegment segmentByIndex(const KoPathPointIndex &pointIndex) const;
243
249 int pointCount() const;
250
256 int subpathCount() const;
257
263 int subpathPointCount(int subpathIndex) const;
264
272 bool isClosedSubpath(int subpathIndex) const;
273
288 bool insertPoint(KoPathPoint *point, const KoPathPointIndex &pointIndex);
289
300 KoPathPoint *removePoint(const KoPathPointIndex &pointIndex);
301
316 bool breakAfter(const KoPathPointIndex &pointIndex);
317
330 bool join(int subpathIndex);
331
340 bool moveSubpath(int oldSubpathIndex, int newSubpathIndex);
341
352 KoPathPointIndex openSubpath(const KoPathPointIndex &pointIndex);
353
363 KoPathPointIndex closeSubpath(const KoPathPointIndex &pointIndex);
364
372 bool reverseSubpath(int subpathIndex);
373
379 KoSubpath *removeSubpath(int subpathIndex);
380
387 bool addSubpath(KoSubpath *subpath, int subpathIndex);
388
394 int combine(KoPathShape *path);
395
401 bool separate(QList<KoPathShape*> &separatedPaths);
402
416 virtual QString pathShapeId() const;
417
419 QString toString(const QTransform &matrix = QTransform()) const;
420
442 QString nodeTypes() const;
443
447 void loadNodeTypes(const QString &nodeTypes);
448
450 Qt::FillRule fillRule() const;
451
453 void setFillRule(Qt::FillRule fillRule);
454
456 static KoPathShape *createShapeFromPainterPath(const QPainterPath &path);
457
458 void setMarker(KoMarker *marker, KoFlake::MarkerPosition pos);
459 KoMarker* marker(KoFlake::MarkerPosition pos) const;
460 bool hasMarkers() const;
461
462 bool autoFillMarkers() const;
463 void setAutoFillMarkers(bool value);
464
465public:
466 struct KRITAFLAKE_EXPORT PointSelectionChangeListener : public ShapeChangeListener {
467 void notifyShapeChanged(ChangeType type, KoShape *shape) override;
468 virtual void recommendPointSelectionChange(KoPathShape *shape, const QList<KoPathPointIndex> &newSelection) = 0;
469 virtual void notifyPathPointsChanged(KoPathShape *shape) = 0;
470 };
471
472 void recommendPointSelectionChange(const QList<KoPathPointIndex> &newSelection);
473
474protected:
475 void notifyPointsChanged();
476
477protected:
481 KoPathShape(const KoPathShape &rhs);
482
483protected:
484
499 int arcToCurve(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle, const QPointF &offset, QPointF *curvePoints) const;
500
507 QTransform resizeMatrix( const QSizeF &newSize ) const;
508
509private:
511 void closeMergeSubpathPriv(KoSubpath *subpath);
513 void closeSubpathPriv(KoSubpath *subpath);
514 void updateLastPriv(KoPathPoint **lastPoint);
515
516protected:
517 const KoSubpathList &subpaths() const;
519 KoSubpathList &subpaths();
520 void map(const QTransform &matrix);
521
522private:
523 class Private;
524 QScopedPointer<Private> d;
525};
526
528
529#endif /* KOPATHSHAPE_H */
float value(const T *src, size_t ch)
const Params2D p
QList< KoPathPoint * > KoSubpath
a KoSubpath contains a path from a moveTo until a close or a new moveTo
Definition KoPathShape.h:31
QList< KoSubpath * > KoSubpathList
Definition KoPathShape.h:32
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
The KisHandlePainterHelper class is a special helper for painting handles around objects....
A KoPathPoint represents a point in a path.
A KoPathSegment consist of two neighboring KoPathPoints.
The position of a path point within a path shape.
Definition KoPathShape.h:63
QScopedPointer< Private > d
void paint(QPainter &painter) const override
reimplemented
virtual QSizeF size() const
Get the size of the shape in pt.
Definition KoShape.cpp:820
virtual QRectF outlineRect() const
Definition KoShape.cpp:637
virtual QPainterPath outline() const
Definition KoShape.cpp:630
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:335
ChangeType
Used by shapeChanged() to select which change was made.
Definition KoShape.h:95
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
Definition KoShape.cpp:200
virtual bool hitTest(const QPointF &position) const
Check if the shape is hit on position.
Definition KoShape.cpp:308
virtual void setSize(const QSizeF &size)
Resize the shape.
Definition KoShape.cpp:276
Q_DECLARE_METATYPE(KisPaintopLodLimitations)
MarkerPosition
Definition KoFlake.h:41
virtual void recommendPointSelectionChange(KoPathShape *shape, const QList< KoPathPointIndex > &newSelection)=0
virtual void notifyPathPointsChanged(KoPathShape *shape)=0