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
 
qreal audioLevel () const
 
QList< QStringaudioTracks () const
 
bool autosave ()
 
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, const QString scalingFilter="Bicubic")
 
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 ()
 
GridConfiggridConfig ()
 
GuidesConfigguidesConfig ()
 
Q_DECL_DEPRECATED bool guidesLocked () const
 
Q_DECL_DEPRECATED bool guidesVisible () const
 
int height () const
 
Q_DECL_DEPRECATED QList< qreal > horizontalGuides () 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)
 
void setAudioLevel (const qreal level)
 
bool setAudioTracks (const QList< QString > files) const
 
void setAutosave (bool active)
 
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 setGridConfig (GridConfig *gridConfig)
 
void setGuidesConfig (GuidesConfig *guidesConfig)
 
Q_DECL_DEPRECATED void setGuidesLocked (bool locked)
 
Q_DECL_DEPRECATED void setGuidesVisible (bool visible)
 
void setHeight (int value)
 
Q_DECL_DEPRECATED void setHorizontalGuides (const QList< qreal > &lines)
 
void setModified (bool modified)
 
void setName (QString value)
 
void setPlayBackRange (int start, int stop)
 
void setResolution (int value)
 
void setSelection (Selection *value)
 
Q_DECL_DEPRECATED 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 ()
 
Q_DECL_DEPRECATED QList< qreal > verticalGuides () const
 
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 operator!= (const Document &other) const
 
bool operator== (const Document &other) const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
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 () const const
 
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 QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
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_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 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
 
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 setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- 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)
 
- 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 36 of file Document.h.

Constructor & Destructor Documentation

◆ Document()

Document::Document ( KisDocument * document,
bool ownsDocument,
QObject * parent = 0 )
explicit

Definition at line 79 of file Document.cpp.

◆ ~Document()

Document::~Document ( )
override

Definition at line 87 of file Document.cpp.

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

◆ animationLength

int Document::animationLength ( )
slot

get total frame range for animation

Returns
total frame range for animation

Definition at line 1051 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 1134 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 1127 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 1100 of file Document.cpp.

◆ audioLevel

qreal Document::audioLevel ( ) const
slot

Return current audio level for document.

Returns
A value between 0.0 and 1.0 (1.0 = 100%)

Definition at line 1277 of file Document.cpp.

◆ audioTracks

QList< QString > Document::audioTracks ( ) const
slot

Return a list of current audio tracks for document.

Returns
List of absolute path/file name of audio files

Definition at line 1287 of file Document.cpp.

◆ autosave

bool Document::autosave ( )
slot

Return autosave status for document Notes:

  • returned value is Autosave flag value Even if autosave is set to True, under condition Krita will not proceed to automatic save of document:
    • autosave is globally deactivated
    • document is read-only
  • When autosave is set to False, Krita never execute automatic save for document
Returns
True if autosave is active, otherwise False

Definition at line 1165 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 236 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 106 of file Document.cpp.

◆ bounds

QRect Document::bounds ( ) const
slot

bounds return the bounds of the image

Returns
the bounds

Definition at line 967 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.

We set ownsDocument to true, it will be reset automatically as soon as we create the first view for the document

Definition at line 891 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 488 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 192 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 198 of file Document.cpp.

◆ colorProfile

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

Definition at line 204 of file Document.cpp.

◆ createCloneLayer

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

createCloneLayer

Parameters
name
source
Returns

Definition at line 709 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 792 of file Document.cpp.

◆ createFileLayer

FileLayer * Document::createFileLayer ( const QString & name,
const QString fileName,
const QString scalingMethod,
const QString scalingFilter = "Bicubic" )
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"
scalingFilterfilter used to scale the file can be "Bicubic", "Hermite", "NearestNeighbor", "Bilinear", "Bell", "BSpline", "Lanczos3", "Mitchell"
Returns
a FileLayer

Definition at line 672 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 *
d = Krita.instance().activeDocument()
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()
Selection represents a selection on Krita.
Definition Selection.h:31

Definition at line 690 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 681 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 728 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 750 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 663 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())
Node * createNode(const QString &name, const QString &nodeType)
Definition Document.cpp:615
Returns
the new Node.

Definition at line 615 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 765 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 783 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 774 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 719 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 511 of file Document.cpp.

◆ currentTime

int Document::currentTime ( )
slot

get current frame selected of animation

Returns
current frame selected of animation

Definition at line 1084 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">
<about>
<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>
<country></country>
<postal-code></postal-code>
<city></city>
<street></street>
<position></position>
<company></company>
</author>
</document-info>
The Document class encapsulates a Krita Document/Image.
Definition Document.h:37
QString name() const
Definition Document.cpp:310

