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

The FillLayer class A fill layer is much like a filter layer in that it takes a name and filter. It however specializes in filters that fill the whole canvas, such as a pattern or full color fill. More...

#include <FillLayer.h>

+ Inheritance diagram for FillLayer:

Public Slots

InfoObjectfilterConfig ()
 
QString generatorName ()
 
bool setGenerator (const QString &generatorName, InfoObject *filterConfig)
 setGenerator set the given generator for this fill layer
 
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

 FillLayer (KisGeneratorLayerSP layer, QObject *parent=0)
 
 FillLayer (KisImageSP image, QString name, KisFilterConfigurationSP filterConfig, Selection &selection, QObject *parent=0)
 FillLayer Create a new fill layer with the given generator plugin.
 
 ~FillLayer () 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 FillLayer class A fill layer is much like a filter layer in that it takes a name and filter. It however specializes in filters that fill the whole canvas, such as a pattern or full color fill.

Definition at line 24 of file FillLayer.h.

Constructor & Destructor Documentation

◆ FillLayer() [1/2]

FillLayer::FillLayer ( KisImageSP image,
QString name,
KisFilterConfigurationSP filterConfig,
Selection & selection,
QObject * parent = 0 )
explicit

FillLayer Create a new fill layer with the given generator plugin.

Parameters
imagethe image this fill layer will belong to
name"pattern" or "color"
filterConfiga configuration object appropriate to the given generator plugin

For a "pattern" fill layer, the InfoObject can contain a single "pattern" parameter with the name of a pattern as known to the resource system: "pattern" = "Cross01.pat".

For a "color" fill layer, the InfoObject can contain a single "color" parameter with a QColor, a string that QColor can parse (see https://doc.qt.io/qt-5/qcolor.html#setNamedColor) or an XML description of the color, which can be derived from a

See also
ManagedColor.
Parameters
selectiona selection object, can be empty
parent

Definition at line 16 of file FillLayer.cpp.

16 :
17 Node(image, new KisGeneratorLayer(image, name, filterConfig->cloneWithResourcesSnapshot(), selection.selection()), parent)
18{
19
20}
InfoObject * filterConfig()
Definition FillLayer.cpp:39
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
KisSelectionSP selection() const

◆ FillLayer() [2/2]

FillLayer::FillLayer ( KisGeneratorLayerSP layer,
QObject * parent = 0 )
explicit

Definition at line 22 of file FillLayer.cpp.

22 :
23 Node(layer->image(), layer, parent)
24{
25
26}
KisImageWSP image

◆ ~FillLayer()

FillLayer::~FillLayer ( )
override

Definition at line 28 of file FillLayer.cpp.

29{
30
31}

Member Function Documentation

◆ filterConfig

InfoObject * FillLayer::filterConfig ( )
slot

Definition at line 39 of file FillLayer.cpp.

40{
41 const KisGeneratorLayer *layer = qobject_cast<const KisGeneratorLayer*>(this->node());
42 return new InfoObject(layer->filter());
43}
virtual KisFilterConfigurationSP filter() const
KisNodeSP node() const
Definition Node.cpp:827

References KisNodeFilterInterface::filter(), and Node::node().

◆ generatorName

QString FillLayer::generatorName ( )
slot

Definition at line 33 of file FillLayer.cpp.

34{
35 const KisGeneratorLayer *layer = qobject_cast<const KisGeneratorLayer*>(this->node());
36 return layer->filter()->name();
37}

References KisNodeFilterInterface::filter(), and Node::node().

◆ setGenerator

bool FillLayer::setGenerator ( const QString & generatorName,
InfoObject * filterConfig )
slot

setGenerator set the given generator for this fill layer

Parameters
generatorName"pattern" or "color"
filterConfiga configuration object appropriate to the given generator plugin
Returns
true if the generator was correctly created and set on the layer

Definition at line 50 of file FillLayer.cpp.

51{
52 KisGeneratorLayer *layer = dynamic_cast<KisGeneratorLayer*>(this->node().data());
54
55 //getting the default configuration here avoids trouble with versioning.
57
58 if (generator) {
60 Q_FOREACH(const QString property, config->properties().keys()) {
61 cfg->setProperty(property, config->property(property));
62 }
63 layer->setFilter(cfg->cloneWithResourcesSnapshot(), false);
64 if (layer->hasPendingTimedUpdates()) {
65 layer->forceUpdateTimedNode();
66 }
67 image()->waitForDone();
68 return true;
69 }
70 return false;
71}
QString generatorName()
Definition FillLayer.cpp:33
static KisGeneratorRegistry * instance()
static KisResourcesInterfaceSP instance()
void waitForDone()
const T value(const QString &id) const
#define KIS_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:85
virtual KisFilterConfigurationSP factoryConfiguration(KisResourcesInterfaceSP resourcesInterface) const
void forceUpdateTimedNode() override
forceUpdateTimedNode forces the node to regenerate its project. The update might be asynchronous,...
bool hasPendingTimedUpdates() const override
void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true) override

References KisSharedPtr< T >::data(), KisBaseProcessor::factoryConfiguration(), KisGeneratorLayer::forceUpdateTimedNode(), generatorName(), KisGeneratorLayer::hasPendingTimedUpdates(), Node::image(), KisGeneratorRegistry::instance(), KisGlobalResourcesInterface::instance(), KIS_ASSERT_RECOVER_RETURN_VALUE, Node::node(), InfoObject::properties(), InfoObject::property(), KisGeneratorLayer::setFilter(), KoGenericRegistry< T >::value(), and KisImage::waitForDone().

◆ type

QString FillLayer::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
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 45 of file FillLayer.cpp.

46{
47 return "filllayer";
48}

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