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

#include <kis_node.h>

+ Inheritance diagram for KisNode:

Public Types

enum  PositionToFilthy { N_ABOVE_FILTHY = 0x08 , N_FILTHY_PROJECTION = 0x20 , N_FILTHY = 0x40 , N_BELOW_FILTHY = 0x80 }
 
- Public Types inherited from KisBaseNode
typedef QList< PropertyPropertyList
 

Signals

void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 

Public Member Functions

bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
virtual bool allowAsChild (KisNodeSP) const =0
 
KisNodeSP at (quint32 index) const
 
KisBusyProgressIndicatorbusyProgressIndicator () const
 
quint32 childCount () const
 
QList< KisNodeSPchildNodes (const QStringList &nodeTypes, const KoProperties &properties) const
 
virtual KisNodeSP clone () const =0
 
const KisNodefindSymmetricClone (const KisNode *srcRoot, const KisNode *dstRoot, const KisNode *srcTarget)
 
KisNodeSP firstChild () const
 
virtual KisPaintDeviceList getLodCapableDevices () const
 
KisNodeGraphListenergraphListener () const
 
int graphSequenceNumber () const
 
void handleKeyframeChannelFrameAboutToBeRemoved (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameAdded (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameChange (const KisKeyframeChannel *channel, int time)
 
void handleKeyframeChannelFrameHasBeenRemoved (const KisKeyframeChannel *channel, int time)
 
KisFrameChangeUpdateRecipe handleKeyframeChannelUpdateImpl (const KisKeyframeChannel *channel, int time)
 
int index (const KisNodeSP node) const
 
void invalidateFrames (const KisTimeSpan &range, const QRect &rect)
 
 KisNode (const KisNode &rhs)
 
 KisNode (KisImageWSP image)
 
KisNodeSP lastChild () const
 
KisNodeSP nextSibling () const
 
KisNodeProgressProxynodeProgressProxy () const
 
KisNodeSP parent () const
 
KisNodeSP prevSibling () const
 
 Private (KisNode *node)
 
void processDuplicatedClones (const KisNode *srcDuplicationRoot, const KisNode *dstDuplicationRoot, KisNode *node)
 
virtual KisProjectionLeafSP projectionLeaf () const
 
virtual KisAbstractProjectionPlaneSP projectionPlane () const
 
void requestTimeSwitch (int time)
 
virtual void setDirty ()
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rect)
 
virtual void setDirty (const QVector< QRect > &rects)
 
void setDirtyDontResetAnimationCache ()
 
void setDirtyDontResetAnimationCache (const QRect &rect)
 
void setDirtyDontResetAnimationCache (const QVector< QRect > &rects)
 setDirtyDontResetAnimationCache does almost the same thing as usual setDirty() call, but doesn't reset the animation cache (since onion skins are not used when rendering animation.
 
void setGraphListener (KisNodeGraphListener *graphListener)
 
void setImage (KisImageWSP newImage) override
 
virtual void syncLodCache ()
 
 ~KisNode () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisBaseNode
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)
 
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 KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Public Attributes

KisBusyProgressIndicatorbusyProgressIndicator
 
std::optional< KisFrameChangeUpdateRecipeframeRemovalUpdateRecipe
 
KisNodeGraphListenergraphListener
 
KisNodeProgressProxynodeProgressProxy
 
KisSafeReadNodeList nodes
 
QReadWriteLock nodeSubgraphLock
 
KisNodeWSP parent
 
KisProjectionLeafSP projectionLeaf
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisBaseNode
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}
 

Protected Member Functions

virtual QRect accessRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
void addKeyframeChannel (KisKeyframeChannel *channel) override
 
void baseNodeChangedCallback () override
 
void baseNodeCollapsedChangedCallback () override
 
void baseNodeInvalidateAllFramesCallback () override
 
virtual QRect changeRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
virtual void childNodeChanged (KisNodeSP changedChildNode)
 
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl (const KisKeyframeChannel *channel, int time)
 
virtual QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
void notifyParentVisibilityChanged (bool value) override
 
KisBaseNodeSP parentCallback () const override
 
- Protected Member Functions inherited from KisBaseNode
virtual KisKeyframeChannelrequestKeyframeChannel (const QString &id)
 
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Private Member Functions

bool add (KisNodeSP newNode, KisNodeSP aboveThis, KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
 
void createNodeProgressProxy ()
 
KisNodeSP nextChildImpl (KisNodeSP child)
 
KisNodeSP prevChildImpl (KisNodeSP child)
 
bool remove (KisNodeSP node)
 
bool remove (quint32 index)
 
void setParent (KisNodeWSP parent)
 

Private Attributes

Private *const m_d
 

Friends

class KisFilterMaskTest
 
class KisLayer
 
class KisNodeFacade
 
class KisNodeTest
 

Detailed Description

Note about "thread safety" of KisNode

1) One can read any information about node and node graph in any number of threads concurrently. This operation is safe because of the usage of KisSafeReadNodeList and will run concurrently (lock-free).

