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();
270 doc.setContent(document);
285 d->
document->setMimeType(mimeType.toLatin1());
293 if (!image)
return 0;
311 return d->
document->documentInfo()->aboutInfo(
"title");
325 if (!image)
return 0;
327 return qRound(
d->
document->image()->xRes() * 72);
348 if (!image)
return 0;
357 if (!
d->
document->image()->globalSelection())
return 0;
378 if (!image)
return 0;
379 return image->
width();
397 if (!image)
return 0;
398 return image->
bounds().x();
416 if (!image)
return 0;
417 return image->
bounds().y();
435 return d->
document->image()->xRes()*72.0;
455 return d->
document->image()->yRes()*72.0;
478 if (!image)
return ba;
482 dev->
readBytes(
reinterpret_cast<quint8*
>(ba.data()), x, y, w, h);
488 bool retval =
d->
document->closePath(
false);
514 QRect rc(x, y, w, h);
524 const QByteArray outputFormat = outputFormatString.toLatin1();
557 QRect rc = image->
bounds();
564 image->
scaleImage(rc.size(), xres / 72.0, yres / 72.0, actualStrategy);
582 image->
shear(angleX, angleY);
589 if (
d->
document->path().isEmpty())
return false;
591 bool retval =
d->
document->save(
true, 0);
603 const QByteArray outputFormat = outputFormatString.toLatin1();
606 bool retval =
d->
document->saveAs(filename, outputFormat,
true);
621 if (
nodeType.toLower()==
"paintlayer") {
624 else if (
nodeType.toLower() ==
"grouplayer") {
627 else if (
nodeType.toLower() ==
"filelayer") {
630 else if (
nodeType.toLower() ==
"filterlayer") {
633 else if (
nodeType.toLower() ==
"filllayer") {
636 else if (
nodeType.toLower() ==
"clonelayer") {
639 else if (
nodeType.toLower() ==
"vectorlayer") {
642 else if (
nodeType.toLower() ==
"transparencymask") {
645 else if (
nodeType.toLower() ==
"filtermask") {
648 else if (
nodeType.toLower() ==
"transformmask") {
651 else if (
nodeType.toLower() ==
"selectionmask") {
654 else if (
nodeType.toLower() ==
"colorizemask") {
698 Q_FOREACH(
const QString property, configuration.
properties().keys()) {
699 config->setProperty(property, configuration.
property(property));
734 if(!selection_source)
743 qobject_cast<KisMask*>(mask->
node().
data())->initSelection(layer);
802 return d->
document->image()->convertToQImage(x, y, w, h, 0);
808 return d->
document->generatePreview(QSize(w, h)).toImage();
834 return d->
document->image()->tryBarrierLock();
840 d->
document->image()->refreshGraphAsync();
847 warnScript <<
"DEPRECATED Document.horizontalGuides() - use Document.guidesConfig().horizontalGuides() instead";
850 const QTransform documentToImage =
854 for (
int i = 0; i< untransformedLines.size(); i++) {
855 qreal line = untransformedLines[i];
856 lines.append(documentToImage.map(QPointF(line, line)).x());
863 warnScript <<
"DEPRECATED Document.verticalGuides() - use Document.guidesConfig().verticalGuides() instead";
866 const QTransform documentToImage =
869 for (
int i = 0; i< untransformedLines.size(); i++) {
870 qreal line = untransformedLines[i];
871 lines.append(documentToImage.map(QPointF(line, line)).y());
878 warnScript <<
"DEPRECATED Document.guidesVisible() - use Document.guidesConfig().visible() instead";
879 return d->
document->guidesConfig().showGuides();
884 warnScript <<
"DEPRECATED Document.guidesLocked() - use Document.guidesConfig().locked() instead";
885 return d->
document->guidesConfig().lockGuides();
902 warnScript <<
"DEPRECATED Document.setHorizontalGuides() - use Document.guidesConfig().setHorizontalGuides() instead";
905 const QTransform imageToDocument =
906 QTransform::fromScale(1.0 /
d->
document->image()->xRes(), 1.0 /
d->
document->image()->yRes());
908 for (
int i = 0; i< lines.size(); i++) {
909 qreal line = lines[i];
910 transformedLines.append(imageToDocument.map(QPointF(line, line)).x());
918 warnScript <<
"DEPRECATED Document.setVerticalGuides() - use Document.guidesConfig().setVerticalGuides() instead";
921 const QTransform imageToDocument =
922 QTransform::fromScale(1.0 /
d->
document->image()->xRes(), 1.0 /
d->
document->image()->yRes());
924 for (
int i = 0; i< lines.size(); i++) {
925 qreal line = lines[i];
926 transformedLines.append(imageToDocument.map(QPointF(line, line)).y());
934 warnScript <<
"DEPRECATED Document.setGuidesVisible() - use Document.guidesConfig().setVisible() instead";
943 warnScript <<
"DEPRECATED Document.setGuidesLocked() - use Document.guidesConfig().setLocked() instead";
985 if (activeView &&
d->
document->fileBatchMode()) {
992 return status.
isOk();
1000 return d->
document->image()->animationInterface()->framerate();
1008 d->
document->image()->animationInterface()->setFramerate(fps);
1016 d->
document->image()->animationInterface()->setDocumentRangeStartFrame(startTime);
1023 if (!
d->
document->image())
return false;
1025 return d->
document->image()->animationInterface()->documentPlaybackRange().start();
1034 d->
document->image()->animationInterface()->setDocumentRangeEndFrame(endTime);
1041 if (!
d->
document->image())
return false;
1043 return d->
document->image()->animationInterface()->documentPlaybackRange().end();
1049 if (!
d->
document->image())
return false;
1051 return d->
document->image()->animationInterface()->totalLength();
1060 d->
document->image()->animationInterface()->setActivePlaybackRange(newTimeRange);
1066 if (!
d->
document->image())
return false;
1068 return d->
document->image()->animationInterface()->activePlaybackRange().start();
1074 if (!
d->
document->image())
return false;
1076 return d->
document->image()->animationInterface()->activePlaybackRange().end();
1082 if (!
d->
document->image())
return false;
1084 return d->
document->image()->animationInterface()->currentTime();
1092 return d->
document->image()->animationInterface()->requestTimeSwitchWithUndo(time);
1109 while (it != endIt) {
1110 if (!(*it) || (*it)->type().isEmpty()) {
1111 qWarning() <<
"Warning: empty annotation";
1115 types << (*it)->type();
1137 return QByteArray();
1190 const QTransform documentToImage =
1194 for (
int i = 0; i< untransformedLines.size(); i++) {
1195 qreal untransformedLine = untransformedLines[i];
1196 transformedLines.append(documentToImage.map(QPointF(untransformedLine, untransformedLine)).x());
1200 transformedLines.clear();
1202 for (
int i = 0; i< untransformedLines.size(); i++) {
1203 qreal untransformedLine = untransformedLines[i];
1204 transformedLines.append(documentToImage.map(QPointF(untransformedLine, untransformedLine)).y());
1225 const QTransform imageToDocument =
1226 QTransform::fromScale(1.0 /
d->
document->image()->xRes(), 1.0 /
d->
document->image()->yRes());
1229 for (
int i = 0; i< untransformedLines.size(); i++) {
1230 qreal untransformedLine = untransformedLines[i];
1231 transformedLines.append(imageToDocument.map(QPointF(untransformedLine, untransformedLine)).x());
1235 transformedLines.clear();
1237 for (
int i = 0; i< untransformedLines.size(); i++) {
1238 qreal untransformedLine = untransformedLines[i];
1239 transformedLines.append(imageToDocument.map(QPointF(untransformedLine, untransformedLine)).x());
1248 d->
document->setGuidesConfig(tmpConfig);
1279 Q_FOREACH(QFileInfo fileInfo,
d->
document->getAudioTracks()) {
1280 fileList.append(fileInfo.absoluteFilePath());
1287 bool returned =
true;
1290 Q_FOREACH(QString
fileName, files) {
1292 if (fileInfo.exists()) {
1294 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()