Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBaseNode Class Referenceabstract

#include <kis_base_node.h>

+ Inheritance diagram for KisBaseNode:

Classes

struct  Property
 

Public Types

typedef QList< PropertyPropertyList
 

Signals

void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 

Public Member Functions

virtual bool accept (KisNodeVisitor &)
 
virtual void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter)
 
bool belongsToIsolatedGroup () const
 
bool check (const KoProperties &properties) const
 
bool collapsed () const
 
int colorLabelIndex () const
 
virtual KisPaintDeviceSP colorSampleSourceDevice () const
 
virtual const KoColorSpacecolorSpace () const =0
 
virtual const KoCompositeOpcompositeOp () const =0
 
const QString & compositeOpId () const
 
virtual QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
virtual QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
void enableAnimation ()
 
virtual QRect exactBounds () const
 
virtual QRect extent () const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id) const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id, bool create)
 
bool hasEditablePaintDevice () const
 
virtual QIcon icon () const
 
KisImageWSP image () const
 
bool isAnimated () const
 
bool isEditable (bool checkVisibility=true) const
 
virtual bool isFakeNode () const
 
bool isIsolatedRoot () const
 
bool isPinnedToTimeline () const
 
QMap< QString, KisKeyframeChannel * > keyframeChannels () const
 
 KisBaseNode (const KisBaseNode &rhs)
 
 KisBaseNode (KisImageWSP image)
 
void mergeNodeProperties (const KoProperties &properties)
 
QString name () const
 
const KoPropertiesnodeProperties () const
 
quint8 opacity () const
 
virtual KisPaintDeviceSP original () const =0
 
virtual KisPaintDeviceSP paintDevice () const =0
 
quint8 percentOpacity () const
 
 Private (const Private &rhs)
 
 Private (KisImageWSP p_image)
 
virtual KisPaintDeviceSP projection () const =0
 
virtual PropertyList sectionModelProperties () const
 
void setCollapsed (bool collapsed)
 
void setColorLabelIndex (int index)
 
void setCompositeOpId (const QString &compositeOpId)
 
virtual void setImage (KisImageWSP image)
 
void setName (const QString &name)
 
void setNodeProperty (const QString &name, const QVariant &value)
 
void setOpacity (quint8 val)
 
void setPercentOpacity (quint8 val)
 
void setPinnedToTimeline (bool pinned)
 
virtual void setSectionModelProperties (const PropertyList &properties)
 
virtual void setUserLocked (bool l)
 
void setUuid (const QUuid &id)
 
virtual void setVisible (bool visible, bool loading=false)
 
virtual void setX (qint32)
 
virtual void setY (qint32)
 
virtual bool supportsKeyframeChannel (const QString &id)
 
bool supportsLodMoves () const
 
virtual bool supportsLodPainting () const
 
virtual int thumbnailSeqNo () const
 
virtual void updateSettings ()
 
bool userLocked () const
 
QUuid uuid () const
 
virtual bool visible (bool recursive=false) const
 
virtual qint32 x () const
 
virtual qint32 y () const
 
 ~KisBaseNode () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Public Attributes

bool animated {false}
 
bool collapsed {false}
 
QString compositeOp
 
KisBaseNode::Property hack_visible
 
QUuid id
 
KisImageWSP image
 
QMap< QString, KisKeyframeChannel * > keyframeChannels
 
KisAnimatedOpacityProperty opacityProperty
 
bool pinnedToTimeline {false}
 
KoProperties properties
 
bool supportsLodMoves {false}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Protected Member Functions

virtual void addKeyframeChannel (KisKeyframeChannel *channel)
 
virtual void baseNodeChangedCallback ()
 
virtual void baseNodeCollapsedChangedCallback ()
 
virtual void baseNodeInvalidateAllFramesCallback ()
 
virtual void notifyParentVisibilityChanged (bool value)
 
virtual KisBaseNodeSP parentCallback () const
 
virtual KisKeyframeChannelrequestKeyframeChannel (const QString &id)
 
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Private Attributes

Private *const m_d
 

Detailed Description

A KisBaseNode is the base class for all components of an image: nodes, layers masks, selections. A node has a number of properties, can be represented as a thumbnail and knows what to do when it gets a certain paint device to process. A KisBaseNode does not know anything about its peers. You should not directly inherit from a KisBaseNode; inherit from KisNode instead.

Definition at line 25 of file kis_base_node.cpp.

Member Typedef Documentation

◆ PropertyList

Return this type for PropertiesRole.

Definition at line 103 of file kis_base_node.h.

Constructor & Destructor Documentation

◆ KisBaseNode() [1/2]

KisBaseNode::KisBaseNode ( KisImageWSP image)

Create a new, empty base node. The node is unnamed, unlocked visible and unlinked.

Be cautious! These two calls are vital to warm-up KoProperties. We use it and its QMap in a threaded environment. This is not officially supported by Qt, but our environment guarantees, that there will be the only writer and several readers. Whilst the value of the QMap is boolean and there are no implicit-sharing calls provocated, it is safe to work with it in such an environment.

Definition at line 65 of file kis_base_node.cpp.

