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
 
QImage createPreferredThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
QImage createPreferredThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
virtual QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio, KisThumbnailBoundsMode boundsMode=KisThumbnailBoundsMode::Precise)
 
virtual QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio, KisThumbnailBoundsMode boundsMode=KisThumbnailBoundsMode::Precise)
 
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
 
KisThumbnailBoundsMode preferredThumbnailBoundsMode () 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)
 
void setPreferredThumbnailBoundsMode (KisThumbnailBoundsMode value) const
 
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}
 
KisThumbnailBoundsMode thumbnailBoundsMode { KisThumbnailBoundsMode::Precise }
 
- 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 66 of file kis_base_node.cpp.

67 : m_d(new Private(image))
68{
78 setVisible(true, true);
79 setUserLocked(false);
80 setCollapsed(false);
82
83 m_d->compositeOp = COMPOSITE_OVER;
84
85 connect(&m_d->opacityProperty, SIGNAL(changed(quint8)), this, SIGNAL(opacityChanged(quint8)));
86}
const QString COMPOSITE_OVER
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, 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 89 of file kis_base_node.cpp.

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

References m_d, and opacityChanged().

◆ ~KisBaseNode()

KisBaseNode::~KisBaseNode ( )
override

Delete this node

Definition at line 102 of file kis_base_node.cpp.

103{
104 delete m_d;
105}

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 462 of file kis_base_node.cpp.

463{
464 m_d->keyframeChannels.insert(channel->id(), channel);
465 Q_EMIT keyframeChannelAdded(channel);
466}
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 585 of file kis_base_node.h.

585 {
586 }

◆ 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 594 of file kis_base_node.h.

594 {
595 }

◆ baseNodeInvalidateAllFramesCallback()

virtual void KisBaseNode::baseNodeInvalidateAllFramesCallback ( )
inlineprotectedvirtual

Reimplemented in KisNode.

Definition at line 598 of file kis_base_node.h.

598 {
599 }

◆ belongsToIsolatedGroup()

bool KisBaseNode::belongsToIsolatedGroup ( ) const

Return whether or not the given node is isolated.

Definition at line 272 of file kis_base_node.cpp.

273{
274 if (!m_d->image) {
275 return false;
276 }
277
278 const KisBaseNode* element = this;
279
280 while (element) {
281 if (element->isIsolatedRoot()) {
282 return true;
283 } else {
284 element = element->parentCallback().data();
285 }
286 }
287
288 return false;
289}
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 184 of file kis_base_node.cpp.

185{
186 QMapIterator<QString, QVariant> iter = properties.propertyIterator();
187 while (iter.hasNext()) {
188 iter.next();
189 if (m_d->properties.contains(iter.key())) {
190 if (m_d->properties.value(iter.key()) != iter.value())
191 return false;
192 }
193 }
194 return true;
195}
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 361 of file kis_base_node.cpp.

362{
363 return m_d->properties.intProperty(KisLayerPropertiesIcons::colorLabelIndex.id(), 0);
364}

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 107 of file kis_base_node.cpp.

108{
109 return projection();
110}
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 133 of file kis_base_node.cpp.

134{
135 return m_d->compositeOp;
136}

References m_d.

◆ createPreferredThumbnail()

QImage KisBaseNode::createPreferredThumbnail ( qint32 w,
qint32 h,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio )

Create a thumbnail in the currently preferred bounds mode

See also
preferredThumbnailBoundsMode()

Definition at line 213 of file kis_base_node.cpp.

214{
215 return createThumbnail(w, h, aspectRatioMode, m_d->thumbnailBoundsMode);
216}
virtual QImage createThumbnail(qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio, KisThumbnailBoundsMode boundsMode=KisThumbnailBoundsMode::Precise)

References createThumbnail(), and m_d.

◆ createPreferredThumbnailForFrame()

QImage KisBaseNode::createPreferredThumbnailForFrame ( qint32 w,
qint32 h,
int time,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio )

Definition at line 239 of file kis_base_node.cpp.

240{
241 return createThumbnailForFrame(w, h, time, aspectRatioMode, m_d->thumbnailBoundsMode);
242}
virtual QImage createThumbnailForFrame(qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio, KisThumbnailBoundsMode boundsMode=KisThumbnailBoundsMode::Precise)

References createThumbnailForFrame(), and m_d.

◆ createThumbnail()

QImage KisBaseNode::createThumbnail ( qint32 w,
qint32 h,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio,
KisThumbnailBoundsMode boundsMode = KisThumbnailBoundsMode::Precise )
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 198 of file kis_base_node.cpp.

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

References image.

◆ createThumbnailForFrame()

QImage KisBaseNode::createThumbnailForFrame ( qint32 w,
qint32 h,
int time,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio,
KisThumbnailBoundsMode boundsMode = KisThumbnailBoundsMode::Precise )
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 233 of file kis_base_node.cpp.

234{
235 Q_UNUSED(time);
236 return createThumbnail(w, h, aspectRatioMode, boundsMode);
237}