2) One can write any information into the node or node graph in a single thread only! Changing the graph concurrently is not sane and therefore not supported.

3) One can read and write information about the node graph concurrently, given that there is only one writer thread and any number of reader threads. Please note that in this case the node's code is just guaranteed not to crash, which is ensured by nodeSubgraphLock. You need to ensure the sanity of the data read by the reader threads yourself!

A KisNode is a KisBaseNode that knows about its direct peers, parent and children and whether it can have children.

THREAD-SAFETY: All const methods of this class and setDirty calls are considered to be thread-safe(!). All the others especially add(), remove() and setParent() must be protected externally.

NOTE: your subclasses must have the Q_OBJECT declaration, even if you do not define new signals or slots.

Definition at line 75 of file kis_node.cpp.

Member Enumeration Documentation

◆ PositionToFilthy

The struct describing the position of the node against the filthy node. NOTE: please change KisBaseRectsWalker::getPositionToFilthy when changing this struct

Enumerator
N_ABOVE_FILTHY 
N_FILTHY_PROJECTION 
N_FILTHY 
N_BELOW_FILTHY 

Definition at line 58 of file kis_node.h.

58 {
59 N_ABOVE_FILTHY = 0x08,
61 N_FILTHY = 0x40,
62 N_BELOW_FILTHY = 0x80
63 };
@ N_ABOVE_FILTHY
Definition kis_node.h:59
@ N_FILTHY
Definition kis_node.h:61
@ N_FILTHY_PROJECTION
Definition kis_node.h:60
@ N_BELOW_FILTHY
Definition kis_node.h:62

Constructor & Destructor Documentation

◆ KisNode() [1/2]

KisNode::KisNode ( KisImageWSP image)

Create an empty node without a parent.

Definition at line 167 of file kis_node.cpp.

169 m_d(new Private(this))
170{
171 m_d->parent = 0;
172 m_d->graphListener = 0;
173 moveToThread(qApp->thread());
174}
KisBaseNode(KisImageWSP image)
KisImageWSP image
Private *const m_d
Definition kis_node.h:415

References m_d.

◆ KisNode() [2/2]

KisNode::KisNode ( const KisNode & rhs)

Create a copy of this node. The copy will not have a parent node.

Definition at line 176 of file kis_node.cpp.

177 : KisBaseNode(rhs)
178 , m_d(new Private(this))
179{
180 m_d->parent = 0;
181 m_d->graphListener = 0;
182 moveToThread(qApp->thread());
183
184 // NOTE: the nodes are not supposed to be added/removed while
185 // creation of another node, so we do *no* locking here!
186
187 KisSafeReadNodeList::const_iterator iter;
188 FOREACH_SAFE(iter, rhs.m_d->nodes) {
189 KisNodeSP child = (*iter)->clone();
191 m_d->nodes.append(child);
192 child->setParent(this);
193 }
194
195 m_d->processDuplicatedClones(&rhs, this, this);
196}
#define FOREACH_SAFE(_iter, _container)
void setParent(KisNodeWSP parent)
Definition kis_node.cpp:301
virtual KisNodeSP clone() const =0
void createNodeProgressProxy()
Definition kis_node.cpp:566

References clone(), createNodeProgressProxy(), FOREACH_SAFE, m_d, and setParent().

◆ ~KisNode()

KisNode::~KisNode ( )
override

Delete this node

Definition at line 198 of file kis_node.cpp.

199{
200 if (m_d->busyProgressIndicator) {
201 m_d->busyProgressIndicator->prepareDestroying();
202 m_d->busyProgressIndicator->deleteLater();
203 }
204
205 if (m_d->nodeProgressProxy) {
206 m_d->nodeProgressProxy->prepareDestroying();
207 m_d->nodeProgressProxy->deleteLater();
208 }
209
210 {
211 QWriteLocker l(&m_d->nodeSubgraphLock);
212 m_d->nodes.clear();
213 }
214
215 delete m_d;
216}

References m_d.

Member Function Documentation

◆ accept() [1/2]

bool KisNode::accept ( KisNodeVisitor & )
overridevirtual

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 from KisBaseNode.

Reimplemented in KisShapeLayer, KisReferenceImagesLayer, KisPaintLayer, KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 269 of file kis_node.cpp.

270{
271 return v.visit(this);
272}
qreal v

References v.

◆ accept() [2/2]

void KisNode::accept ( KisProcessingVisitor & visitor,
KisUndoAdapter * undoAdapter )
overridevirtual

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 from KisBaseNode.

Reimplemented in KisPaintLayer, KisSelectionMask, KisTransformMask, KisTransparencyMask, KisShapeLayer, and KisReferenceImagesLayer.

Definition at line 274 of file kis_node.cpp.

275{
276 visitor.visit(this, undoAdapter);
277}
virtual void visit(KisNode *node, KisUndoAdapter *undoAdapter)=0

References KisProcessingVisitor::visit().

◆ accessRect()

