Document

Search for usage in LXR

#include <Document.h>

Inheritance diagram for Document:

Public Slots

NodeactiveNode () const
 
int animationLength ()
 
QByteArray annotation (const QString &type)
 
QString annotationDescription (const QString &type) const
 
QStringList annotationTypes () const
 
QColor backgroundColor ()
 
bool batchmode () const
 
QRect bounds () const
 
Documentclone () const
 
bool close ()
 
QString colorDepth () const
 
QString colorModel () const
 
QString colorProfile () const
 
CloneLayercreateCloneLayer (const QString &name, const Node *source)
 
ColorizeMaskcreateColorizeMask (const QString &name)
 
FileLayercreateFileLayer (const QString &name, const QString fileName, const QString scalingMethod)
 
FillLayercreateFillLayer (const QString &name, const QString generatorName, InfoObject &configuration, Selection &selection)
 
FilterLayercreateFilterLayer (const QString &name, Filter &filter, Selection &selection)
 
FilterMaskcreateFilterMask (const QString &name, Filter &filter, const Node *selection_source)
 
FilterMaskcreateFilterMask (const QString &name, Filter &filter, Selection &selection)
 
GroupLayercreateGroupLayer (const QString &name)
 
NodecreateNode (const QString &name, const QString &nodeType)
 
SelectionMaskcreateSelectionMask (const QString &name)
 
TransformMaskcreateTransformMask (const QString &name)
 
TransparencyMaskcreateTransparencyMask (const QString &name)
 
VectorLayercreateVectorLayer (const QString &name)
 
void crop (int x, int y, int w, int h)
 
int currentTime ()
 
QString documentInfo () const
 
bool exportImage (const QString &filename, const InfoObject &exportConfiguration)
 
QString fileName () const
 
void flatten ()
 
int framesPerSecond ()
 
int fullClipRangeEndTime ()
 
int fullClipRangeStartTime ()
 
int height () const
 
bool importAnimation (const QList< QString > &files, int firstFrame, int step)
 
void lock ()
 
bool modified () const
 
QString name () const
 
NodenodeByName (const QString &name) const
 
NodenodeByUniqueID (const QUuid &id) const
 
QByteArray pixelData (int x, int y, int w, int h) const
 
int playBackEndTime ()
 
int playBackStartTime ()
 
QImage projection (int x=0, int y=0, int w=0, int h=0) const
 
void refreshProjection ()
 
void removeAnnotation (const QString &type)
 
void resizeImage (int x, int y, int w, int h)
 
int resolution () const
 
NoderootNode () const
 
void rotateImage (double radians)
 
bool save ()
 
bool saveAs (const QString &filename)
 
void scaleImage (int w, int h, int xres, int yres, QString strategy)
 
Selectionselection () const
 
void setActiveNode (Node *value)
 
void setAnnotation (const QString &type, const QString &description, const QByteArray &annotation)
 
bool setBackgroundColor (const QColor &color)
 
void setBatchmode (bool value)
 
bool setColorProfile (const QString &colorProfile)
 
