Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_shape_selection.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KIS_SHAPE_SELECTION_H
7#define KIS_SHAPE_SELECTION_H
8
9#include <QPainterPath>
10
11#include <KoShapeLayer.h>
12#include <KoShapeFactoryBase.h>
13#include <KoShapeUserData.h>
16
18#include <kis_types.h>
19
20#include <kritaui_export.h>
21
22class KoStore;
23class KoShapeManager;
27class KUndo2Command;
28
35{
36 KoShapeUserData* clone() const override {
37 return new KisShapeSelectionMarker(*this);
38 }
39};
40
41
42class KRITAUI_EXPORT KisShapeSelection : public QObject, public KoShapeLayer, public KisSelectionComponent
43{
44 Q_OBJECT
45
47public:
48
49 KisShapeSelection(KoShapeControllerBase *shapeControllerBase, KisSelectionWSP selection);
50
51 ~KisShapeSelection() override;
52
53 KisShapeSelection(const KisShapeSelection& rhs, KisSelection* selection);
54
55 KisSelectionComponent* clone(KisSelection* selection) override;
56
57 bool saveSelection(KoStore * store, const QRect &imageRect) const;
58
59 bool loadSelection(KoStore * store, const QRect &imageRect);
66 void renderToProjection(KisPaintDeviceSP projection) override;
67 void renderToProjection(KisPaintDeviceSP projection, const QRect& r) override;
68
69 KUndo2Command* resetToEmpty() override;
70 bool isEmpty() const override;
71
72 QPainterPath outlineCache() const override;
73 bool outlineCacheValid() const override;
74 void recalculateOutlineCache() override;
75
76 KoShapeManager *shapeManager() const;
77
78 void moveX(qint32 x) override;
79 void moveY(qint32 y) override;
80
81 KUndo2Command* transform(const QTransform &transform) override;
82
83 void setResolutionProxy(KisImageResolutionProxySP resolutionProxy ) override;
84
85Q_SIGNALS:
86 void sigMoveShapes(const QPointF &diff);
87
88private Q_SLOTS:
89 void slotMoveShapes(const QPointF &diff);
90
91protected:
92
93 void paintComponent(QPainter& painter) const override;
94
95private:
97 void setUpdatesEnabled(bool enabled);
98 bool updatesEnabled() const;
99 void init(KisImageResolutionProxySP resolutionProxy, KoShapeControllerBase *shapeControllerBase);
100private:
102
103 void renderSelection(KisPaintDeviceSP projection, const QRect& requestedRect);
104
105 QPainterPath m_outline;
106 KisImageViewConverter *m_converter {nullptr};
107 KisShapeSelectionCanvas *m_canvas {nullptr};
110 KoShapeControllerBase *m_shapeControllerBase {nullptr};
112};
113
114
115class KRITAUI_EXPORT KisShapeSelectionFactory : public KoShapeFactoryBase
116{
117public:
118
121
122 KoShape *createDefaultShape(KoDocumentResourceManager *documentResources = 0) const override {
123 Q_UNUSED(documentResources);
124 return 0;
125 }
126
127 bool supports(const QDomElement & e, KoShapeLoadingContext &context) const override {
128 Q_UNUSED(e);
129 Q_UNUSED(context);
130 return false;
131 }
132};
133
134#endif
virtual bool isEmpty() const =0
virtual bool outlineCacheValid() const =0
virtual void renderToProjection(KisPaintDeviceSP projection)=0
virtual void moveY(qint32 y)
virtual KisSelectionComponent * clone(KisSelection *selection)=0
virtual void setResolutionProxy(KisImageResolutionProxySP)
virtual QPainterPath outlineCache() const =0
virtual void recalculateOutlineCache()=0
virtual void moveX(qint32 x)
virtual KUndo2Command * resetToEmpty()
bool supports(const QDomElement &e, KoShapeLoadingContext &context) const override
KoShape * createDefaultShape(KoDocumentResourceManager *documentResources=0) const override
KoShapeUserData * clone() const override
KisShapeSelectionModel * m_model
KisShapeSelection(const KisShapeSelection &rhs)
KisShapeSelectionModel * initModel(KisImageWSP image, KisSelectionWSP selection)
KisImageResolutionProxySP m_resolutionProxy
void sigMoveShapes(const QPointF &diff)
void paintComponent(QPainter &painter) const override
QTransform transform() const
return the current matrix that contains the rotation/scale/position of this shape
Definition KoShape.cpp:1145