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

The TransformMask class A transform mask is a mask type node that can be used to store transformations. More...

#include <TransformMask.h>

+ Inheritance diagram for TransformMask:

Public Slots

QTransform finalAffineTransform () const
 
bool fromXML (const QString &xml)
 
QString toXML () const
 toXML
 
virtual QString type () const override
 type Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.
 
- Public Slots inherited from Node
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

 TransformMask (KisImageSP image, KisTransformMaskSP mask, QObject *parent=0)
 
 TransformMask (KisImageSP image, QString name, QObject *parent=0)
 
 ~TransformMask () override
 
- Public Member Functions inherited from Node
bool operator!= (const Node &other) const
 
bool operator== (const Node &other) const
 
 ~Node () override
 

Additional Inherited Members

- Static Public Member Functions inherited from Node
static NodecreateNode (KisImageSP image, KisNodeSP node, QObject *parent=0)
 

Detailed Description

The TransformMask class A transform mask is a mask type node that can be used to store transformations.

Definition at line 22 of file TransformMask.h.

Constructor & Destructor Documentation

◆ TransformMask() [1/2]

TransformMask::TransformMask ( KisImageSP image,
QString name,
QObject * parent = 0 )
explicit

Definition at line 22 of file TransformMask.cpp.

22 :
23 Node(image, new KisTransformMask(image, name), parent)
24{
25
26}
Node(KisImageSP image, KisNodeSP node, QObject *parent=0)
Definition Node.cpp:83
KisImageSP image() const
Definition Node.cpp:822
QString name() const
Definition Node.cpp:428

◆ TransformMask() [2/2]

TransformMask::TransformMask ( KisImageSP image,
KisTransformMaskSP mask,
QObject * parent = 0 )
explicit

Definition at line 28 of file TransformMask.cpp.

28 :
29 Node(image, mask, parent)
30{
31
32}

◆ ~TransformMask()

TransformMask::~TransformMask ( )
override

Definition at line 34 of file TransformMask.cpp.

35{
36
37}

Member Function Documentation

◆ finalAffineTransform

QTransform TransformMask::finalAffineTransform ( ) const
slot

Definition at line 44 of file TransformMask.cpp.

45{
46 QTransform affineTransformation;
47 KisTransformMask *mask = dynamic_cast<KisTransformMask*>(this->node().data());
48 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(mask, QTransform());
49
50 affineTransformation = mask->transformParams()->finalAffineTransform();
51
52 return affineTransformation;
53}
KisNodeSP node() const
Definition Node.cpp:827
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
KisTransformMaskParamsInterfaceSP transformParams() const

References KisSharedPtr< T >::data(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), and KisTransformMask::transformParams().

◆ fromXML

bool TransformMask::fromXML ( const QString & xml)
slot
   @brief fromXML set the transform of the transform mask from XML formatted data.
   The xml must have a valid id

   dumbparams - placeholder for static transform masks
   tooltransformparams - static transform mask
   animatedtransformparams - animated transform mask
<!DOCTYPE transform_params>
<transform_params>
<main id="tooltransformparams"/>
<data mode="0">
<free_transform>
<transformedCenter type="pointf" x="12.3102137276208" y="11.0727768562035"/>
<originalCenter type="pointf" x="20" y="20"/>
<rotationCenterOffset type="pointf" x="0" y="0"/>
<transformAroundRotationCenter value="0" type="value"/>
<aX value="0" type="value"/>
<aY value="0" type="value"/>
<aZ value="0" type="value"/>
<cameraPos z="1024" type="vector3d" x="0" y="0"/>
<scaleX value="1" type="value"/>
<scaleY value="1" type="value"/>
<shearX value="0" type="value"/>
<shearY value="0" type="value"/>
<keepAspectRatio value="0" type="value"/>
<flattenedPerspectiveTransform m23="0" m31="0" m32="0" type="transform" m33="1" m12="0" m13="0" m22="1" m11="1" m21="0"/>
<filterId value="Bicubic" type="value"/>
</free_transform>
</data>
</transform_params>
float value(const T *src, size_t ch)
virtual QString type() const override
type Krita has several types of nodes, split in layers and masks. Group layers can contain other laye...
int main(int argc, char **argv)
Definition main.cpp:26
Parameters
xmla valid formatted XML string with proper main and data elements.
Returns
a true response if successful, a false response if failed.

Definition at line 75 of file TransformMask.cpp.

76{
77 QDomDocument doc;
78 KisTransformMaskSP mask = qobject_cast<KisTransformMask*>(this->node().data());
80
81 doc.setContent(xml);
82
83 QDomElement rootElement = doc.documentElement();
84 QDomElement main = rootElement.firstChildElement("main");
85 QDomElement data = rootElement.firstChildElement("data");
86
87 if (!main.isElement() || !main.hasAttribute("id") || !data.isElement()) {
88 return false;
89 }
90
91 QString id = main.attribute("id", "not-valid");
92
93 // backward compatibility
94 if (id == "animatedtransformparams") {
95 id = "tooltransformparams";
96 }
97
99
100 if (!params) {
101 return false;
102 }
103
104 QScopedPointer<KUndo2Command> cmd(new KUndo2Command);
105
107 new KisLazyCreateTransformMaskKeyframesCommand(mask, cmd.data());
108 }
109
110 new KisSimpleModifyTransformMaskCommand(mask, params, {}, cmd.data());
111
113
114 return true;
115}
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...
static KisTransformMaskParamsFactoryRegistry * instance()
KisTransformMaskParamsInterfaceSP createParams(const QString &id, const QDomElement &e)

References KisTransformMaskParamsFactoryRegistry::createParams(), KisSharedPtr< T >::data(), Node::image(), KisTransformMaskParamsFactoryRegistry::instance(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, main(), KisLazyCreateTransformMaskKeyframesCommand::maskHasAnimation(), Node::node(), and KisProcessingApplicator::runSingleCommandStroke().

◆ toXML

QString TransformMask::toXML ( ) const
slot

toXML

Returns
a string containing XML formatted transform parameters.

Definition at line 55 of file TransformMask.cpp.

56{
57 KisTransformMaskSP mask = qobject_cast<KisTransformMask*>(this->node().data());
59
60 QDomDocument doc("transform_params");
61 QDomElement root = doc.createElement("transform_params");
62 QDomElement main = doc.createElement("main");
63 QDomElement data = doc.createElement("data");
64
65 main.setAttribute("id", mask->transformParams()->id());
66
67 mask->transformParams()->toXML(&data);
68 doc.appendChild(root);
69 root.appendChild(main);
70 root.appendChild(data);
71
72 return doc.toString();
73}

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, main(), Node::node(), and KisTransformMask::transformParams().

◆ type

QString TransformMask::type ( ) const
overridevirtualslot

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

Returns
transformmask

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

Definition at line 39 of file TransformMask.cpp.

40{
41 return "transformmask";
42}

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