66 : m_d(new Private(image))
67{
77 setVisible(true, true);
78 setUserLocked(false);
79 setCollapsed(false);
81
82 m_d->compositeOp = COMPOSITE_OVER;
83
84 connect(&m_d->opacityProperty, SIGNAL(changed(quint8)), this, SIGNAL(opacityChanged(quint8)));
85}
const QString COMPOSITE_OVER
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setSupportsLodMoves(bool value)
virtual void setUserLocked(bool l)
virtual void setVisible(bool visible, bool loading=false)
Private *const m_d
void setCollapsed(bool collapsed)
KisImageWSP image
void opacityChanged(quint8 value)

References COMPOSITE_OVER, connect(), m_d, opacityChanged(), setCollapsed(), setSupportsLodMoves(), setUserLocked(), and setVisible().

◆ KisBaseNode() [2/2]

KisBaseNode::KisBaseNode ( const KisBaseNode & rhs)

Create a copy of this node.

Definition at line 88 of file kis_base_node.cpp.

89 : QObject()
90 , KisShared()
91 , m_d(new Private(*rhs.m_d))
92{
93 if (rhs.m_d->opacityProperty.hasChannel()) {
94 m_d->opacityProperty.transferKeyframeData(rhs.m_d->opacityProperty);
95 m_d->keyframeChannels.insert(m_d->opacityProperty.channel()->id(), m_d->opacityProperty.channel());
96 }
97
98 connect(&m_d->opacityProperty, SIGNAL(changed(quint8)), this, SIGNAL(opacityChanged(quint8)));
99}

References connect(), m_d, and opacityChanged().

◆ ~KisBaseNode()

KisBaseNode::~KisBaseNode ( )
override

Delete this node

Definition at line 101 of file kis_base_node.cpp.

102{
103 delete m_d;
104}

References m_d.

Member Function Documentation

◆ accept() [1/2]

virtual bool KisBaseNode::accept ( KisNodeVisitor & )
inlinevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisNodeVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

return false if the visitor could not successfully act on this node instance.

Reimplemented in KisGeneratorLayer, KisAdjustmentLayer, KisCloneLayer, KisShapeLayer, KisReferenceImagesLayer, KisFileLayer, KisDecorationsWrapperLayer, KisFilterMask, KisGroupLayer, KisNode, KisPaintLayer, KisSelectionMask, KisTransformMask, KisTransparencyMask, and KisColorizeMask.

Definition at line 297 of file kis_base_node.h.

297 {
298 return false;
299 }

◆ accept() [2/2]

virtual void KisBaseNode::accept ( KisProcessingVisitor & visitor,
KisUndoAdapter * undoAdapter )
inlinevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisProcessingVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

The processing visitor differs from node visitor in the way that it accepts undo adapter, that allows the processing to be multithreaded

Reimplemented in KisGeneratorLayer, KisAdjustmentLayer, KisCloneLayer, KisFilterMask, KisGroupLayer, KisNode, KisPaintLayer, KisSelectionMask, KisTransformMask, KisTransparencyMask, KisColorizeMask, KisShapeLayer, KisReferenceImagesLayer, KisFileLayer, and KisDecorationsWrapperLayer.

Definition at line 311 of file kis_base_node.h.

311 {
312 Q_UNUSED(visitor);
313 Q_UNUSED(undoAdapter);
314 }

◆ addKeyframeChannel()

void KisBaseNode::addKeyframeChannel ( KisKeyframeChannel * channel)
protectedvirtual

Add a keyframe channel for this node. The channel will be added to the common hash table which will be available to the UI.

WARNING: the channel object NOT become owned by the node! The caller must ensure manually that the lifetime of the object coincide with the lifetime of the node.

Reimplemented in KisNode.

Definition at line 441 of file kis_base_node.cpp.

442{
443 m_d->keyframeChannels.insert(channel->id(), channel);
444 Q_EMIT keyframeChannelAdded(channel);
445}
void keyframeChannelAdded(KisKeyframeChannel *channel)

References KisKeyframeChannel::id(), keyframeChannelAdded(), and m_d.

◆ baseNodeChangedCallback()

virtual void KisBaseNode::baseNodeChangedCallback ( )
inlineprotectedvirtual

This callback is called when some meta state of the base node that can be interesting to the UI has changed. E.g. visibility, lockness, opacity, compositeOp and etc. This signal is forwarded by the KisNode and KisNodeGraphListener to the model in KisLayerBox, so it can update its controls when information changes.

Reimplemented in KisMask, and KisNode.

Definition at line 557 of file kis_base_node.h.

557 {
558 }

◆ baseNodeCollapsedChangedCallback()

virtual void KisBaseNode::baseNodeCollapsedChangedCallback ( )
inlineprotectedvirtual

This callback is called when collapsed state of the base node has changed. This signal is forwarded by the KisNode and KisNodeGraphListener to the model in KisLayerBox, so it can update its controls when information changes.

Reimplemented in KisNode.

Definition at line 566 of file kis_base_node.h.

566 {
567 }

◆ baseNodeInvalidateAllFramesCallback()

virtual void KisBaseNode::baseNodeInvalidateAllFramesCallback ( )
inlineprotectedvirtual

Reimplemented in KisNode.

Definition at line 570 of file kis_base_node.h.

570 {
571 }

◆ belongsToIsolatedGroup()

bool KisBaseNode::belongsToIsolatedGroup ( ) const

Return whether or not the given node is isolated.

Definition at line 251 of file kis_base_node.cpp.

