11#include <KisSynchronizedConnection.h>
12#include <KoColorSpaceConstants.h>
13#include <KisDocument.h>
16#include <kis_paint_device.h>
17#include <KisMainWindow.h>
18#include <kis_node_manager.h>
19#include <kis_node_selection_adapter.h>
20#include <KisViewManager.h>
21#include <kis_file_layer.h>
22#include <kis_adjustment_layer.h>
24#include <kis_clone_layer.h>
25#include <kis_group_layer.h>
26#include <kis_filter_mask.h>
27#include <kis_transform_mask.h>
28#include <kis_transparency_mask.h>
29#include <kis_selection_mask.h>
30#include <lazybrush/kis_colorize_mask.h>
31#include <kis_effect_mask.h>
32#include <kis_paint_layer.h>
33#include <kis_generator_layer.h>
34#include <kis_generator_registry.h>
35#include <kis_shape_layer.h>
36#include <kis_filter_configuration.h>
37#include <kis_filter_registry.h>
38#include <kis_selection.h>
39#include <KisMimeDatabase.h>
40#include <kis_filter_strategy.h>
41#include <kis_guides_config.h>
42#include <kis_grid_config.h>
43#include <kis_coordinates_converter.h>
44#include <kis_time_span.h>
45#include <KisImportExportErrorCode.h>
47#include <kis_annotation.h>
50#include <KoColorSpace.h>
51#include <KoColorProfile.h>
52#include <KoColorSpaceRegistry.h>
53#include <KoColorConversionTransformation.h>
54#include <KoDocumentInfo.h>
55#include <KisGlobalResourcesInterface.h>
57#include <InfoObject.h>
60#include <LibKisUtils.h>
62#include "kis_animation_importer.h"
63#include <kis_canvas2.h>
67#include <kis_image_animation_interface.h>
68#include <kis_layer_utils.h>
69#include <kis_undo_adapter.h>
70#include <commands/kis_set_global_selection_command.h>
73struct Document::Private {
76 bool ownsDocument {
false};
79Document::Document(KisDocument *document,
bool ownsDocument,
QObject *parent)
83 d->document = document;
84 d->ownsDocument = ownsDocument;
89 if (d->ownsDocument && d->document) {
90 KisPart::instance()->removeDocument(d->document);
96bool Document::operator==(
const Document &other)
const
98 return (d->document == other.d->document);
101bool Document::operator!=(
const Document &other)
const
103 return !(operator==(other));
108 if (!d->document)
return false;
109 return d->document->fileBatchMode();
114 if (!d->document)
return;
115 d->document->setFileBatchMode(value);
121 KisSynchronizedConnectionBase::forceDeliverAllSynchronizedEvents();
125 if (view && view->document() == d->document) {
126 activeNodes << view->currentNode();
130 if (activeNodes.
size() > 0) {
131 QList<Node*> nodes = LibKisUtils::createNodeList(activeNodes, d->document->image());
132 return nodes.
first();
141 if (!value->node())
return;
142 KisMainWindow *mainWin = KisPart::instance()->currentMainwindow();
143 if (!mainWin)
return;
144 KisViewManager *viewManager = mainWin->viewManager();
145 if (!viewManager)
return;
146 if (viewManager->document() != d->document)
return;
147 KisNodeManager *nodeManager = viewManager->nodeManager();
148 if (!nodeManager)
return;
149 KisNodeSelectionAdapter *selectionAdapter = nodeManager->nodeSelectionAdapter();
150 if (!selectionAdapter)
return;
158 KisSynchronizedConnectionBase::forceDeliverAllSynchronizedEvents();
160 selectionAdapter->setActiveNode(value->node());
166 Node n(d->document->image(), d->document->image()->rootLayer());
173 if (!d->document)
return 0;
174 KisNodeSP node = KisLayerUtils::findNodeByName(d->document->image()->rootLayer(),
name);
176 if (node.isNull())
return 0;
178 return Node::createNode(d->document->image(), node);
183 if (!d->document)
return 0;
185 KisNodeSP node = KisLayerUtils::findNodeByUuid(d->document->image()->rootLayer(),
id);
187 if (node.isNull())
return 0;
188 return Node::createNode(d->document->image(), node);
194 if (!d->document)
return "";
195 return d->document->image()->colorSpace()->colorDepthId().id();
200 if (!d->document)
return "";
201 return d->document->image()->colorSpace()->colorModelId().id();
206 if (!d->document)
return "";
207 return d->document->image()->colorSpace()->profile()->name();
212 if (!d->document)
return false;
213 if (!d->document->image())
return false;
214 const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileByName(value);
215 if (!profile)
return false;
216 bool retval = d->document->image()->assignImageProfile(profile);
217 d->document->image()->waitForDone();
223 if (!d->document)
return false;
224 if (!d->document->image())
return false;
226 if (!colorSpace)
return false;
228 d->document->image()->convertImageColorSpace(colorSpace,
229 KoColorConversionTransformation::IntentPerceptual,
230 KoColorConversionTransformation::HighQuality | KoColorConversionTransformation::NoOptimization);
232 d->document->image()->waitForDone();
238 if (!d->document)
return QColor();
239 if (!d->document->image())
return QColor();
241 const KoColor color = d->document->image()->defaultProjectionColor();
242 return color.toQColor();
247 if (!d->document)
return false;
248 if (!d->document->image())
return false;
250 KoColor background = KoColor(color, d->document->image()->colorSpace());
251 d->document->image()->setDefaultProjectionColor(background);
253 d->document->image()->setModifiedWithoutUndo();
254 d->document->image()->initialRefreshGraph();
261 QDomDocument doc = KisDocument::createDomDocument(
"document-info"
262 ,
"document-info" ,
"1.1");
263 doc = d->document->documentInfo()->save(doc);
271 int errorLine, errorColumn;
272 doc.
setContent(document, &errorMsg, &errorLine, &errorColumn);
273 d->document->documentInfo()->load(doc);
279 if (!d->document)
return QString();
280 return d->document->path();
285 if (!d->document)
return;
286 QString mimeType = KisMimeDatabase::mimeTypeForFile(value,
false);
287 d->document->setMimeType(mimeType.
toLatin1());
288 d->document->setPath(value);
293 if (!d->document)
return 0;
294 KisImageSP image = d->document->image();
295 if (!image)
return 0;
296 return image->height();
301 if (!d->document)
return;
302 if (!d->document->image())
return;
304 d->document->image()->bounds().y(),
305 d->document->image()->width(),
312 if (!d->document)
return "";
313 return d->document->documentInfo()->aboutInfo(
"title");
318 if (!d->document)
return;
319 d->document->documentInfo()->setAboutInfo(
"title", value);
325 if (!d->document)
return 0;
326 KisImageSP image = d->document->image();
327 if (!image)
return 0;
329 return qRound(d->document->image()->xRes() * 72);
334 if (!d->document)
return;
335 KisImageSP image = d->document->image();
338 KisFilterStrategy *strategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
339 KIS_SAFE_ASSERT_RECOVER_RETURN(strategy);
341 image->scaleImage(image->size(), value / 72.0, value / 72.0, strategy);
342 image->waitForDone();
348 if (!d->document)
return 0;
349 KisImageSP image = d->document->image();
350 if (!image)
return 0;
352 return Node::createNode(image, image->root());
357 if (!d->document)
return 0;
358 if (!d->document->image())
return 0;
359 if (!d->document->image()->globalSelection())
return 0;
360 return new Selection(d->document->image()->globalSelection());
365 if (!d->document)
return;
366 if (!d->document->image())
return;
368 d->document->image()->undoAdapter()->addCommand(
new KisSetGlobalSelectionCommand(d->document->image(), value->selection()));
371 d->document->image()->undoAdapter()->addCommand(
new KisSetGlobalSelectionCommand(d->document->image(),
nullptr));
378 if (!d->document)
return 0;
379 KisImageSP image = d->document->image();
380 if (!image)
return 0;
381 return image->width();
386 if (!d->document)
return;
387 if (!d->document->image())
return;
389 d->document->image()->bounds().y(),
391 d->document->image()->height());
397 if (!d->document)
return 0;
398 KisImageSP image = d->document->image();
399 if (!image)
return 0;
400 return image->bounds().x();
405 if (!d->document)
return;
406 if (!d->document->image())
return;
408 d->document->image()->bounds().y(),
409 d->document->image()->width(),
410 d->document->image()->height());
416 if (!d->document)
return 0;
417 KisImageSP image = d->document->image();
418 if (!image)
return 0;
419 return image->bounds().y();
424 if (!d->document)
return;
425 if (!d->document->image())
return;
428 d->document->image()->width(),
429 d->document->image()->height());
435 if (!d->document)
return 0.0;
436 if (!d->document->image())
return 0.0;
437 return d->document->image()->xRes()*72.0;
442 if (!d->document)
return;
443 KisImageSP image = d->document->image();
446 KisFilterStrategy *strategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
447 KIS_SAFE_ASSERT_RECOVER_RETURN(strategy);
449 image->scaleImage(image->size(),
xRes / 72.0, image->yRes(), strategy);
450 image->waitForDone();
455 if (!d->document)
return 0.0;
456 if (!d->document->image())
return 0.0;
457 return d->document->image()->yRes()*72.0;
462 if (!d->document)
return;
463 KisImageSP image = d->document->image();
466 KisFilterStrategy *strategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
467 KIS_SAFE_ASSERT_RECOVER_RETURN(strategy);
469 image->scaleImage(image->size(), image->xRes(),
yRes / 72.0, strategy);
470 image->waitForDone();
478 if (!d->document)
return ba;
479 KisImageSP image = d->document->image();
480 if (!image)
return ba;
482 KisPaintDeviceSP dev = image->projection();
483 ba.
resize(w * h * dev->pixelSize());
484 dev->readBytes(
reinterpret_cast<quint8*
>(ba.
data()), x, y, w, h);
490 bool retval = d->document->closePath(
false);
492 Q_FOREACH(KisView *view, KisPart::instance()->views()) {
493 if (view->document() == d->document) {
500 KisPart::instance()->removeDocument(d->document, !d->ownsDocument);
502 if (d->ownsDocument) {
513 if (!d->document)
return;
514 KisImageSP image = d->document->image();
516 QRect rc(x, y, w, h);
517 image->cropImage(rc);
518 image->waitForDone();
523 if (!d->document)
return false;
525 const QString outputFormatString = KisMimeDatabase::mimeTypeForFile(filename,
false);
528 return d->document->exportDocumentSync(filename, outputFormat, exportConfiguration.configuration());
533 if (!d->document)
return;
534 if (!d->document->image())
return;
535 d->document->image()->flatten(0);
536 d->document->image()->waitForDone();
541 if (!d->document)
return;
542 KisImageSP image = d->document->image();
550 image->resizeImage(rc);
551 image->waitForDone();
556 if (!d->document)
return;
557 KisImageSP image = d->document->image();
559 QRect rc = image->bounds();
563 KisFilterStrategy *actualStrategy = KisFilterStrategyRegistry::instance()->get(strategy);
564 if (!actualStrategy) actualStrategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
566 image->scaleImage(rc.
size(), xres / 72.0, yres / 72.0, actualStrategy);
567 image->waitForDone();
572 if (!d->document)
return;
573 KisImageSP image = d->document->image();
575 image->rotateImage(radians);
576 image->waitForDone();
581 if (!d->document)
return;
582 KisImageSP image = d->document->image();
584 image->shear(angleX, angleY);
585 image->waitForDone();
590 if (!d->document)
return false;
591 if (d->document->path().isEmpty())
return false;
593 bool retval = d->document->save(
true, 0);
594 d->document->waitForSavingToComplete();
601 if (!d->document)
return false;
604 const QString outputFormatString = KisMimeDatabase::mimeTypeForFile(filename,
false);
606 QString oldPath = d->document->path();
607 d->document->setPath(filename);
608 bool retval = d->document->saveAs(filename, outputFormat,
true);
609 d->document->waitForSavingToComplete();
610 d->document->setPath(oldPath);
617 if (!d->document)
return 0;
618 if (!d->document->image())
return 0;
619 KisImageSP image = d->document->image();
623 if (nodeType.
toLower()==
"paintlayer") {
624 node =
new Node(image,
new KisPaintLayer(image,
name, OPACITY_OPAQUE_U8));
626 else if (nodeType.
toLower() ==
"grouplayer") {
627 node =
new Node(image,
new KisGroupLayer(image,
name, OPACITY_OPAQUE_U8));
629 else if (nodeType.
toLower() ==
"filelayer") {
630 node =
new Node(image,
new KisFileLayer(image,
name, OPACITY_OPAQUE_U8));
632 else if (nodeType.
toLower() ==
"filterlayer") {
633 node =
new Node(image,
new KisAdjustmentLayer(image,
name, 0, 0));
635 else if (nodeType.
toLower() ==
"filllayer") {
636 node =
new Node(image,
new KisGeneratorLayer(image,
name, 0, 0));
638 else if (nodeType.
toLower() ==
"clonelayer") {
639 node =
new Node(image,
new KisCloneLayer(0, image,
name, OPACITY_OPAQUE_U8));
641 else if (nodeType.
toLower() ==
"vectorlayer") {
642 node =
new Node(image,
new KisShapeLayer(d->document->shapeController(), image,
name, OPACITY_OPAQUE_U8));
644 else if (nodeType.
toLower() ==
"transparencymask") {
645 node =
new Node(image,
new KisTransparencyMask(image,
name));
647 else if (nodeType.
toLower() ==
"filtermask") {
648 node =
new Node(image,
new KisFilterMask(image,
name));
650 else if (nodeType.
toLower() ==
"transformmask") {
651 node =
new Node(image,
new KisTransformMask(image,
name));
653 else if (nodeType.
toLower() ==
"selectionmask") {
654 node =
new Node(image,
new KisSelectionMask(image,
name));
656 else if (nodeType.
toLower() ==
"colorizemask") {
657 node =
new Node(image,
new KisColorizeMask(image,
name));
665 if (!d->document)
return 0;
666 if (!d->document->image())
return 0;
667 KisImageSP image = d->document->image();
674 if (!d->document)
return 0;
675 if (!d->document->image())
return 0;
676 KisImageSP image = d->document->image();
683 if (!d->document)
return 0;
684 if (!d->document->image())
return 0;
685 KisImageSP image = d->document->image();
692 if (!d->document)
return 0;
693 if (!d->document->image())
return 0;
694 KisImageSP image = d->document->image();
696 KisGeneratorSP generator = KisGeneratorRegistry::instance()->value(generatorName);
699 KisFilterConfigurationSP config = generator->factoryConfiguration(KisGlobalResourcesInterface::instance());
711 if (!d->document)
return 0;
712 if (!d->document->image())
return 0;
713 KisImageSP image = d->document->image();
721 if (!d->document)
return 0;
722 if (!d->document->image())
return 0;
723 KisImageSP image = d->document->image();
733 if (!d->document->image())
736 if(!selection_source)
743 KisImageSP image = d->document->image();
755 if (!d->document->image())
758 KisImageSP image = d->document->image();
767 if (!d->document)
return 0;
768 if (!d->document->image())
return 0;
769 KisImageSP image = d->document->image();
776 if (!d->document)
return 0;
777 if (!d->document->image())
return 0;
778 KisImageSP image = d->document->image();
785 if (!d->document)
return 0;
786 if (!d->document->image())
return 0;
787 KisImageSP image = d->document->image();
794 if (!d->document)
return 0;
795 if (!d->document->image())
return 0;
796 KisImageSP image = d->document->image();
803 if (!d->document || !d->document->image())
return QImage();
804 return d->document->image()->convertToQImage(x, y, w, h, 0);
809 if (!d->document || !d->document->image())
return QImage();
810 return d->document->generatePreview(
QSize(w, h)).toImage();
816 if (!d->document || !d->document->image())
return;
817 d->document->image()->barrierLock();
822 if (!d->document || !d->document->image())
return;
823 d->document->image()->unlock();
828 if (!d->document || !d->document->image())
return;
829 KisLayerUtils::forceAllDelayedNodesUpdate(d->document->image()->rootLayer());
830 d->document->image()->waitForDone();
835 if (!d->document || !d->document->image())
return false;
836 return d->document->image()->tryBarrierLock();
841 if (!d->document || !d->document->image())
return;
842 d->document->image()->refreshGraphAsync();
843 d->document->image()->waitForDone();
849 warnScript <<
"DEPRECATED Document.horizontalGuides() - use Document.guidesConfig().horizontalGuides() instead";
851 if (!d->document || !d->document->image())
return lines;
852 KisCoordinatesConverter converter;
853 converter.setImage(d->document->image());
854 QTransform transform = converter.imageToDocumentTransform().inverted();
855 QList<qreal> untransformedLines = d->document->guidesConfig().horizontalGuideLines();
856 for (
int i = 0; i< untransformedLines.
size(); i++) {
857 qreal line = untransformedLines[i];
865 warnScript <<
"DEPRECATED Document.verticalGuides() - use Document.guidesConfig().verticalGuides() instead";
867 if (!d->document || !d->document->image())
return lines;
868 KisCoordinatesConverter converter;
869 converter.setImage(d->document->image());
870 QTransform transform = converter.imageToDocumentTransform().inverted();
871 QList<qreal> untransformedLines = d->document->guidesConfig().verticalGuideLines();
872 for (
int i = 0; i< untransformedLines.
size(); i++) {
873 qreal line = untransformedLines[i];
881 warnScript <<
"DEPRECATED Document.guidesVisible() - use Document.guidesConfig().visible() instead";
882 return d->document->guidesConfig().showGuides();
887 warnScript <<
"DEPRECATED Document.guidesLocked() - use Document.guidesConfig().locked() instead";
888 return d->document->guidesConfig().lockGuides();
893 if (!d->document)
return 0;
905 warnScript <<
"DEPRECATED Document.setHorizontalGuides() - use Document.guidesConfig().setHorizontalGuides() instead";
906 if (!d->document)
return;
907 KisGuidesConfig config = d->document->guidesConfig();
908 KisCoordinatesConverter converter;
909 converter.setImage(d->document->image());
910 QTransform transform = converter.imageToDocumentTransform();
912 for (
int i = 0; i< lines.
size(); i++) {
913 qreal line = lines[i];
914 transformedLines.
append(transform.map(
QPointF(line, line)).x());
916 config.setHorizontalGuideLines(transformedLines);
917 d->document->setGuidesConfig(config);
922 warnScript <<
"DEPRECATED Document.setVerticalGuides() - use Document.guidesConfig().setVerticalGuides() instead";
923 if (!d->document)
return;
924 KisGuidesConfig config = d->document->guidesConfig();
925 KisCoordinatesConverter converter;
926 converter.setImage(d->document->image());
927 QTransform transform = converter.imageToDocumentTransform();
929 for (
int i = 0; i< lines.
size(); i++) {
930 qreal line = lines[i];
931 transformedLines.
append(transform.map(
QPointF(line, line)).y());
933 config.setVerticalGuideLines(transformedLines);
934 d->document->setGuidesConfig(config);
939 warnScript <<
"DEPRECATED Document.setGuidesVisible() - use Document.guidesConfig().setVisible() instead";
940 if (!d->document)
return;
941 KisGuidesConfig config = d->document->guidesConfig();
942 config.setShowGuides(visible);
943 d->document->setGuidesConfig(config);
948 warnScript <<
"DEPRECATED Document.setGuidesLocked() - use Document.guidesConfig().setLocked() instead";
949 if (!d->document)
return;
950 KisGuidesConfig config = d->document->guidesConfig();
951 config.setLockGuides(locked);
952 d->document->setGuidesConfig(config);
957 if (!d->document)
return false;
958 return d->document->isModified();
963 if (!d->document)
return;
969 if (!d->document)
return QRect();
970 return d->document->image()->bounds();
978void Document::setOwnsDocument(
bool ownsDocument)
980 d->ownsDocument = ownsDocument;
987 KisView *activeView = KisPart::instance()->currentMainwindow()->activeView();
989 KoUpdaterPtr updater = 0;
990 if (activeView && d->document->fileBatchMode()) {
991 updater = activeView->viewManager()->createUnthreadedUpdater(
i18n(
"Import frames"));
994 KisAnimationImporter importer(d->document->image(), updater);
995 KisImportExportErrorCode
status = importer.import(files, firstFrame, step);
1002 if (!d->document)
return false;
1003 if (!d->document->image())
return false;
1005 return d->document->image()->animationInterface()->framerate();
1010 if (!d->document)
return;
1011 if (!d->document->image())
return;
1013 d->document->image()->animationInterface()->setFramerate(fps);
1018 if (!d->document)
return;
1019 if (!d->document->image())
return;
1021 d->document->image()->animationInterface()->setDocumentRangeStartFrame(startTime);
1027 if (!d->document)
return false;
1028 if (!d->document->image())
return false;
1030 return d->document->image()->animationInterface()->documentPlaybackRange().start();
1036 if (!d->document)
return;
1037 if (!d->document->image())
return;
1039 d->document->image()->animationInterface()->setDocumentRangeEndFrame(endTime);
1045 if (!d->document)
return false;
1046 if (!d->document->image())
return false;
1048 return d->document->image()->animationInterface()->documentPlaybackRange().end();
1053 if (!d->document)
return false;
1054 if (!d->document->image())
return false;
1056 return d->document->image()->animationInterface()->totalLength();
1061 if (!d->document)
return;
1062 if (!d->document->image())
return;
1064 const KisTimeSpan newTimeRange = KisTimeSpan::fromTimeWithDuration(
start, (
stop-
start));
1065 d->document->image()->animationInterface()->setActivePlaybackRange(newTimeRange);
1070 if (!d->document)
return false;
1071 if (!d->document->image())
return false;
1073 return d->document->image()->animationInterface()->activePlaybackRange().start();
1078 if (!d->document)
return false;
1079 if (!d->document->image())
return false;
1081 return d->document->image()->animationInterface()->activePlaybackRange().end();
1086 if (!d->document)
return false;
1087 if (!d->document->image())
return false;
1089 return d->document->image()->animationInterface()->currentTime();
1094 if (!d->document)
return;
1095 if (!d->document->image())
return;
1097 return d->document->image()->animationInterface()->requestTimeSwitchWithUndo(time);
1106 KisImageSP image = d->document->image().toStrongRef();
1110 vKisAnnotationSP_it beginIt = image->beginAnnotations();
1111 vKisAnnotationSP_it endIt = image->endAnnotations();
1113 vKisAnnotationSP_it it = beginIt;
1114 while (it != endIt) {
1115 if (!(*it) || (*it)->type().isEmpty()) {
1116 qWarning() <<
"Warning: empty annotation";
1120 types << (*it)->type();
1129 KisImageSP image = d->document->image().toStrongRef();
1130 KisAnnotationSP
annotation = image->annotation(type);
1136 KisImageSP image = d->document->image().toStrongRef();
1137 KisAnnotationSP
annotation = image->annotation(type);
1148 KisAnnotation *a =
new KisAnnotation(key, description,
annotation);
1149 KisImageSP image = d->document->image().toStrongRef();
1150 image->addAnnotation(a);
1156 KisImageSP image = d->document->image().toStrongRef();
1157 image->removeAnnotation(type);
1162 d->document->setAutoSaveActive(active);
1167 return d->document->isAutoSaveActive();
1192 KisGuidesConfig *tmpConfig =
new KisGuidesConfig(d->document->guidesConfig());
1194 if (d->document && d->document->image()) {
1195 KisCoordinatesConverter converter;
1196 converter.setImage(d->document->image());
1198 QTransform transform = converter.imageToDocumentTransform().inverted();
1201 QList<qreal> untransformedLines = tmpConfig->horizontalGuideLines();
1202 for (
int i = 0; i< untransformedLines.
size(); i++) {
1203 qreal untransformedLine = untransformedLines[i];
1204 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).x());
1206 tmpConfig->setHorizontalGuideLines(transformedLines);
1208 transformedLines.
clear();
1209 untransformedLines = tmpConfig->verticalGuideLines();
1210 for (
int i = 0; i< untransformedLines.
size(); i++) {
1211 qreal untransformedLine = untransformedLines[i];
1212 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).y());
1214 tmpConfig->setVerticalGuideLines(transformedLines);
1218 tmpConfig->removeAllGuides();
1227 if (!d->document)
return;
1230 KisGuidesConfig tmpConfig =
guidesConfig->guidesConfig();
1232 if (d->document->image()) {
1233 KisCoordinatesConverter converter;
1234 converter.setImage(d->document->image());
1236 QTransform transform = converter.imageToDocumentTransform();
1239 QList<qreal> untransformedLines = tmpConfig.horizontalGuideLines();
1240 for (
int i = 0; i< untransformedLines.
size(); i++) {
1241 qreal untransformedLine = untransformedLines[i];
1242 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).x());
1244 tmpConfig.setHorizontalGuideLines(transformedLines);
1246 transformedLines.
clear();
1247 untransformedLines = tmpConfig.verticalGuideLines();
1248 for (
int i = 0; i< untransformedLines.
size(); i++) {
1249 qreal untransformedLine = untransformedLines[i];
1250 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).x());
1252 tmpConfig.setVerticalGuideLines(transformedLines);
1256 tmpConfig.removeAllGuides();
1259 d->document->setGuidesConfig(tmpConfig);
1265 KisGridConfig *tmpConfig =
new KisGridConfig(d->document->gridConfig());
1272 if (!d->document)
return;
1273 KisGridConfig tmpConfig =
gridConfig->gridConfig();
1274 d->document->setGridConfig(tmpConfig);
1279 return d->document->getAudioLevel();
1284 d->document->setAudioVolume(level);
1290 Q_FOREACH(
QFileInfo fileInfo, d->document->getAudioTracks()) {
1298 bool returned =
true;
1312 d->document->setAudioTracks(fileList);
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.
The Document class encapsulates a Krita Document/Image.
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
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.
int fullClipRangeStartTime()
get the full clip range start time
bool setBackgroundColor(const QColor &color)
setBackgroundColor sets the background color of the document.
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 saveAs(const QString &filename)
saveAs save the document under the filename.
void unlock()
Unlocks the image and starts/resumes all the pending internal jobs.
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.
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.
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...
Document * clone() const
clone create a shallow clone of this document.
void setName(QString value)
setName sets the name of the document to value.
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.
void removeAnnotation(const QString &type)
removeAnnotation remove the specified annotation from the image
bool batchmode() const
Batchmode means that no actions on the document should show dialogs or popups.
void waitForDone()
Wait for all the internal image jobs to complete and return without locking 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.
void refreshProjection()
Starts a synchronous recomposition of the projection: everything will wait until the image is fully r...
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
colorDepth A string describing the color depth of the image:
bool save()
save the image to its currently set path.
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)
Set batchmode to 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.
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
void lock()
[low-level] Lock the image without waiting for all the internal job queues are processed
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.
void setCurrentTime(int time)
set current time of document's animation
GroupLayer * createGroupLayer(const QString &name)
createGroupLayer Returns a grouplayer object.
void setHeight(int value)
setHeight resize the document to
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...
The GridConfig class encapsulates a Krita Guides configuration.
The GroupLayer class A group layer is a layer that can contain other layers.
The GuidesConfig class encapsulates a Krita Guides configuration.
InfoObject wrap a properties map.
QVariant property(const QString &key)
return the value for the property identified by key, or None if there is no such key.
QMap< QString, QVariant > properties() const
Return all properties this InfoObject manages.
Node represents a layer or mask in a Krita image's Node hierarchy.
QList< Node * > childNodes() const
childNodes
The SelectionMask class A selection mask is a mask type node that can be used to store selections.
Selection represents a selection on Krita.
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.
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE CaptureState status()
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18n(const char *text, const TYPE &arg...)
void resize(qsizetype newSize, char c)
ParseResult setContent(QAnyStringView text, ParseOptions options)
QString toString(int indent) const const
QString absoluteFilePath() const const
bool exists(const QString &path)
void setFile(const QDir &dir, const QString &path)
void append(QList< T > &&value)
qsizetype size() const const
QVariant property(const char *name) const const
T qobject_cast(QObject *object)
void setHeight(int height)
QByteArray toLatin1() const const
QString toLower() const const