Definition at line 259 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 521 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 277 of file Document.cpp.

◆ flatten

void Document::flatten ( )
slot

flatten all layers in the image

Definition at line 531 of file Document.cpp.

◆ framesPerSecond

int Document::framesPerSecond ( )
slot

frames per second of document

Returns
the fps of the document

Definition at line 1000 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 1043 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 1025 of file Document.cpp.

◆ gridConfig

GridConfig * Document::gridConfig ( )
slot

Returns a GridConfig grid configuration for current document.

Returns
a GridConfig object with grid configuration

Definition at line 1263 of file Document.cpp.

◆ guidesConfig

GuidesConfig * Document::guidesConfig ( )
slot

Returns a GuidesConfig guides configuration for current document.

Returns
a GuidesConfig object with guides configuration

Definition at line 1170 of file Document.cpp.

◆ guidesLocked

bool Document::guidesLocked ( ) const
slot

DEPRECATED - use guidesConfig() instead Returns guide lockedness.

Returns
whether the guides are locked.

Definition at line 885 of file Document.cpp.

◆ guidesVisible

bool Document::guidesVisible ( ) const
slot

DEPRECATED - use guidesConfig() instead Returns guide visibility.

Returns
whether the guides are visible.

Definition at line 879 of file Document.cpp.

◆ height

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

Definition at line 291 of file Document.cpp.

◆ horizontalGuides

QList< qreal > Document::horizontalGuides ( ) const
slot

DEPRECATED - use guidesConfig() instead The horizontal guides.

Returns
a list of the horizontal positions of guides.

Definition at line 847 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 985 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 814 of file Document.cpp.

◆ modified

bool Document::modified ( ) const
slot

modified returns true if the document has unsaved modifications.

Definition at line 955 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 310 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 171 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 181 of file Document.cpp.

◆ operator!=()

bool Document::operator!= ( const Document & other) const

Definition at line 101 of file Document.cpp.

◆ operator==()

bool Document::operator== ( const Document & other) const

Definition at line 96 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 474 of file Document.cpp.

◆ playBackEndTime

int Document::playBackEndTime ( )
slot

get end time of current playback

Returns
end time of current playback

Definition at line 1076 of file Document.cpp.

◆ playBackStartTime

int Document::playBackStartTime ( )
slot

get start time of current playback

Returns
start time of current playback

Definition at line 1068 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 801 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 839 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 1154 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 539 of file Document.cpp.

◆ resolution

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

Definition at line 323 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 346 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 570 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 588 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 599 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 554 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 355 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.

If we created any nodes via the same script, then dummies state may be not synchronized with the actual state of the nodes in the image. Hence, we should explicitly deliver the synchronized events before we try to manipulate with the GUI representation of nodes.

Definition at line 138 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 1146 of file Document.cpp.

◆ setAudioLevel

void Document::setAudioLevel ( const qreal level)
slot

Set current audio level for document.

Parameters
levelAudio volumne between 0.0 and 1.0 (1.0 = 100%)

Definition at line 1282 of file Document.cpp.

◆ setAudioTracks

bool Document::setAudioTracks ( const QList< QString > files) const
slot

Set a list of audio tracks for document Note: the function allows to add more than one file while from Krita's UI, importing a file will replace the complete list.

The reason why this method let the ability to provide more than one file is related to the internal's Krita method from KisDocument class: void KisDocument::setAudioTracks(QVector<QFileInfo> f)

Parameters
filesList of absolute path/file name of audio files
Returns
True if all files from list have been added, otherwise False (a file was not found)

Definition at line 1296 of file Document.cpp.

◆ setAutosave

void Document::setAutosave ( bool active)
slot

Allow to activate/deactivate autosave for document When activated, it will use default Krita autosave settings It means that even when autosave is set to True, under condition Krita will not proceed to automatic save of document:

  • autosave is globally deactivated
  • document is read-only

Being able to deactivate autosave on a document can make sense when a plugin use internal document (document is not exposed in a view, only created for intenal process purposes)

Parameters
activeTrue to activate autosave

Definition at line 1160 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 245 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 112 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 210 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 221 of file Document.cpp.

◆ setCurrentTime

void Document::setCurrentTime ( int time)
slot

set current time of document's animation

Definition at line 1092 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 267 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 283 of file Document.cpp.

◆ setFramesPerSecond

void Document::setFramesPerSecond ( int fps)
slot

set frames per second of document

Definition at line 1008 of file Document.cpp.

◆ setFullClipRangeEndTime

void Document::setFullClipRangeEndTime ( int endTime)
slot

set full clip range end time

Definition at line 1034 of file Document.cpp.

◆ setFullClipRangeStartTime