252{
253 if (!m_d->image) {
254 return false;
255 }
256
257 const KisBaseNode* element = this;
258
259 while (element) {
260 if (element->isIsolatedRoot()) {
261 return true;
262 } else {
263 element = element->parentCallback().data();
264 }
265 }
266
267 return false;
268}
bool isIsolatedRoot() const
virtual KisBaseNodeSP parentCallback() const

References KisSharedPtr< T >::data(), isIsolatedRoot(), m_d, and parentCallback().

◆ check()

bool KisBaseNode::check ( const KoProperties & properties) const

Compare the given properties list with the properties of this node.

Returns
false only if the same property exists in both lists but with a different value. Properties that are not in both lists are disregarded.

Definition at line 183 of file kis_base_node.cpp.

184{
185 QMapIterator<QString, QVariant> iter = properties.propertyIterator();
186 while (iter.hasNext()) {
187 iter.next();
188 if (m_d->properties.contains(iter.key())) {
189 if (m_d->properties.value(iter.key()) != iter.value())
190 return false;
191 }
192 }
193 return true;
194}
QMapIterator< QString, QVariant > propertyIterator() const
KoProperties properties

References m_d, properties, and KoProperties::propertyIterator().

◆ collapsed()

bool KisBaseNode::collapsed ( ) const

returns the collapsed state of this node

◆ colorLabelIndex()

int KisBaseNode::colorLabelIndex ( ) const
See also
setColorLabelIndex

Definition at line 340 of file kis_base_node.cpp.

341{
342 return m_d->properties.intProperty(KisLayerPropertiesIcons::colorLabelIndex.id(), 0);
343}

References KisLayerPropertiesIcons::colorLabelIndex, and m_d.

◆ colorSampleSourceDevice()

KisPaintDeviceSP KisBaseNode::colorSampleSourceDevice ( ) const
virtual
Returns
a special device from where the color sampler tool should sample color when in layer-only mode. For most of the nodes just shortcuts to projection() device. TODO: can it be null?

Reimplemented in KisColorizeMask.

Definition at line 106 of file kis_base_node.cpp.

107{
108 return projection();
109}
virtual KisPaintDeviceSP projection() const =0

References projection().

◆ colorSpace()

virtual const KoColorSpace * KisBaseNode::colorSpace ( ) const
pure virtual

◆ compositeOp()

virtual const KoCompositeOp * KisBaseNode::compositeOp ( ) const
pure virtual

Return the composite op associated with this layer.

Implemented in KisLayer, and KisMask.

◆ compositeOpId()

const QString & KisBaseNode::compositeOpId ( ) const

Definition at line 132 of file kis_base_node.cpp.

133{
134 return m_d->compositeOp;
135}

References m_d.

◆ createThumbnail()

QImage KisBaseNode::createThumbnail ( qint32 w,
qint32 h,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio )
virtual
Returns
a thumbnail in requested size. The thumbnail is a rgba QImage and may have transparent parts. Returns a fully transparent QImage of the requested size if the current node type cannot generate a thumbnail. If the requested size is too big, return a null QImage.

Reimplemented in KisLayer, KisMask, and KisSelectionBasedLayer.

Definition at line 197 of file kis_base_node.cpp.

198{
199 Q_UNUSED(aspectRatioMode);
200
201 try {
202 QImage image(w, h, QImage::Format_ARGB32);
203 image.fill(0);
204 return image;
205 } catch (const std::bad_alloc&) {
206 return QImage();
207 }
208
209}

References image.

◆ createThumbnailForFrame()

QImage KisBaseNode::createThumbnailForFrame ( qint32 w,
qint32 h,
int time,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio )
virtual
Returns
a thumbnail in requested size for the defined timestamp. The thumbnail is a rgba Image and may have transparent parts. Returns a fully transparent QImage of the requested size if the current node type cannot generate a thumbnail. If the requested size is too big, return a null QImage.

Reimplemented in KisLayer.

Definition at line 216 of file kis_base_node.cpp.

217{
218 Q_UNUSED(time);
219 Q_UNUSED(aspectRatioMode);
220 return createThumbnail(w, h);
221}
virtual QImage createThumbnail(qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)

References createThumbnail().

◆ enableAnimation()

void KisBaseNode::enableAnimation ( )

Definition at line 435 of file kis_base_node.cpp.

436{
437 m_d->animated = true;
439}
virtual void baseNodeChangedCallback()

References baseNodeChangedCallback(), and m_d.

◆ exactBounds()

virtual QRect KisBaseNode::exactBounds ( ) const
inlinevirtual

Returns the exact bounds of where the actual data resides in this node.

Reimplemented in KisCloneLayer, KisFilterMask, KisGroupLayer, KisLayer, KisMask, KisPaintLayer, KisSelectionBasedLayer, KisSelectionMask, KisTransformMask, KisTransparencyMask, and KisColorizeMask.

Definition at line 453 of file kis_base_node.h.

453 {
454 return QRect();
455 }

◆ extent()

virtual QRect KisBaseNode::extent ( ) const
inlinevirtual

Returns an approximation of where the bounds on actual data are in this node.

Reimplemented in KisCloneLayer, KisFilterMask, KisGroupLayer, KisLayer, KisMask, KisPaintLayer, KisSelectionBasedLayer, KisSelectionMask, KisTransformMask, KisTransparencyMask, and KisColorizeMask.

