7#include <QScopedPointer>
96 if (
node->inherits(
"KisGroupLayer")) {
99 else if (
node->inherits(
"KisCloneLayer")) {
102 else if (
node->inherits(
"KisFileLayer")) {
105 else if (
node->inherits(
"KisAdjustmentLayer")) {
108 else if (
node->inherits(
"KisGeneratorLayer")) {
111 else if (
node->inherits(
"KisShapeLayer")) {
114 else if (
node->inherits(
"KisFilterMask")) {
117 else if (
node->inherits(
"KisSelectionMask")) {
120 else if (
node->inherits(
"KisTransparencyMask")) {
123 else if (
node->inherits(
"KisTransformMask")) {
126 else if (
node->inherits(
"KisColorizeMask")) {
160 if (!
d->
node)
return false;
170 if (!
d->
node)
return;
180 if (!
d->
node)
return QString();
187 if (!
d->
node)
return;
218 for (
int i = 0; i < childCount; ++i) {
228 if (!
d->
node)
return {};
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)))
249 nodeList.removeAt(i);
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);
267 if (!
d->
node)
return false;
285 if (!
d->
node)
return false;
291 if (!
d->
node)
return;
304 if (!
d->
node)
return 0;
310 if (!
d->
node)
return;
316 if (!
d->
node)
return "";
323 if (!
d->
node)
return "";
331 if (!
d->
node)
return "";
338 if (!
d->
node)
return false;
339 if (!
d->
node->inherits(
"KisLayer"))
return false;
347bool Node::setColorSpace(
const QString &colorModel,
const QString &colorDepth,
const QString &colorProfile)
349 if (!
d->
node)
return false;
350 if (!
d->
node->inherits(
"KisLayer"))
return false;
352 if (!profile)
return false;
363 if (!
d->
node)
return false;
369 if (!
d->
node)
return;
375 if (!
d->
node)
return;
381 if (!
d->
node)
return false;
387 if (!
d->
node)
return false;
393 if (!
d->
node)
return;
399 if (!
d->
node)
return false;
400 if (!
d->
node->inherits(
"KisLayer"))
return false;
401 return qobject_cast<const KisLayer*>(
d->
node)->alphaChannelDisabled();
406 if (!
d->
node)
return;
407 if (!
d->
node->inherits(
"KisLayer"))
return;
408 const_cast<KisLayer*
>(qobject_cast<const KisLayer*>(
d->
node))->disableAlphaChannel(
value);
413 if (!
d->
node)
return false;
419 if (!
d->
node)
return;
430 if (!
d->
node)
return QString();
436 if (!
d->
node)
return;
443 if (!
d->
node)
return 0;
449 if (!
d->
node)
return;
458 if (!
d->
node)
return 0;
465 if (!
d->
node)
return QString();
466 if (qobject_cast<const KisPaintLayer*>(
d->
node)) {
469 else if (qobject_cast<const KisGroupLayer*>(
d->
node)) {
472 if (qobject_cast<const KisFileLayer*>(
d->
node)) {
475 if (qobject_cast<const KisAdjustmentLayer*>(
d->
node)) {
476 return "filterlayer";
478 if (qobject_cast<const KisGeneratorLayer*>(
d->
node)) {
481 if (qobject_cast<const KisCloneLayer*>(
d->
node)) {
484 if (qobject_cast<const KisReferenceImagesLayer*>(
d->
node)) {
485 return "referenceimageslayer";
487 if (qobject_cast<const KisShapeLayer*>(
d->
node)) {
488 return "vectorlayer";
490 if (qobject_cast<const KisTransparencyMask*>(
d->
node)) {
491 return "transparencymask";
493 if (qobject_cast<const KisFilterMask*>(
d->
node)) {
496 if (qobject_cast<const KisTransformMask*>(
d->
node)) {
497 return "transformmask";
499 if (qobject_cast<const KisSelectionMask*>(
d->
node)) {
500 return "selectionmask";
502 if (qobject_cast<const KisColorizeMask*>(
d->
node)) {
503 return "colorizemask";
519 if (!
d->
node)
return false;
528 if (!rkc)
return false;
532 if (!currentKeyframe) {
541 if (!
d->
node)
return;
550 if (!
d->
node)
return ba;
556 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
570 if (!frame)
return ba;
574 frame->writeFrameToDevice(dev);
577 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
586 if (!
d->
node)
return ba;
591 dev = mask->coloringProjection();
598 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
604 if (!
d->
node)
return false;
606 if (!dev)
return false;
608 qWarning() <<
"Node::setPixelData: not enough data to write to the paint device";
617 if (!
d->
node)
return QRect();
623 if (!
d->
node)
return;
630 if (!
d->
node)
return QPoint();
636 if (!
d->
node)
return false;
649 if (!
d->
node)
return 0;
653bool Node::save(
const QString &filename,
double xRes,
double yRes,
const InfoObject &exportConfiguration,
const QRect &exportRect)
655 if (!
d->
node)
return false;
656 if (filename.isEmpty())
return false;
671 doc->setCurrentImage(dst);
678 bool r = doc->exportDocumentSync(filename, mimeType.toLatin1(), exportConfiguration.
configuration());
680 qWarning() << doc->errorMessage();
687 if (!
d->
node)
return 0;
688 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return 0;
699 if (!
d->
node)
return;
700 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
710 qreal(width) /
bounds.width(),
711 qreal(height) /
bounds.height(),
718 if (!
d->
node)
return;
719 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
728 if (!
d->
node)
return;
729 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
732 QRect
rect = QRect(x, y, w, h);
739 if (!
d->
node)
return;
740 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
749 if (!
d->
node)
return QImage();
755 if (!
d->
node)
return QString();
759 if (!layer)
return QString();
763 if (!layerStyle)
return QString();
774 if (!
d->
node)
return false;
778 if (!layer)
return false;
782 if (!aslDoc.setContent(asl)) {
783 qWarning() <<
"ASL string format is invalid!";
792 if (serializer.
styles().size() != 1)
return false;
805 if (!
d->
node)
return -1;
813 if (!
d->
node)
return QUuid();
838 return "UNPAINTABLE";
842 return "UNPAINTABLE";
845 if (
d->
node->inherits(
"KisShapeLayer")) {
848 if (
d->
node->inherits(
"KisCloneLayer")) {
854 if (currentPaintOpPreset->paintOp().id() ==
"mypaintbrush") {
857 return "MYPAINTBRUSH_UNPAINTABLE";
864 return "UNPAINTABLE";
867void Node::paintLine(
const QPointF pointOne,
const QPointF pointTwo,
double pressureOne,
double pressureTwo,
const QString strokeStyle)
870 dbgScript <<
"Script attempted to use Node::paintLine() on an unpaintable node, ignoring.";
876 pointOneInfo.
setPos(pointOne);
880 pointTwoInfo.
setPos(pointTwo);
883 helper.
paintLine(pointOneInfo, pointTwoInfo);
890 dbgScript <<
"Script attempted to use Node::paintRectangle() on an unpaintable node, ignoring.";
905 dbgScript <<
"Script attempted to use Node::paintPolygon() on an unpaintable node, ignoring.";
919 dbgScript <<
"Script attempted to use Node::paintEllipse() on an unpaintable node, ignoring.";
928void Node::paintPath(
const QPainterPath &path,
const QString strokeStyle,
const QString fillStyle)
931 dbgScript <<
"Script attempted to use Node::paintPath() on an unpaintable node, ignoring.";
float value(const T *src, size_t ch)
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
KisPropertiesConfigurationSP configuration() const
configuration gives access to the internal configuration object. Must be used internally in libkis
QVector< KisPSDLayerStyleSP > styles() const
void readFromPSDXML(const QDomDocument &doc)
void registerPSDPattern(const QDomDocument &doc)
QDomDocument formPsdXmlDocument() const
void setStyles(const QVector< KisPSDLayerStyleSP > &styles)
The KisFileLayer class loads a particular file as a layer into the layer stack.
static KisFilterStrategyRegistry * instance()
The command for adding a layer.
void scaleNode(KisNodeSP node, const QPointF ¢er, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy, KisSelectionSP selection)
start asynchronous operation on scaling a subtree of nodes starting at node
KisGroupLayerSP rootLayer() const
void cropNode(KisNodeSP node, const QRect &newRect, const bool activeFrameOnly=false)
start asynchronous operation on cropping a subtree of nodes starting at node
void shearNode(KisNodeSP node, double angleX, double angleY, KisSelectionSP selection)
start asynchronous operation on shearing a subtree of nodes starting at node
void cropImage(const QRect &newRect)
start asynchronous operation on cropping the image
bool assignLayerProfile(KisNodeSP node, const KoColorProfile *profile)
void initialRefreshGraph()
void mergeDown(KisLayerSP l, const KisMetaData::MergeStrategy *strategy)
void convertLayerColorSpace(KisNodeSP node, const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
void setResolution(double xres, double yres)
void rotateNode(KisNodeSP node, double radians, KisSelectionSP selection)
start asynchronous operation on rotating a subtree of nodes starting at node
KisKeyframeSP keyframeAt(int time) const
Get a keyframe at specified time. Used primarily when the value of a given keyframe is needed.
QPointer< KisView > activeView
static QString mimeTypeForFile(const QString &file, bool checkExistingFiles=true)
Find the mimetype for the given filename. The filename must include a suffix.
The command for setting the composite op.
quint32 pixelSize() const
virtual const KoColorSpace * compositionSourceColorSpace() const
const KoColorSpace * colorSpace() const
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
void makeCloneFrom(KisPaintDeviceSP src, const QRect &rect)
void writeBytes(const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
static KisPart * instance()
KisMainWindow * currentMainwindow() const
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...
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image ...
QPointer< KoCanvasResourceProvider > resourceManager
virtual quint32 pixelSize() const =0
QList< KoChannelInfo * > channels
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual const KoColorProfile * profile() const =0
T get(const QString &id) const
static Krita * instance()
instance retrieve the singleton instance of the Application object.
bool alphaLocked() const
alphaLocked checks whether the node is a paint layer and returns whether it is alpha locked
void setBlendingMode(QString value)
setBlendingMode set the blending mode of the node to the given value
QList< Node * > childNodes() const
childNodes
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 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
Node * mergeDown()
mergeDown merges the given node with the first visible node underneath this node in the layerstack....
bool operator==(const Node &other) const
void setCollapsed(bool collapsed)
QList< Channel * > channels() const
channels creates a list of Channel objects that can be used individually to show or hide certain chan...
QList< Node * > findChildNodes(const QString &name=QString(), bool recursive=false, bool partialMatch=false, const QString &type=QString(), int colorLabelIndex=0) const
findChildNodes
void enableAnimation() const
enableAnimation make the current layer animated, so it can have frames.
Node(KisImageSP image, KisNodeSP node, QObject *parent=0)
QString colorDepth() const
void setOpacity(int value)
bool locked() const
locked checks whether the Node is locked. A locked node cannot be changed.
QUuid uniqueId() const
uniqueId uniqueId of the node
QPoint position() const
position returns the position of the paint device of this node. The position is always 0,...
void setPinnedToTimeline(bool pinned) const
Sets whether or not node should be pinned to the Timeline Docker, regardless of selection activity.
void setChildNodes(QList< Node * > nodes)
setChildNodes this replaces the existing set of child nodes with the new set.
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
QString colorModel() const
colorModel retrieve the current color model of this document:
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
bool operator!=(const Node &other) const
bool hasKeyframeAtTime(int frameNumber)
void shearNode(double angleX, double angleY)
shearNode perform a shear operation on this node.
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,...
friend class TransparencyMask
bool setColorSpace(const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
setColorSpace convert the node to the given colorspace
virtual QString type() const
type Krita has several types of nodes, split in layers and masks. Group layers can contain other laye...
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
void setLocked(bool value)
bool animated() const
Krita layers can be animated, i.e., have frames.
bool remove()
remove removes this node from its parent image.
bool inheritAlpha() const
inheritAlpha checks whether this node has the inherits alpha flag set
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,...
void setName(QString name)
friend class SelectionMask
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 cropNode(int x, int y, int w, int h)
cropNode crop this layer.
QString paintAbility()
paintAbility can be used to determine whether this node can be painted on with the current brush pres...
static Node * createNode(KisImageSP image, KisNodeSP node, QObject *parent=0)
void rotateNode(double radians)
rotateNode rotate this layer by the given radians.
int index() const
index the index of the node inside the parent
bool setLayerStyleFromAsl(const QString &asl)
setLayerStyleFromAsl set a new layer style for this node.
QString blendingMode() const
QString layerStyleToAsl()
layerStyleToAsl retrieve the current layer's style in ASL format.
bool setColorProfile(const QString &colorProfile)
setColorProfile set the color profile of the image to the given profile. The profile has to be regist...
bool addChildNode(Node *child, Node *above)
addChildNode adds the given node in the list of children.
QImage thumbnail(int w, int h)
thumbnail create a thumbnail of the given dimensions. The thumbnail is sized according to the layer d...
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
bool hasExtents()
does the node have any content in it?
KisPaintDeviceSP paintDevice() const
paintDevice gives access to the internal paint device of this Node
Node * duplicate()
duplicate returns a full copy of the current node. The node is not inserted in the graphic
void setInheritAlpha(bool value)
friend class TransformMask
bool removeChildNode(Node *child)
removeChildNode removes the given node from the list of children.
Node * parentNode() const
void setVisible(bool visible)
QByteArray projectionPixelData(int x, int y, int w, int h) const
projectionPixelData reads the given rectangle from the Node's projection (that is,...
void setColorLabel(int index)
setColorLabel sets a color label index associated to the layer. The actual color of the label and the...
Node * clone() const
clone clone the current node. The node is not associated with any image.
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.
bool isPinnedToTimeline() const
QRect bounds() const
bounds return the exact bounds of the node's paint device
QString colorProfile() const
friend class ColorizeMask
KisDocument * createDocument(QList< KisNodeSP > nodes, KisImageSP srcImage, const QRect &copiedBounds)
QList< KisNodeSP > findNodesByName(KisNodeSP root, const QString &name, bool recursive, bool partialMatch)
QList< Node * > createNodeList(KisNodeList kisnodes, KisImageWSP image)
KisFigurePaintingToolHelper createHelper(KisImageWSP image, KisNodeSP node, const QString strokeStyle=defaultStrokeStyle, const QString fillStyle=defaultFillStyle)
void setPinnedToTimeline(bool pinned)
virtual void setUserLocked(bool l)
virtual KisPaintDeviceSP projection() const =0
const QString & compositeOpId() const
void setOpacity(quint8 val)
virtual void setVisible(bool visible, bool loading=false)
bool isPinnedToTimeline() const
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
virtual QRect exactBounds() const
virtual QImage createThumbnail(qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
virtual void setX(qint32)
virtual void setY(qint32)
void setColorLabelIndex(int index)
void setName(const QString &name)
void setCollapsed(bool collapsed)
virtual const KoColorSpace * colorSpace() const =0
int colorLabelIndex() const
virtual QRect extent() const
virtual KisPaintDeviceSP paintDevice() const =0
virtual bool visible(bool recursive=false) const
virtual QIcon icon() const
KisPSDLayerStyleSP layerStyle
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
bool removeNode(KisNodeSP node)
KisNodeSP prevSibling() const
KisNodeSP firstChild() const
int index(const KisNodeSP node) const
virtual KisNodeSP clone() const =0
quint32 childCount() const
KisNodeSP at(quint32 index) const
KisNodeSP nextSibling() const
KisPaintDeviceSP paintDevice
void setAlphaLocked(bool lock)
const KoColorProfile * profileByName(const QString &name) const
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()