References createThumbnail().

◆ enableAnimation()

void KisBaseNode::enableAnimation ( )

Definition at line 456 of file kis_base_node.cpp.

457{
458 m_d->animated = true;
460}
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 481 of file kis_base_node.h.

481 {
482 return QRect();
483 }

◆ 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 473 of file kis_base_node.h.

473 {
474 return QRect();
475 }

◆ getKeyframeChannel() [1/2]

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

Definition at line 414 of file kis_base_node.cpp.

415{
416 QMap<QString, KisKeyframeChannel*>::const_iterator i = m_d->keyframeChannels.constFind(id);
417 if (i == m_d->keyframeChannels.constEnd()) {
418 return 0;
419 }
420 return i.value();
421}

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 436 of file kis_base_node.cpp.

437{
439
440 if (!channel && create) {
441 channel = requestKeyframeChannel(id);
442
443 if (channel) {
444 addKeyframeChannel(channel);
445 }
446 }
447
448 return channel;
449}
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 330 of file kis_base_node.cpp.

331{
332 return paintDevice() && isEditable();
333}
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 451 of file kis_base_node.cpp.

452{
453 return m_d->animated;
454}

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 311 of file kis_base_node.cpp.

312{
313 bool editable = true;
314 if (checkVisibility) {
315 editable = ((visible(false) || belongsToIsolatedGroup()) && !userLocked());
316 }
317 else {
318 editable = (!userLocked());
319 }
320
321 if (editable) {
322 KisBaseNodeSP parentNode = parentCallback();
323 if (parentNode && parentNode != this) {
324 editable = parentNode->isEditable(checkVisibility);
325 }
326 }
327 return editable;
328}
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 398 of file kis_base_node.cpp.

399{
400 return false;
401}

◆ isIsolatedRoot()

bool KisBaseNode::isIsolatedRoot ( ) const

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

Definition at line 291 of file kis_base_node.cpp.

292{
293 if (!m_d->image) {
294 return false;
295 }
296
297 const KisBaseNode* isolatedRoot = m_d->image->isolationRootNode().data();
298
299 return (this == isolatedRoot);
300}

References m_d.

◆ isPinnedToTimeline()

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

Definition at line 423 of file kis_base_node.cpp.

424{
425 return m_d->pinnedToTimeline;
426}

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 173 of file kis_base_node.cpp.

174{
175 QMapIterator<QString, QVariant> iter = properties.propertyIterator();
176 while (iter.hasNext()) {
177 iter.next();
178 m_d->properties.setProperty(iter.key(), iter.value());
179 }
182}
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 162 of file kis_base_node.cpp.

163{
164 return m_d->properties;
165}

References m_d.

◆ notifyParentVisibilityChanged()

virtual void KisBaseNode::notifyParentVisibilityChanged ( bool value)
inlineprotectedvirtual

Reimplemented in KisCloneLayer, and KisNode.

Definition at line 573 of file kis_base_node.h.

573 {
574 Q_UNUSED(value);
575 }
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 112 of file kis_base_node.cpp.

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

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 569 of file kis_base_node.h.

569 {
570 return KisBaseNodeSP();
571 }
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 123 of file kis_base_node.cpp.

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

References opacity().

◆ preferredThumbnailBoundsMode()

KisThumbnailBoundsMode KisBaseNode::preferredThumbnailBoundsMode ( ) const
Returns
the currently preferred bounds mode for the thumbnails (whether to use exactBounds() or extent())

Some layers with huge areas of empty pixels may take too much time to generate a thumbnail (because of slow exactBounds() calculation).

If thumbnail generator notices a slowdown it switches the layer's thumbnail generation into Coarse mode, which will force thumbnails to be genrated from extent() of the device instead.

Definition at line 218 of file kis_base_node.cpp.

219{
220 return m_d->thumbnailBoundsMode;
221}

References m_d.

◆ Private() [1/2]

KisBaseNode::Private ( const Private & rhs)
inline

Definition at line 48 of file kis_base_node.cpp.

49 : compositeOp(rhs.compositeOp),
50 id(QUuid::createUuid()),
52 collapsed(rhs.collapsed),
53 supportsLodMoves(rhs.supportsLodMoves),
54 animated(rhs.animated),
55 pinnedToTimeline(rhs.pinnedToTimeline),
56 image(rhs.image)
57 {
58 QMapIterator<QString, QVariant> iter = rhs.properties.propertyIterator();
59 while (iter.hasNext()) {
60 iter.next();
61 properties.setProperty(iter.key(), iter.value());
62 }
63 }
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 41 of file kis_base_node.cpp.

42 : id(QUuid::createUuid())
44 , image(p_image)
45 {
46 }

◆ 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 468 of file kis_base_node.cpp.

469{
470 if (id == KisKeyframeChannel::Opacity.id()) {
471 Q_ASSERT(!m_d->opacityProperty.hasChannel());
472
473 KisPaintDeviceSP device = original();
474 KisNode* node = dynamic_cast<KisNode*>(this);
475
476 if (device && node) {
477 m_d->opacityProperty.makeAnimated(node);
478 return m_d->opacityProperty.channel();
479 }
480 }
481
482 return 0;
483}
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 147 of file kis_base_node.cpp.