QRect KisNode::accessRect ( const QRect & rect,
PositionToFilthy pos = N_FILTHY ) const
protectedvirtual
Returns
internal accessRect() of the node. Do not mix with
See also
projectionPlane()

Shows the area of image, that may be accessed during accessing the node.

Example. You have a layer that needs to prepare some rect on a projection, say expectedRect. To perform this, the projection of all the layers below of the size needRect(expectedRect) should be calculated by the merger beforehand and the layer will access some other area of image inside the rect accessRect(expectedRect) during updateProjection call.

This knowledge about real access rect of a node is used by the scheduler to avoid collisions between two multithreaded updaters and so avoid flickering of the image.

Currently, this method has nondefault value for shifted clone layers only.

Reimplemented in KisCloneLayer.

Definition at line 230 of file kis_node.cpp.

231{
232 Q_UNUSED(pos);
233 return rect;
234}

◆ add()

bool KisNode::add ( KisNodeSP newNode,
KisNodeSP aboveThis,
KisNodeAdditionFlags flags = KisNodeAdditionFlag::None )
private

Add the specified node above the specified node. If aboveThis is 0, the node is added at the bottom.

Definition at line 469 of file kis_node.cpp.

470{
472 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(!aboveThis || aboveThis->parent().data() == this, false);
475 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(index(newNode) < 0, false);
476
477 int idx = aboveThis ? this->index(aboveThis) + 1 : 0;
478
479 // theoretical race condition may happen here ('idx' may become
480 // deprecated until the write lock will be held). But we ignore
481 // it, because it is not supported to add/remove nodes from two
482 // concurrent threads simultaneously
483
484 if (m_d->graphListener) {
485 m_d->graphListener->aboutToAddANode(this, idx);
486 }
487
488 {
489 QWriteLocker l(&m_d->nodeSubgraphLock);
490
491 newNode->createNodeProgressProxy();
492
493 m_d->nodes.insert(idx, newNode);
494
495 newNode->setParent(this);
496 newNode->setGraphListener(m_d->graphListener);
497 }
498
499 newNode->setImage(image());
500
501 if (m_d->graphListener) {
502 m_d->graphListener->nodeHasBeenAdded(this, idx, flags);
503 }
504
505 childNodeChanged(newNode);
506
507 return true;
508}
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
void setImage(KisImageWSP newImage) override
Definition kis_node.cpp:254
int index(const KisNodeSP node) const
Definition kis_node.cpp:432
KisNodeWSP parent
Definition kis_node.cpp:86
void setGraphListener(KisNodeGraphListener *graphListener)
Definition kis_node.cpp:289
virtual void childNodeChanged(KisNodeSP changedChildNode)
Definition kis_node.cpp:236
virtual bool allowAsChild(KisNodeSP) const =0

