125 if (view && view->document() ==
d->
document) {
126 activeNodes << view->currentNode();
130 if (activeNodes.size() > 0) {
132 return nodes.first();
141 if (!
value->node())
return;
143 if (!mainWin)
return;
145 if (!viewManager)
return;
148 if (!nodeManager)
return;
150 if (!selectionAdapter)
return;
176 if (node.
isNull())
return 0;
187 if (node.
isNull())
return 0;
195 return d->
document->image()->colorSpace()->colorDepthId().id();
201 return d->
document->image()->colorSpace()->colorModelId().id();
207 return d->
document->image()->colorSpace()->profile()->name();
215 if (!profile)
return false;
216 bool retval =
d->
document->image()->assignImageProfile(profile);
226 if (!colorSpace)
return false;
228 d->
document->image()->convertImageColorSpace(colorSpace,
239 if (!
d->
document->image())
return QColor();
251 d->
document->image()->setDefaultProjectionColor(background);
253 d->
document->image()->setModifiedWithoutUndo();
254 d->
document->image()->initialRefreshGraph();
262 ,
"document-info" ,
"1.1");
263 doc =
d->
document->documentInfo()->save(doc);
264 return doc.toString();
271 int errorLine, errorColumn;
272 doc.setContent(document, &errorMsg, &errorLine, &errorColumn);
287 d->
document->setMimeType(mimeType.toLatin1());
295 if (!image)
return 0;
313 return d->
document->documentInfo()->aboutInfo(
"title");
327 if (!image)
return 0;
329 return qRound(
d->
document->image()->xRes() * 72);
350 if (!image)
return 0;
359 if (!
d->
document->image()->globalSelection())
return 0;
380 if (!image)
return 0;
381 return image->
width();
399 if (!image)
return 0;
400 return image->
bounds().x();
418 if (!image)
return 0;
419 return image->
bounds().y();
437 return d->
document->image()->xRes()*72.0;
457 return d->
document->image()->yRes()*72.0;
480 if (!image)
return ba;
484 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
490 bool retval =
d->
document->closePath(
false);
516 QRect rc(x, y, w, h);
526 const QByteArray outputFormat = outputFormatString.toLatin1();
559 QRect rc = image->
bounds();
566 image->
scaleImage(rc.size(), xres / 72.0, yres / 72.0, actualStrategy);
584 image->
shear(angleX, angleY);
591 if (
d->
document->path().isEmpty())
return false;
593 bool retval =
d->
document->save(
true, 0);
605 const QByteArray outputFormat = outputFormatString.toLatin1();
608 bool retval =
d->
document->saveAs(filename, outputFormat,
true);
623 if (
nodeType.toLower()==
"paintlayer") {
626 else if (
nodeType.toLower() ==
"grouplayer") {
629 else if (
nodeType.toLower() ==
"filelayer") {
632 else if (
nodeType.toLower() ==
"filterlayer") {
635 else if (
nodeType.toLower() ==
"filllayer") {
638 else if (
nodeType.toLower() ==
"clonelayer") {
641 else if (
nodeType.toLower() ==
"vectorlayer") {
644 else if (
nodeType.toLower() ==
"transparencymask") {
647 else if (
nodeType.toLower() ==
"filtermask") {
650 else if (
nodeType.toLower() ==
"transformmask") {
653 else if (
nodeType.toLower() ==
"selectionmask") {
656 else if (
nodeType.toLower() ==
"colorizemask") {
700 Q_FOREACH(
const QString property, configuration.
properties().keys()) {
701 config->setProperty(property, configuration.
property(property));
736 if(!selection_source)
745 qobject_cast<KisMask*>(mask->
node().
data())->initSelection(layer);
804 return d->
document->image()->convertToQImage(x, y, w, h, 0);
810 return d->
document->generatePreview(QSize(w, h)).toImage();
836 return d->
document->image()->tryBarrierLock();
842 d->
document->image()->refreshGraphAsync();
849 warnScript <<
"DEPRECATED Document.horizontalGuides() - use Document.guidesConfig().horizontalGuides() instead";
852 const QTransform documentToImage =
856 for (
int i = 0; i< untransformedLines.size(); i++) {
857 qreal line = untransformedLines[i];
858 lines.append(documentToImage.map(QPointF(line, line)).x());
865 warnScript <<
"DEPRECATED Document.verticalGuides() - use Document.guidesConfig().verticalGuides() instead";
868 const QTransform documentToImage =
871 for (
int i = 0; i< untransformedLines.size(); i++) {
872 qreal line = untransformedLines[i];
873 lines.append(documentToImage.map(QPointF(line, line)).y());
880 warnScript <<
"DEPRECATED Document.guidesVisible() - use Document.guidesConfig().visible() instead";
881 return d->
document->guidesConfig().showGuides();
886 warnScript <<
"DEPRECATED Document.guidesLocked() - use Document.guidesConfig().locked() instead";
887 return d->
document->guidesConfig().lockGuides();
904 warnScript <<
"DEPRECATED Document.setHorizontalGuides() - use Document.guidesConfig().setHorizontalGuides() instead";
907 const QTransform imageToDocument =
908 QTransform::fromScale(1.0 /
d->
document->image()->xRes(), 1.0 /
d->
document->image()->yRes());
910 for (
int i = 0; i< lines.size(); i++) {
911 qreal line = lines[i];
912 transformedLines.append(imageToDocument.map(QPointF(line, line)).x());
920 warnScript <<
"DEPRECATED Document.setVerticalGuides() - use Document.guidesConfig().setVerticalGuides() instead";
923 const QTransform imageToDocument =
924 QTransform::fromScale(1.0 /
d->
document->image()->xRes(), 1.0 /
d->
document->image()->yRes());
926 for (
int i = 0; i< lines.size(); i++) {
927 qreal line = lines[i];
928 transformedLines.append(imageToDocument.map(QPointF(line, line)).y());
936 warnScript <<
"DEPRECATED Document.setGuidesVisible() - use Document.guidesConfig().setVisible() instead";
945 warnScript <<
"DEPRECATED Document.setGuidesLocked() - use Document.guidesConfig().setLocked() instead";
987 if (activeView &&
d->
document->fileBatchMode()) {
994 return status.
isOk();
1000 if (!
d->
document->image())
return false;
1002 return d->
document->image()->animationInterface()->framerate();
1010 d->
document->image()->animationInterface()->setFramerate(fps);
1018 d->
document->image()->animationInterface()->setDocumentRangeStartFrame(startTime);
1025 if (!
d->
document->image())
return false;
1027 return d->
document->image()->animationInterface()->documentPlaybackRange().start();
1036 d->
document->image()->animationInterface()->setDocumentRangeEndFrame(endTime);
1043 if (!
d->
document->image())
return false;
1045 return d->
document->image()->animationInterface()->documentPlaybackRange().end();
1051 if (!
d->
document->image())
return false;
1053 return d->
document->image()->animationInterface()->totalLength();
1062 d->
document->image()->animationInterface()->setActivePlaybackRange(newTimeRange);
1068 if (!
d->
document->image())
return false;
1070 return d->
document->image()->animationInterface()->activePlaybackRange().start();
1076 if (!
d->
document->image())
return false;
1078 return d->
document->image()->animationInterface()->activePlaybackRange().end();
1084 if (!
d->
document->image())
return false;
1086 return d->
document->image()->animationInterface()->currentTime();
1094 return d->
document->image()->animationInterface()->requestTimeSwitchWithUndo(time);
1111 while (it != endIt) {
1112 if (!(*it) || (*it)->type().isEmpty()) {
1113 qWarning() <<
"Warning: empty annotation";
1117 types << (*it)->type();
1139 return QByteArray();
1192 const QTransform documentToImage =
1196 for (
int i = 0; i< untransformedLines.size(); i++) {
1197 qreal untransformedLine = untransformedLines[i];
1198 transformedLines.append(documentToImage.map(QPointF(untransformedLine, untransformedLine)).x());
1202 transformedLines.clear();
1204 for (
int i = 0; i< untransformedLines.size(); i++) {
1205 qreal untransformedLine = untransformedLines[i];
1206 transformedLines.append(documentToImage.map(QPointF(untransformedLine, untransformedLine)).y());
1227 const QTransform imageToDocument =
1228 QTransform::fromScale(1.0 /
d->
document->image()->xRes(), 1.0 /
d->
document->image()->yRes());
1231 for (
int i = 0; i< untransformedLines.size(); i++) {
1232 qreal untransformedLine = untransformedLines[i];
1233 transformedLines.append(imageToDocument.map(QPointF(untransformedLine, untransformedLine)).x());
1237 transformedLines.clear();
1239 for (
int i = 0; i< untransformedLines.size(); i++) {
1240 qreal untransformedLine = untransformedLines[i];
1241 transformedLines.append(imageToDocument.map(QPointF(untransformedLine, untransformedLine)).x());
1250 d->
document->setGuidesConfig(tmpConfig);
1281 Q_FOREACH(QFileInfo fileInfo,
d->
document->getAudioTracks()) {
1282 fileList.append(fileInfo.absoluteFilePath());
1289 bool returned =
true;
1292 Q_FOREACH(QString
fileName, files) {
1294 if (fileInfo.exists()) {
1296 fileList.append(fileInfo);
float value(const T *src, size_t ch)
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
QList< QString > QStringList
const quint8 OPACITY_OPAQUE_U8
char nodeType(const KoPathPoint *point)
The CloneLayer class A clone layer is a layer that takes a reference inside the image and shows the e...
The ColorizeMask class A colorize mask is a mask type node that can be used to color in line art.
QImage projection(int x=0, int y=0, int w=0, int h=0) const
projection creates a QImage from the rendered image or a cutout rectangle.
Q_DECL_DEPRECATED bool guidesVisible() const
DEPRECATED - use guidesConfig() instead Returns guide visibility.
TransformMask * createTransformMask(const QString &name)
createTransformMask Creates a transform mask, which can be used to apply a transformation non-destruc...
int animationLength()
get total frame range for animation
Q_DECL_DEPRECATED void setGuidesLocked(bool locked)
DEPRECATED - use guidesConfig() instead set guides locked on this document.
void setGuidesConfig(GuidesConfig *guidesConfig)
void setFramesPerSecond(int fps)
set frames per second of document
void setFullClipRangeEndTime(int endTime)
set full clip range end time
QPointer< KisDocument > document() const
void setSelection(Selection *value)
setSelection set or replace the global selection
void setFullClipRangeStartTime(int startTime)
set start time of animation
SelectionMask * createSelectionMask(const QString &name)
createSelectionMask Creates a selection mask, which can be used to store selections.
QList< Node * > topLevelNodes() const
toplevelNodes return a list with all top level nodes in the image graph
int currentTime()
get current frame selected of animation
bool close()
close Close the document: remove it from Krita's internal list of documents and close all views....
bool modified() const
modified returns true if the document has unsaved modifications.
void setDocumentInfo(const QString &document)
setDocumentInfo set the Document information to the information contained in document
int fullClipRangeEndTime()
get the full clip range end time
QImage thumbnail(int w, int h) const
thumbnail create a thumbnail of the given dimensions.
ColorizeMask * createColorizeMask(const QString &name)
createColorizeMask Creates a colorize mask, which can be used to color fill via keystrokes.
void flatten()
flatten all layers in the image
void setXOffset(int x)
setXOffset sets the left edge of the canvas to x.
bool importAnimation(const QList< QString > &files, int firstFrame, int step)
Import an image sequence of files from a directory. This will grab all images from the directory and ...
int fullClipRangeStartTime()
get the full clip range start time
bool setBackgroundColor(const QColor &color)
setBackgroundColor sets the background color of the document. It will trigger a projection update.
void setActiveNode(Node *value)
setActiveNode make the given node active in the currently active view and window
void setYOffset(int y)
setYOffset sets the top edge of the canvas to y.
void setGridConfig(GridConfig *gridConfig)
Q_DECL_DEPRECATED void setHorizontalGuides(const QList< qreal > &lines)
DEPRECATED - use guidesConfig() instead replace all existing horizontal guides with the entries in th...
QString colorProfile() const
void resizeImage(int x, int y, int w, int h)
resizeImage resizes the canvas to the given left edge, top edge, width and height....
Node * rootNode() const
rootNode the root node is the invisible group layer that contains the entire node hierarchy.
QString colorModel() const
colorModel retrieve the current color model of this document:
bool setAudioTracks(const QList< QString > files) const
Set a list of audio tracks for document Note: the function allows to add more than one file while fro...
bool operator!=(const Document &other) const
bool saveAs(const QString &filename)
saveAs save the document under the filename. The document's filename will be reset to filename.
Node * activeNode() const
activeNode retrieve the node that is currently active in the currently active window
QStringList annotationTypes() const
annotationTypes returns the list of annotations present in the document. Each annotation type is uniq...
Document(KisDocument *document, bool ownsDocument, QObject *parent=0)
void rotateImage(double radians)
rotateImage Rotate the image by the given radians.
int playBackEndTime()
get end time of current playback
FillLayer * createFillLayer(const QString &name, const QString generatorName, InfoObject &configuration, Selection &selection)
createFillLayer creates a fill layer object, which is a layer
bool setColorProfile(const QString &colorProfile)
setColorProfile set the color profile of the image to the given profile. The profile has to be regist...
void setPlayBackRange(int start, int stop)
set temporary playback range of document
GuidesConfig * guidesConfig()
Returns a GuidesConfig guides configuration for current document.
void scaleImage(int w, int h, int xres, int yres, QString strategy)
scaleImage
void setAudioLevel(const qreal level)
Set current audio level for document.
void setAutosave(bool active)
Allow to activate/deactivate autosave for document When activated, it will use default Krita autosave...
bool operator==(const Document &other) const
Document * clone() const
clone create a shallow clone of this document.
void setName(QString value)
setName sets the name of the document to value. This is the title field in the documentInfo
void setXRes(double xRes) const
setXRes set the horizontal resolution of the image to xRes in pixels per inch
CloneLayer * createCloneLayer(const QString &name, const Node *source)
createCloneLayer
qreal audioLevel() const
Return current audio level for document.
bool setColorSpace(const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
setColorSpace convert the nodes and the image to the given colorspace. The conversion is done with Pe...
void removeAnnotation(const QString &type)
removeAnnotation remove the specified annotation from the image
Q_DECL_DEPRECATED void setGuidesVisible(bool visible)
DEPRECATED - use guidesConfig() instead set guides visible on this document.
void setModified(bool modified)
setModified sets the modified status of the document
Q_DECL_DEPRECATED QList< qreal > verticalGuides() const
DEPRECATED - use guidesConfig() instead The vertical guide lines.
Q_DECL_DEPRECATED bool guidesLocked() const
DEPRECATED - use guidesConfig() instead Returns guide lockedness.
QString documentInfo() const
documentInfo creates and XML document representing document and author information.
Node * nodeByUniqueID(const QUuid &id) const
nodeByUniqueID searches the node tree for a node with the given name and returns it.
VectorLayer * createVectorLayer(const QString &name)
createVectorLayer Creates a vector layer that can contain vector shapes.
Node * createNode(const QString &name, const QString &nodeType)
Q_DECL_DEPRECATED QList< qreal > horizontalGuides() const
DEPRECATED - use guidesConfig() instead The horizontal guides.
void setWidth(int value)
setWidth resize the document to
GridConfig * gridConfig()
Returns a GridConfig grid configuration for current document.
Q_DECL_DEPRECATED void setVerticalGuides(const QList< qreal > &lines)
DEPRECATED - use guidesConfig() instead replace all existing horizontal guides with the entries in th...
bool tryBarrierLock()
Tries to lock the image without waiting for the jobs to finish.
QString colorDepth() const
bool save()
save the image to its currently set path. The modified flag of the document will be reset
void setYRes(double yRes) const
setYRes set the vertical resolution of the image to yRes in pixels per inch
bool autosave()
Return autosave status for document Notes:
void setFileName(QString value)
setFileName set the full path of the document to
FileLayer * createFileLayer(const QString &name, const QString fileName, const QString scalingMethod, const QString scalingFilter="Bicubic")
createFileLayer returns a layer that shows an external image.
int playBackStartTime()
get start time of current playback
TransparencyMask * createTransparencyMask(const QString &name)
createTransparencyMask Creates a transparency mask, which can be used to assign transparency to regio...
bool exportImage(const QString &filename, const InfoObject &exportConfiguration)
exportImage export the image, without changing its URL to the given path.
void setBatchmode(bool value)
void setAnnotation(const QString &type, const QString &description, const QByteArray &annotation)
setAnnotation Add the given annotation to the document
int framesPerSecond()
frames per second of document
void crop(int x, int y, int w, int h)
crop the image to rectangle described by x, y, w and h
Selection * selection() const
selection Create a Selection object around the global selection, if there is one.
void setResolution(int value)
setResolution set the resolution of the image; this does not scale the image
QColor backgroundColor()
backgroundColor returns the current background color of the document. The color will also include the...
QByteArray pixelData(int x, int y, int w, int h) const
pixelData reads the given rectangle from the image projection and returns it as a byte array....
QRect bounds() const
bounds return the bounds of the image
QString annotationDescription(const QString &type) const
annotationDescription gets the pretty description for the current annotation
void shearImage(double angleX, double angleY)
shearImage shear the whole image.
FilterLayer * createFilterLayer(const QString &name, Filter &filter, Selection &selection)
createFilterLayer creates a filter layer, which is a layer that represents a filter applied non-destr...
Node * nodeByName(const QString &name) const
nodeByName searches the node tree for a node with the given name and returns it
QList< QString > audioTracks() const
Return a list of current audio tracks for document.
FilterMask * createFilterMask(const QString &name, Filter &filter, Selection &selection)
createFilterMask Creates a filter mask object that much like a filterlayer can apply a filter non-des...
QByteArray annotation(const QString &type)
annotation the actual data for the annotation for this type. It's a simple QByteArray,...
void setCurrentTime(int time)
set current time of document's animation
GroupLayer * createGroupLayer(const QString &name)
createGroupLayer Returns a grouplayer object. Grouplayers are nodes that can have other layers as chi...
void setHeight(int value)
setHeight resize the document to
void setOwnsDocument(bool ownsDocument)
The FileLayer class A file layer is a layer that can reference an external image and show said refere...
The FillLayer class A fill layer is much like a filter layer in that it takes a name and filter....
The FilterLayer class A filter layer will, when compositing, take the composited image up to the poin...
The FilterMask class A filter mask, unlike a filter layer, will add a non-destructive filter to the c...
KisGridConfig gridConfig() const
The GroupLayer class A group layer is a layer that can contain other layers. In Krita,...
KisGuidesConfig guidesConfig() const
QVariant property(const QString &key)
QMap< QString, QVariant > properties() const
KisPropertiesConfigurationSP configuration() const
configuration gives access to the internal configuration object. Must be used internally in libkis
KisImportExportErrorCode import(QStringList files, int firstFrame, int step, bool autoAddHoldframes=false, bool startfrom0=false, int isAscending=0, bool assignDocumentProfile=false, QList< int > optionalKeyframeTimeList={})
A data extension mechanism for Krita.
QDomDocument createDomDocument(const QString &tagName, const QString &version) const
The KisFileLayer class loads a particular file as a layer into the layer stack.
static KisFilterStrategyRegistry * instance()
static KisGeneratorRegistry * instance()
static KisResourcesInterfaceSP instance()
void setHorizontalGuideLines(const QList< qreal > &lines)
Set the positions of the horizontal guide lines.
void setShowGuides(bool value)
const QList< qreal > & verticalGuideLines() const
Returns the list of vertical guide lines.
void setLockGuides(bool value)
void setVerticalGuideLines(const QList< qreal > &lines)
Set the positions of the vertical guide lines.
const QList< qreal > & horizontalGuideLines() const
Returns the list of horizontal guide lines.
void resizeImage(const QRect &newRect)
start asynchronous operation on resizing the image
vKisAnnotationSP_it endAnnotations()
void addAnnotation(KisAnnotationSP annotation)
void shear(double angleX, double angleY)
start asynchronous operation on shearing the image
KisAnnotationSP annotation(const QString &type)
void rotateImage(double radians)
start asynchronous operation on rotating the image
KisPaintDeviceSP projection() const
void scaleImage(const QSize &size, qreal xres, qreal yres, KisFilterStrategy *filterStrategy)
start asynchronous operation on scaling the image
void cropImage(const QRect &newRect)
start asynchronous operation on cropping the image
void removeAnnotation(const QString &type)
QRect bounds() const override
vKisAnnotationSP_it beginAnnotations()
QPointer< KisView > activeView
KisViewManager * viewManager
static QString mimeTypeForFile(const QString &file, bool checkExistingFiles=true)
Find the mimetype for the given filename. The filename must include a suffix.
KisNodeSelectionAdapter * nodeSelectionAdapter() const
void setActiveNode(KisNodeSP node)
quint32 pixelSize() const
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
static KisPart * instance()
KisMainWindow * currentMainwindow() const
void removeDocument(KisDocument *document, bool deleteDocument=true)
static void forceDeliverAllSynchronizedEvents()
static KisTimeSpan fromTimeWithDuration(int start, int duration)
KisDocument * document() const
QPointer< KoUpdater > createUnthreadedUpdater(const QString &name)
create a new progress updater
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
KisViewManager * viewManager
QPointer< KisDocument > document
void toQColor(QColor *c) const
a convenience method for the above.
const T value(const QString &id) const
T get(const QString &id) const
QList< Node * > childNodes() const
childNodes
static Node * createNode(KisImageSP image, KisNodeSP node, QObject *parent=0)
The SelectionMask class A selection mask is a mask type node that can be used to store selections....
KisSelectionSP selection() const
The TransparencyMask class A transparency mask is a mask type node that can be used to show and hide ...
The VectorLayer class A vector layer is a special layer that stores and shows vector shapes.
This file is part of the Krita application in calligra.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
vKisAnnotationSP::iterator vKisAnnotationSP_it
KisNodeSP findNodeByName(KisNodeSP root, const QString &name)
KisNodeSP findNodeByUuid(KisNodeSP root, const QUuid &uuid)
void forceAllDelayedNodesUpdate(KisNodeSP root)
QList< Node * > createNodeList(KisNodeList kisnodes, KisImageWSP image)
QPointer< KisDocument > document
virtual KisFilterConfigurationSP factoryConfiguration(KisResourcesInterfaceSP resourcesInterface) const
const KoColorProfile * profileByName(const QString &name) const
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()