Definition at line 445 of file kis_base_node.h.

445 {
446 return QRect();
447 }

◆ getKeyframeChannel() [1/2]

KisKeyframeChannel * KisBaseNode::getKeyframeChannel ( const QString & id) const

Definition at line 393 of file kis_base_node.cpp.

394{
395 QMap<QString, KisKeyframeChannel*>::const_iterator i = m_d->keyframeChannels.constFind(id);
396 if (i == m_d->keyframeChannels.constEnd()) {
397 return 0;
398 }
399 return i.value();
400}

References m_d.

◆ getKeyframeChannel() [2/2]

KisKeyframeChannel * KisBaseNode::getKeyframeChannel ( const QString & id,
bool create )

Get the keyframe channel with given id. If the channel does not yet exist and the node supports the requested channel, it will be created if create is true.

Parameters
idinternal name for channel
createattempt to create the channel if it does not exist yet
Returns
keyframe channel with the id, or null if not found

Definition at line 415 of file kis_base_node.cpp.

416{
418
419 if (!channel && create) {
420 channel = requestKeyframeChannel(id);
421
422 if (channel) {
423 addKeyframeChannel(channel);
424 }
425 }
426
427 return channel;
428}
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
virtual KisKeyframeChannel * requestKeyframeChannel(const QString &id)
virtual void addKeyframeChannel(KisKeyframeChannel *channel)

References addKeyframeChannel(), getKeyframeChannel(), and requestKeyframeChannel().

◆ hasEditablePaintDevice()

bool KisBaseNode::hasEditablePaintDevice ( ) const
Returns
true if the node is editable and has a paintDevice() which can be used for accessing pixels. It is an equivalent to (isEditable() && paintDevice())

Definition at line 309 of file kis_base_node.cpp.

310{
311 return paintDevice() && isEditable();
312}
bool isEditable(bool checkVisibility=true) const
virtual KisPaintDeviceSP paintDevice() const =0

References isEditable(), and paintDevice().

◆ icon()

virtual QIcon KisBaseNode::icon ( ) const
inlinevirtual
Returns
the icon used to represent the node type, for instance in the layerbox and in the menu.

Reimplemented in KisGeneratorLayer, KisAdjustmentLayer, KisCloneLayer, KisEffectMask, KisExternalLayer, KisFilterMask, KisGroupLayer, KisPaintLayer, KisSelectionMask, KisTransformMask, KisTransparencyMask, KisColorizeMask, KisShapeLayer, and KisFileLayer.

Definition at line 230 of file kis_base_node.h.

230 {
231 return QIcon();
232 }

◆ image()

KisImageWSP KisBaseNode::image ( ) const

◆ isAnimated()

bool KisBaseNode::isAnimated ( ) const

Definition at line 430 of file kis_base_node.cpp.

431{
432 return m_d->animated;
433}

References m_d.

◆ isEditable()

bool KisBaseNode::isEditable ( bool checkVisibility = true) const
Returns
true if the node can be edited:

if checkVisibility is true, then the node is only editable if it is visible and not locked. if checkVisibility is false, then the node is editable if it's not locked.

Definition at line 290 of file kis_base_node.cpp.

291{
292 bool editable = true;
293 if (checkVisibility) {
294 editable = ((visible(false) || belongsToIsolatedGroup()) && !userLocked());
295 }
296 else {
297 editable = (!userLocked());
298 }
299
300 if (editable) {
301 KisBaseNodeSP parentNode = parentCallback();
302 if (parentNode && parentNode != this) {
303 editable = parentNode->isEditable(checkVisibility);
304 }
305 }
306 return editable;
307}
bool belongsToIsolatedGroup() const
bool userLocked() const
virtual bool visible(bool recursive=false) const

References belongsToIsolatedGroup(), parentCallback(), userLocked(), and visible().

◆ isFakeNode()

bool KisBaseNode::isFakeNode ( ) const
virtual

Fake node is not present in the layer stack and is not used for normal projection rendering algorithms.

Reimplemented in KisReferenceImagesLayer, and KisDecorationsWrapperLayer.

Definition at line 377 of file kis_base_node.cpp.

378{
379 return false;
380}

◆ isIsolatedRoot()

bool KisBaseNode::isIsolatedRoot ( ) const

Return whether or not the given node is the root of isolation.

Definition at line 270 of file kis_base_node.cpp.

271{
272 if (!m_d->image) {
273 return false;
274 }
275
276 const KisBaseNode* isolatedRoot = m_d->image->isolationRootNode().data();
277
278 return (this == isolatedRoot);
279}

References m_d.

◆ isPinnedToTimeline()

bool KisBaseNode::isPinnedToTimeline ( ) const
Returns
If true, node will be visible on animation timeline even when inactive.

Definition at line 402 of file kis_base_node.cpp.

403{
404 return m_d->pinnedToTimeline;
405}

References m_d.

◆ keyframeChannelAdded

void KisBaseNode::keyframeChannelAdded ( KisKeyframeChannel * channel)
signal

◆ keyframeChannels()

QMap< QString, KisKeyframeChannel * > KisBaseNode::keyframeChannels ( ) const

Return the keyframe channels associated with this node

Returns
list of keyframe channels

◆ mergeNodeProperties()

void KisBaseNode::mergeNodeProperties ( const KoProperties & properties)

