Krita Source Code Documentation
Loading...
Searching...
No Matches
Node Class Reference

#include <Node.h>

+ Inheritance diagram for Node:

Classes

struct  Private
 

Public Slots

bool addChildNode (Node *child, Node *above)
 addChildNode adds the given node in the list of children.
 
bool alphaLocked () const
 alphaLocked checks whether the node is a paint layer and returns whether it is alpha locked
 
bool animated () const
 Krita layers can be animated, i.e., have frames.
 
QString blendingMode () const
 
QRect bounds () const
 bounds return the exact bounds of the node's paint device
 
QList< Channel * > channels () const
 channels creates a list of Channel objects that can be used individually to show or hide certain channels, and to retrieve the contents of each channel in a node separately.
 
QList< Node * > childNodes () const
 childNodes
 
Nodeclone () const
 clone clone the current node. The node is not associated with any image.
 
bool collapsed () const
 
QString colorDepth () const
 
int colorLabel () const
 
QString colorModel () const
 colorModel retrieve the current color model of this document:
 
QString colorProfile () const
 
void cropNode (int x, int y, int w, int h)
 cropNode crop this layer.
 
Nodeduplicate ()
 duplicate returns a full copy of the current node. The node is not inserted in the graphic
 
void enableAnimation () const
 enableAnimation make the current layer animated, so it can have frames.
 
QList< Node * > findChildNodes (const QString &name=QString(), bool recursive=false, bool partialMatch=false, const QString &type=QString(), int colorLabelIndex=0) const
 findChildNodes
 
bool hasExtents ()
 does the node have any content in it?
 
bool hasKeyframeAtTime (int frameNumber)
 
QIcon icon () const
 icon
 
int index () const
 index the index of the node inside the parent
 
bool inheritAlpha () const
 inheritAlpha checks whether this node has the inherits alpha flag set
 
bool isPinnedToTimeline () const
 
QString layerStyleToAsl ()
 layerStyleToAsl retrieve the current layer's style in ASL format.
 
bool locked () const
 locked checks whether the Node is locked. A locked node cannot be changed.
 
NodemergeDown ()
 mergeDown merges the given node with the first visible node underneath this node in the layerstack. This will drop all per-layer metadata.
 
void move (int x, int y)
 
QString name () const
 
int opacity () const
 
QString paintAbility ()
 paintAbility can be used to determine whether this node can be painted on with the current brush preset.
 
