Changeset View
Changeset View
Standalone View
Standalone View
libs/flake/KoMarker.h
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #ifndef KOMARKER_H | 20 | #ifndef KOMARKER_H | ||
21 | #define KOMARKER_H | 21 | #define KOMARKER_H | ||
22 | 22 | | |||
23 | #include <QMetaType> | 23 | #include <QMetaType> | ||
24 | #include <QSharedData> | 24 | #include <QSharedData> | ||
25 | 25 | | |||
26 | #include "kritaflake_export.h" | 26 | #include "kritaflake_export.h" | ||
27 | #include <KoFlake.h> | ||||
27 | 28 | | |||
28 | class KoXmlElement; | 29 | class KoXmlElement; | ||
29 | class KoShapeLoadingContext; | 30 | class KoShapeLoadingContext; | ||
30 | class KoShapeSavingContext; | 31 | class KoShapeSavingContext; | ||
31 | class QString; | 32 | class QString; | ||
32 | class QPainterPath; | 33 | class QPainterPath; | ||
34 | class KoShape; | ||||
35 | class QPainter; | ||||
36 | class KoShapeStroke; | ||||
33 | 37 | | |||
34 | class KRITAFLAKE_EXPORT KoMarker : public QSharedData | 38 | class KRITAFLAKE_EXPORT KoMarker : public QSharedData | ||
35 | { | 39 | { | ||
36 | public: | 40 | public: | ||
37 | KoMarker(); | 41 | KoMarker(); | ||
38 | ~KoMarker(); | 42 | ~KoMarker(); | ||
39 | 43 | | |||
40 | /** | 44 | /** | ||
41 | * Load the marker | 45 | * Display name of the marker | ||
42 | * | 46 | * | ||
43 | * @param element The xml element containing the marker | 47 | * @return Display name of the marker | ||
44 | * @param context The shape loading context | 48 | */ | ||
49 | QString name() const; | ||||
50 | | ||||
51 | KoMarker(const KoMarker &rhs); | ||||
52 | bool operator==(const KoMarker &other) const; | ||||
53 | | ||||
54 | enum MarkerCoordinateSystem { | ||||
55 | StrokeWidth, | ||||
56 | UserSpaceOnUse | ||||
57 | }; | ||||
58 | | ||||
59 | void setCoordinateSystem(MarkerCoordinateSystem value); | ||||
60 | MarkerCoordinateSystem coordinateSystem() const; | ||||
61 | | ||||
62 | static MarkerCoordinateSystem coordinateSystemFromString(const QString &value); | ||||
63 | static QString coordinateSystemToString(MarkerCoordinateSystem value); | ||||
64 | | ||||
65 | void setReferencePoint(const QPointF &value); | ||||
66 | QPointF referencePoint() const; | ||||
67 | | ||||
68 | void setReferenceSize(const QSizeF &size); | ||||
69 | QSizeF referenceSize() const; | ||||
70 | | ||||
71 | bool hasAutoOtientation() const; | ||||
72 | void setAutoOrientation(bool value); | ||||
73 | | ||||
74 | // measured in radians! | ||||
75 | qreal explicitOrientation() const; | ||||
76 | | ||||
77 | // measured in radians! | ||||
78 | void setExplicitOrientation(qreal value); | ||||
79 | | ||||
80 | void setShapes(const QList<KoShape*> &shapes); | ||||
81 | QList<KoShape*> shapes() const; | ||||
82 | | ||||
83 | /** | ||||
84 | * @brief paintAtOrigin paints the marker at the position \p pos. | ||||
85 | * Scales and rotates the masrker if needed. | ||||
45 | */ | 86 | */ | ||
46 | bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context); | 87 | void paintAtPosition(QPainter *painter, const QPointF &pos, qreal strokeWidth, qreal nodeAngle); | ||
47 | 88 | | |||
48 | /** | 89 | /** | ||
49 | * Save the marker | 90 | * Return maximum distance that the marker can take outside the shape itself | ||
50 | * | | |||
51 | * @return The reference of the marker. | | |||
52 | */ | 91 | */ | ||
53 | QString saveOdf(KoShapeSavingContext &context) const; | 92 | qreal maxInset(qreal strokeWidth) const; | ||
54 | 93 | | |||
55 | /** | 94 | /** | ||
56 | * Display name of the marker | 95 | * Bounding rect of the marker in local coordinates. It is assumed that the marker | ||
57 | * | 96 | * is painted with the reference point placed at position (0,0) | ||
58 | * @return Display name of the marker | | |||
59 | */ | 97 | */ | ||
60 | QString name() const; | 98 | QRectF boundingRect(qreal strokeWidth, qreal nodeAngle) const; | ||
61 | 99 | | |||
62 | /** | 100 | /** | ||
63 | * Get the path of the marker | 101 | * Outline of the marker in local coordinates. It is assumed that the marker | ||
64 | * | 102 | * is painted with the reference point placed at position (0,0) | ||
65 | * It calculates the offset depending on the line width | | |||
66 | * | | |||
67 | * @param The width of the line the marker is attached to. | | |||
68 | * @return the path of the marker | | |||
69 | */ | 103 | */ | ||
70 | QPainterPath path(qreal width) const; | 104 | QPainterPath outline(qreal strokeWidth, qreal nodeAngle) const; | ||
71 | 105 | | |||
72 | bool operator==(const KoMarker &other) const; | 106 | /** | ||
107 | * Draws a preview of the marker in \p previewRect of \p painter | ||||
108 | */ | ||||
109 | void drawPreview(QPainter *painter, const QRectF &previewRect, | ||||
110 | const QPen &pen, KoFlake::MarkerPosition position); | ||||
111 | | ||||
112 | | ||||
113 | void applyShapeStroke(KoShape *shape, KoShapeStroke *stroke, const QPointF &pos, qreal strokeWidth, qreal nodeAngle); | ||||
73 | 114 | | |||
74 | private: | 115 | private: | ||
75 | class Private; | 116 | class Private; | ||
76 | Private * const d; | 117 | Private * const d; | ||
77 | }; | 118 | }; | ||
78 | 119 | | |||
79 | Q_DECLARE_METATYPE(KoMarker*) | 120 | Q_DECLARE_METATYPE(KoMarker*) | ||
80 | 121 | | |||
81 | #endif /* KOMARKER_H */ | 122 | #endif /* KOMARKER_H */ |