Merge the specified properties with the properties of this layer. Wherever these properties overlap, the value of the node properties is changed. No properties on the node are deleted. If there are new properties in this list, they will be added on the node.

Definition at line 172 of file kis_base_node.cpp.

173{
174 QMapIterator<QString, QVariant> iter = properties.propertyIterator();
175 while (iter.hasNext()) {
176 iter.next();
177 m_d->properties.setProperty(iter.key(), iter.value());
178 }
181}
virtual void baseNodeInvalidateAllFramesCallback()

References baseNodeChangedCallback(), baseNodeInvalidateAllFramesCallback(), m_d, properties, and KoProperties::propertyIterator().

◆ name()

QString KisBaseNode::name ( ) const
inline

return the name of this node. This is the same as the QObject::objectName.

Definition at line 212 of file kis_base_node.h.

212 {
213 return objectName();
214 }

◆ nodeProperties()

const KoProperties & KisBaseNode::nodeProperties ( ) const

Return all the properties of this layer as a KoProperties-based serializable key-value list.

Definition at line 161 of file kis_base_node.cpp.

162{
163 return m_d->properties;
164}

References m_d.

◆ notifyParentVisibilityChanged()

virtual void KisBaseNode::notifyParentVisibilityChanged ( bool value)
inlineprotectedvirtual

Reimplemented in KisCloneLayer, and KisNode.

Definition at line 545 of file kis_base_node.h.

545 {
546 Q_UNUSED(value);
547 }
float value(const T *src, size_t ch)

References value().

◆ opacity()

quint8 KisBaseNode::opacity ( ) const

Return the opacity of this layer, scaled to a range between 0 and 255. XXX: Allow true float opacity

Definition at line 111 of file kis_base_node.cpp.

112{
113 return m_d->opacityProperty.get();
114}

References m_d.

◆ opacityChanged

void KisBaseNode::opacityChanged ( quint8 value)
signal

◆ original()

virtual KisPaintDeviceSP KisBaseNode::original ( ) const
pure virtual
Returns
the rendered representation of a node before the effect masks have had their go at it. Can be 0.

Implemented in KisCloneLayer, KisGroupLayer, KisMask, KisPaintLayer, KisSelectionBasedLayer, KisShapeLayer, KisFileLayer, KisDecorationsWrapperLayer, and KisLayer.

◆ paintDevice()

virtual KisPaintDeviceSP KisBaseNode::paintDevice ( ) const
pure virtual

Return the paintdevice you can use to change pixels on. For a paint layer these will be paint pixels, for an adjustment layer or a mask the selection paint device.

Returns
the paint device to paint on. Can be 0 if the actual node type does not support painting.

Implemented in KisCloneLayer, KisGroupLayer, KisMask, KisPaintLayer, KisSelectionBasedLayer, KisTransformMask, KisColorizeMask, KisShapeLayer, KisFileLayer, and KisDecorationsWrapperLayer.

◆ parentCallback()

virtual KisBaseNodeSP KisBaseNode::parentCallback ( ) const
inlineprotectedvirtual

FIXME: This method is a workaround for getting parent node on a level of KisBaseNode. In fact, KisBaseNode should inherit KisNode (in terms of current Krita) to be able to traverse the node stack

Reimplemented in KisNode.

Definition at line 541 of file kis_base_node.h.

541 {
542 return KisBaseNodeSP();
543 }
KisSharedPtr< KisBaseNode > KisBaseNodeSP
Definition kis_types.h:93

◆ percentOpacity()

quint8 KisBaseNode::percentOpacity ( ) const

return the 8-bit opacity of this layer scaled to the range 0-100

XXX: Allow true float opacity

Definition at line 122 of file kis_base_node.cpp.

123{
124 return int(float(opacity() * 100) / 255 + 0.5);
125}
quint8 opacity() const

References opacity().

◆ Private() [1/2]

KisBaseNode::Private ( const Private & rhs)
inline

Definition at line 47 of file kis_base_node.cpp.

48 : compositeOp(rhs.compositeOp),
49 id(QUuid::createUuid()),
51 collapsed(rhs.collapsed),
52 supportsLodMoves(rhs.supportsLodMoves),
53 animated(rhs.animated),
54 pinnedToTimeline(rhs.pinnedToTimeline),
55 image(rhs.image)
56 {
57 QMapIterator<QString, QVariant> iter = rhs.properties.propertyIterator();
58 while (iter.hasNext()) {
59 iter.next();
60 properties.setProperty(iter.key(), iter.value());
61 }
62 }
const quint8 OPACITY_OPAQUE_U8
void setProperty(const QString &name, const QVariant &value)
KisAnimatedOpacityProperty opacityProperty
QString compositeOp

References KoProperties::setProperty().

◆ Private() [2/2]

KisBaseNode::Private ( KisImageWSP p_image)
inline

Definition at line 40 of file kis_base_node.cpp.

41 : id(QUuid::createUuid())
43 , image(p_image)
44 {
45 }

◆ projection()

virtual KisPaintDeviceSP KisBaseNode::projection ( ) const
pure virtual
Returns
the fully rendered representation of this layer: its rendered original and its effect masks. Can be 0.

Implemented in KisLayer, and KisMask.

◆ requestKeyframeChannel()

KisKeyframeChannel * KisBaseNode::requestKeyframeChannel ( const QString & id)
protectedvirtual

