Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_node_shape.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include "kis_node_shape.h"
8
9#include <KoCanvasBase.h>
10#include <KoCanvasController.h>
11#include <KoSelection.h>
12#include <KoToolManager.h>
13
14#include <kis_types.h>
15#include <kis_layer.h>
16#include <kis_node.h>
17
19#include "kis_shape_layer.h"
20
21
23{
24public:
26};
27
29 : KoShapeLayer()
30 , m_d(new Private())
31{
32
33 m_d->node = node;
34
36
37 setSelectable(false);
38
39 connect(node, SIGNAL(sigNodeChangedInternal()), SLOT(editabilityChanged()));
40 editabilityChanged(); // Correctly set the lock at loading
41}
42
44{
47 // If we're the active layer, we should tell the active selection we're dead meat.
48 if (canvasController && canvasController->canvas()) {
49 KoSelection *activeSelection = canvasController->canvas()->selectedShapesProxy()->selection();
50 KoShapeLayer *activeLayer = activeSelection->activeLayer();
51 if (activeLayer == this){
52 activeSelection->setActiveLayer(0);
53 }
54 }
55 }
56 delete m_d;
57}
58
60{
61 return m_d->node;
62}
63
65{
66 bool found(false);
67 KoShapeLayer *layer = activeLayer;
68
69 while(layer && !(found = layer == this)) {
70 layer = dynamic_cast<KoShapeLayer*>(layer->parent());
71 }
72
73 return found;
74}
75
77{
78 if (m_d->node->inherits("KisShapeLayer")) {
80 } else {
82 }
83
84 Q_FOREACH (KoShape *shape, this->shapes()) {
85 KisNodeShape *node = dynamic_cast<KisNodeShape*>(shape);
86 KIS_SAFE_ASSERT_RECOVER(node) { continue; }
87 if (node) {
88 node->editabilityChanged();
89 }
90 }
91
99
100 if(canvasController && canvasController->canvas()) {
101 KoSelection *activeSelection = canvasController->canvas()->selectedShapesProxy()->selection();
102 KoShapeLayer *activeLayer = activeSelection->activeLayer();
103
104
105 KisShapeLayer *shapeLayer = dynamic_cast<KisShapeLayer*>(m_d->node.data());
106
107 if(activeLayer && (checkIfDescendant(activeLayer) || (shapeLayer && shapeLayer == activeLayer))) {
108 activeSelection->setActiveLayer(activeLayer);
109 }
110 }
111
112}
113
114QSizeF KisNodeShape::size() const
115{
116 return boundingRect().size();
117}
118
120{
121 return QRectF();
122}
123
124void KisNodeShape::setPosition(const QPointF &)
125{
126}
127
128void KisNodeShape::paint(QPainter &) const
129{
130}
131
132
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void editabilityChanged()
QSizeF size() const override
Get the size of the shape in pt.
void paint(QPainter &painter) const override
Paint the shape fill The class extending this one is responsible for painting itself....
KisNodeSP node()
Private *const m_d
void setPosition(const QPointF &) override
Set the position of the shape in pt.
bool checkIfDescendant(KoShapeLayer *activeLayer)
QRectF boundingRect() const override
Get the bounding box of the shape.
KisNodeShape(KisNodeSP node)
~KisNodeShape() override
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
virtual KoCanvasBase * canvas() const
virtual KoSelection * selection()=0
void setActiveLayer(KoShapeLayer *layer)
KoShapeLayer * activeLayer() const
QList< KoShape * > shapes() const
void setSelectable(bool selectable)
Definition KoShape.cpp:1009
KoShapeContainer * parent() const
Definition KoShape.cpp:1039
void setGeometryProtected(bool on)
Definition KoShape.cpp:1019
void setShapeId(const QString &id)
Definition KoShape.cpp:1062
KoCanvasController * activeCanvasController() const
static KoToolManager * instance()
Return the toolmanager singleton.
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_NODE_SHAPE_ID
bool isEditable(bool checkVisibility=true) const