References allowAsChild(), childNodeChanged(), createNodeProgressProxy(), KisWeakSharedPtr< T >::data(), KisBaseNode::image, index(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_d, parent, setGraphListener(), setImage(), and setParent().

◆ addKeyframeChannel()

void KisNode::addKeyframeChannel ( KisKeyframeChannel * channel)
overrideprotectedvirtual

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 from KisBaseNode.

Definition at line 351 of file kis_node.cpp.

352{
353 channel->setNode(this);
355
356 if (m_d->graphListener) {
357 m_d->graphListener->keyframeChannelHasBeenAdded(this, channel);
358 }
359}
void setNode(KisNodeWSP node)
virtual void addKeyframeChannel(KisKeyframeChannel *channel)

References KisBaseNode::addKeyframeChannel(), m_d, and KisKeyframeChannel::setNode().

◆ allowAsChild()

virtual bool KisNode::allowAsChild ( KisNodeSP ) const
pure virtual

Re-implement this method to add constraints for the subclasses that can be added as children to this node

Returns
false if the given node is not allowed as a child to this node

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

◆ at()

KisNodeSP KisNode::at ( quint32 index) const

Retrieve the child node at the specified index.

Returns
0 if there is no node at this index.

Definition at line 421 of file kis_node.cpp.

422{
423 QReadLocker l(&m_d->nodeSubgraphLock);
424
425 if (!m_d->nodes.isEmpty() && index < (quint32)m_d->nodes.size()) {
426 return m_d->nodes.at(index);
427 }
428
429 return 0;
430}

References index(), and m_d.

◆ baseNodeChangedCallback()

void KisNode::baseNodeChangedCallback ( )
overrideprotectedvirtual

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 from KisBaseNode.

Definition at line 329 of file kis_node.cpp.

330{
331 if(m_d->graphListener) {
332 m_d->graphListener->nodeChanged(this);
333 Q_EMIT sigNodeChangedInternal();
334 }
335}
void sigNodeChangedInternal()

References m_d, and sigNodeChangedInternal().

◆ baseNodeCollapsedChangedCallback()

void KisNode::baseNodeCollapsedChangedCallback ( )
overrideprotectedvirtual

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 from KisBaseNode.

Definition at line 344 of file kis_node.cpp.

345{
346 if(m_d->graphListener) {
347 m_d->graphListener->nodeCollapsedChanged(this);
348 }
349}

References m_d.

◆ baseNodeInvalidateAllFramesCallback()

void KisNode::baseNodeInvalidateAllFramesCallback ( )
overrideprotectedvirtual

Reimplemented from KisBaseNode.

Definition at line 337 of file kis_node.cpp.

338{
339 if(m_d->graphListener) {
340 m_d->graphListener->invalidateAllFrames();
341 }
342}

References m_d.

◆ busyProgressIndicator()

KisBusyProgressIndicator * KisNode::busyProgressIndicator ( ) const

◆ changeRect()

QRect KisNode::changeRect ( const QRect & rect,
PositionToFilthy pos = N_FILTHY ) const
protectedvirtual
Returns
internal changeRect() of the node. Do not mix with
See also
projectionPlane()

Some filters will cause a change of pixels those are outside a requested rect. E.g. we change a rect of 2x2, then we want to apply a convolution filter with kernel 4x4 (changeRect is (2+2*3)x(2+2*3)=8x8) to that area. The rect that should be updated on the layer will be exactly 8x8. More than that the needRect for that update will be 14x14. See needRect.

Reimplemented in KisFilterMask, KisLayer, KisMask, KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 224 of file kis_node.cpp.

225{
226 Q_UNUSED(pos);
227 return rect;
228}

◆ childCount()

quint32 KisNode::childCount ( ) const

Returns how many direct child nodes this node has (not recursive).

Definition at line 414 of file kis_node.cpp.

415{
416 QReadLocker l(&m_d->nodeSubgraphLock);
417 return m_d->nodes.size();
418}

References m_d.

◆ childNodeChanged()

void KisNode::childNodeChanged ( KisNodeSP changedChildNode)
protectedvirtual

Called each time direct child nodes are added or removed under this node as parent. This does not track changes inside the child nodes or the child nodes' properties.

Reimplemented in KisLayer.

Definition at line 236 of file kis_node.cpp.

237{
238}

◆ childNodes()

QList< KisNodeSP > KisNode::childNodes ( const QStringList & nodeTypes,
const KoProperties & properties ) const

Return a list of child nodes of the current node that conform to the specified constraints. There are no guarantees about the order of the nodes in the list. The function is not recursive.

Parameters
nodeTypes.if not empty, only nodes that inherit the classnames in this stringlist will be returned.
properties.if not empty, only nodes for which KisNodeBase::check(properties) returns true will be returned.

Definition at line 439 of file kis_node.cpp.

440{
441 QReadLocker l(&m_d->nodeSubgraphLock);
442
444
445 KisSafeReadNodeList::const_iterator iter;
446 FOREACH_SAFE(iter, m_d->nodes) {
447 if (*iter) {
448 if (properties.isEmpty() || (*iter)->check(properties)) {
449 bool rightType = true;
450
451 if(!nodeTypes.isEmpty()) {
452 rightType = false;
453 Q_FOREACH (const QString &nodeType, nodeTypes) {
454 if ((*iter)->inherits(nodeType.toLatin1())) {
455 rightType = true;
456 break;
457 }
458 }
459 }
460 if (rightType) {
461 nodes.append(*iter);
462 }
463 }
464 }
465 }
466 return nodes;
467}
char nodeType(const KoPathPoint *point)
bool isEmpty() const
KoProperties properties
KisSafeReadNodeList nodes
Definition kis_node.cpp:88

References FOREACH_SAFE, KoProperties::isEmpty(), m_d, nodes, nodeType(), and KisBaseNode::properties.

◆ clone()

◆ createNodeProgressProxy()

void KisNode::createNodeProgressProxy ( )
private

Create a node progress proxy for this node. You need to create a progress proxy only if the node is going to appear in the layerbox, and it needs to be created before the layer box is made aware of the proxy.

Definition at line 566 of file kis_node.cpp.

567{
568 if (!m_d->nodeProgressProxy) {
569 m_d->nodeProgressProxy = new KisNodeProgressProxy(this);
570 m_d->busyProgressIndicator = new KisBusyProgressIndicator(m_d->nodeProgressProxy);
571
572 m_d->nodeProgressProxy->moveToThread(this->thread());
573 m_d->busyProgressIndicator->moveToThread(this->thread());
574 }
575}

References m_d.

◆ findSymmetricClone()

const KisNode * KisNode::findSymmetricClone ( const KisNode * srcRoot,
const KisNode * dstRoot,
const KisNode * srcTarget )

◆ firstChild()

KisNodeSP KisNode::firstChild ( ) const

Returns the first child node of this node, or 0 if there are no child nodes.

Definition at line 361 of file kis_node.cpp.

362{
363 QReadLocker l(&m_d->nodeSubgraphLock);
364 return !m_d->nodes.isEmpty() ? m_d->nodes.first() : 0;
365}

References m_d.

◆ getLodCapableDevices()

KisPaintDeviceList KisNode::getLodCapableDevices ( ) const
virtual

Reimplemented in KisPaintLayer, KisTransformMask, and KisColorizeMask.

Definition at line 682 of file kis_node.cpp.

683{
685
686 KisPaintDeviceSP device = paintDevice();
687 if (device) {
688 list << device;
689 }
690
691 KisPaintDeviceSP originalDevice = original();
692 if (originalDevice && originalDevice != device) {
693 list << originalDevice;
694 }
695
696 list << projectionPlane()->getLodCapableDevices();
697
698 return list;
699}
virtual KisPaintDeviceSP original() const =0
virtual KisPaintDeviceSP paintDevice() const =0
virtual KisAbstractProjectionPlaneSP projectionPlane() const
Definition kis_node.cpp:240

References KisBaseNode::original(), KisBaseNode::paintDevice(), and projectionPlane().

◆ graphListener()

KisNodeGraphListener * KisNode::graphListener ( ) const
Returns
the graph listener this node belongs to. 0 if the node does not belong to a graph listener.

◆ graphSequenceNumber()

int KisNode::graphSequenceNumber ( ) const
Returns
the graph sequence number calculated by the associated graph listener. You can use it for checking for changes in the graph.

Definition at line 279 of file kis_node.cpp.

280{
281 return m_d->graphListener ? m_d->graphListener->graphSequenceNumber() : -1;
282}

References m_d.

◆ handleKeyframeChannelFrameAboutToBeRemoved()

void KisNode::handleKeyframeChannelFrameAboutToBeRemoved ( const KisKeyframeChannel * channel,
int time )

Definition at line 657 of file kis_node.cpp.

658{
659 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_d->frameRemovalUpdateRecipe);
660 m_d->frameRemovalUpdateRecipe = handleKeyframeChannelFrameAboutToBeRemovedImpl(channel, time);
661}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl(const KisKeyframeChannel *channel, int time)
Definition kis_node.cpp:652