Attempt to create the requested channel. Used internally by getKeyframeChannel. Subclasses should implement this method to catch any new channel types they support.

Parameters
idchannel to create
Returns
newly created channel or null

Reimplemented in KisMask, KisPaintLayer, KisSelectionBasedLayer, and KisTransformMask.

Definition at line 447 of file kis_base_node.cpp.

448{
449 if (id == KisKeyframeChannel::Opacity.id()) {
450 Q_ASSERT(!m_d->opacityProperty.hasChannel());
451
452 KisPaintDeviceSP device = original();
453 KisNode* node = dynamic_cast<KisNode*>(this);
454
455 if (device && node) {
456 m_d->opacityProperty.makeAnimated(node);
457 return m_d->opacityProperty.channel();
458 }
459 }
460
461 return 0;
462}
static const KoID Opacity
virtual KisPaintDeviceSP original() const =0

References m_d, KisKeyframeChannel::Opacity, and original().

◆ sectionModelProperties()

KisBaseNode::PropertyList KisBaseNode::sectionModelProperties ( ) const
virtual

Return a the properties of this base node (locked, visible etc, with the right icons for their representation and their state.

Subclasses can extend this list with new properties, like opacity for layers or visualized for masks.

The order of properties is, unfortunately, for now, important, so take care which properties superclasses of your class define.

KisBaseNode defines visible = 0, locked = 1 KisLayer defines opacity = 2, compositeOp = 3 KisMask defines active = 2 (KisMask does not inherit kislayer)

Reimplemented in KisGeneratorLayer, KisAdjustmentLayer, KisCloneLayer, KisGroupLayer, KisLayer, KisPaintLayer, KisSelectionMask, KisColorizeMask, KisShapeLayer, and KisFileLayer.

Definition at line 146 of file kis_base_node.cpp.

147{
149 l << KisLayerPropertiesIcons::getProperty(KisLayerPropertiesIcons::visible, visible(), m_d->hack_visible.isInStasis, m_d->hack_visible.stateInStasis);
151 return l;
152}
static KisBaseNode::Property getProperty(const KoID &id, bool state)

References KisLayerPropertiesIcons::getProperty(), KisLayerPropertiesIcons::locked, m_d, userLocked(), visible(), and KisLayerPropertiesIcons::visible.

◆ setCollapsed()

void KisBaseNode::setCollapsed ( bool collapsed)

Sets the state of the node to the value of

Parameters
collapsed

Definition at line 314 of file kis_base_node.cpp.

315{
316 const bool oldCollapsed = m_d->collapsed;
317
318 m_d->collapsed = collapsed;
319
320 if (oldCollapsed != collapsed) {
322 }
323}
virtual void baseNodeCollapsedChangedCallback()

References baseNodeCollapsedChangedCallback(), collapsed, and m_d.

◆ setColorLabelIndex()

void KisBaseNode::setColorLabelIndex ( int index)

Sets a color label index associated to the layer. The actual color of the label and the number of available colors is defined by Krita GUI configuration.

Definition at line 330 of file kis_base_node.cpp.

331{
332 const int currentLabel = colorLabelIndex();
333
334 if (currentLabel == index) return;
335
336 m_d->properties.setProperty(KisLayerPropertiesIcons::colorLabelIndex.id(), index);
338}
int colorLabelIndex() const

References baseNodeChangedCallback(), colorLabelIndex(), KisLayerPropertiesIcons::colorLabelIndex, and m_d.

◆ setCompositeOpId()

void KisBaseNode::setCompositeOpId ( const QString & compositeOpId)

Set a new composite op for this layer. The layer will be marked dirty.

Definition at line 137 of file kis_base_node.cpp.

138{
139 if (m_d->compositeOp == compositeOp) return;
140
141 m_d->compositeOp = compositeOp;
144}

References baseNodeChangedCallback(), baseNodeInvalidateAllFramesCallback(), compositeOp, and m_d.

◆ setImage()

void KisBaseNode::setImage ( KisImageWSP image)
virtual

Reimplemented in KisCloneLayer, KisGroupLayer, KisLayer, KisMask, KisPaintLayer, KisSelectionBasedLayer, KisTransformMask, KisColorizeMask, KisShapeLayer, KisFileLayer, KisDecorationsWrapperLayer, and KisNode.

Definition at line 366 of file kis_base_node.cpp.

367{
368 m_d->image = image;
369 m_d->opacityProperty.updateDefaultBounds(new KisDefaultBounds(image));
370}

References image, and m_d.

◆ setName()

void KisBaseNode::setName ( const QString & name)
inline

set the QObject::objectName. This is also the user-visible name of the layer. The reason for this is that we want to see the layer name also when debugging.

Definition at line 221 of file kis_base_node.h.

221 {
222 setObjectName(name);
224 }
QString name() const

◆ setNodeProperty()

void KisBaseNode::setNodeProperty ( const QString & name,
const QVariant & value )

Set a node property.

Parameters
namename of the property to be set.
valuevalue to set the property to.

Definition at line 166 of file kis_base_node.cpp.

167{
168 m_d->properties.setProperty(name, value);
170}

References baseNodeChangedCallback(), m_d, name(), and value().

◆ setOpacity()

void KisBaseNode::setOpacity ( quint8 val)

Set the opacity for this layer. The range is between 0 and 255. The layer will be marked dirty.

XXX: Allow true float opacity

Definition at line 116 of file kis_base_node.cpp.

117{
118 m_d->opacityProperty.set(val);
120}

References baseNodeChangedCallback(), and m_d.

◆ setPercentOpacity()

void KisBaseNode::setPercentOpacity ( quint8 val)

Set the opacity of this layer with a number between 0 and 100; the number will be scaled to between 0 and 255. XXX: Allow true float opacity

Definition at line 127 of file kis_base_node.cpp.

128{
129 setOpacity(int(float(val * 255) / 100 + 0.5));
130}
void setOpacity(quint8 val)

References setOpacity().

◆ setPinnedToTimeline()

void KisBaseNode::setPinnedToTimeline ( bool pinned)

Set whether node should be visible on animation timeline even when inactive.

Definition at line 407 of file kis_base_node.cpp.

408{
409 if (pinned == m_d->pinnedToTimeline) return;
410
411 m_d->pinnedToTimeline = pinned;
413}

References baseNodeChangedCallback(), and m_d.

◆ setSectionModelProperties()

void KisBaseNode::setSectionModelProperties ( const PropertyList & properties)
virtual

Change the section model properties.

Reimplemented in KisGroupLayer, KisLayer, KisPaintLayer, KisSelectionMask, KisColorizeMask, KisShapeLayer, and KisFileLayer.

Definition at line 154 of file kis_base_node.cpp.

155{
156 setVisible(properties.at(0).state.toBool());
157 m_d->hack_visible = properties.at(0);
158 setUserLocked(properties.at(1).state.toBool());
159}

References m_d, properties, setUserLocked(), and setVisible().

◆ setSupportsLodMoves()

void KisBaseNode::setSupportsLodMoves ( bool value)
protected

Definition at line 382 of file kis_base_node.cpp.

383{
384 m_d->supportsLodMoves = value;
385}

References m_d, and value().

◆ setUserLocked()

void KisBaseNode::setUserLocked ( bool l)
virtual

Set the locked status of this node. Locked nodes cannot be edited.

Reimplemented in KisShapeLayer.

Definition at line 281 of file kis_base_node.cpp.

282{
283 const bool isLocked = m_d->properties.boolProperty(KisLayerPropertiesIcons::locked.id(), true);
284 if (isLocked == locked) return;
285
286 m_d->properties.setProperty(KisLayerPropertiesIcons::locked.id(), locked);
288}

References baseNodeChangedCallback(), KisLayerPropertiesIcons::locked, and m_d.

◆ setUuid()

void KisBaseNode::setUuid ( const QUuid & id)

Set the uuid of node. This should only be used when loading existing node and in constructor.

Definition at line 350 of file kis_base_node.cpp.

351{
352 m_d->id = id;
354}

References baseNodeChangedCallback(), id, and m_d.

◆ setVisible()

void KisBaseNode::setVisible ( bool visible,
bool loading = false )
virtual

Set the visible status of this node. Visible nodes are active in the graph (except for selections masks which can be active while hidden), that is to say, they are taken into account when merging. Invisible nodes play no role in the final image , but will be modified when modifying all layers, for instance when cropping.

Toggling the visibility of a node will not automatically lead to recomposition.

Parameters
visiblethe new visibility state
isLoadingif true, the property is set during loading.

Reimplemented in KisSelectionMask, and KisShapeLayer.

Definition at line 232 of file kis_base_node.cpp.

233{
234 const bool isVisible = m_d->properties.boolProperty(KisLayerPropertiesIcons::visible.id(), true);
235 if (!loading && isVisible == visible) return;
236
237 m_d->properties.setProperty(KisLayerPropertiesIcons::visible.id(), visible);
239
240 if (!loading) {
243 }
244}
virtual void notifyParentVisibilityChanged(bool value)

References baseNodeChangedCallback(), baseNodeInvalidateAllFramesCallback(), m_d, notifyParentVisibilityChanged(), visible(), and KisLayerPropertiesIcons::visible.

◆ setX()

virtual void KisBaseNode::setX ( qint32 )
inlinevirtual

Set the x offset of this layer in the image place. Re-implement this where it makes sense, by default it does nothing. It should not move child nodes.

Reimplemented in KisGeneratorLayer, KisGroupLayer, KisLayer, KisMask, KisSelectionBasedLayer, KisTransformMask, KisColorizeMask, KisCloneLayer, and KisShapeLayer.

Definition at line 423 of file kis_base_node.h.

423 {
424 }

◆ setY()

virtual void KisBaseNode::setY ( qint32 )
inlinevirtual

Set the y offset of this layer in the image place. Re-implement this where it makes sense, by default it does nothing. It should not move child nodes.

Reimplemented in KisGeneratorLayer, KisGroupLayer, KisLayer, KisMask, KisSelectionBasedLayer, KisTransformMask, KisColorizeMask, KisCloneLayer, and KisShapeLayer.

Definition at line 438 of file kis_base_node.h.

438 {
439 }

◆ supportsKeyframeChannel()

bool KisBaseNode::supportsKeyframeChannel ( const QString & id)
virtual

Ideally, this function would be used to query for keyframe support before trying to create channels. The ability to query would help in cases such as animation curves where you might want to ask which channels it supports before allowing the user to add.

Parameters
idqueried channel
Returns
bool whether it supports said channel or not.

Reimplemented in KisMask, KisPaintLayer, KisSelectionBasedLayer, and KisTransformMask.

Definition at line 464 of file kis_base_node.cpp.

465{
466 if (id == KisKeyframeChannel::Opacity.id() && original()) {
467 return true;
468 }
469
470 return false;
471}

References KisKeyframeChannel::Opacity, and original().

◆ supportsLodMoves()

bool KisBaseNode::supportsLodMoves ( ) const

Returns true if the offset of the node can be changed in a LodN stroke. Currently, all the nodes except shape layers support that.

◆ supportsLodPainting()

bool KisBaseNode::supportsLodPainting ( ) const
virtual

Returns true if the node can be painted via KisPaintDevice. Notable exceptions are selection-based layers and masks.

Reimplemented in KisMask, and KisSelectionBasedLayer.

Definition at line 361 of file kis_base_node.cpp.

362{
363 return true;
364}

◆ thumbnailSeqNo()

int KisBaseNode::thumbnailSeqNo ( ) const
virtual
Returns
a sequence number of the thumbnail of the node. Every time the layer changes, the sequence number increases.

Reimplemented in KisLayer, KisMask, and KisSelectionBasedLayer.

Definition at line 211 of file kis_base_node.cpp.

212{
213 return -1;
214}

◆ updateSettings()

virtual void KisBaseNode::updateSettings ( )
inlinevirtual

Ask this node to re-read the pertinent settings from the krita configuration.

Definition at line 344 of file kis_base_node.h.

344 {
345 }

◆ userLocked()

bool KisBaseNode::userLocked ( ) const

Return the locked status of this node. Locked nodes cannot be edited.

Definition at line 246 of file kis_base_node.cpp.

247{
248 return m_d->properties.boolProperty(KisLayerPropertiesIcons::locked.id(), false);
249}

References KisLayerPropertiesIcons::locked, and m_d.

◆ uuid()

QUuid KisBaseNode::uuid ( ) const
Returns
unique id, which is now used by clone layers.

Definition at line 345 of file kis_base_node.cpp.

346{
347 return m_d->id;
348}

References m_d.

◆ visible()

bool KisBaseNode::visible ( bool recursive = false) const
virtual
Returns
true if this node is visible (i.e, active (except for selection masks where visible and active properties are different)) in the graph
Parameters
boolrecursive if true, check whether all parents of this node are visible as well.

Reimplemented in KisShapeLayer.

Definition at line 223 of file kis_base_node.cpp.

224{
225 bool isVisible = m_d->properties.boolProperty(KisLayerPropertiesIcons::visible.id(), true);
226 KisBaseNodeSP parentNode = parentCallback();
227
228 return recursive && isVisible && parentNode ?
229 parentNode->visible(recursive) : isVisible;
230}

References m_d, parentCallback(), and KisLayerPropertiesIcons::visible.

◆ x()

virtual qint32 KisBaseNode::x ( ) const
inlinevirtual
Returns
the x-offset of this layer in the image plane.

Reimplemented in KisCloneLayer, KisGroupLayer, KisLayer, KisMask, KisSelectionBasedLayer, KisTransformMask, KisColorizeMask, and KisShapeLayer.

Definition at line 414 of file kis_base_node.h.

414 {
415 return 0;
416 }

◆ y()

virtual qint32 KisBaseNode::y ( ) const
inlinevirtual
Returns
the y-offset of this layer in the image plane.

Reimplemented in KisCloneLayer, KisGroupLayer, KisLayer, KisMask, KisSelectionBasedLayer, KisTransformMask, KisColorizeMask, and KisShapeLayer.

Definition at line 429 of file kis_base_node.h.

429 {
430 return 0;
431 }

Member Data Documentation

◆ animated

bool KisBaseNode::animated {false}

Definition at line 36 of file kis_base_node.cpp.

36{false};

◆ collapsed

bool KisBaseNode::collapsed {false}

Definition at line 34 of file kis_base_node.cpp.

34{false};

◆ compositeOp

QString KisBaseNode::compositeOp

Definition at line 27 of file kis_base_node.cpp.

◆ hack_visible

KisBaseNode::Property KisBaseNode::hack_visible

Definition at line 29 of file kis_base_node.cpp.

◆ id

QUuid KisBaseNode::id

Definition at line 30 of file kis_base_node.cpp.

◆ image

KisImageWSP KisBaseNode::image

Definition at line 38 of file kis_base_node.cpp.

◆ keyframeChannels

QMap< QString, KisKeyframeChannel * > KisBaseNode::keyframeChannels

Definition at line 31 of file kis_base_node.cpp.

◆ m_d

Private* const KisBaseNode::m_d
private

Definition at line 610 of file kis_base_node.h.

◆ opacityProperty

KisAnimatedOpacityProperty KisBaseNode::opacityProperty

Definition at line 32 of file kis_base_node.cpp.

◆ pinnedToTimeline

bool KisBaseNode::pinnedToTimeline {false}

Definition at line 37 of file kis_base_node.cpp.

37{false};

◆ properties

KoProperties KisBaseNode::properties

Definition at line 28 of file kis_base_node.cpp.

◆ supportsLodMoves

bool KisBaseNode::supportsLodMoves {false}

Definition at line 35 of file kis_base_node.cpp.

35{false};

The documentation for this class was generated from the following files: