Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_base_node.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef _KIS_BASE_NODE_H
7#define _KIS_BASE_NODE_H
8
9#include <QObject>
10#include <QIcon>
11#include <QUuid>
12#include <QString>
13
14#include <KoID.h>
15
16#include "kis_shared.h"
17#include "kis_paint_device.h"
18#include "kis_processing_visitor.h" // included, not forward declared for msvc
19
20class KoProperties;
21class KoColorSpace;
22class KoCompositeOp;
23class KisNodeVisitor;
24class KisUndoAdapter;
26
27#include "kritaimage_export.h"
28
37class KRITAIMAGE_EXPORT KisBaseNode : public QObject, public KisShared
38{
39
40 Q_OBJECT
41
42public:
51 struct Property
52 {
53 QString id;
54
56 QString name;
57
59 bool isMutable {false};
60
62 QIcon onIcon;
63 QIcon offIcon;
64
66 QVariant state;
67
71 bool canHaveStasis {false};
72
74 bool isInStasis {false};
75
78 bool stateInStasis {false};
79
80 bool operator==(const Property &rhs) const {
81 return rhs.name == name && rhs.state == state && isInStasis == rhs.isInStasis;
82 }
83
84 Property(): isMutable( false ), isInStasis(false) { }
85
87 Property( const KoID &n, const QIcon &on, const QIcon &off, bool isOn )
88 : id(n.id()), name( n.name() ), isMutable( true ), onIcon( on ), offIcon( off ), state( isOn ),
89 canHaveStasis( false ), isInStasis(false) { }
90
92 Property( const KoID &n, const QIcon &on, const QIcon &off, bool isOn,
93 bool _isInStasis, bool _stateInStasis = false )
94 : id(n.id()), name(n.name()), isMutable( true ), onIcon( on ), offIcon( off ), state( isOn ),
95 canHaveStasis( true ), isInStasis( _isInStasis ), stateInStasis( _stateInStasis ) { }
96
98 Property( const KoID &n, const QString &s )
99 : id(n.id()), name(n.name()), isMutable( false ), state( s ), isInStasis(false) { }
100 };
101
104
105public:
106
112
116 KisBaseNode(const KisBaseNode & rhs);
117
121 ~KisBaseNode() override;
122
123
132 virtual KisPaintDeviceSP paintDevice() const = 0;
133
138 virtual KisPaintDeviceSP original() const = 0;
139
144 virtual KisPaintDeviceSP projection() const = 0;
145
151 virtual KisPaintDeviceSP colorSampleSourceDevice() const;
152
153 virtual const KoColorSpace *colorSpace() const = 0;
154
160 quint8 opacity() const; //0-255
161
168 void setOpacity(quint8 val); //0-255
169
176 quint8 percentOpacity() const; //0-100
177
183 void setPercentOpacity(quint8 val); //0-100
184
188 virtual const KoCompositeOp *compositeOp() const = 0;
189 const QString& compositeOpId() const;
190
195 void setCompositeOpId(const QString& compositeOpId);
196
200 QUuid uuid() const;
201
206 void setUuid(const QUuid& id);
207
212 QString name() const {
213 return objectName();
214 }
215
221 void setName(const QString& name) {
222 setObjectName(name);
223 baseNodeChangedCallback();
224 }
225
230 virtual QIcon icon() const {
231 return QIcon();
232 }
233
249 virtual PropertyList sectionModelProperties() const;
250
254 virtual void setSectionModelProperties(const PropertyList &properties);
255
260 const KoProperties & nodeProperties() const;
261
267 void setNodeProperty(const QString & name, const QVariant & value);
268
276 void mergeNodeProperties(const KoProperties & properties);
277
286 bool check(const KoProperties & properties) const;
287
297 virtual bool accept(KisNodeVisitor &) {
298 return false;
299 }
300
311 virtual void accept(KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) {
312 Q_UNUSED(visitor);
313 Q_UNUSED(undoAdapter);
314 }
315
323 virtual QImage createThumbnail(qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio);
324
329 virtual int thumbnailSeqNo() const;
330
338 virtual QImage createThumbnailForFrame(qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio);
339
344 virtual void updateSettings() {
345 }
346
355 virtual bool visible(bool recursive = false) const;
356
371 virtual void setVisible(bool visible, bool loading = false);
372
377 bool userLocked() const;
378
382 bool belongsToIsolatedGroup() const;
383
388 bool isIsolatedRoot() const;
389
394 virtual void setUserLocked(bool l);
395
402 bool isEditable(bool checkVisibility = true) const;
403
409 bool hasEditablePaintDevice() const;
410
414 virtual qint32 x() const {
415 return 0;
416 }
417
423 virtual void setX(qint32) {
424 }
425
429 virtual qint32 y() const {
430 return 0;
431 }
432
438 virtual void setY(qint32) {
439 }
440
445 virtual QRect extent() const {
446 return QRect();
447 }
448
453 virtual QRect exactBounds() const {
454 return QRect();
455 }
456
460 void setCollapsed(bool collapsed);
461
465 bool collapsed() const;
466
472 void setColorLabelIndex(int index);
473
477 int colorLabelIndex() const;
478
483 bool supportsLodMoves() const;
484
489 virtual bool supportsLodPainting() const;
490
495 QMap<QString, KisKeyframeChannel*> keyframeChannels() const;
496
505 KisKeyframeChannel *getKeyframeChannel(const QString &id, bool create);
506 KisKeyframeChannel *getKeyframeChannel(const QString &id) const;
507
511 bool isPinnedToTimeline() const;
512
516 void setPinnedToTimeline(bool pinned);
517
518 bool isAnimated() const;
519 void enableAnimation();
520
521 virtual void setImage(KisImageWSP image);
523
524
529 virtual bool isFakeNode() const;
530
531protected:
532
533 void setSupportsLodMoves(bool value);
534
542 return KisBaseNodeSP();
543 }
544
546 Q_UNUSED(value);
547 }
548
557 virtual void baseNodeChangedCallback() {
558 }
559
567 }
568
569
572
581 virtual void addKeyframeChannel(KisKeyframeChannel* channel);
582
589 virtual KisKeyframeChannel * requestKeyframeChannel(const QString &id);
590
591public:
601 virtual bool supportsKeyframeChannel(const QString &id);
602
603Q_SIGNALS:
605 void opacityChanged(quint8 value);
606
607private:
608
609 struct Private;
610 Private * const m_d;
611
612};
613
614KRITAIMAGE_EXPORT QDebug operator<<(QDebug dbg, const KisBaseNode::Property &prop);
615
617
618
619#endif
float value(const T *src, size_t ch)
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
Definition KoID.h:30
KRITAIMAGE_EXPORT QDebug operator<<(QDebug dbg, const KisBaseNode::Property &prop)
Q_DECLARE_METATYPE(KisPaintopLodLimitations)
KisSharedPtr< KisBaseNode > KisBaseNodeSP
Definition kis_types.h:93
Property(const KoID &n, const QIcon &on, const QIcon &off, bool isOn)
Constructor for a mutable property.
Property(const KoID &n, const QIcon &on, const QIcon &off, bool isOn, bool _isInStasis, bool _stateInStasis=false)
Property(const KoID &n, const QString &s)
Constructor for a nonmutable property.
bool operator==(const Property &rhs) const
virtual const KoCompositeOp * compositeOp() const =0
virtual bool accept(KisNodeVisitor &)
virtual void baseNodeInvalidateAllFramesCallback()
virtual KisPaintDeviceSP projection() const =0
virtual void accept(KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter)
QList< Property > PropertyList
virtual void baseNodeCollapsedChangedCallback()
virtual void baseNodeChangedCallback()
virtual qint32 y() const
KisImageWSP image() const
virtual QRect exactBounds() const
QMap< QString, KisKeyframeChannel * > keyframeChannels() const
virtual KisPaintDeviceSP original() const =0
virtual void notifyParentVisibilityChanged(bool value)
virtual void setX(qint32)
virtual void setY(qint32)
void setName(const QString &name)
bool collapsed() const
Private *const m_d
virtual const KoColorSpace * colorSpace() const =0
void keyframeChannelAdded(KisKeyframeChannel *channel)
virtual qint32 x() const
bool supportsLodMoves() const
virtual QRect extent() const
void opacityChanged(quint8 value)
virtual KisPaintDeviceSP paintDevice() const =0
QString name() const
virtual KisBaseNodeSP parentCallback() const
virtual void updateSettings()
virtual QIcon icon() const