bool setColorSpace (const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
 
void setCurrentTime (int time)
 
void setDocumentInfo (const QString &document)
 
void setFileName (QString value)
 
void setFramesPerSecond (int fps)
 
void setFullClipRangeEndTime (int endTime)
 
void setFullClipRangeStartTime (int startTime)
 
void setGuidesLocked (bool locked)
 
void setGuidesVisible (bool visible)
 
void setHeight (int value)
 
void setHorizontalGuides (const QList< qreal > &lines)
 
void setName (QString value)
 
void setPlayBackRange (int start, int stop)
 
void setResolution (int value)
 
void setSelection (Selection *value)
 
void setVerticalGuides (const QList< qreal > &lines)
 
void setWidth (int value)
 
void setXOffset (int x)
 
void setXRes (double xRes) const
 
void setYOffset (int y)
 
void setYRes (double yRes) const
 
void shearImage (double angleX, double angleY)
 
QImage thumbnail (int w, int h) const
 
QList< Node * > topLevelNodes () const
 
bool tryBarrierLock ()
 
void unlock ()
 
void waitForDone ()
 
int width () const
 
int xOffset () const
 
double xRes () const
 
int yOffset () const
 
double yRes () const
 

Public Member Functions

 Document (KisDocument *document, bool ownsDocument, QObject *parent=0)
 
bool guidesLocked () const
 
bool guidesVisible () const
 
QList< qreal > horizontalGuides () const
 
bool operator!= (const Document &other) const
 
bool operator== (const Document &other) const
 
QList< qreal > verticalGuides () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The Document class encapsulates a Krita Document/Image.

A Krita document is an Image with a filename. Libkis does not differentiate between a document and an image, like Krita does internally.

Definition at line 33 of file Document.h.

Member Function Documentation

◆ activeNode

Node * Document::activeNode ( ) const
slot

activeNode retrieve the node that is currently active in the currently active window

Returns
the active node. If there is no active window, the first child node is returned.

Definition at line 113 of file Document.cpp.

◆ animationLength

int Document::animationLength ( )
slot

get total frame range for animation

Returns
total frame range for animation

Definition at line 1011 of file Document.cpp.

◆ annotation

QByteArray Document::annotation ( const QString type)
slot

annotation the actual data for the annotation for this type.

It's a simple QByteArray, what's in it depends on the type of the annotation

Parameters
typethe type of the annotation
Returns
a bytearray, possibly empty if this type of annotation doesn't exist

Definition at line 1094 of file Document.cpp.

◆ annotationDescription

QString Document::annotationDescription ( const QString type) const
slot

annotationDescription gets the pretty description for the current annotation

Parameters
typethe type of the annotation
Returns
a string that can be presented to the user

Definition at line 1087 of file Document.cpp.

◆ annotationTypes

QStringList Document::annotationTypes ( ) const
slot

annotationTypes returns the list of annotations present in the document.

Each annotation type is unique.

Definition at line 1060 of file Document.cpp.

◆ backgroundColor

QColor Document::backgroundColor ( )
slot

backgroundColor returns the current background color of the document.

The color will also include the opacity.

Returns
QColor

Definition at line 217 of file Document.cpp.

◆ batchmode

bool Document::batchmode ( ) const
slot

Batchmode means that no actions on the document should show dialogs or popups.

Returns
true if the document is in batchmode.

Definition at line 101 of file Document.cpp.

◆ bounds

QRect Document::bounds ( ) const
slot

bounds return the bounds of the image

Returns
the bounds

Definition at line 927 of file Document.cpp.

◆ clone

Document * Document::clone ( ) const
slot

clone create a shallow clone of this document.

Returns
a new Document that should be identical to this one in every respect.

Definition at line 864 of file Document.cpp.

◆ close

bool Document::close ( )
slot

close Close the document: remove it from Krita's internal list of documents and close all views.

If the document is modified, you should save it first. There will be no prompt for saving.

After closing the document it becomes invalid.

Returns
true if the document is closed.

Definition at line 469 of file Document.cpp.

◆ colorDepth

QString Document::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 173 of file Document.cpp.

◆ colorModel

QString Document::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 179 of file Document.cpp.

◆ colorProfile

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

Definition at line 185 of file Document.cpp.

◆ createCloneLayer

CloneLayer * Document::createCloneLayer ( const QString name,
const Node source 
)
slot

createCloneLayer

Parameters
name
source
Returns

Definition at line 689 of file Document.cpp.

◆ createColorizeMask

ColorizeMask * Document::createColorizeMask ( const QString name)
slot

createColorizeMask Creates a colorize mask, which can be used to color fill via keystrokes.

Parameters
name- the name of the layer.
Returns
a TransparencyMask

Definition at line 772 of file Document.cpp.

◆ createFileLayer

FileLayer * Document::createFileLayer ( const QString name,
const QString  fileName,
const QString  scalingMethod 
)
slot

createFileLayer returns a layer that shows an external image.

Parameters
namename of the file layer.
fileNamethe absolute filename of the file referenced. Symlinks will be resolved.
scalingMethodhow the dimensions of the file are interpreted can be either "None", "ImageToSize" or "ImageToPPI"
Returns
a FileLayer

Definition at line 652 of file Document.cpp.

◆ createFillLayer

FillLayer * Document::createFillLayer ( const QString name,
const QString  generatorName,
InfoObject configuration,
Selection selection 
)
slot

createFillLayer creates a fill layer object, which is a layer

Parameters
name
generatorName- name of the generation filter.
configuration- the configuration for the generation filter.
selection- the selection.
Returns
a filllayer object.
from krita import *
i = InfoObject();
i.setProperty("pattern", "Cross01.pat")
s = Selection();
s.select(0, 0, d.width(), d.height(), 255)
n = d.createFillLayer("test", "pattern", i, s)
r = d.rootNode();
c = r.childNodes();
r.addChildNode(n, c[0])
d.refreshProjection()

Definition at line 670 of file Document.cpp.

◆ createFilterLayer

FilterLayer * Document::createFilterLayer ( const QString name,
Filter filter,
Selection selection 
)
slot

createFilterLayer creates a filter layer, which is a layer that represents a filter applied non-destructively.

Parameters
namename of the filterLayer
filterthe filter that this filter layer will us.
selectionthe selection.
Returns
a filter layer object.

Definition at line 661 of file Document.cpp.

◆ createFilterMask [1/2]

FilterMask * Document::createFilterMask ( const QString name,
Filter filter,
const Node selection_source 
)
slot

createFilterMask Creates a filter mask object that much like a filterlayer can apply a filter non-destructively.

Parameters
namethe name of the layer.
filterthe filter assigned.
selection_sourcea node from which the selection should be initialized
Returns
a FilterMask

Definition at line 708 of file Document.cpp.

◆ createFilterMask [2/2]

FilterMask * Document::createFilterMask ( const QString name,
Filter filter,
Selection selection 
)
slot

createFilterMask Creates a filter mask object that much like a filterlayer can apply a filter non-destructively.

Parameters
namethe name of the layer.
filterthe filter assigned.
selectionthe selection to be used by the filter mask
Returns
a FilterMask

Definition at line 730 of file Document.cpp.

◆ createGroupLayer

GroupLayer * Document::createGroupLayer ( const QString name)
slot

createGroupLayer Returns a grouplayer object.

Grouplayers are nodes that can have other layers as children and have the passthrough mode.

Parameters
namethe name of the layer.
Returns
a GroupLayer object.

Definition at line 643 of file Document.cpp.

◆ createNode

Node * Document::createNode ( const QString name,
const QString nodeType 
)
slot
   @brief createNode create a new node of the given type. The node is not added
   to the node hierarchy; you need to do that by finding the right parent node,
   getting its list of child nodes and adding the node in the right place, then
   calling Node::SetChildNodes

   @param name The name of the node

   @param nodeType The type of the node. Valid types are:
   <ul>
    <li>paintlayer
    <li>grouplayer
    <li>filelayer
    <li>filterlayer
    <li>filllayer
    <li>clonelayer
    <li>vectorlayer
    <li>transparencymask
    <li>filtermask
    <li>transformmask
    <li>selectionmask
   </ul>

   When relevant, the new Node will have the colorspace of the image by default;
   that can be changed with Node::setColorSpace.

   The settings and selections for relevant layer and mask types can also be set
   after the Node has been created.
d = Application.createDocument(1000, 1000, "Test", "RGBA", "U8", "", 120.0)
root = d.rootNode();
print(root.childNodes())
l2 = d.createNode("layer2", "paintLayer")
print(l2)
root.addChildNode(l2, None)
print(root.childNodes())
Returns
the new Node.

Definition at line 595 of file Document.cpp.

◆ createSelectionMask

SelectionMask * Document::createSelectionMask ( const QString name)
slot

createSelectionMask Creates a selection mask, which can be used to store selections.

Parameters
name- the name of the layer.
Returns
a SelectionMask

Definition at line 745 of file Document.cpp.

◆ createTransformMask

TransformMask * Document::createTransformMask ( const QString name)
slot

createTransformMask Creates a transform mask, which can be used to apply a transformation non-destructively.

Parameters
name- the name of the layer mask.
Returns
a TransformMask

Definition at line 763 of file Document.cpp.

◆ createTransparencyMask

TransparencyMask * Document::createTransparencyMask ( const QString name)
slot

createTransparencyMask Creates a transparency mask, which can be used to assign transparency to regions.

Parameters
name- the name of the layer.
Returns
a TransparencyMask

Definition at line 754 of file Document.cpp.

◆ createVectorLayer

VectorLayer * Document::createVectorLayer ( const QString name)
slot

createVectorLayer Creates a vector layer that can contain vector shapes.

Parameters
namethe name of this layer.
Returns
a VectorLayer.

Definition at line 699 of file Document.cpp.

◆ crop

void Document::crop ( int  x,
int  y,
int  w,
int  h 
)
slot

crop the image to rectangle described by x, y, w and h

Parameters
xx coordinate of the top left corner
yy coordinate of the top left corner
wwidth
hheight

Definition at line 492 of file Document.cpp.

◆ currentTime

int Document::currentTime ( )
slot

get current frame selected of animation

Returns
current frame selected of animation

Definition at line 1044 of file Document.cpp.

◆ documentInfo

QString Document::documentInfo ( ) const
slot

documentInfo creates and XML document representing document and author information.

Returns
a string containing a valid XML document with the right information about the document and author. The DTD can be found here:

https://phabricator.kde.org/source/krita/browse/master/krita/dtd/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document-info PUBLIC '-//KDE//DTD document-info 1.1//EN' 'http://www.calligra.org/DTD/document-info-1.1.dtd'>
<document-info xmlns="http://www.calligra.org/DTD/document-info">
<title>My Document</title>
<description></description>
<subject></subject>
<abstract><![CDATA[]]></abstract>
<keyword></keyword>
<initial-creator>Unknown</initial-creator>
<editing-cycles>1</editing-cycles>
<editing-time>35</editing-time>
<date>2017-02-27T20:15:09</date>
<creation-date>2017-02-27T20:14:33</creation-date>
<language></language>
</about>
<author>
<full-name>Boudewijn Rempt</full-name>
<initial></initial>
<author-title></author-title>
<email></email>
<telephone></telephone>
<telephone-work></telephone-work>
<fax></fax>
<postal-code></postal-code>
<city></city>
<street></street>
<position></position>
<company></company>
</author>
</document-info>

Definition at line 240 of file Document.cpp.

◆ exportImage

bool Document::exportImage ( const QString filename,
const InfoObject exportConfiguration 
)
slot

exportImage export the image, without changing its URL to the given path.

Parameters
filenamethe full path to which the image is to be saved
exportConfigurationa configuration object appropriate to the file format. An InfoObject will used to that configuration.

The supported formats have specific configurations that must be used when in batchmode. They are described below:

png

  • alpha: bool (True or False)
  • compression: int (1 to 9)
  • forceSRGB: bool (True or False)
  • indexed: bool (True or False)
  • interlaced: bool (True or False)
  • saveSRGBProfile: bool (True or False)
  • transparencyFillcolor: rgb (Ex:[255,255,255])

jpeg

  • baseline: bool (True or False)
  • exif: bool (True or False)
  • filters: bool (['ToolInfo', 'Anonymizer'])
  • forceSRGB: bool (True or False)
  • iptc: bool (True or False)
  • is_sRGB: bool (True or False)
  • optimize: bool (True or False)
  • progressive: bool (True or False)
  • quality: int (0 to 100)
  • saveProfile: bool (True or False)
  • smoothing: int (0 to 100)
  • subsampling: int (0 to 3)
  • transparencyFillcolor: rgb (Ex:[255,255,255])
  • xmp: bool (True or False)
Returns
true if the export succeeded, false if it failed.

Definition at line 502 of file Document.cpp.

◆ fileName

QString Document::fileName ( ) const
slot
Returns
the full path to the document, if it has been set.

Definition at line 258 of file Document.cpp.

◆ flatten

void Document::flatten ( )
slot

flatten all layers in the image

Definition at line 512 of file Document.cpp.

◆ framesPerSecond

int Document::framesPerSecond ( )
slot

frames per second of document

Returns
the fps of the document

Definition at line 960 of file Document.cpp.

◆ fullClipRangeEndTime

int Document::fullClipRangeEndTime ( )
slot

get the full clip range end time

Returns
full clip range end time

Definition at line 1003 of file Document.cpp.

◆ fullClipRangeStartTime

int Document::fullClipRangeStartTime ( )
slot

get the full clip range start time

Returns
full clip range start time

Definition at line 985 of file Document.cpp.

◆ guidesLocked()

bool Document::guidesLocked ( ) const

guidesLocked Returns guide lockedness.

Returns
whether the guides are locked.

Definition at line 859 of file Document.cpp.

◆ guidesVisible()

bool Document::guidesVisible ( ) const

guidesVisible Returns guide visibility.

Returns
whether the guides are visible.

Definition at line 854 of file Document.cpp.

◆ height

int Document::height ( ) const
slot
Returns
the height of the image in pixels

Definition at line 272 of file Document.cpp.

◆ horizontalGuides()

QList< qreal > Document::horizontalGuides ( ) const

horizontalGuides The horizontal guides.

Returns
a list of the horizontal positions of guides.

Definition at line 824 of file Document.cpp.

◆ importAnimation

bool Document::importAnimation ( const QList< QString > &  files,
int  firstFrame,
int  step 
)
slot

Import an image sequence of files from a directory.

This will grab all images from the directory and import them with a potential offset (firstFrame) and step (images on 2s, 3s, etc)

Returns
whether the animation import was successful

Definition at line 945 of file Document.cpp.

◆ lock

void Document::lock ( )
slot

[low-level] Lock the image without waiting for all the internal job queues are processed

WARNING: Don't use it unless you really know what you are doing! Use barrierLock() instead!

Waits for all the currently running internal jobs to complete and locks the image for writing. Please note that this function does not wait for all the internal queues to process, so there might be some non-finished actions pending. It means that you just postpone these actions until you unlock() the image back. Until then, then image might easily be frozen in some inconsistent state.

The only sane usage for this function is to lock the image for emergency processing, when some internal action or scheduler got hung up, and you just want to fetch some data from the image without races.

In all other cases, please use barrierLock() instead!

Definition at line 794 of file Document.cpp.

◆ modified

bool Document::modified ( ) const
slot

modified returns true if the document has unsaved modifications.

Definition at line 921 of file Document.cpp.

◆ name

QString Document::name ( ) const
slot
Returns
the name of the document. This is the title field in the documentInfo

Definition at line 291 of file Document.cpp.

◆ nodeByName

Node * Document::nodeByName ( const QString name) const
slot

nodeByName searches the node tree for a node with the given name and returns it

Parameters
namethe name of the node
Returns
the first node with the given name or 0 if no node is found

Definition at line 154 of file Document.cpp.

◆ nodeByUniqueID

Node * Document::nodeByUniqueID ( const QUuid id) const
slot

nodeByUniqueID searches the node tree for a node with the given name and returns it.

Parameters
uuidthe unique id of the node
Returns
the node with the given unique id, or 0 if no node is found.

Definition at line 162 of file Document.cpp.

◆ pixelData

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

pixelData reads the given rectangle from the image projection 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 image boundaries; those pixels will be transparent black.

The order of channels is:

  • Integer RGBA: Blue, Green, Red, Alpha
  • Float RGBA: Red, Green, Blue, Alpha
  • 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 image data. In Python, you can use bytes, bytearray and the struct module to interpret the data and construct, for instance, a Pillow Image object.

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 455 of file Document.cpp.

◆ playBackEndTime

int Document::playBackEndTime ( )
slot

get end time of current playback

Returns
end time of current playback

Definition at line 1036 of file Document.cpp.

◆ playBackStartTime

int Document::playBackStartTime ( )
slot

get start time of current playback

Returns
start time of current playback

Definition at line 1028 of file Document.cpp.

◆ projection

QImage Document::projection ( int  x = 0,
int  y = 0,
int  w = 0,
int  h = 0 
) const
slot

projection creates a QImage from the rendered image or a cutout rectangle.

Definition at line 781 of file Document.cpp.

◆ refreshProjection

void Document::refreshProjection ( )
slot

Starts a synchronous recomposition of the projection: everything will wait until the image is fully recomputed.

Definition at line 818 of file Document.cpp.

◆ removeAnnotation

void Document::removeAnnotation ( const QString type)
slot

removeAnnotation remove the specified annotation from the image

Parameters
typethe type defining the annotation

Definition at line 1114 of file Document.cpp.

◆ resizeImage

void Document::resizeImage ( int  x,
int  y,
int  w,
int  h 
)
slot

resizeImage resizes the canvas to the given left edge, top edge, width and height.

Note: This doesn't scale, use scale image for that.

Parameters
xthe new left edge
ythe new top edge
wthe new width
hthe new height

Definition at line 520 of file Document.cpp.

◆ resolution

int Document::resolution ( ) const
slot
Returns
the resolution in pixels per inch

Definition at line 304 of file Document.cpp.

◆ rootNode

Node * Document::rootNode ( ) const
slot

rootNode the root node is the invisible group layer that contains the entire node hierarchy.

Returns
the root of the image

Definition at line 327 of file Document.cpp.

◆ rotateImage

void Document::rotateImage ( double  radians)
slot

rotateImage Rotate the image by the given radians.

Parameters
radiansthe amount you wish to rotate the image in radians

Definition at line 551 of file Document.cpp.

◆ save

bool Document::save ( )
slot

save the image to its currently set path.

The modified flag of the document will be reset

Returns
true if saving succeeded, false otherwise.

Definition at line 569 of file Document.cpp.

◆ saveAs

bool Document::saveAs ( const QString filename)
slot

saveAs save the document under the filename.

The document's filename will be reset to filename.

Parameters
filenamethe new filename (full path) for the document
Returns
true if saving succeeded, false otherwise.

Definition at line 580 of file Document.cpp.

◆ scaleImage

void Document::scaleImage ( int  w,
int  h,
int  xres,
int  yres,
QString  strategy 
)
slot

scaleImage

Parameters
wthe new width
hthe new height
xresthe new xres
yresthe new yres
strategythe scaling strategy. There's several ones amongst these that aren't available in the regular UI. The list of filters is extensible and can be retrieved with Krita::filter
  • 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
  • Kanczos3 - Offers similar results than Bicubic, but maybe a little bit sharper. Can produce light and dark halos along strong edges.
  • Mitchell

Definition at line 535 of file Document.cpp.

◆ selection

Selection * Document::selection ( ) const
slot

selection Create a Selection object around the global selection, if there is one.

Returns
the global selection or None if there is no global selection.

Definition at line 336 of file Document.cpp.

◆ setActiveNode

void Document::setActiveNode ( Node value)
slot

setActiveNode make the given node active in the currently active view and window

Parameters
valuethe node to make active.

Definition at line 130 of file Document.cpp.

◆ setAnnotation

void Document::setAnnotation ( const QString type,
const QString description,
const QByteArray annotation 
)
slot

setAnnotation Add the given annotation to the document

Parameters
typethe unique type of the annotation
descriptionthe user-visible description of the annotation
annotationthe annotation itself

Definition at line 1106 of file Document.cpp.

◆ setBackgroundColor

bool Document::setBackgroundColor ( const QColor color)
slot

setBackgroundColor sets the background color of the document.

It will trigger a projection update.

Parameters
colorA QColor. The color will be converted from sRGB.
Returns
bool

Definition at line 226 of file Document.cpp.

◆ setBatchmode

void Document::setBatchmode ( bool  value)
slot

Set batchmode to value.

If batchmode is true, then there should be no popups or dialogs shown to the user.

Definition at line 107 of file Document.cpp.

◆ setColorProfile

bool Document::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
false if the colorProfile name does not correspond to to a registered profile or if assigning the profile failed.

Definition at line 191 of file Document.cpp.

◆ setColorSpace

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

setColorSpace convert the nodes and the image to the given colorspace.

The conversion is done with Perceptual as intent, High Quality and No LCMS Optimizations as flags and no blackpoint compensation.

Parameters
colorModelA string describing the color model of the image:
  • 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.
Returns
false the combination of these arguments does not correspond to a colorspace.

Definition at line 202 of file Document.cpp.

◆ setCurrentTime

void Document::setCurrentTime ( int  time)
slot

set current time of document's animation

Definition at line 1052 of file Document.cpp.

◆ setDocumentInfo

void Document::setDocumentInfo ( const QString document)
slot

setDocumentInfo set the Document information to the information contained in document

Parameters
documentA string containing a valid XML document that conforms to the document-info DTD that can be found here:

https://phabricator.kde.org/source/krita/browse/master/krita/dtd/

Definition at line 248 of file Document.cpp.

◆ setFileName

void Document::setFileName ( QString  value)
slot

setFileName set the full path of the document to

Parameters
value

Definition at line 264 of file Document.cpp.

◆ setFramesPerSecond

void Document::setFramesPerSecond ( int  fps)
slot

set frames per second of document

Definition at line 968 of file Document.cpp.

◆ setFullClipRangeEndTime

void Document::setFullClipRangeEndTime ( int  endTime)
slot

set full clip range end time

Definition at line 994 of file Document.cpp.

◆ setFullClipRangeStartTime

void Document::setFullClipRangeStartTime ( int  startTime)
slot

set start time of animation

Definition at line 976 of file Document.cpp.

◆ setGuidesLocked

void Document::setGuidesLocked ( bool  locked)
slot

setGuidesLocked set guides locked on this document

Parameters
lockedwhether or not to lock the guides on this document.

Definition at line 913 of file Document.cpp.

◆ setGuidesVisible

void Document::setGuidesVisible ( bool  visible)
slot

setGuidesVisible set guides visible on this document.

Parameters
visiblewhether or not the guides are visible.

Definition at line 905 of file Document.cpp.

◆ setHeight

void Document::setHeight ( int  value)
slot

setHeight resize the document to

Parameters
valueheight. This is a canvas resize, not a scale.

Definition at line 280 of file Document.cpp.

◆ setHorizontalGuides

void Document::setHorizontalGuides ( const QList< qreal > &  lines)
slot

setHorizontalGuides replace all existing horizontal guides with the entries in the list.

Parameters
linesa list of floats containing the new guides.

Definition at line 873 of file Document.cpp.

◆ setName

void Document::setName ( QString  value)
slot

setName sets the name of the document to value.

This is the title field in the documentInfo

Definition at line 297 of file Document.cpp.

◆ setPlayBackRange

void Document::setPlayBackRange ( int  start,
int  stop 
)
slot

set temporary playback range of document

Definition at line 1019 of file Document.cpp.

◆ setResolution

void Document::setResolution ( int  value)
slot

setResolution set the resolution of the image; this does not scale the image

Parameters
valuethe resolution in pixels per inch

Definition at line 313 of file Document.cpp.

◆ setSelection

void Document::setSelection ( Selection value)
slot

setSelection set or replace the global selection

Parameters
valuea valid selection object.

Definition at line 344 of file Document.cpp.

◆ setVerticalGuides

void Document::setVerticalGuides ( const QList< qreal > &  lines)
slot

setVerticalGuides replace all existing horizontal guides with the entries in the list.

Parameters
linesa list of floats containing the new guides.

Definition at line 889 of file Document.cpp.

◆ setWidth

void Document::setWidth ( int  value)
slot

setWidth resize the document to

Parameters
valuewidth. This is a canvas resize, not a scale.

Definition at line 365 of file Document.cpp.

◆ setXOffset

void Document::setXOffset ( int  x)
slot

setXOffset sets the left edge of the canvas to x.

Definition at line 384 of file Document.cpp.

◆ setXRes

void Document::setXRes ( double  xRes) const
slot

setXRes set the horizontal resolution of the image to xRes in pixels per inch

Definition at line 421 of file Document.cpp.

◆ setYOffset

void Document::setYOffset ( int  y)
slot

setYOffset sets the top edge of the canvas to y.

Definition at line 403 of file Document.cpp.

◆ setYRes

void Document::setYRes ( double  yRes) const
slot

setYRes set the vertical resolution of the image to yRes in pixels per inch

Definition at line 441 of file Document.cpp.

◆ shearImage

void Document::shearImage ( double  angleX,
double  angleY 
)
slot

shearImage shear the whole image.

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

Definition at line 560 of file Document.cpp.

◆ thumbnail

QImage Document::thumbnail ( int  w,
int  h 
) const
slot

thumbnail create a thumbnail of the given dimensions.

If the requested size is too big a null QImage is created.

Returns
a QImage representing the layer contents.

Definition at line 787 of file Document.cpp.

◆ topLevelNodes

QList< Node * > Document::topLevelNodes ( ) const
slot

toplevelNodes return a list with all top level nodes in the image graph

Definition at line 146 of file Document.cpp.

◆ tryBarrierLock

bool Document::tryBarrierLock ( )
slot

Tries to lock the image without waiting for the jobs to finish.

Same as barrierLock(), but doesn't block execution of the calling thread until all the background jobs are finished. Instead, in case of presence of unfinished jobs in the queue, it just returns false

Returns
whether the lock has been acquired

Definition at line 812 of file Document.cpp.

◆ unlock

void Document::unlock ( )
slot

Unlocks the image and starts/resumes all the pending internal jobs.

If the image has been locked for a non-readOnly access, then all the internal caches of the image (e.g. lod-planes) are reset and regeneration jobs are scheduled.

Definition at line 800 of file Document.cpp.

◆ verticalGuides()

QList< qreal > Document::verticalGuides ( ) const

verticalGuides The vertical guide lines.

Returns
a list of vertical guides.

Definition at line 839 of file Document.cpp.

◆ waitForDone

void Document::waitForDone ( )
slot

Wait for all the internal image jobs to complete and return without locking the image.

This function is handly for tests or other synchronous actions, when one needs to wait for the result of his actions.

Definition at line 806 of file Document.cpp.

◆ width

int Document::width ( ) const
slot
Returns
the width of the image in pixels.

Definition at line 357 of file Document.cpp.

◆ xOffset

int Document::xOffset ( ) const
slot
Returns
the left edge of the canvas in pixels.

Definition at line 376 of file Document.cpp.

◆ xRes

double Document::xRes ( ) const
slot
Returns
xRes the horizontal resolution of the image in pixels per inch

Definition at line 414 of file Document.cpp.

◆ yOffset

int Document::yOffset ( ) const
slot
Returns
the top edge of the canvas in pixels.

Definition at line 395 of file Document.cpp.

◆ yRes

double Document::yRes ( ) const
slot
Returns
yRes the vertical resolution of the image in pixels per inch

Definition at line 434 of file Document.cpp.


The documentation for this class was generated from the following files:
QAction * print(const QObject *recvr, const char *slot, QObject *parent)
InfoObject wrap a properties map.
Definition: InfoObject.h:19
KI18NLOCALEDATA_EXPORT KCountry country(const char *ianaId)
The Document class encapsulates a Krita Document/Image.
Definition: Document.h:33
Selection represents a selection on Krita.
Definition: Selection.h:30
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition: Krita.cpp:403
QString name() const
Definition: Document.cpp:291
Krita is a singleton class that offers the root access to the Krita object hierarchy.
Definition: Krita.h:27
void about(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
Document * activeDocument() const
Definition: Krita.cpp:104
KDB_EXPORT KDbVersionInfo version()
Node * createNode(const QString &name, const QString &nodeType)
Definition: Document.cpp:595
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:59:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.