Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeManager.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2
3 SPDX-FileCopyrightText: 2006-2008 Thorsten Zachmann <zachmann@kde.org>
4 SPDX-FileCopyrightText: 2007, 2009 Thomas Zander <zander@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KOSHAPEMANAGER_H
10#define KOSHAPEMANAGER_H
11
12#include <QList>
13#include <QObject>
14#include <QRect>
15
16#include "KoFlake.h"
17#include "kritaflake_export.h"
18
19#include <memory>
20#include <vector>
21
22class KoShape;
23class KoSelection;
24class KoViewConverter;
25class KoCanvasBase;
26class KoPointerEvent;
27
28class QPainter;
29class QPointF;
30class QRectF;
31
41class KRITAFLAKE_EXPORT KoShapeManager : public QObject
42{
43 Q_OBJECT
44
45public:
47 enum Repaint {
49 AddWithoutRepaint
50 };
51
55 explicit KoShapeManager(KoCanvasBase *canvas);
61 KoShapeManager(KoCanvasBase *canvas, const QList<KoShape *> &shapes);
62 ~KoShapeManager() override;
63
64
71 void setShapes(const QList<KoShape *> &shapes, Repaint repaint = PaintShapeOnAdd);
72
75
79 QList<KoShape*> topLevelShapes() const;
80
81public Q_SLOTS:
88 void addShape(KoShape *shape, KoShapeManager::Repaint repaint = PaintShapeOnAdd);
89
90
95 void remove(KoShape *shape);
96
97public:
100
101 struct PaintJob {
102 using ShapesStorage = std::vector<std::unique_ptr<KoShape>>;
103 using SharedSafeStorage = std::shared_ptr<ShapesStorage>;
104
105 PaintJob() = default;
106 PaintJob(QRectF _docUpdateRect, QRect _viewUpdateRect)
107 : docUpdateRect(_docUpdateRect),
108 viewUpdateRect(_viewUpdateRect)
109 {
110 }
111
112 bool isEmpty() const {
113 return shapes.isEmpty();
114 }
115
118
121 };
122
124 {
127
128 inline void clear() {
129 jobs.clear();
130 uncroppedViewUpdateRect = QRect();
131 }
132
133 inline bool isEmpty() const {
134 return jobs.isEmpty();
135 }
136 };
137
145 void explicitlyIssueShapeChangedSignals();
146
160 void preparePaintJobs(PaintJobsOrder &jobsOrder, KoShape *excludeRoot);
161
173 void paintJob(QPainter &painter, const KoShapeManager::PaintJob &job);
174
181 void paint(QPainter &painter);
182
191 KoShape *shapeAt(const QPointF &position, KoFlake::ShapeSelection selection = KoFlake::ShapeOnTop, bool omitHiddenShapes = true);
192
199 QList<KoShape *> shapesAt(const QRectF &rect, bool omitHiddenShapes = true, bool containedMode = false);
200
213 void update(const QRectF &rect, const KoShape *shape = 0, bool selectionHandles = false);
214
219 void setUpdatesBlocked(bool value);
220
224 bool updatesBlocked() const;
225
233 void notifyShapeChanged(KoShape *shape);
234
239 static void renderSingleShape(KoShape *shape, QPainter &painter);
240
247
253 void notifyShapeDestructed(KoShape *shape);
254
255 protected:
257 };
258
260
261Q_SIGNALS:
268
271
272private:
274
275
276 class Private;
277 Private * const d;
278 Q_PRIVATE_SLOT(d, void updateTree())
279 Q_PRIVATE_SLOT(d, void forwardCompressedUpdate())
280};
281
282#endif
float value(const T *src, size_t ch)
Repaint
enum for add()
@ PaintShapeOnAdd
Causes each shapes 'update()' to be called after being added to the shapeManager.
ShapeInterface * shapeInterface()
QList< KoShape * > shapes() const
returns the list of maintained shapes
bool updatesBlocked() const
KoSelection * selection() const
return the selection shapes for this shapeManager
void selectionContentChanged()
emitted when an object in the selection is changed (moved/rotated etc)
KoCanvasBase * canvas()
void selectionChanged()
emitted when the selection is changed
Private *const d
void forwardUpdate()
Emitted upon update and used to update the canvas.
void contentChanged()
emitted when any object changed (moved/rotated etc)
ShapeSelection
Definition KoFlake.h:70
@ ShapeOnTop
return the shape highest z-ordering, regardless of selection.
Definition KoFlake.h:74
std::vector< std::unique_ptr< KoShape > > ShapesStorage
SharedSafeStorage allClonedShapes
std::shared_ptr< ShapesStorage > SharedSafeStorage
PaintJob(QRectF _docUpdateRect, QRect _viewUpdateRect)
QList< KoShape * > shapes