void paintEllipse (const QRectF &rect, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint an ellipse on the canvas. Uses current brush preset
 
void paintLine (const QPointF pointOne, const QPointF pointTwo, double pressureOne=1.0, double pressureTwo=1.0, const QString strokeStyle=PaintingResources::defaultStrokeStyle)
 paint a line on the canvas. Uses current brush preset
 
void paintPath (const QPainterPath &path, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint a custom path on the canvas. Uses current brush preset
 
void paintPolygon (const QList< QPointF > points, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint a polygon on the canvas. Uses current brush preset
 
void paintRectangle (const QRectF &rect, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint a rectangle on the canvas. Uses current brush preset
 
NodeparentNode () const
 
QByteArray pixelData (int x, int y, int w, int h) const
 pixelData reads the given rectangle from the Node's paintable pixels, if those exist, and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.
 
QByteArray pixelDataAtTime (int x, int y, int w, int h, int time) const
 pixelDataAtTime a basic function to get pixeldata from an animated node at a given time.
 
QPoint position () const
 position returns the position of the paint device of this node. The position is always 0,0 unless the layer has been moved. If you want to know the topleft position of the rectangle around the actual non-transparent pixels in the node, use bounds().
 
QByteArray projectionPixelData (int x, int y, int w, int h) const
 projectionPixelData reads the given rectangle from the Node's projection (that is, what the node looks like after all sub-Nodes (like layers in a group or masks on a layer) have been applied, and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.
 
bool remove ()
 remove removes this node from its parent image.
 
bool removeChildNode (Node *child)
 removeChildNode removes the given node from the list of children.
 
void rotateNode (double radians)
 rotateNode rotate this layer by the given radians.
 
bool save (const QString &filename, double xRes, double yRes, const InfoObject &exportConfiguration, const QRect &exportRect=QRect())
 save exports the given node with this filename. The extension of the filename determines the filetype.
 
void scaleNode (QPointF origin, int width, int height, QString strategy)
 scaleNode
 
void setAlphaLocked (bool value)
 setAlphaLocked set the layer to value if the node is paint layer.
 
void setBlendingMode (QString value)
 setBlendingMode set the blending mode of the node to the given value
 
void setChildNodes (QList< Node * > nodes)
 setChildNodes this replaces the existing set of child nodes with the new set.
 
void setCollapsed (bool collapsed)
 
void setColorLabel (int index)
 setColorLabel 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.
 
bool setColorProfile (const QString &colorProfile)
 setColorProfile set the color profile of the image to the given profile. The profile has to be registered with krita and be compatible with the current color model and depth; the image data is not converted.
 
bool setColorSpace (const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
 setColorSpace convert the node to the given colorspace
 
void setInheritAlpha (bool value)
 
bool setLayerStyleFromAsl (const QString &asl)
 setLayerStyleFromAsl set a new layer style for this node.
 
void setLocked (bool value)
 
void setName (QString name)
 
void setOpacity (int value)
 
void setPinnedToTimeline (bool pinned) const
 Sets whether or not node should be pinned to the Timeline Docker, regardless of selection activity.
 
bool setPixelData (QByteArray value, int x, int y, int w, int h)
 setPixelData writes the given bytes, of which there must be enough, into the Node, if the Node has writable pixel data:
 
void setVisible (bool visible)
 
void shearNode (double angleX, double angleY)
 shearNode perform a shear operation on this node.
 
QImage thumbnail (int w, int h)
 thumbnail create a thumbnail of the given dimensions. The thumbnail is sized according to the layer dimensions, not the image dimensions. If the requested size is too big a null QImage is created. If the current node cannot generate a thumbnail, a transparent QImage of the requested size is generated.
 
virtual QString type () const
 type Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.
 
QUuid uniqueId () const
 uniqueId uniqueId of the node
 
bool visible () const
 

Public Member Functions

bool operator!= (const Node &other) const
 
bool operator== (const Node &other) const
 
 ~Node () override
 

Static Public Member Functions

static NodecreateNode (KisImageSP image, KisNodeSP node, QObject *parent=0)
 

Private Member Functions

KisImageSP image () const
 
KisNodeSP node () const
 
 Node (KisImageSP image, KisNodeSP node, QObject *parent=0)
 
KisPaintDeviceSP paintDevice () const
 paintDevice gives access to the internal paint device of this Node
 

Private Attributes

Private *const d
 

Friends

class CloneLayer
 
class ColorizeMask
 
class Document
 
class FileLayer
 
class FillLayer
 
class Filter
 
class FilterLayer
 
class FilterMask
 
class GroupLayer
 
class Selection
 
class SelectionMask
 
class TransformMask
 
class TransparencyMask
 
class VectorLayer
 

Detailed Description

Node represents a layer or mask in a Krita image's Node hierarchy. Group layers can contain other layers and masks; layers can contain masks.

Definition at line 23 of file Node.h.

Constructor & Destructor Documentation

◆ ~Node()

Node::~Node ( )
override

Definition at line 134 of file Node.cpp.

135{
136 delete d;
137}
Private *const d
Definition Node.h:721

References d.

◆ Node()

Node::Node ( KisImageSP image,
KisNodeSP node,
QObject * parent = 0 )
explicitprivate

Definition at line 83 of file Node.cpp.

84 : QObject(parent)
85 , d(new Private)
86{
87 d->image = image;
88 d->node = node;
89}
KisNodeSP node() const
Definition Node.cpp:827
KisImageSP image() const
Definition Node.cpp:822
KisImageWSP image
Definition Node.cpp:79
KisNodeSP node
Definition Node.cpp:80

References d, Node::Private::image, image(), Node::Private::node, and node().

Member Function Documentation

◆ addChildNode

bool Node::addChildNode ( Node * child,
Node * above )
slot

addChildNode adds the given node in the list of children.

Parameters
childthe node to be added
abovethe node above which this node will be placed
Returns
false if adding the node failed

Definition at line 265 of file Node.cpp.

266{
267 if (!d->node) return false;
268
269 KUndo2Command *cmd = 0;
270
271 if (above) {
272 cmd = new KisImageLayerAddCommand(d->image, child->node(), d->node, above->node());
273 } else {
274 cmd = new KisImageLayerAddCommand(d->image, child->node(), d->node, d->node->childCount());
275 }
276
278 d->image->waitForDone();
279
280 return true;
281}
The command for adding a layer.
void waitForDone()
static void runSingleCommandStroke(KisImageSP image, KUndo2Command *cmd, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
runSingleCommandStroke creates a stroke and runs cmd in it. The text() field of cmd is used as a titl...
quint32 childCount() const
Definition kis_node.cpp:414

References KisNode::childCount(), d, Node::Private::image, Node::Private::node, node(), KisProcessingApplicator::runSingleCommandStroke(), and KisImage::waitForDone().

◆ alphaLocked

bool Node::alphaLocked ( ) const
slot

alphaLocked checks whether the node is a paint layer and returns whether it is alpha locked

Returns
whether the paint layer is alpha locked, or false if the node is not a paint layer

Definition at line 158 of file Node.cpp.

159{
160 if (!d->node) return false;
161 KisPaintLayerSP paintLayer = qobject_cast<KisPaintLayer*>(d->node.data());
162 if (paintLayer) {
163 return paintLayer->alphaLocked();
164 }
165 return false;
166}
bool alphaLocked() const

References KisPaintLayer::alphaLocked(), d, KisSharedPtr< T >::data(), and Node::Private::node.

◆ animated

bool Node::animated ( ) const
slot

Krita layers can be animated, i.e., have frames.

Returns
return true if the layer has frames. Currently, the scripting framework does not give access to the animation features.

Definition at line 361 of file Node.cpp.

362{
363 if (!d->node) return false;
364 return d->node->isAnimated();
365}
bool isAnimated() const

References d, KisBaseNode::isAnimated(), and Node::Private::node.

◆ blendingMode

QString Node::blendingMode ( ) const
slot
Returns
the blending mode of the layer. The values of the blending modes are defined in
See also
KoCompositeOpRegistry.h

Definition at line 178 of file Node.cpp.

179{
180 if (!d->node) return QString();
181
182 return d->node->compositeOpId();
183}
const QString & compositeOpId() const

References KisBaseNode::compositeOpId(), d, and Node::Private::node.

◆ bounds

QRect Node::bounds ( ) const
slot

bounds return the exact bounds of the node's paint device

Returns
the bounds, or an empty QRect if the node has no paint device or is empty.

Definition at line 615 of file Node.cpp.

616{
617 if (!d->node) return QRect();
618 return d->node->exactBounds();
619}
virtual QRect exactBounds() const

References d, KisBaseNode::exactBounds(), and Node::Private::node.

◆ channels

QList< Channel * > Node::channels ( ) const
slot

channels creates a list of Channel objects that can be used individually to show or hide certain channels, and to retrieve the contents of each channel in a node separately.

Only layers have channels, masks do not, and calling channels on a Node that is a mask will return an empty list.

Returns
the list of channels ordered in by position of the channels in pixel position

Definition at line 197 of file Node.cpp.

198{
200
201 if (!d->node) return channels;
202 if (!d->node->inherits("KisLayer")) return channels;
203
204 Q_FOREACH(KoChannelInfo *info, d->node->colorSpace()->channels()) {
205 Channel *channel = new Channel(d->node, info);
206 channels << channel;
207 }
208
209 return channels;
210}
QList< KoChannelInfo * > channels
QList< Channel * > channels() const
channels creates a list of Channel objects that can be used individually to show or hide certain chan...
Definition Node.cpp:197
virtual const KoColorSpace * colorSpace() const =0

References channels(), KoColorSpace::channels, KisBaseNode::colorSpace(), d, and Node::Private::node.

◆ childNodes

QList< Node * > Node::childNodes ( ) const
slot

childNodes

Returns
returns a list of child nodes of the current node. The nodes are ordered from the bottommost up. The function is not recursive.

Definition at line 212 of file Node.cpp.

213{
214 QList<Node*> nodes;
215 if (d->node) {
216 KisNodeList nodeList;
217 int childCount = d->node->childCount();
218 for (int i = 0; i < childCount; ++i) {
219 nodeList << d->node->at(i);
220 }
221 nodes = LibKisUtils::createNodeList(nodeList, d->image);
222 }
223 return nodes;
224}
QList< Node * > createNodeList(KisNodeList kisnodes, KisImageWSP image)
KisNodeSP at(quint32 index) const
Definition kis_node.cpp:421

References KisNode::at(), KisNode::childCount(), LibKisUtils::createNodeList(), d, Node::Private::image, and Node::Private::node.

◆ clone

Node * Node::clone ( ) const
slot

clone clone the current node. The node is not associated with any image.

Definition at line 150 of file Node.cpp.

151{
152 KisNodeSP clone = d->node->clone();
154 return node;
155}
Definition Node.h:24
static Node * createNode(KisImageSP image, KisNodeSP node, QObject *parent=0)
Definition Node.cpp:91
Node * clone() const
clone clone the current node. The node is not associated with any image.
Definition Node.cpp:150
virtual KisNodeSP clone() const =0

References clone(), KisNode::clone(), createNode(), d, Node::Private::node, and node().

◆ collapsed

bool Node::collapsed ( ) const
slot

returns the collapsed state of this node

Definition at line 385 of file Node.cpp.

386{
387 if (!d->node) return false;
388 return d->node->collapsed();
389}

References KisBaseNode::collapsed, d, and Node::Private::node.

◆ colorDepth

QString Node::colorDepth ( ) const
slot

colorDepth A string describing the color depth of the image:

  • U8: unsigned 8 bits integer, the most common type
  • U16: unsigned 16 bits integer
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • F32: 32 bits floating point
Returns
the color depth.

Definition at line 314 of file Node.cpp.

315{
316 if (!d->node) return "";
317 if (!d->node->projection()) return d->node->colorSpace()->colorDepthId().id();
318 return d->node->projection()->colorSpace()->colorDepthId().id();
319}
const KoColorSpace * colorSpace() const
virtual KoID colorDepthId() const =0
QString id() const
Definition KoID.cpp:63
virtual KisPaintDeviceSP projection() const =0

References KoColorSpace::colorDepthId(), KisPaintDevice::colorSpace(), KisBaseNode::colorSpace(), d, KoID::id(), Node::Private::node, and KisBaseNode::projection().

◆ colorLabel

int Node::colorLabel ( ) const
slot

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

303{
304 if (!d->node) return 0;
305 return d->node->colorLabelIndex();
306}
int colorLabelIndex() const

References KisBaseNode::colorLabelIndex(), d, and Node::Private::node.

◆ colorModel

QString Node::colorModel ( ) const
slot

colorModel retrieve the current color model of this document:

  • A: Alpha mask
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • XYZA: XYZ with alpha channel
  • LABA: LAB with alpha channel
  • CMYKA: CMYK with alpha channel
  • GRAYA: Gray with alpha channel
  • YCbCrA: YCbCr with alpha channel
Returns
the internal color model string.

Definition at line 321 of file Node.cpp.

322{
323 if (!d->node) return "";
324 if (!d->node->projection()) return d->node->colorSpace()->colorModelId().id();
325 return d->node->projection()->colorSpace()->colorModelId().id();
326}
virtual KoID colorModelId() const =0

References KoColorSpace::colorModelId(), KisPaintDevice::colorSpace(), KisBaseNode::colorSpace(), d, KoID::id(), Node::Private::node, and KisBaseNode::projection().

◆ colorProfile

QString Node::colorProfile ( ) const
slot
Returns
the name of the current color profile

Definition at line 329 of file Node.cpp.

330{
331 if (!d->node) return "";
332 if (!d->node->projection()) return d->node->colorSpace()->profile()->name();
333 return d->node->projection()->colorSpace()->profile()->name();
334}
virtual const KoColorProfile * profile() const =0

References KisPaintDevice::colorSpace(), KisBaseNode::colorSpace(), d, KoColorProfile::name, Node::Private::node, KoColorSpace::profile(), and KisBaseNode::projection().

◆ createNode()

Node * Node::createNode ( KisImageSP image,
KisNodeSP node,
QObject * parent = 0 )
static

Definition at line 91 of file Node.cpp.

92{
93 if (node.isNull()) {
94 return 0;
95 }
96 if (node->inherits("KisGroupLayer")) {
97 return new GroupLayer(dynamic_cast<KisGroupLayer*>(node.data()));
98 }
99 else if (node->inherits("KisCloneLayer")) {
100 return new CloneLayer(dynamic_cast<KisCloneLayer*>(node.data()));
101 }
102 else if (node->inherits("KisFileLayer")) {
103 return new FileLayer(dynamic_cast<KisFileLayer*>(node.data()));
104 }
105 else if (node->inherits("KisAdjustmentLayer")) {
106 return new FilterLayer(dynamic_cast<KisAdjustmentLayer*>(node.data()));
107 }
108 else if (node->inherits("KisGeneratorLayer")) {
109 return new FillLayer(dynamic_cast<KisGeneratorLayer*>(node.data()));
110 }
111 else if (node->inherits("KisShapeLayer")) {
112 return new VectorLayer(dynamic_cast<KisShapeLayer*>(node.data()));
113 }
114 else if (node->inherits("KisFilterMask")) {
115 return new FilterMask(image, dynamic_cast<KisFilterMask*>(node.data()));
116 }
117 else if (node->inherits("KisSelectionMask")) {
118 return new SelectionMask(image, dynamic_cast<KisSelectionMask*>(node.data()));
119 }
120 else if (node->inherits("KisTransparencyMask")) {
121 return new TransparencyMask(image, dynamic_cast<KisTransparencyMask*>(node.data()));
122 }
123 else if (node->inherits("KisTransformMask")) {
124 return new TransformMask(image, dynamic_cast<KisTransformMask*>(node.data()));
125 }
126 else if (node->inherits("KisColorizeMask")) {
127 return new ColorizeMask(image, dynamic_cast<KisColorizeMask*>(node.data()));
128 }
129 else {
130 return new Node(image, node, parent);
131 }
132}
The KisFileLayer class loads a particular file as a layer into the layer stack.
bool isNull() const
Node(KisImageSP image, KisNodeSP node, QObject *parent=0)
Definition Node.cpp:83
friend class FilterMask
Definition Node.h:703
friend class TransparencyMask
Definition Node.h:705
friend class SelectionMask
Definition Node.h:704
friend class FilterLayer
Definition Node.h:700
friend class FileLayer
Definition Node.h:699
friend class VectorLayer
Definition Node.h:702
friend class FillLayer
Definition Node.h:701
friend class TransformMask
Definition Node.h:706
friend class CloneLayer
Definition Node.h:708
friend class GroupLayer
Definition Node.h:698
friend class ColorizeMask
Definition Node.h:707

References CloneLayer, ColorizeMask, KisSharedPtr< T >::data(), FileLayer, FillLayer, FilterLayer, FilterMask, GroupLayer, image(), KisSharedPtr< T >::isNull(), node(), Node(), SelectionMask, TransformMask, TransparencyMask, and VectorLayer.

◆ cropNode

void Node::cropNode ( int x,
int y,
int w,
int h )
slot

cropNode crop this layer.

Parameters
xthe left edge of the cropping rectangle.
ythe top edge of the cropping rectangle
wthe right edge of the cropping rectangle
hthe bottom edge of the cropping rectangle

Definition at line 726 of file Node.cpp.

727{
728 if (!d->node) return;
729 if (!qobject_cast<KisLayer*>(d->node.data())) return;
730 if (!d->node->parent()) return;
731
732 QRect rect = QRect(x, y, w, h);
733 d->image->cropNode(d->node, rect);
734 d->image->waitForDone();
735}
void cropNode(KisNodeSP node, const QRect &newRect, const bool activeFrameOnly=false)
start asynchronous operation on cropping a subtree of nodes starting at node
Definition kis_image.cc:931
KisNodeWSP parent
Definition kis_node.cpp:86

References KisImage::cropNode(), d, KisSharedPtr< T >::data(), Node::Private::image, Node::Private::node, KisNode::parent, and KisImage::waitForDone().

◆ duplicate

Node * Node::duplicate ( )
slot

duplicate returns a full copy of the current node. The node is not inserted in the graphic

Returns
a valid Node object or 0 if the node couldn't be duplicated.

Definition at line 647 of file Node.cpp.

648{
649 if (!d->node) return 0;
650 return Node::createNode(d->image, d->node->clone());
651}

References KisNode::clone(), createNode(), d, Node::Private::image, and Node::Private::node.

◆ enableAnimation

void Node::enableAnimation ( ) const
slot

enableAnimation make the current layer animated, so it can have frames.

Definition at line 367 of file Node.cpp.

368{
369 if (!d->node) return;
371}
void enableAnimation()

References d, KisBaseNode::enableAnimation(), and Node::Private::node.

◆ findChildNodes

QList< Node * > Node::findChildNodes ( const QString & name = QString(),
bool recursive = false,
bool partialMatch = false,
const QString & type = QString(),
int colorLabelIndex = 0 ) const
slot

findChildNodes

Parameters
namename of the child node to search for. Leaving this blank will return all nodes.
recursivewhether or not to search recursively. Defaults to false.
partialMatchreturn if the name partially contains the string (case insensitive). Defaults to false.
typefilter returned nodes based on type
colorLabelIndexfilter returned nodes based on color label index
Returns
returns a list of child nodes and grand child nodes of the current node that match the search criteria.

Definition at line 226 of file Node.cpp.

227{
228 if (!d->node) return {};
229
230 QList<Node*> nodes;
231 KisNodeList nodeList = KisLayerUtils::findNodesByName(d->node, name, recursive, partialMatch);
232
233 if (!type.isEmpty()) {
234 for (int i = nodeList.size() - 1; i >= 0; i--) {
235 if ((type == "paintlayer" && !qobject_cast<const KisPaintLayer*>(nodeList.at(i))) ||
236 (type == "vectorlayer" && !qobject_cast<const KisShapeLayer*>(nodeList.at(i))) ||
237 (type == "grouplayer" && !qobject_cast<const KisGroupLayer*>(nodeList.at(i))) ||
238 (type == "filelayer" && !qobject_cast<const KisFileLayer*>(nodeList.at(i))) ||
239 (type == "filterlayer" && !qobject_cast<const KisAdjustmentLayer*>(nodeList.at(i))) ||
240 (type == "filllayer" && !qobject_cast<const KisGeneratorLayer*>(nodeList.at(i))) ||
241 (type == "clonelayer" && !qobject_cast<const KisCloneLayer*>(nodeList.at(i))) ||
242 (type == "transformmask" && !qobject_cast<const KisTransformMask*>(nodeList.at(i))) ||
243 (type == "referenceimageslayer" && !qobject_cast<const KisReferenceImagesLayer*>(nodeList.at(i))) ||
244 (type == "transparencymask" && !qobject_cast<const KisTransformMask*>(nodeList.at(i))) ||
245 (type == "filtermask" && !qobject_cast<const KisFilterMask*>(nodeList.at(i))) ||
246 (type == "selectionmask" && !qobject_cast<const KisSelectionMask*>(nodeList.at(i))) ||
247 (type == "colorizemask" && !qobject_cast<const KisColorizeMask*>(nodeList.at(i)))
248 ) {
249 nodeList.removeAt(i);
250 }
251 }
252 }
253
254 if (colorLabelIndex > 0) {
255 for (int i = nodeList.size() - 1; i >= 0; i--) {
256 if (nodeList.at(i)->colorLabelIndex() != colorLabelIndex) {
257 nodeList.removeAt(i);
258 }
259 }
260 }
261
262 return LibKisUtils::createNodeList(nodeList, d->image);
263}
virtual QString type() const
type Krita has several types of nodes, split in layers and masks. Group layers can contain other laye...
Definition Node.cpp:463
QString name() const
Definition Node.cpp:428
QList< KisNodeSP > findNodesByName(KisNodeSP root, const QString &name, bool recursive, bool partialMatch)

References LibKisUtils::createNodeList(), d, KisLayerUtils::findNodesByName(), Node::Private::image, name(), Node::Private::node, and type().

◆ hasExtents

bool Node::hasExtents ( )
slot

does the node have any content in it?

Returns
if node has any content in it

Definition at line 423 of file Node.cpp.

424{
425 return !d->node->extent().isEmpty();
426}
virtual QRect extent() const

References d, KisBaseNode::extent(), and Node::Private::node.

◆ hasKeyframeAtTime

bool Node::hasKeyframeAtTime ( int frameNumber)
slot

Check to see if frame number on layer is a keyframe

Definition at line 523 of file Node.cpp.

524{
525 if (!d->node || !d->node->isAnimated()) return false;
526
528 if (!rkc) return false;
529
530 KisKeyframeSP currentKeyframe = rkc->keyframeAt(frameNumber);
531
532 if (!currentKeyframe) {
533 return false;
534 }
535
536 return true;
537}
static const KoID Raster
KisKeyframeSP keyframeAt(int time) const
Get a keyframe at specified time. Used primarily when the value of a given keyframe is needed.
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)

References d, KisBaseNode::getKeyframeChannel(), KisBaseNode::isAnimated(), KisKeyframeChannel::keyframeAt(), Node::Private::node, and KisKeyframeChannel::Raster.

◆ icon

QIcon Node::icon ( ) const
slot

icon

Returns
the icon associated with the layer.

Definition at line 508 of file Node.cpp.

509{
510 QIcon icon;
511 if (d->node) {
512 icon = d->node->icon();
513 }
514 return icon;
515}
QIcon icon() const
icon
Definition Node.cpp:508
virtual QIcon icon() const

References d, KisBaseNode::icon(), icon(), and Node::Private::node.

◆ image()

KisImageSP Node::image ( ) const
private

Definition at line 822 of file Node.cpp.

823{
824 return d->image;
825}

References d, and Node::Private::image.

◆ index

int Node::index ( ) const
slot

index the index of the node inside the parent

Returns
an integer representing the node's index inside the parent

Definition at line 803 of file Node.cpp.

804{
805 if (!d->node) return -1;
806 if (!d->node->parent()) return -1;
807
808 return d->node->parent()->index(d->node);
809}
int index(const KisNodeSP node) const
Definition kis_node.cpp:432

References d, KisNode::index(), Node::Private::node, and KisNode::parent.

◆ inheritAlpha

bool Node::inheritAlpha ( ) const
slot

inheritAlpha checks whether this node has the inherits alpha flag set

Returns
true if the Inherit Alpha is set

Definition at line 397 of file Node.cpp.

398{
399 if (!d->node) return false;
400 if (!d->node->inherits("KisLayer")) return false;
401 return qobject_cast<const KisLayer*>(d->node)->alphaChannelDisabled();
402}

References d, and Node::Private::node.

◆ isPinnedToTimeline

bool Node::isPinnedToTimeline ( ) const
slot
Returns
Returns true if node is pinned to the Timeline Docker or false if it is not.

Definition at line 379 of file Node.cpp.

380{
381 if (!d->node) return false;
382 return d->node->isPinnedToTimeline();
383}
bool isPinnedToTimeline() const

References d, KisBaseNode::isPinnedToTimeline(), and Node::Private::node.

◆ layerStyleToAsl

QString Node::layerStyleToAsl ( )
slot

layerStyleToAsl retrieve the current layer's style in ASL format.

Returns
a QString in ASL format representing the layer style.

Definition at line 753 of file Node.cpp.

754{
755 if (!d->node) return QString();
756
757 KisLayer *layer = qobject_cast<KisLayer*>(d->node.data());
758
759 if (!layer) return QString();
760
761 KisPSDLayerStyleSP layerStyle = layer->layerStyle();
762
763 if (!layerStyle) return QString();
764
766
767 serializer.setStyles(QVector<KisPSDLayerStyleSP>() << layerStyle);
768
769 return serializer.formPsdXmlDocument().toString();
770}
void setStyles(const QVector< KisPSDLayerStyleSP > &styles)
KisPSDLayerStyleSP layerStyle
Definition kis_layer.cc:171

References d, KisSharedPtr< T >::data(), KisAslLayerStyleSerializer::formPsdXmlDocument(), KisLayer::layerStyle, Node::Private::node, and KisAslLayerStyleSerializer::setStyles().

◆ locked

bool Node::locked ( ) const
slot

locked checks whether the Node is locked. A locked node cannot be changed.

Returns
true if the Node is locked, false if it hasn't been locked.

Definition at line 411 of file Node.cpp.

412{
413 if (!d->node) return false;
414 return d->node->userLocked();
415}
bool userLocked() const

References d, Node::Private::node, and KisBaseNode::userLocked().

◆ mergeDown

Node * Node::mergeDown ( )
slot

mergeDown merges the given node with the first visible node underneath this node in the layerstack. This will drop all per-layer metadata.

Definition at line 685 of file Node.cpp.

686{
687 if (!d->node) return 0;
688 if (!qobject_cast<KisLayer*>(d->node.data())) return 0;
689 if (!d->node->prevSibling()) return 0;
690
691 d->image->mergeDown(qobject_cast<KisLayer*>(d->node.data()), KisMetaData::MergeStrategyRegistry::instance()->get("Drop"));
692 d->image->waitForDone();
693
695}
void mergeDown(KisLayerSP l, const KisMetaData::MergeStrategy *strategy)
T get(const QString &id) const
KisNodeSP prevSibling() const
Definition kis_node.cpp:402

References createNode(), d, KisSharedPtr< T >::data(), KoGenericRegistry< T >::get(), Node::Private::image, KisMetaData::MergeStrategyRegistry::instance(), KisImage::mergeDown(), Node::Private::node, KisNode::prevSibling(), and KisImage::waitForDone().

◆ move

void Node::move ( int x,
int y )
slot

move the pixels to the given x, y location in the image coordinate space.

Definition at line 621 of file Node.cpp.

622{
623 if (!d->node) return;
624 d->node->setX(x);
625 d->node->setY(y);
626}
virtual void setX(qint32)
virtual void setY(qint32)

References d, Node::Private::node, KisBaseNode::setX(), and KisBaseNode::setY().

◆ name

QString Node::name ( ) const
slot
Returns
the user-visible name of this node.

Definition at line 428 of file Node.cpp.

429{
430 if (!d->node) return QString();
431 return d->node->name();
432}
QString name() const

References d, KisBaseNode::name(), and Node::Private::node.

◆ node()

KisNodeSP Node::node ( ) const
private

Definition at line 827 of file Node.cpp.

828{
829 return d->node;
830}

References d, and Node::Private::node.

◆ opacity

int Node::opacity ( ) const
slot

return the opacity of the Node. The opacity is a value between 0 and 255.

Definition at line 441 of file Node.cpp.

442{
443 if (!d->node) return 0;
444 return d->node->opacity();
445}
quint8 opacity() const

References d, Node::Private::node, and KisBaseNode::opacity().

◆ operator!=()

bool Node::operator!= ( const Node & other) const

Definition at line 145 of file Node.cpp.

146{
147 return !(operator==(other));
148}
bool operator==(const Node &other) const
Definition Node.cpp:139

References operator==().

◆ operator==()

bool Node::operator== ( const Node & other) const

Definition at line 139 of file Node.cpp.

140{
141 return (d->node == other.d->node
142 && d->image == other.d->image);
143}

References d, Node::Private::image, and Node::Private::node.

◆ paintAbility

QString Node::paintAbility ( )
slot

paintAbility can be used to determine whether this node can be painted on with the current brush preset.

Returns
QString, one of the following:
  • VECTOR - This node is vector-based.
  • CLONE - This node is a Clone Layer.
  • PAINT - This node is paintable by the current brush preset.
  • UNPAINTABLE - This node is not paintable, or a null preset is somehow selected./li>
  • MYPAINTBRUSH_UNPAINTABLE - This node's non-RGBA colorspace cannot be painted on by the currently selected MyPaint brush.

Definition at line 832 of file Node.cpp.

833{
834 // Taken from KisTool:nodePaintAbility().
836 KisCanvas2 *canvas = mainWindow->activeView()->canvasBase();
837 if (canvas->resourceManager()->resource(KoCanvasResource::CurrentPaintOpPreset).isNull()) {
838 return "UNPAINTABLE";
839 }
840
841 if (!d->node) {
842 return "UNPAINTABLE";
843 }
844
845 if (d->node->inherits("KisShapeLayer")) {
846 return "VECTOR";
847 }
848 if (d->node->inherits("KisCloneLayer")) {
849 return "CLONE";
850 }
851 if (d->node->paintDevice()) {
852
853 KisPaintOpPresetSP currentPaintOpPreset = canvas->resourceManager()->resource(KoCanvasResource::CurrentPaintOpPreset).value<KisPaintOpPresetSP>();
854 if (currentPaintOpPreset->paintOp().id() == "mypaintbrush") {
855 const KoColorSpace *colorSpace = d->node->paintDevice()->colorSpace();
856 if (colorSpace->colorModelId() != RGBAColorModelID) {
857 return "MYPAINTBRUSH_UNPAINTABLE";
858 }
859 }
860
861 return "PAINT";
862 }
863
864 return "UNPAINTABLE";
865}
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
Main window for Krita.
QPointer< KisView > activeView
static KisPart * instance()
Definition KisPart.cpp:131
KisMainWindow * currentMainwindow() const
Definition KisPart.cpp:483
QPointer< KoCanvasResourceProvider > resourceManager
virtual KisPaintDeviceSP paintDevice() const =0

References KisMainWindow::activeView, KoColorSpace::colorModelId(), KisPaintDevice::colorSpace(), KisPart::currentMainwindow(), KoCanvasResource::CurrentPaintOpPreset, d, KisPart::instance(), Node::Private::node, KisBaseNode::paintDevice(), KoCanvasBase::resourceManager, and RGBAColorModelID.

◆ paintDevice()

KisPaintDeviceSP Node::paintDevice ( ) const
private

paintDevice gives access to the internal paint device of this Node

Returns
the paintdevice or 0 if the node does not have an editable paint device.

Definition at line 817 of file Node.cpp.

818{
819 return d->node->paintDevice();
820}

References d, Node::Private::node, and KisBaseNode::paintDevice().

◆ paintEllipse

void Node::paintEllipse ( const QRectF & rect,
const QString strokeStyle = PaintingResources::defaultStrokeStyle,
const QString fillStyle = PaintingResources::defaultFillStyle )
slot

paint an ellipse on the canvas. Uses current brush preset

Parameters
rectQRect with x, y, width, and height
  • None
  • ForegroundColor
  • BackgroundColor
Default is ForegroundColor.
fillStyleappearance of the fill, one of:
  • None
  • ForegroundColor
  • BackgroundColor
  • Pattern
Default is None.

Definition at line 916 of file Node.cpp.

917{
918 if (paintAbility() != "PAINT") {
919 dbgScript << "Script attempted to use Node::paintEllipse() on an unpaintable node, ignoring.";
920 return;
921 }
922
923 KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
924 helper.paintEllipse(rect);
925}
QString paintAbility()
paintAbility can be used to determine whether this node can be painted on with the current brush pres...
Definition Node.cpp:832
#define dbgScript
Definition kis_debug.h:56
KisFigurePaintingToolHelper createHelper(KisImageWSP image, KisNodeSP node, const QString strokeStyle=defaultStrokeStyle, const QString fillStyle=defaultFillStyle)

References PaintingResources::createHelper(), d, dbgScript, Node::Private::image, node(), paintAbility(), and KisFigurePaintingToolHelper::paintEllipse().

◆ paintLine

void Node::paintLine ( const QPointF pointOne,
const QPointF pointTwo,
double pressureOne = 1.0,
double pressureTwo = 1.0,
const QString strokeStyle = PaintingResources::defaultStrokeStyle )
slot

paint a line on the canvas. Uses current brush preset

Parameters
pointOnestarting point
pointTwoend point
pressureOnestarting pressure
pressureTwoend pressure
strokeStyleappearance of the outline, one of:
  • None - will use Foreground Color, since line would be invisible otherwise
  • ForegroundColor
  • BackgroundColor

Definition at line 867 of file Node.cpp.

868{
869 if (paintAbility() != "PAINT") {
870 dbgScript << "Script attempted to use Node::paintLine() on an unpaintable node, ignoring.";
871 return;
872 }
873
874 KisPaintInformation pointOneInfo;
875 pointOneInfo.setPressure(pressureOne);
876 pointOneInfo.setPos(pointOne);
877
878 KisPaintInformation pointTwoInfo;
879 pointTwoInfo.setPressure(pressureTwo);
880 pointTwoInfo.setPos(pointTwo);
881
883 helper.paintLine(pointOneInfo, pointTwoInfo);
884}
void paintLine(const KisPaintInformation &pi0, const KisPaintInformation &pi1)
void setPos(const QPointF &p)
void setPressure(qreal p)
Set the pressure.

References PaintingResources::createHelper(), d, dbgScript, Node::Private::image, node(), paintAbility(), KisFigurePaintingToolHelper::paintLine(), KisPaintInformation::setPos(), and KisPaintInformation::setPressure().

◆ paintPath

void Node::paintPath ( const QPainterPath & path,
const QString strokeStyle = PaintingResources::defaultStrokeStyle,
const QString fillStyle = PaintingResources::defaultFillStyle )
slot

paint a custom path on the canvas. Uses current brush preset

Parameters
pathQPainterPath to determine path
  • None
  • ForegroundColor
  • BackgroundColor
Default is ForegroundColor.
fillStyleappearance of the fill, one of:
  • None
  • ForegroundColor
  • BackgroundColor
  • Pattern
Default is None.

Definition at line 928 of file Node.cpp.

929{
930 if (paintAbility() != "PAINT") {
931 dbgScript << "Script attempted to use Node::paintPath() on an unpaintable node, ignoring.";
932 return;
933 }
934
935 KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
936 helper.paintPainterPath(path);
937}
void paintPainterPath(const QPainterPath &path)

References PaintingResources::createHelper(), d, dbgScript, Node::Private::image, node(), paintAbility(), and KisFigurePaintingToolHelper::paintPainterPath().

◆ paintPolygon

void Node::paintPolygon ( const QList< QPointF > points,
const QString strokeStyle = PaintingResources::defaultStrokeStyle,
const QString fillStyle = PaintingResources::defaultFillStyle )
slot

paint a polygon on the canvas. Uses current brush preset

Parameters
listof Qpoints
  • None
  • ForegroundColor
  • BackgroundColor
Default is ForegroundColor.
fillStyleappearance of the fill, one of:
  • None
  • ForegroundColor
  • BackgroundColor
  • Pattern
Default is None.

Definition at line 902 of file Node.cpp.

903{
904 if (paintAbility() != "PAINT") {
905 dbgScript << "Script attempted to use Node::paintPolygon() on an unpaintable node, ignoring.";
906 return;
907 }
908
909 // strategy needs points in vPointF format
910 QVector<QPointF> points = points.fromList(listPoint);
911 KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
912 helper.paintPolygon(points);
913}

References PaintingResources::createHelper(), d, dbgScript, Node::Private::image, node(), paintAbility(), and KisFigurePaintingToolHelper::paintPolygon().

◆ paintRectangle

void Node::paintRectangle ( const QRectF & rect,
const QString strokeStyle = PaintingResources::defaultStrokeStyle,
const QString fillStyle = PaintingResources::defaultFillStyle )
slot

paint a rectangle on the canvas. Uses current brush preset

Parameters
rectQRect with x, y, width, and height
strokeStyleappearance of the outline, one of:
  • None
  • ForegroundColor
  • BackgroundColor
Default is ForegroundColor.
fillStyleappearance of the fill, one of:
  • None
  • ForegroundColor
  • BackgroundColor
  • Pattern
Default is None.

Definition at line 887 of file Node.cpp.

888{
889 if (paintAbility() != "PAINT") {
890 dbgScript << "Script attempted to use Node::paintRectangle() on an unpaintable node, ignoring.";
891 return;
892 }
893
894 // reference class where this stuff is being done. Maybe can use the "facade" like that does for setup?
895 // void KisFigurePaintingToolHelper::paintRect(const QRectF &rect)
896
897 KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
898 helper.paintRect(rect);
899}

References PaintingResources::createHelper(), d, dbgScript, Node::Private::image, node(), paintAbility(), and KisFigurePaintingToolHelper::paintRect().

◆ parentNode

Node * Node::parentNode ( ) const
slot

return the Node that is the parent of the current Node, or 0 if this is the root Node.

Definition at line 456 of file Node.cpp.

457{
458 if (!d->node) return 0;
459 if (!d->node->parent()) return 0;
460 return Node::createNode(d->image, d->node->parent());
461}

References createNode(), d, Node::Private::image, Node::Private::node, and KisNode::parent.

◆ pixelData

QByteArray Node::pixelData ( int x,
int y,
int w,
int h ) const
slot

pixelData reads the given rectangle from the Node's paintable pixels, if those exist, and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.

The byte array can be interpreted as follows: 8 bits images have one byte per channel, and as many bytes as there are channels. 16 bits integer images have two bytes per channel, representing an unsigned short. 16 bits float images have two bytes per channel, representing a half, or 16 bits float. 32 bits float images have four bytes per channel, representing a float.

You can read outside the node boundaries; those pixels will be transparent black.

The order of channels is:

  • Integer RGBA: Blue, Green, Red, Alpha
  • Float RGBA: Red, Green, Blue, Alpha
  • GrayA: Gray, Alpha
  • Selection: selectedness
  • LabA: L, a, b, Alpha
  • CMYKA: Cyan, Magenta, Yellow, Key, Alpha
  • XYZA: X, Y, Z, A
  • YCbCrA: Y, Cb, Cr, Alpha

The byte array is a copy of the original node data. In Python, you can use bytes, bytearray and the struct module to interpret the data and construct, for instance, a Pillow Image object.

If you read the pixeldata of a mask, a filter or generator layer, you get the selection bytes, which is one channel with values in the range from 0..255.

If you want to change the pixels of a node you can write the pixels back after manipulation with setPixelData(). This will only succeed on nodes with writable pixel data, e.g not on groups or file layers.

Parameters
xx position from where to start reading
yy position from where to start reading
wrow length to read
hnumber of rows to read
Returns
a QByteArray with the pixel data. The byte array may be empty.

Definition at line 546 of file Node.cpp.

547{
548 QByteArray ba;
549
550 if (!d->node) return ba;
551
553 if (!dev) return ba;
554
555 ba.resize(w * h * dev->pixelSize());
556 dev->readBytes(reinterpret_cast<quint8*>(ba.data()), x, y, w, h);
557 return ba;
558}
quint32 pixelSize() const
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const

References d, Node::Private::node, KisBaseNode::paintDevice(), KisPaintDevice::pixelSize(), and KisPaintDevice::readBytes().

◆ pixelDataAtTime

QByteArray Node::pixelDataAtTime ( int x,
int y,
int w,
int h,
int time ) const
slot

pixelDataAtTime a basic function to get pixeldata from an animated node at a given time.

Parameters
xthe position from the left to start reading.
ythe position from the top to start reader
wthe row length to read
hthe number of rows to read
timethe frame number
Returns
a QByteArray with the pixel data. The byte array may be empty.

Definition at line 560 of file Node.cpp.

561{
562 QByteArray ba;
563
564 if (!d->node || !d->node->isAnimated()) return ba;
565
566 //
568 if (!rkc) return ba;
570 if (!frame) return ba;
572 if (!dev) return ba;
573
574 frame->writeFrameToDevice(dev);
575
576 ba.resize(w * h * dev->pixelSize());
577 dev->readBytes(reinterpret_cast<quint8*>(ba.data()), x, y, w, h);
578 return ba;
579}
The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image ...

References KritaUtils::CopySnapshot, d, KisBaseNode::getKeyframeChannel(), KisBaseNode::isAnimated(), KisKeyframeChannel::keyframeAt(), Node::Private::node, KisBaseNode::paintDevice(), KisPaintDevice::pixelSize(), KisKeyframeChannel::Raster, and KisPaintDevice::readBytes().

◆ position

QPoint Node::position ( ) const
slot

position returns the position of the paint device of this node. The position is always 0,0 unless the layer has been moved. If you want to know the topleft position of the rectangle around the actual non-transparent pixels in the node, use bounds().

Returns
the top-left position of the node

Definition at line 628 of file Node.cpp.

629{
630 if (!d->node) return QPoint();
631 return QPoint(d->node->x(), d->node->y());
632}
virtual qint32 y() const
virtual qint32 x() const

References d, Node::Private::node, KisBaseNode::x(), and KisBaseNode::y().

◆ projectionPixelData

QByteArray Node::projectionPixelData ( int x,
int y,
int w,
int h ) const
slot

projectionPixelData reads the given rectangle from the Node's projection (that is, what the node looks like after all sub-Nodes (like layers in a group or masks on a layer) have been applied, and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.

The byte array can be interpreted as follows: 8 bits images have one byte per channel, and as many bytes as there are channels. 16 bits integer images have two bytes per channel, representing an unsigned short. 16 bits float images have two bytes per channel, representing a half, or 16 bits float. 32 bits float images have four bytes per channel, representing a float.

You can read outside the node boundaries; those pixels will be transparent black.

The order of channels is:

  • Integer RGBA: Blue, Green, Red, Alpha
  • Float RGBA: Red, Green, Blue, Alpha
  • GrayA: Gray, Alpha
  • Selection: selectedness
  • LabA: L, a, b, Alpha
  • CMYKA: Cyan, Magenta, Yellow, Key, Alpha
  • XYZA: X, Y, Z, A
  • YCbCrA: Y, Cb, Cr, Alpha

The byte array is a copy of the original node data. In Python, you can use bytes, bytearray and the struct module to interpret the data and construct, for instance, a Pillow Image object.

If you read the projection of a mask, you get the selection bytes, which is one channel with values in the range from 0..255.

If you want to change the pixels of a node you can write the pixels back after manipulation with setPixelData(). This will only succeed on nodes with writable pixel data, e.g not on groups or file layers.

Parameters
xx position from where to start reading
yy position from where to start reading
wrow length to read
hnumber of rows to read
Returns
a QByteArray with the pixel data. The byte array may be empty.

Definition at line 582 of file Node.cpp.

583{
584 QByteArray ba;
585
586 if (!d->node) return ba;
587
589 if (const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(d->node)) {
590
591 dev = mask->coloringProjection();
592 } else {
593 dev = d->node->projection();
594 }
595 if (!dev) return ba;
596
597 ba.resize(w * h * dev->pixelSize());
598 dev->readBytes(reinterpret_cast<quint8*>(ba.data()), x, y, w, h);
599 return ba;
600}

References d, Node::Private::node, KisPaintDevice::pixelSize(), KisBaseNode::projection(), and KisPaintDevice::readBytes().

◆ remove

bool Node::remove ( )
slot

remove removes this node from its parent image.

Definition at line 634 of file Node.cpp.

635{
636 if (!d->node) return false;
637 if (!d->node->parent()) return false;
638
640
642 d->image->waitForDone();
643
644 return true;
645}

References d, Node::Private::image, Node::Private::node, KisNode::parent, KisProcessingApplicator::runSingleCommandStroke(), and KisImage::waitForDone().

◆ removeChildNode

bool Node::removeChildNode ( Node * child)
slot

removeChildNode removes the given node from the list of children.

Parameters
childthe node to be removed

Definition at line 283 of file Node.cpp.

284{
285 if (!d->node) return false;
286 return child->remove();
287}
bool remove()
remove removes this node from its parent image.
Definition Node.cpp:634

References d, Node::Private::node, and remove().

◆ rotateNode

void Node::rotateNode ( double radians)
slot

rotateNode rotate this layer by the given radians.

Parameters
radiansamount the layer should be rotated in, in radians.

Definition at line 716 of file Node.cpp.

717{
718 if (!d->node) return;
719 if (!qobject_cast<KisLayer*>(d->node.data())) return;
720 if (!d->node->parent()) return;
721
722 d->image->rotateNode(d->node, radians, 0);
723 d->image->waitForDone();
724}
void rotateNode(KisNodeSP node, double radians, KisSelectionSP selection)
start asynchronous operation on rotating a subtree of nodes starting at node

References d, KisSharedPtr< T >::data(), Node::Private::image, Node::Private::node, KisNode::parent, KisImage::rotateNode(), and KisImage::waitForDone().

◆ save

bool Node::save ( const QString & filename,
double xRes,
double yRes,
const InfoObject & exportConfiguration,
const QRect & exportRect = QRect() )
slot

save exports the given node with this filename. The extension of the filename determines the filetype.

Parameters
filenamethe filename including extension
xResthe horizontal resolution in pixels per pt (there are 72 pts in an inch)
yResthe horizontal resolution in pixels per pt (there are 72 pts in an inch)
exportConfigurationa configuration object appropriate to the file format.
exportRectthe export bounds for saving a node as a QRect If exportRect is empty, then save exactBounds() of the node. If you'd like to save the image- aligned area of the node, just pass image->bounds() there. See Document->exportImage for InfoObject details.
Returns
true if saving succeeded, false if it failed.

Definition at line 653 of file Node.cpp.

654{
655 if (!d->node) return false;
656 if (filename.isEmpty()) return false;
657
658 KisPaintDeviceSP projection = d->node->projection();
659 QRect bounds = (exportRect.isEmpty())? d->node->exactBounds() : exportRect;
660
661 QString mimeType = KisMimeDatabase::mimeTypeForFile(filename, false);
662 QScopedPointer<KisDocument> doc(KisPart::instance()->createDocument());
663
664 KisImageSP dst = new KisImage(doc->createUndoStore(),
665 bounds.right(),
666 bounds.bottom(),
667 projection->compositionSourceColorSpace(),
668 d->node->name());
669 dst->setResolution(xRes, yRes);
670 doc->setFileBatchMode(Krita::instance()->batchmode());
671 doc->setCurrentImage(dst);
672 KisPaintLayer* paintLayer = new KisPaintLayer(dst, "paint device", d->node->opacity());
673 paintLayer->paintDevice()->makeCloneFrom(projection, bounds);
674 dst->addNode(paintLayer, dst->rootLayer(), KisLayerSP(0));
675 dst->cropImage(bounds);
676 dst->initialRefreshGraph();
677
678 bool r = doc->exportDocumentSync(filename, mimeType.toLatin1(), exportConfiguration.configuration());
679 if (!r) {
680 qWarning() << doc->errorMessage();
681 }
682 return r;
683}
KisPropertiesConfigurationSP configuration() const
configuration gives access to the internal configuration object. Must be used internally in libkis
KisGroupLayerSP rootLayer() const
void cropImage(const QRect &newRect)
start asynchronous operation on cropping the image
Definition kis_image.cc:870
void initialRefreshGraph()
void setResolution(double xres, double yres)
static QString mimeTypeForFile(const QString &file, bool checkExistingFiles=true)
Find the mimetype for the given filename. The filename must include a suffix.
virtual const KoColorSpace * compositionSourceColorSpace() const
void makeCloneFrom(KisPaintDeviceSP src, const QRect &rect)
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:390
#define bounds(x, a, b)
KisDocument * createDocument(QList< KisNodeSP > nodes, KisImageSP srcImage, const QRect &copiedBounds)
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
KisPaintDeviceSP paintDevice

References KisNodeFacade::addNode(), bounds, KisPaintDevice::compositionSourceColorSpace(), InfoObject::configuration(), createDocument(), KisImage::cropImage(), d, KisBaseNode::exactBounds(), KisImage::initialRefreshGraph(), Krita::instance(), KisPart::instance(), KisPaintDevice::makeCloneFrom(), KisMimeDatabase::mimeTypeForFile(), KisBaseNode::name(), Node::Private::node, KisBaseNode::opacity(), KisPaintLayer::paintDevice, KisBaseNode::projection(), KisImage::rootLayer(), and KisImage::setResolution().

◆ scaleNode

void Node::scaleNode ( QPointF origin,
int width,
int height,
QString strategy )
slot

scaleNode

Parameters
originthe origin point
widththe width
heightthe height
strategythe scaling strategy. There's several ones amongst these that aren't available in the regular UI.
  • Hermite
  • Bicubic - Adds pixels using the color of surrounding pixels. Produces smoother tonal gradations than Bilinear.
  • Box - Replicate pixels in the image. Preserves all the original detail, but can produce jagged effects.
  • Bilinear - Adds pixels averaging the color values of surrounding pixels. Produces medium quality results when the image is scaled from half to two times the original size.
  • Bell
  • BSpline
  • Lanczos3 - Offers similar results than Bicubic, but maybe a little bit sharper. Can produce light and dark halos along strong edges.
  • Mitchell

Definition at line 697 of file Node.cpp.

698{
699 if (!d->node) return;
700 if (!qobject_cast<KisLayer*>(d->node.data())) return;
701 if (!d->node->parent()) return;
702
703 KisFilterStrategy *actualStrategy = KisFilterStrategyRegistry::instance()->get(strategy);
704 if (!actualStrategy) actualStrategy = KisFilterStrategyRegistry::instance()->get("Bicubic");
705
706 const QRect bounds(d->node->exactBounds());
707
709 origin,
710 qreal(width) / bounds.width(),
711 qreal(height) / bounds.height(),
712 actualStrategy, 0);
713 d->image->waitForDone();
714}
static KisFilterStrategyRegistry * instance()
void scaleNode(KisNodeSP node, const QPointF &center, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection)
start asynchronous operation on scaling a subtree of nodes starting at node

References bounds, d, KisSharedPtr< T >::data(), KisBaseNode::exactBounds(), KoGenericRegistry< T >::get(), Node::Private::image, KisFilterStrategyRegistry::instance(), Node::Private::node, KisNode::parent, KisImage::scaleNode(), and KisImage::waitForDone().

◆ setAlphaLocked

void Node::setAlphaLocked ( bool value)
slot

setAlphaLocked set the layer to value if the node is paint layer.

Definition at line 168 of file Node.cpp.

169{
170 if (!d->node) return;
171 KisPaintLayerSP paintLayer = qobject_cast<KisPaintLayer*>(d->node.data());
172 if (paintLayer) {
173 paintLayer->setAlphaLocked(value);
174 }
175}
float value(const T *src, size_t ch)
void setAlphaLocked(bool lock)

References d, KisSharedPtr< T >::data(), Node::Private::node, KisPaintLayer::setAlphaLocked(), and value().

◆ setBlendingMode

void Node::setBlendingMode ( QString value)
slot

setBlendingMode set the blending mode of the node to the given value

Parameters
valueone of the string values from
See also
KoCompositeOpRegistry.h

Definition at line 185 of file Node.cpp.

186{
187 if (!d->node) return;
188
190 value);
191
193 d->image->waitForDone();
194}
The command for setting the composite op.

References d, Node::Private::image, Node::Private::node, KisProcessingApplicator::runSingleCommandStroke(), value(), and KisImage::waitForDone().

◆ setChildNodes

void Node::setChildNodes ( QList< Node * > nodes)
slot

setChildNodes this replaces the existing set of child nodes with the new set.

Parameters
nodesThe list of nodes that will become children, bottom-up – the first node, is the bottom-most node in the stack.

Definition at line 289 of file Node.cpp.

290{
291 if (!d->node) return;
293 while (node) {
295 node = node->nextSibling();
296 }
297 Q_FOREACH(Node *node, nodes) {
298 d->image->addNode(node->node(), d->node);
299 }
300}
bool removeNode(KisNodeSP node)
KisNodeSP firstChild() const
Definition kis_node.cpp:361
KisNodeSP nextSibling() const
Definition kis_node.cpp:408

References KisNodeFacade::addNode(), d, KisNode::firstChild(), Node::Private::image, KisNode::nextSibling(), Node::Private::node, node(), and KisNodeFacade::removeNode().

◆ setCollapsed

void Node::setCollapsed ( bool collapsed)
slot

Sets the state of the node to the value of

Parameters
collapsed

Definition at line 391 of file Node.cpp.

392{
393 if (!d->node) return;
395}
bool collapsed() const
Definition Node.cpp:385
void setCollapsed(bool collapsed)

References collapsed(), d, Node::Private::node, and KisBaseNode::setCollapsed().

◆ setColorLabel

void Node::setColorLabel ( int index)
slot

setColorLabel 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.

Parameters
indexan integer corresponding to the set of available color labels.

Definition at line 308 of file Node.cpp.

309{
310 if (!d->node) return;
312}
int index() const
index the index of the node inside the parent
Definition Node.cpp:803
void setColorLabelIndex(int index)

References d, index(), Node::Private::node, and KisBaseNode::setColorLabelIndex().

◆ setColorProfile

bool Node::setColorProfile ( const QString & colorProfile)
slot

setColorProfile set the color profile of the image to the given profile. The profile has to be registered with krita and be compatible with the current color model and depth; the image data is not converted.

Parameters
colorProfile
Returns
if assigning the color profile worked

Definition at line 336 of file Node.cpp.

337{
338 if (!d->node) return false;
339 if (!d->node->inherits("KisLayer")) return false;
340 KisLayer *layer = qobject_cast<KisLayer*>(d->node.data());
342 bool result = d->image->assignLayerProfile(layer, profile);
343 d->image->waitForDone();
344 return result;
345}
bool assignLayerProfile(KisNodeSP node, const KoColorProfile *profile)
QString colorProfile() const
Definition Node.cpp:329
const KoColorProfile * profileByName(const QString &name) const
static KoColorSpaceRegistry * instance()

References KisImage::assignLayerProfile(), colorProfile(), d, KisSharedPtr< T >::data(), Node::Private::image, KoColorSpaceRegistry::instance(), Node::Private::node, KoColorSpaceRegistry::profileByName(), and KisImage::waitForDone().

◆ setColorSpace

bool Node::setColorSpace ( const QString & colorModel,
const QString & colorDepth,
const QString & colorProfile )
slot

setColorSpace convert the node to the given colorspace

Parameters
colorModelA string describing the color model of the node:
  • A: Alpha mask
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • XYZA: XYZ with alpha channel
  • LABA: LAB with alpha channel
  • CMYKA: CMYK with alpha channel
  • GRAYA: Gray with alpha channel
  • YCbCrA: YCbCr with alpha channel
colorDepthA string describing the color depth of the image:
  • U8: unsigned 8 bits integer, the most common type
  • U16: unsigned 16 bits integer
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • F32: 32 bits floating point
colorProfilea valid color profile for this color model and color depth combination.

Definition at line 347 of file Node.cpp.

348{
349 if (!d->node) return false;
350 if (!d->node->inherits("KisLayer")) return false;
352 if (!profile) return false;
355 profile);
357 d->image->waitForDone();
358 return true;
359}
void convertLayerColorSpace(KisNodeSP node, const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
QString colorDepth() const
Definition Node.cpp:314
QString colorModel() const
colorModel retrieve the current color model of this document:
Definition Node.cpp:321
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)

References colorDepth(), colorModel(), colorProfile(), KoColorSpaceRegistry::colorSpace(), KisImage::convertLayerColorSpace(), d, Node::Private::image, KoColorSpaceRegistry::instance(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), Node::Private::node, KoColorSpaceRegistry::profileByName(), and KisImage::waitForDone().

◆ setInheritAlpha

void Node::setInheritAlpha ( bool value)
slot

set the Inherit Alpha flag to the given value

Definition at line 404 of file Node.cpp.

405{
406 if (!d->node) return;
407 if (!d->node->inherits("KisLayer")) return;
408 const_cast<KisLayer*>(qobject_cast<const KisLayer*>(d->node))->disableAlphaChannel(value);
409}

References d, Node::Private::node, and value().

◆ setLayerStyleFromAsl

bool Node::setLayerStyleFromAsl ( const QString & asl)
slot

setLayerStyleFromAsl set a new layer style for this node.

Parameters
aslContenta string formatted in ASL format containing the layer style
Returns
true if layer style was set, false if failed.

Definition at line 772 of file Node.cpp.

773{
774 if (!d->node) return false;
775
776 KisLayer *layer = qobject_cast<KisLayer*>(d->node.data());
777
778 if (!layer) return false;
779
780 QDomDocument aslDoc;
781
782 if (!aslDoc.setContent(asl)) {
783 qWarning() << "ASL string format is invalid!";
784 return false;
785 }
786
788
789 serializer.registerPSDPattern(aslDoc);
790 serializer.readFromPSDXML(aslDoc);
791
792 if (serializer.styles().size() != 1) return false;
793
794 KisPSDLayerStyleSP newStyle = serializer.styles().first();
795 KUndo2Command *cmd = new KisSetLayerStyleCommand(layer, layer->layerStyle(), newStyle);
796
798 d->image->waitForDone();
799
800 return true;
801}
QVector< KisPSDLayerStyleSP > styles() const
void readFromPSDXML(const QDomDocument &doc)
void registerPSDPattern(const QDomDocument &doc)

References d, KisSharedPtr< T >::data(), Node::Private::image, KisLayer::layerStyle, Node::Private::node, KisAslLayerStyleSerializer::readFromPSDXML(), KisAslLayerStyleSerializer::registerPSDPattern(), KisProcessingApplicator::runSingleCommandStroke(), KisAslLayerStyleSerializer::styles(), and KisImage::waitForDone().

◆ setLocked

void Node::setLocked ( bool value)
slot

set the Locked flag to the give value

Definition at line 417 of file Node.cpp.

418{
419 if (!d->node) return;
421}
virtual void setUserLocked(bool l)

References d, Node::Private::node, KisBaseNode::setUserLocked(), and value().

◆ setName

void Node::setName ( QString name)
slot

rename the Node to the given name

Definition at line 434 of file Node.cpp.

435{
436 if (!d->node) return;
437 d->node->setName(name);
438}
void setName(const QString &name)

References d, name(), Node::Private::node, and KisBaseNode::setName().

◆ setOpacity

void Node::setOpacity ( int value)
slot

set the opacity of the Node to the given value. The opacity is a value between 0 and 255.

Definition at line 447 of file Node.cpp.

448{
449 if (!d->node) return;
450 if (value < 0) value = 0;
451 if (value > 255) value = 255;
453}
void setOpacity(quint8 val)

References d, Node::Private::node, KisBaseNode::setOpacity(), and value().

◆ setPinnedToTimeline

void Node::setPinnedToTimeline ( bool pinned) const
slot

Sets whether or not node should be pinned to the Timeline Docker, regardless of selection activity.

Definition at line 373 of file Node.cpp.

374{
375 if (!d->node) return;
376 d->node->setPinnedToTimeline(pinned);
377}
void setPinnedToTimeline(bool pinned)

References d, Node::Private::node, and KisBaseNode::setPinnedToTimeline().

◆ setPixelData

bool Node::setPixelData ( QByteArray value,
int x,
int y,
int w,
int h )
slot

setPixelData writes the given bytes, of which there must be enough, into the Node, if the Node has writable pixel data:

  • paint layer: the layer's original pixels are overwritten
  • filter layer, generator layer, any mask: the embedded selection's pixels are overwritten. Note: for these

File layers, Group layers, Clone layers cannot be written to. Calling setPixelData on those layer types will silently do nothing.

Parameters
valuethe byte array representing the pixels. There must be enough bytes available. Krita will take the raw pointer from the QByteArray and start reading, not stopping before (number of channels * size of channel * w * h) bytes are read.
xthe x position to start writing from
ythe y position to start writing from
wthe width of each row
hthe number of rows to write
Returns
true if writing the pixeldata worked

Definition at line 602 of file Node.cpp.

603{
604 if (!d->node) return false;
606 if (!dev) return false;
607 if (value.length() < w * h * (int)dev->colorSpace()->pixelSize()) {
608 qWarning() << "Node::setPixelData: not enough data to write to the paint device";
609 return false;
610 }
611 dev->writeBytes((const quint8*)value.constData(), x, y, w, h);
612 return true;
613}
void writeBytes(const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
virtual quint32 pixelSize() const =0

References KisPaintDevice::colorSpace(), d, Node::Private::node, KisBaseNode::paintDevice(), KoColorSpace::pixelSize(), value(), and KisPaintDevice::writeBytes().

◆ setVisible

void Node::setVisible ( bool visible)
slot

Set the visibility of the current node to

Parameters
visible

Definition at line 539 of file Node.cpp.

540{
541 if (!d->node) return;
543}
bool visible() const
Definition Node.cpp:517
virtual void setVisible(bool visible, bool loading=false)

References d, Node::Private::node, KisBaseNode::setVisible(), and visible().

◆ shearNode

void Node::shearNode ( double angleX,
double angleY )
slot

shearNode perform a shear operation on this node.

Parameters
angleXthe X-angle in degrees to shear by
angleYthe Y-angle in degrees to shear by

Definition at line 737 of file Node.cpp.

738{
739 if (!d->node) return;
740 if (!qobject_cast<KisLayer*>(d->node.data())) return;
741 if (!d->node->parent()) return;
742
743 d->image->shearNode(d->node, angleX, angleY, 0);
744 d->image->waitForDone();
745}
void shearNode(KisNodeSP node, double angleX, double angleY, KisSelectionSP selection)
start asynchronous operation on shearing a subtree of nodes starting at node

References d, KisSharedPtr< T >::data(), Node::Private::image, Node::Private::node, KisNode::parent, KisImage::shearNode(), and KisImage::waitForDone().

◆ thumbnail

QImage Node::thumbnail ( int w,
int h )
slot

thumbnail create a thumbnail of the given dimensions. The thumbnail is sized according to the layer dimensions, not the image dimensions. If the requested size is too big a null QImage is created. If the current node cannot generate a thumbnail, a transparent QImage of the requested size is generated.

Returns
a QImage representing the layer contents.

Definition at line 747 of file Node.cpp.

748{
749 if (!d->node) return QImage();
750 return d->node->createThumbnail(w, h);
751}
virtual QImage createThumbnail(qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)

References KisBaseNode::createThumbnail(), d, and Node::Private::node.

◆ type

QString Node::type ( ) const
virtualslot

type Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.

Returns
The type of the node. Valid types are:
  • paintlayer
  • grouplayer
  • filelayer
  • filterlayer
  • filllayer
  • clonelayer
  • vectorlayer
  • transparencymask
  • filtermask
  • transformmask
  • selectionmask
  • colorizemask

If the Node object isn't wrapping a valid Krita layer or mask object, and empty string is returned.

Definition at line 463 of file Node.cpp.

464{
465 if (!d->node) return QString();
466 if (qobject_cast<const KisPaintLayer*>(d->node)) {
467 return "paintlayer";
468 }
469 else if (qobject_cast<const KisGroupLayer*>(d->node)) {
470 return "grouplayer";
471 }
472 if (qobject_cast<const KisFileLayer*>(d->node)) {
473 return "filelayer";
474 }
475 if (qobject_cast<const KisAdjustmentLayer*>(d->node)) {
476 return "filterlayer";
477 }
478 if (qobject_cast<const KisGeneratorLayer*>(d->node)) {
479 return "filllayer";
480 }
481 if (qobject_cast<const KisCloneLayer*>(d->node)) {
482 return "clonelayer";
483 }
484 if (qobject_cast<const KisReferenceImagesLayer*>(d->node)) {
485 return "referenceimageslayer";
486 }
487 if (qobject_cast<const KisShapeLayer*>(d->node)) {
488 return "vectorlayer";
489 }
490 if (qobject_cast<const KisTransparencyMask*>(d->node)) {
491 return "transparencymask";
492 }
493 if (qobject_cast<const KisFilterMask*>(d->node)) {
494 return "filtermask";
495 }
496 if (qobject_cast<const KisTransformMask*>(d->node)) {
497 return "transformmask";
498 }
499 if (qobject_cast<const KisSelectionMask*>(d->node)) {
500 return "selectionmask";
501 }
502 if (qobject_cast<const KisColorizeMask*>(d->node)) {
503 return "colorizemask";
504 }
505 return QString();
506}

References d, and Node::Private::node.

◆ uniqueId

QUuid Node::uniqueId ( ) const
slot

uniqueId uniqueId of the node

Returns
a QUuid representing a unique id to identify the node

Definition at line 811 of file Node.cpp.

812{
813 if (!d->node) return QUuid();
814 return d->node->uuid();
815}
QUuid uuid() const

References d, Node::Private::node, and KisBaseNode::uuid().

◆ visible

bool Node::visible ( ) const
slot

Check whether the current Node is visible in the layer stack

Definition at line 517 of file Node.cpp.

518{
519 if (!d->node) return false;
520 return d->node->visible();
521}
virtual bool visible(bool recursive=false) const

References d, Node::Private::node, and KisBaseNode::visible().

Friends And Related Symbol Documentation

◆ CloneLayer

friend class CloneLayer
friend

Definition at line 708 of file Node.h.

◆ ColorizeMask

friend class ColorizeMask
friend

Definition at line 707 of file Node.h.

◆ Document

friend class Document
friend

Definition at line 696 of file Node.h.

◆ FileLayer

friend class FileLayer
friend

Definition at line 699 of file Node.h.

◆ FillLayer

friend class FillLayer
friend

Definition at line 701 of file Node.h.

◆ Filter

friend class Filter
friend

Definition at line 695 of file Node.h.

◆ FilterLayer

friend class FilterLayer
friend

Definition at line 700 of file Node.h.

◆ FilterMask

friend class FilterMask
friend

Definition at line 703 of file Node.h.

◆ GroupLayer

friend class GroupLayer
friend

Definition at line 698 of file Node.h.

◆ Selection

friend class Selection
friend

Definition at line 697 of file Node.h.

◆ SelectionMask

friend class SelectionMask
friend

Definition at line 704 of file Node.h.

◆ TransformMask

friend class TransformMask
friend

Definition at line 706 of file Node.h.

◆ TransparencyMask

friend class TransparencyMask
friend

Definition at line 705 of file Node.h.

◆ VectorLayer

friend class VectorLayer
friend

Definition at line 702 of file Node.h.

Member Data Documentation

◆ d

Private* const Node::d
private

Definition at line 721 of file Node.h.


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