References handleKeyframeChannelFrameAboutToBeRemovedImpl(), KIS_SAFE_ASSERT_RECOVER_NOOP, and m_d.

◆ handleKeyframeChannelFrameAboutToBeRemovedImpl()

KisFrameChangeUpdateRecipe KisNode::handleKeyframeChannelFrameAboutToBeRemovedImpl ( const KisKeyframeChannel * channel,
int time )
protectedvirtual

Reimplemented in KisPaintLayer.

Definition at line 652 of file kis_node.cpp.

653{
654 return m_d->handleKeyframeChannelUpdateImpl(channel, time);
655}

References m_d.

◆ handleKeyframeChannelFrameAdded()

void KisNode::handleKeyframeChannelFrameAdded ( const KisKeyframeChannel * channel,
int time )
virtual

Reimplemented in KisPaintLayer.

Definition at line 647 of file kis_node.cpp.

648{
649 m_d->handleKeyframeChannelUpdateImpl(channel, time).notify(this);
650}

References m_d.

◆ handleKeyframeChannelFrameChange()

void KisNode::handleKeyframeChannelFrameChange ( const KisKeyframeChannel * channel,
int time )
virtual

Reimplemented in KisPaintLayer.

Definition at line 642 of file kis_node.cpp.

643{
644 m_d->handleKeyframeChannelUpdateImpl(channel, time).notify(this);
645}

References m_d.

◆ handleKeyframeChannelFrameHasBeenRemoved()

void KisNode::handleKeyframeChannelFrameHasBeenRemoved ( const KisKeyframeChannel * channel,
int time )

Definition at line 663 of file kis_node.cpp.

664{
665 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->frameRemovalUpdateRecipe);
666 m_d->frameRemovalUpdateRecipe->notify(this);
667 m_d->frameRemovalUpdateRecipe = std::nullopt;
668}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KIS_SAFE_ASSERT_RECOVER_RETURN, and m_d.

◆ handleKeyframeChannelUpdateImpl()

KisFrameChangeUpdateRecipe KisNode::handleKeyframeChannelUpdateImpl ( const KisKeyframeChannel * channel,
int time )

◆ index()

int KisNode::index ( const KisNodeSP node) const

Retrieve the index of the specified child node.

Returns
-1 if the specified node is not a child node of this node.

Definition at line 432 of file kis_node.cpp.

433{
434 QReadLocker l(&m_d->nodeSubgraphLock);
435
436 return m_d->nodes.indexOf(node);
437}

References m_d.

◆ invalidateFrames()

void KisNode::invalidateFrames ( const KisTimeSpan & range,
const QRect & rect )

Informs animation cache that the frames in the given range are no longer valid and need to be recached.

Parameters
rangeframes to invalidate

Definition at line 616 of file kis_node.cpp.

617{
618 if(m_d->graphListener) {
619 m_d->graphListener->invalidateFrames(range, rect);
620 }
621}

References m_d.

◆ lastChild()

KisNodeSP KisNode::lastChild ( ) const

Returns the last child node of this node, or 0 if there are no child nodes.

Definition at line 367 of file kis_node.cpp.

368{
369 QReadLocker l(&m_d->nodeSubgraphLock);
370 return !m_d->nodes.isEmpty() ? m_d->nodes.last() : 0;
371}