void Document::setFullClipRangeStartTime ( int startTime)
slot

set start time of animation

Definition at line 1016 of file Document.cpp.

◆ setGridConfig

void Document::setGridConfig ( GridConfig * gridConfig)
slot
   @brief Set grid configuration for current document
   @param gridConfig a GridConfig object to apply for grid configuration

   To modify/set grid property on a document
# get document (create one or get active one for example)
newDoc = Krita.instance().createDocument(500, 500, "Test", "RGBA", "U8", "", 300)
# retrieve document grid configuration
newDocGrid = newDoc.gridConfig()
# update properties
newDocGrid.setColorMain(QColor('#ff00ff'))
newDocGrid.setLineTypeMain('dashed')
newDocGrid.setVisible(True)
newDocGrid.setAngleLeft(30)
newDocGrid.setAngleRight(15)
newDocGrid.setType('isometric')
# set grid configuration to document
newDoc.setGridConfig(newDocGrid)
GridConfig * gridConfig()
Returns a GridConfig grid configuration for current document.
void setColorMain(QColor colorMain)
Set grid main line color.
Krita is a singleton class that offers the root access to the Krita object hierarchy.
Definition Krita.h:28
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:402
Document * createDocument(int width, int height, const QString &name, const QString &colorModel, const QString &colorDepth, const QString &profile, double resolution)
Definition Krita.cpp:329

Definition at line 1270 of file Document.cpp.

◆ setGuidesConfig

void Document::setGuidesConfig ( GuidesConfig * guidesConfig)
slot
   @brief Set guides configuration for current document
   @param guidesConfig a GuidesConfig object to apply for guides configuration

   To modify/set guides property on a document
# get document (create one or get active one for example)
newDoc = Krita.instance().createDocument(500, 500, "Test", "RGBA", "U8", "", 300)
# retrieve document guides configuration
newDocGuides = newDoc.guidesConfig()
# update properties
newDocGuides.setColor(QColor('#ff00ff'))
newDocGuides.setLineType('dotted')
newDocGuides.setVisible(True)
newDocGuides.setLocked(True)
newDocGuides.setSnap(True)
newDocGuides.setHorizontalGuides([100,200])
# set guides configuration to document
newDoc.setGuidesConfig(newDocGuides)
GuidesConfig * guidesConfig()
Returns a GuidesConfig guides configuration for current document.
void setColor(const QColor &color) const
Define guides color.

Definition at line 1225 of file Document.cpp.

◆ setGuidesLocked

void Document::setGuidesLocked ( bool locked)
slot

DEPRECATED - use guidesConfig() instead set guides locked on this document.

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

Definition at line 946 of file Document.cpp.

◆ setGuidesVisible

void Document::setGuidesVisible ( bool visible)
slot

DEPRECATED - use guidesConfig() instead set guides visible on this document.

Parameters
visiblewhether or not the guides are visible.

Definition at line 937 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 299 of file Document.cpp.

◆ setHorizontalGuides

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

DEPRECATED - use guidesConfig() instead replace all existing horizontal guides with the entries in the list.

Parameters
linesa list of floats containing the new guides.

Definition at line 903 of file Document.cpp.

◆ setModified

void Document::setModified ( bool modified)
slot

setModified sets the modified status of the document

Parameters
modifiedif true, the document is considered modified and closing it will ask for saving.

Definition at line 961 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 316 of file Document.cpp.

◆ setPlayBackRange

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

set temporary playback range of document

Definition at line 1059 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 332 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 363 of file Document.cpp.

◆ setVerticalGuides

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

DEPRECATED - use guidesConfig() instead replace all existing horizontal guides with the entries in the list.

Parameters
linesa list of floats containing the new guides.

Definition at line 920 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 384 of file Document.cpp.

◆ setXOffset

void Document::setXOffset ( int x)
slot

setXOffset sets the left edge of the canvas to x.

Definition at line 403 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 440 of file Document.cpp.

◆ setYOffset

void Document::setYOffset ( int y)
slot

setYOffset sets the top edge of the canvas to y.

Definition at line 422 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 460 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 579 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 807 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 163 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 833 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 820 of file Document.cpp.

◆ verticalGuides

QList< qreal > Document::verticalGuides ( ) const
slot

DEPRECATED - use guidesConfig() instead The vertical guide lines.

Returns
a list of vertical guides.

Definition at line 863 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 handy for tests or other synchronous actions, when one needs to wait for the result of his actions.

Definition at line 826 of file Document.cpp.

◆ width

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

Definition at line 376 of file Document.cpp.

◆ xOffset

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

Definition at line 395 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 433 of file Document.cpp.

◆ yOffset

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

Definition at line 414 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 453 of file Document.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.