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;
302 if (!
d->
node)
return 0;
308 if (!
d->
node)
return;
314 if (!
d->
node)
return "";
321 if (!
d->
node)
return "";
329 if (!
d->
node)
return "";
336 if (!
d->
node)
return false;
337 if (!
d->
node->inherits(
"KisLayer"))
return false;
345bool Node::setColorSpace(
const QString &colorModel,
const QString &colorDepth,
const QString &colorProfile)
347 if (!
d->
node)
return false;
348 if (!
d->
node->inherits(
"KisLayer"))
return false;
350 if (!profile)
return false;
361 if (!
d->
node)
return false;
367 if (!
d->
node)
return;
373 if (!
d->
node)
return;
379 if (!
d->
node)
return false;
385 if (!
d->
node)
return false;
391 if (!
d->
node)
return;
397 if (!
d->
node)
return false;
398 if (!
d->
node->inherits(
"KisLayer"))
return false;
399 return qobject_cast<const KisLayer*>(
d->
node)->alphaChannelDisabled();
404 if (!
d->
node)
return;
405 if (!
d->
node->inherits(
"KisLayer"))
return;
406 const_cast<KisLayer*
>(qobject_cast<const KisLayer*>(
d->
node))->disableAlphaChannel(
value);
411 if (!
d->
node)
return false;
417 if (!
d->
node)
return;
428 if (!
d->
node)
return QString();
434 if (!
d->
node)
return;
441 if (!
d->
node)
return 0;
447 if (!
d->
node)
return;
456 if (!
d->
node)
return 0;
463 if (!
d->
node)
return QString();
464 if (qobject_cast<const KisPaintLayer*>(
d->
node)) {
467 else if (qobject_cast<const KisGroupLayer*>(
d->
node)) {
470 if (qobject_cast<const KisFileLayer*>(
d->
node)) {
473 if (qobject_cast<const KisAdjustmentLayer*>(
d->
node)) {
474 return "filterlayer";
476 if (qobject_cast<const KisGeneratorLayer*>(
d->
node)) {
479 if (qobject_cast<const KisCloneLayer*>(
d->
node)) {
482 if (qobject_cast<const KisReferenceImagesLayer*>(
d->
node)) {
483 return "referenceimageslayer";
485 if (qobject_cast<const KisShapeLayer*>(
d->
node)) {
486 return "vectorlayer";
488 if (qobject_cast<const KisTransparencyMask*>(
d->
node)) {
489 return "transparencymask";
491 if (qobject_cast<const KisFilterMask*>(
d->
node)) {
494 if (qobject_cast<const KisTransformMask*>(
d->
node)) {
495 return "transformmask";
497 if (qobject_cast<const KisSelectionMask*>(
d->
node)) {
498 return "selectionmask";
500 if (qobject_cast<const KisColorizeMask*>(
d->
node)) {
501 return "colorizemask";
517 if (!
d->
node)
return false;
526 if (!rkc)
return false;
530 if (!currentKeyframe) {
539 if (!
d->
node)
return;
548 if (!
d->
node)
return ba;
554 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
568 if (!frame)
return ba;
572 frame->writeFrameToDevice(dev);
575 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
584 if (!
d->
node)
return ba;
589 dev = mask->coloringProjection();
596 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
602 if (!
d->
node)
return false;
604 if (!dev)
return false;
606 qWarning() <<
"Node::setPixelData: not enough data to write to the paint device";
615 if (!
d->
node)
return QRect();
621 if (!
d->
node)
return;
628 if (!
d->
node)
return QPoint();
634 if (!
d->
node)
return false;
647 if (!
d->
node)
return 0;
651bool Node::save(
const QString &filename,
double xRes,
double yRes,
const InfoObject &exportConfiguration,
const QRect &exportRect)
653 if (!
d->
node)
return false;
654 if (filename.isEmpty())
return false;
669 doc->setCurrentImage(dst);
676 bool r = doc->exportDocumentSync(filename, mimeType.toLatin1(), exportConfiguration.
configuration());
678 qWarning() << doc->errorMessage();
685 if (!
d->
node)
return 0;
686 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return 0;
697 if (!
d->
node)
return;
698 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
708 qreal(width) /
bounds.width(),
709 qreal(height) /
bounds.height(),
716 if (!
d->
node)
return;
717 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
726 if (!
d->
node)
return;
727 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
730 QRect
rect = QRect(x, y, w, h);
737 if (!
d->
node)
return;
738 if (!qobject_cast<KisLayer*>(
d->
node.
data()))
return;
747 if (!
d->
node)
return QImage();
753 if (!
d->
node)
return QString();
757 if (!layer)
return QString();
761 if (!layerStyle)
return QString();
772 if (!
d->
node)
return false;
776 if (!layer)
return false;
780 if (!aslDoc.setContent(asl)) {
781 qWarning() <<
"ASL string format is invalid!";
790 if (serializer.
styles().size() != 1)
return false;
803 if (!
d->
node)
return -1;
811 if (!
d->
node)
return QUuid();
836 return "UNPAINTABLE";
840 return "UNPAINTABLE";
843 if (
d->
node->inherits(
"KisShapeLayer")) {
846 if (
d->
node->inherits(
"KisCloneLayer")) {
852 if (currentPaintOpPreset->paintOp().id() ==
"mypaintbrush") {
855 return "MYPAINTBRUSH_UNPAINTABLE";
862 return "UNPAINTABLE";
865void Node::paintLine(
const QPointF pointOne,
const QPointF pointTwo,
double pressureOne,
double pressureTwo,
const QString strokeStyle)
868 dbgScript <<
"Script attempted to use Node::paintLine() on an unpaintable node, ignoring.";
874 pointOneInfo.
setPos(pointOne);
878 pointTwoInfo.
setPos(pointTwo);
881 helper.
paintLine(pointOneInfo, pointTwoInfo);
888 dbgScript <<
"Script attempted to use Node::paintRectangle() on an unpaintable node, ignoring.";
903 dbgScript <<
"Script attempted to use Node::paintPolygon() on an unpaintable node, ignoring.";
917 dbgScript <<
"Script attempted to use Node::paintEllipse() on an unpaintable node, ignoring.";
926void Node::paintPath(
const QPainterPath &path,
const QString strokeStyle,
const QString fillStyle)
929 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
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()