148{
150 l << KisLayerPropertiesIcons::getProperty(KisLayerPropertiesIcons::visible, visible(), m_d->hack_visible.isInStasis, m_d->hack_visible.stateInStasis);
152 return l;
153}
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 335 of file kis_base_node.cpp.

336{
337 const bool oldCollapsed = m_d->collapsed;
338
339 m_d->collapsed = collapsed;
340
341 if (oldCollapsed != collapsed) {
343 }
344}
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 351 of file kis_base_node.cpp.

352{
353 const int currentLabel = colorLabelIndex();
354
355 if (currentLabel == index) return;
356
357 m_d->properties.setProperty(KisLayerPropertiesIcons::colorLabelIndex.id(), index);
359}
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 138 of file kis_base_node.cpp.

139{
140 if (m_d->compositeOp == compositeOp) return;
141
142 m_d->compositeOp = compositeOp;
145}

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 387 of file kis_base_node.cpp.

388{
389 m_d->image = image;
390 m_d->opacityProperty.updateDefaultBounds(new KisDefaultBounds(image));
391}

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 167 of file kis_base_node.cpp.

168{
169 m_d->properties.setProperty(name, value);
171}

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 117 of file kis_base_node.cpp.

118{
119 m_d->opacityProperty.set(val);
121}

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 128 of file kis_base_node.cpp.

129{
130 setOpacity(int(float(val * 255) / 100 + 0.5));
131}
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 428 of file kis_base_node.cpp.

429{
430 if (pinned == m_d->pinnedToTimeline) return;
431
432 m_d->pinnedToTimeline = pinned;
434}

References baseNodeChangedCallback(), and m_d.

◆ setPreferredThumbnailBoundsMode()

void KisBaseNode::setPreferredThumbnailBoundsMode ( KisThumbnailBoundsMode value) const

Set preferred bounds mode for the layer thumbnails

See also
preferredThumbnailBoundsMode()

Definition at line 223 of file kis_base_node.cpp.

224{
225 m_d->thumbnailBoundsMode = value;
226}

References m_d, and value().

◆ 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 155 of file kis_base_node.cpp.

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

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

◆ setSupportsLodMoves()

void KisBaseNode::setSupportsLodMoves ( bool value)
protected

Definition at line 403 of file kis_base_node.cpp.

404{
405 m_d->supportsLodMoves = value;
406}

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 302 of file kis_base_node.cpp.

303{
304 const bool isLocked = m_d->properties.boolProperty(KisLayerPropertiesIcons::locked.id(), true);
305 if (isLocked == locked) return;
306
307 m_d->properties.setProperty(KisLayerPropertiesIcons::locked.id(), locked);
309}

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 371 of file kis_base_node.cpp.

372{
373 m_d->id = id;
375}

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 253 of file kis_base_node.cpp.

254{
255 const bool isVisible = m_d->properties.boolProperty(KisLayerPropertiesIcons::visible.id(), true);
256 if (!loading && isVisible == visible) return;
257
258 m_d->properties.setProperty(KisLayerPropertiesIcons::visible.id(), visible);
260
261 if (!loading) {
264 }
265}
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 451 of file kis_base_node.h.

451 {
452 }

◆ 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 466 of file kis_base_node.h.

466 {
467 }

◆ 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 485 of file kis_base_node.cpp.

486{
487 if (id == KisKeyframeChannel::Opacity.id() && original()) {
488 return true;
489 }
490
491 return false;
492}

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 382 of file kis_base_node.cpp.

383{
384 return true;
385}

◆ 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 228 of file kis_base_node.cpp.

229{
230 return -1;
231}

◆ updateSettings()

virtual void KisBaseNode::updateSettings ( )
inlinevirtual

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

Definition at line 372 of file kis_base_node.h.

372 {
373 }

◆ userLocked()

bool KisBaseNode::userLocked ( ) const

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

Definition at line 267 of file kis_base_node.cpp.

268{
269 return m_d->properties.boolProperty(KisLayerPropertiesIcons::locked.id(), false);
270}

References KisLayerPropertiesIcons::locked, and m_d.

◆ uuid()

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

Definition at line 366 of file kis_base_node.cpp.

367{
368 return m_d->id;
369}

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 244 of file kis_base_node.cpp.

245{
246 bool isVisible = m_d->properties.boolProperty(KisLayerPropertiesIcons::visible.id(), true);
247 KisBaseNodeSP parentNode = parentCallback();
248
249 return recursive && isVisible && parentNode ?
250 parentNode->visible(recursive) : isVisible;
251}

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 442 of file kis_base_node.h.

442 {
443 return 0;
444 }

◆ 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 457 of file kis_base_node.h.

457 {
458 return 0;
459 }

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 638 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};

◆ thumbnailBoundsMode


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