References m_d.

◆ needRect()

QRect KisNode::needRect ( const QRect & rect,
PositionToFilthy pos = N_FILTHY ) const
protectedvirtual
Returns
internal needRect() of the node. Do not mix with
See also
projectionPlane()

Some filters need pixels outside the current processing rect to compute the new value (for instance, convolution filters) See changeRect See accessRect

Reimplemented in KisAdjustmentLayer, KisFilterMask, KisMask, KisSelectionBasedLayer, KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 218 of file kis_node.cpp.

219{
220 Q_UNUSED(pos);
221 return rect;
222}

◆ nextChildImpl()

KisNodeSP KisNode::nextChildImpl ( KisNodeSP child)
private

See a comment in KisNode::prevChildImpl()

Definition at line 391 of file kis_node.cpp.

392{
396 QReadLocker l(&m_d->nodeSubgraphLock);
397
398 int i = m_d->nodes.indexOf(child) + 1;
399 return i > 0 && i < m_d->nodes.size() ? m_d->nodes.at(i) : 0;
400}

References m_d.

◆ nextSibling()

KisNodeSP KisNode::nextSibling ( ) const

Returns the next sibling of this node in the parent's list. This is the node below this node in the composition stack. 0 is returned if this child has no more next siblings (== lastChild())

Definition at line 408 of file kis_node.cpp.

409{
410 KisNodeSP parentNode = parent();
411 return parentNode ? parentNode->nextChildImpl(const_cast<KisNode*>(this)) : 0;
412}
KisNodeSP nextChildImpl(KisNodeSP child)
Definition kis_node.cpp:391

References nextChildImpl(), and parent.

◆ nodeProgressProxy()

KisNodeProgressProxy * KisNode::nodeProgressProxy ( ) const
Returns
the node progress proxy used by this node, if this node has no progress proxy, it will return the proxy of its parent, if the parent has no progress proxy it will return 0

◆ notifyParentVisibilityChanged()

void KisNode::notifyParentVisibilityChanged ( bool value)
overrideprotectedvirtual

Reimplemented from KisBaseNode.

Definition at line 318 of file kis_node.cpp.

319{
320 QReadLocker l(&m_d->nodeSubgraphLock);
321
322 KisSafeReadNodeList::const_iterator iter;
323 FOREACH_SAFE(iter, m_d->nodes) {
324 KisNodeSP child = (*iter);
326 }
327}
float value(const T *src, size_t ch)
void notifyParentVisibilityChanged(bool value) override
Definition kis_node.cpp:318

References FOREACH_SAFE, m_d, notifyParentVisibilityChanged(), and value().

◆ parent()

KisNodeSP KisNode::parent ( ) const

Returns the parent node of this node. This is 0 only for a root node; otherwise this will be an actual Node

◆ parentCallback()

KisBaseNodeSP KisNode::parentCallback ( ) const
overrideprotectedvirtual

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 from KisBaseNode.

Definition at line 313 of file kis_node.cpp.

314{
315 return parent();
316}

References parent.

◆ prevChildImpl()

KisNodeSP KisNode::prevChildImpl ( KisNodeSP child)
private

Warning: mind locking policy!

The graph locks must be always taken in descending order. That is if you want to (or it implicitly happens that you) take a lock of a parent and a chil, you must first take the lock of a parent, and only after that ask a child to do the same. Otherwise you'll get a deadlock.

Definition at line 373 of file kis_node.cpp.

374{
385 QReadLocker l(&m_d->nodeSubgraphLock);
386
387 int i = m_d->nodes.indexOf(child) - 1;
388 return i >= 0 ? m_d->nodes.at(i) : 0;
389}

References m_d.

◆ prevSibling()

KisNodeSP KisNode::prevSibling ( ) const

Returns the previous sibling of this node in the parent's list. This is the node above this node in the composition stack. 0 is returned if this child has no more previous siblings (== firstChild())

Definition at line 402 of file kis_node.cpp.

403{
404 KisNodeSP parentNode = parent();
405 return parentNode ? parentNode->prevChildImpl(const_cast<KisNode*>(this)) : 0;
406}
KisNodeSP prevChildImpl(KisNodeSP child)
Definition kis_node.cpp:373

References parent, and prevChildImpl().

◆ Private()

KisNode::Private ( KisNode * node)
inline

Definition at line 78 of file kis_node.cpp.

79 : graphListener(0)
83 {
84 }
KisBusyProgressIndicator * busyProgressIndicator
Definition kis_node.cpp:90
KisProjectionLeafSP projectionLeaf
Definition kis_node.cpp:93
KisNodeProgressProxy * nodeProgressProxy
Definition kis_node.cpp:89
KisNodeGraphListener * graphListener
Definition kis_node.cpp:87

◆ processDuplicatedClones()

void KisNode::processDuplicatedClones ( const KisNode * srcDuplicationRoot,
const KisNode * dstDuplicationRoot,
KisNode * node )

