File indexing completed on 2024-05-12 15:56:42

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2011 Thorsten Zachmann <zachmann@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KOMARKER_H
0008 #define KOMARKER_H
0009 
0010 #include <QMetaType>
0011 #include <QSharedData>
0012 
0013 #include "kritaflake_export.h"
0014 #include <KoFlake.h>
0015 
0016 #include <QDomDocument>
0017 
0018 class KoShapeLoadingContext;
0019 class KoShapeSavingContext;
0020 class QString;
0021 class QPainterPath;
0022 class KoShape;
0023 class QPainter;
0024 class KoShapeStroke;
0025 
0026 class  KRITAFLAKE_EXPORT KoMarker : public QSharedData
0027 {
0028 public:
0029     KoMarker();
0030     ~KoMarker();
0031 
0032     /**
0033      * Display name of the marker
0034      *
0035      * @return Display name of the marker
0036      */
0037     QString name() const;
0038 
0039     KoMarker(const KoMarker &rhs);
0040     bool operator==(const KoMarker &other) const;
0041 
0042     enum MarkerCoordinateSystem {
0043         StrokeWidth,
0044         UserSpaceOnUse
0045     };
0046 
0047     void setCoordinateSystem(MarkerCoordinateSystem value);
0048     MarkerCoordinateSystem coordinateSystem() const;
0049 
0050     static MarkerCoordinateSystem coordinateSystemFromString(const QString &value);
0051     static QString coordinateSystemToString(MarkerCoordinateSystem value);
0052 
0053     void setReferencePoint(const QPointF &value);
0054     QPointF referencePoint() const;
0055 
0056     void setReferenceSize(const QSizeF &size);
0057     QSizeF referenceSize() const;
0058 
0059     bool hasAutoOtientation() const;
0060     void setAutoOrientation(bool value);
0061 
0062     // measured in radians!
0063     qreal explicitOrientation() const;
0064 
0065     // measured in radians!
0066     void setExplicitOrientation(qreal value);
0067 
0068     void setShapes(const QList<KoShape*> &shapes);
0069     QList<KoShape*> shapes() const;
0070 
0071     /**
0072      * @brief paintAtOrigin paints the marker at the position \p pos.
0073      *        Scales and rotates the masrker if needed.
0074      */
0075     void paintAtPosition(QPainter *painter, const QPointF &pos, qreal strokeWidth, qreal nodeAngle);
0076 
0077     /**
0078      * Return maximum distance that the marker can take outside the shape itself
0079      */
0080     qreal maxInset(qreal strokeWidth) const;
0081 
0082     /**
0083      * Bounding rect of the marker in local coordinates. It is assumed that the marker
0084      * is painted with the reference point placed at position (0,0)
0085      */
0086     QRectF boundingRect(qreal strokeWidth, qreal nodeAngle) const;
0087 
0088     /**
0089      * Outline of the marker in local coordinates. It is assumed that the marker
0090      * is painted with the reference point placed at position (0,0)
0091      */
0092     QPainterPath outline(qreal strokeWidth, qreal nodeAngle) const;
0093 
0094     /**
0095      * Draws a preview of the marker in \p previewRect of \p painter
0096      */
0097     void drawPreview(QPainter *painter, const QRectF &previewRect,
0098                      const QPen &pen, KoFlake::MarkerPosition position);
0099 
0100 
0101     void applyShapeStroke(const KoShape *shape, KoShapeStroke *stroke, const QPointF &pos, qreal strokeWidth, qreal nodeAngle);
0102 
0103 private:
0104     class Private;
0105     Private * const d;
0106 };
0107 
0108 Q_DECLARE_METATYPE(KoMarker*)
0109 
0110 #endif /* KOMARKER_H */