Changeset View
Changeset View
Standalone View
Standalone View
libs/flake/resources/KoGamutMask.h
- This file was added.
1 | #ifndef KOGAMUTMASK_H | ||||
---|---|---|---|---|---|
2 | #define KOGAMUTMASK_H | ||||
3 | | ||||
4 | #include <QPainter> | ||||
5 | #include <QString> | ||||
6 | #include <QVector> | ||||
7 | #include <cmath> | ||||
8 | | ||||
9 | #include <FlakeDebug.h> | ||||
10 | #include <resources/KoResource.h> | ||||
11 | #include <KoShape.h> | ||||
12 | #include <KisGamutMaskViewConverter.h> | ||||
13 | #include <KoShapePaintingContext.h> | ||||
14 | | ||||
15 | class KoViewConverter; | ||||
16 | | ||||
17 | class KoGamutMaskShape | ||||
18 | { | ||||
19 | public: | ||||
20 | KoGamutMaskShape(KoShape* shape); | ||||
21 | KoGamutMaskShape(); | ||||
22 | ~KoGamutMaskShape(); | ||||
23 | | ||||
24 | bool coordIsClear(const QPointF& coord, const KoViewConverter& viewConverter) const; | ||||
25 | QPainterPath outline(); | ||||
26 | void paint(QPainter &painter, const KoViewConverter& viewConverter); | ||||
27 | KoShape* koShape(); | ||||
28 | | ||||
29 | private: | ||||
30 | KoShape* m_maskShape; | ||||
31 | KoShapePaintingContext m_shapePaintingContext; | ||||
32 | }; | ||||
33 | | ||||
34 | | ||||
35 | /** | ||||
36 | * @brief The resource type for gamut masks used by the artistic color selector | ||||
37 | */ | ||||
38 | class KRITAFLAKE_EXPORT KoGamutMask : public QObject, public KoResource | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | | ||||
42 | public: | ||||
43 | /** | ||||
44 | * @brief load a gamut mask from given file | ||||
45 | * @param filename | ||||
46 | */ | ||||
47 | KoGamutMask(const QString &filename); | ||||
48 | | ||||
49 | /** | ||||
50 | * @brief create KoGamutMask from polygons | ||||
51 | * @param polygons | ||||
52 | */ | ||||
53 | KoGamutMask(); | ||||
54 | | ||||
55 | // TODO: copy constructor, for duplicating masks | ||||
56 | KoGamutMask(KoGamutMask *rhs); | ||||
57 | | ||||
58 | /** | ||||
59 | * @brief pointIsClear, returns true if the color can be used, false if masked out | ||||
60 | * @param point - point in qpainter coords, 0,0 in center | ||||
61 | * @return | ||||
62 | */ | ||||
63 | bool coordIsClear(const QPointF& coord); | ||||
64 | | ||||
65 | bool load() override __attribute__((optimize(0))); | ||||
66 | bool loadFromDevice(QIODevice *dev) override; | ||||
67 | bool save() override; | ||||
68 | bool saveToDevice(QIODevice* dev) const override; | ||||
69 | | ||||
70 | void paint(QPainter &painter); | ||||
71 | void setViewSize(int size); | ||||
72 | | ||||
73 | QString title(); | ||||
74 | void setTitle(QString title); | ||||
75 | | ||||
76 | QString description(); | ||||
77 | void setDescription(QString description); | ||||
78 | | ||||
79 | void setMaskShapes(QList<KoShape*> shapes); | ||||
80 | | ||||
81 | QList<KoShape*> koShapes() const; | ||||
82 | | ||||
83 | void setPreviewMaskShapes(QList<KoShape*> shapes); | ||||
84 | | ||||
85 | // switch back to loaded shapes when ending mask preview | ||||
86 | void resetMaskShapes(); | ||||
87 | | ||||
88 | private: | ||||
89 | QImage generateIcon(); | ||||
90 | struct Private; | ||||
91 | Private* const d; | ||||
92 | | ||||
93 | }; | ||||
94 | | ||||
95 | #endif // KOGAMUTMASK_H |