◆ projectionLeaf()

virtual KisProjectionLeafSP KisNode::projectionLeaf ( ) const
virtual

The rendering of the image may not always happen in the order of the main graph. Pass-through nodes make some subgraphs linear, so it the order of rendering change. projectionLeaf() is a special interface of KisNode that represents "a graph for projection rendering". Therefore the nodes in projectionLeaf() graph may have a different order the main one.

◆ projectionPlane()

KisAbstractProjectionPlaneSP KisNode::projectionPlane ( ) const
virtual
Returns
a pointer to a KisAbstractProjectionPlane interface of the node. This interface is used by the image merging framework to get information and to blending for the layer.

Please note the difference between need/change/accessRect and the projectionPlane() interface. The former one gives information about internal composition of the layer, and the latter one about the total composition, including layer styles, pass-through blending and etc.

Reimplemented in KisLayer, and KisMask.

Definition at line 240 of file kis_node.cpp.

241{
242 KIS_ASSERT_RECOVER_NOOP(0 && "KisNode::projectionPlane() is not defined!");
243 static KisAbstractProjectionPlaneSP plane =
245
246 return plane;
247}
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
QSharedPointer< T > toQShared(T *ptr)

References KIS_ASSERT_RECOVER_NOOP, and toQShared().

◆ remove() [1/2]

bool KisNode::remove ( KisNodeSP node)
private

Removes the node from the child nodes.

Returns
false if there's no such node in this node.

Definition at line 541 of file kis_node.cpp.

542{
543 return node->parent().data() == this ? remove(index(node)) : false;
544}
bool remove(quint32 index)
Definition kis_node.cpp:510

References KisWeakSharedPtr< T >::data(), index(), parent, and remove().

◆ remove() [2/2]

bool KisNode::remove ( quint32 index)
private

Removes the node at the specified index from the child nodes.

Returns
false if there is no node at this index

Definition at line 510 of file kis_node.cpp.

511{
512 if (index < childCount()) {
513 KisNodeSP removedNode = at(index);
514
515 if (m_d->graphListener) {
516 m_d->graphListener->aboutToRemoveANode(this, index);
517 }
518
519 removedNode->setImage(0);
520
521 {
522 QWriteLocker l(&m_d->nodeSubgraphLock);
523
524 removedNode->setGraphListener(0);
525
526 removedNode->setParent(0); // after calling aboutToRemoveANode or then the model get broken according to TT's modeltest
527 m_d->nodes.removeAt(index);
528 }
529
530 if (m_d->graphListener) {
531 m_d->graphListener->nodeHasBeenRemoved(this, index);
532 }
533
534 childNodeChanged(removedNode);
535
536 return true;
537 }
538 return false;
539}
quint32 childCount() const
Definition kis_node.cpp:414
KisNodeSP at(quint32 index) const
Definition kis_node.cpp:421

References at(), childCount(), childNodeChanged(), index(), m_d, setGraphListener(), setImage(), and setParent().

◆ requestTimeSwitch()

void KisNode::requestTimeSwitch ( int time)

Informs that the current world time should be changed. Might be caused by e.g. undo operation

Definition at line 670 of file kis_node.cpp.

671{
672 if(m_d->graphListener) {
673 m_d->graphListener->requestTimeSwitch(time);
674 }
675}

References m_d.

◆ setDirty() [1/4]

void KisNode::setDirty ( )
virtual

Set the entire node extent dirty; this percolates up to parent nodes all the way to the root node. By default this is the empty rect (through KisBaseNode::extent())

Reimplemented in KisGeneratorLayer, and KisSelectionBasedLayer.

Definition at line 577 of file kis_node.cpp.

578{
579 setDirty(extent());
580}
virtual QRect extent() const
virtual void setDirty()
Definition kis_node.cpp:577

References KisBaseNode::extent(), and setDirty().

◆ setDirty() [2/4]

void KisNode::setDirty ( const KisRegion & region)

Add the given region to the set of dirty rects for this node; this percolates up to parent nodes all the way to the root node, if propagate is true;

Definition at line 589 of file kis_node.cpp.

590{
591 setDirty(region.rects());
592}
QVector< QRect > rects() const

References KisRegion::rects(), and setDirty().

◆ setDirty() [3/4]

void KisNode::setDirty ( const QRect & rect)

Add the given rect to the set of dirty rects for this node; this percolates up to parent nodes all the way to the root node.

Definition at line 594 of file kis_node.cpp.

595{
597}

References setDirty().

◆ setDirty() [4/4]

void KisNode::setDirty ( const QVector< QRect > & rects)
virtual

Add the given rects to the set of dirty rects for this node; this percolates up to parent nodes all the way to the root node.

Reimplemented in KisGeneratorLayer, and KisSelectionMask.

Definition at line 582 of file kis_node.cpp.

583{
584 if(m_d->graphListener) {
585 m_d->graphListener->requestProjectionUpdate(this, rects, KisProjectionUpdateFlag::None);
586 }
587}

References m_d, and None.

◆ setDirtyDontResetAnimationCache() [1/3]

void KisNode::setDirtyDontResetAnimationCache ( )

◆ setDirtyDontResetAnimationCache() [2/3]

void KisNode::setDirtyDontResetAnimationCache ( const QRect & rect)

◆ setDirtyDontResetAnimationCache() [3/3]

void KisNode::setDirtyDontResetAnimationCache ( const QVector< QRect > & rects)

setDirtyDontResetAnimationCache does almost the same thing as usual setDirty() call, but doesn't reset the animation cache (since onion skins are not used when rendering animation.

Definition at line 609 of file kis_node.cpp.

610{
611 if(m_d->graphListener) {
612 m_d->graphListener->requestProjectionUpdate(this, rects, KisProjectionUpdateFlag::DontInvalidateFrames);
613 }
614}

References DontInvalidateFrames, and m_d.

◆ setGraphListener()

void KisNode::setGraphListener ( KisNodeGraphListener * graphListener)

Set the graph listener for this node. The graphlistener will be informed before and after the list of child nodes has changed.

Definition at line 289 of file kis_node.cpp.

290{
291 m_d->graphListener = graphListener;
292
293 QReadLocker l(&m_d->nodeSubgraphLock);
294 KisSafeReadNodeList::const_iterator iter;
295 FOREACH_SAFE(iter, m_d->nodes) {
296 KisNodeSP child = (*iter);
298 }
299}

References FOREACH_SAFE, graphListener, m_d, and setGraphListener().

◆ setImage()

void KisNode::setImage ( KisImageWSP newImage)
overridevirtual

Reimplemented from KisBaseNode.

Reimplemented in KisPaintLayer, KisSelectionBasedLayer, KisTransformMask, and KisShapeLayer.

Definition at line 254 of file kis_node.cpp.

255{
256 KisBaseNode::setImage(newImage);
257
258 KisNodeSP node = firstChild();
259 while (node) {
261 [newImage] (KisNodeSP node) {
262 node->setImage(newImage);
263 });
264
265 node = node->nextSibling();
266 }
267}
void recursiveApplyNodes(NodePointer node, Functor func)
virtual void setImage(KisImageWSP image)
KisNodeSP firstChild() const
Definition kis_node.cpp:361
KisNodeSP nextSibling() const
Definition kis_node.cpp:408

References firstChild(), nextSibling(), KisLayerUtils::recursiveApplyNodes(), KisBaseNode::setImage(), and setImage().

◆ setParent()

void KisNode::setParent ( KisNodeWSP parent)
private

Set the parent of this node.

Definition at line 301 of file kis_node.cpp.

302{
303 QWriteLocker l(&m_d->nodeSubgraphLock);
304 m_d->parent = parent;
305}

References m_d, and parent.

◆ sigNodeChangedInternal

void KisNode::sigNodeChangedInternal ( )
signal

Don't use this signal anywhere other than KisNodeShape. It's a hack.

◆ syncLodCache()

void KisNode::syncLodCache ( )
virtual

Synchronizes LoD caches of the node with the current state of it. The current level of detail is fetched from the image pointed by default bounds object

Reimplemented in KisCloneLayer, and KisTransformMask.

Definition at line 677 of file kis_node.cpp.

678{
679 // noop. everything is done by getLodCapableDevices()
680}

Friends And Related Symbol Documentation

◆ KisFilterMaskTest

friend class KisFilterMaskTest
friend

Definition at line 48 of file kis_node.h.

◆ KisLayer

friend class KisLayer
friend

Definition at line 383 of file kis_node.h.

◆ KisNodeFacade

friend class KisNodeFacade
friend

Definition at line 381 of file kis_node.h.

◆ KisNodeTest

friend class KisNodeTest
friend

Definition at line 382 of file kis_node.h.

Member Data Documentation

◆ busyProgressIndicator

KisBusyProgressIndicator * KisNode::busyProgressIndicator

Definition at line 90 of file kis_node.cpp.

◆ frameRemovalUpdateRecipe

std::optional<KisFrameChangeUpdateRecipe> KisNode::frameRemovalUpdateRecipe

Definition at line 102 of file kis_node.cpp.

◆ graphListener

KisNodeGraphListener * KisNode::graphListener

Definition at line 87 of file kis_node.cpp.

◆ m_d

Private* const KisNode::m_d
private

Definition at line 415 of file kis_node.h.

◆ nodeProgressProxy

KisNodeProgressProxy * KisNode::nodeProgressProxy

Definition at line 89 of file kis_node.cpp.

◆ nodes

KisSafeReadNodeList KisNode::nodes

Definition at line 88 of file kis_node.cpp.

◆ nodeSubgraphLock

QReadWriteLock KisNode::nodeSubgraphLock

Definition at line 91 of file kis_node.cpp.

◆ parent

KisNodeSP KisNode::parent

Definition at line 86 of file kis_node.cpp.

◆ projectionLeaf

KisProjectionLeafSP KisNode::projectionLeaf

Definition at line 93 of file kis_node.cpp.


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