11#include <KoColorSpaceConstants.h>
12#include <KisDocument.h>
15#include <kis_paint_device.h>
16#include <KisMainWindow.h>
17#include <kis_node_manager.h>
18#include <kis_node_selection_adapter.h>
19#include <KisViewManager.h>
20#include <kis_file_layer.h>
21#include <kis_adjustment_layer.h>
23#include <kis_clone_layer.h>
24#include <kis_group_layer.h>
25#include <kis_filter_mask.h>
26#include <kis_transform_mask.h>
27#include <kis_transparency_mask.h>
28#include <kis_selection_mask.h>
29#include <lazybrush/kis_colorize_mask.h>
30#include <kis_effect_mask.h>
31#include <kis_paint_layer.h>
32#include <kis_generator_layer.h>
33#include <kis_generator_registry.h>
34#include <kis_shape_layer.h>
35#include <kis_filter_configuration.h>
36#include <kis_filter_registry.h>
37#include <kis_selection.h>
38#include <KisMimeDatabase.h>
39#include <kis_filter_strategy.h>
40#include <kis_guides_config.h>
41#include <kis_grid_config.h>
42#include <kis_coordinates_converter.h>
43#include <kis_time_span.h>
44#include <KisImportExportErrorCode.h>
46#include <kis_annotation.h>
49#include <KoColorSpace.h>
50#include <KoColorProfile.h>
51#include <KoColorSpaceRegistry.h>
52#include <KoColorConversionTransformation.h>
53#include <KoDocumentInfo.h>
54#include <KisGlobalResourcesInterface.h>
56#include <InfoObject.h>
59#include <LibKisUtils.h>
61#include "kis_animation_importer.h"
62#include <kis_canvas2.h>
66#include <kis_image_animation_interface.h>
67#include <kis_layer_utils.h>
68#include <kis_undo_adapter.h>
69#include <commands/kis_set_global_selection_command.h>
72struct Document::Private {
75 bool ownsDocument {
false};
78Document::Document(KisDocument *document,
bool ownsDocument,
QObject *parent)
82 d->document = document;
83 d->ownsDocument = ownsDocument;
88 if (d->ownsDocument && d->document) {
89 KisPart::instance()->removeDocument(d->document);
95bool Document::operator==(
const Document &other)
const
97 return (d->document == other.d->document);
100bool Document::operator!=(
const Document &other)
const
102 return !(operator==(other));
107 if (!d->document)
return false;
108 return d->document->fileBatchMode();
113 if (!d->document)
return;
114 d->document->setFileBatchMode(value);
121 if (view && view->document() == d->document) {
122 activeNodes << view->currentNode();
126 if (activeNodes.
size() > 0) {
127 QList<Node*> nodes = LibKisUtils::createNodeList(activeNodes, d->document->image());
128 return nodes.
first();
137 if (!value->node())
return;
138 KisMainWindow *mainWin = KisPart::instance()->currentMainwindow();
139 if (!mainWin)
return;
140 KisViewManager *viewManager = mainWin->viewManager();
141 if (!viewManager)
return;
142 if (viewManager->document() != d->document)
return;
143 KisNodeManager *nodeManager = viewManager->nodeManager();
144 if (!nodeManager)
return;
145 KisNodeSelectionAdapter *selectionAdapter = nodeManager->nodeSelectionAdapter();
146 if (!selectionAdapter)
return;
147 selectionAdapter->setActiveNode(value->node());
154 Node n(d->document->image(), d->document->image()->rootLayer());
161 if (!d->document)
return 0;
162 KisNodeSP node = KisLayerUtils::findNodeByName(d->document->image()->rootLayer(),
name);
164 if (node.isNull())
return 0;
166 return Node::createNode(d->document->image(), node);
171 if (!d->document)
return 0;
173 KisNodeSP node = KisLayerUtils::findNodeByUuid(d->document->image()->rootLayer(),
id);
175 if (node.isNull())
return 0;
176 return Node::createNode(d->document->image(), node);
182 if (!d->document)
return "";
183 return d->document->image()->colorSpace()->colorDepthId().id();
188 if (!d->document)
return "";
189 return d->document->image()->colorSpace()->colorModelId().id();
194 if (!d->document)
return "";
195 return d->document->image()->colorSpace()->profile()->name();
200 if (!d->document)
return false;
201 if (!d->document->image())
return false;
202 const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileByName(value);
203 if (!profile)
return false;
204 bool retval = d->document->image()->assignImageProfile(profile);
205 d->document->image()->waitForDone();
211 if (!d->document)
return false;
212 if (!d->document->image())
return false;
214 if (!colorSpace)
return false;
216 d->document->image()->convertImageColorSpace(colorSpace,
217 KoColorConversionTransformation::IntentPerceptual,
218 KoColorConversionTransformation::HighQuality | KoColorConversionTransformation::NoOptimization);
220 d->document->image()->waitForDone();
226 if (!d->document)
return QColor();
227 if (!d->document->image())
return QColor();
229 const KoColor color = d->document->image()->defaultProjectionColor();
230 return color.toQColor();
235 if (!d->document)
return false;
236 if (!d->document->image())
return false;
238 KoColor background = KoColor(color, d->document->image()->colorSpace());
239 d->document->image()->setDefaultProjectionColor(background);
241 d->document->image()->setModifiedWithoutUndo();
242 d->document->image()->initialRefreshGraph();
249 QDomDocument doc = KisDocument::createDomDocument(
"document-info"
250 ,
"document-info" ,
"1.1");
251 doc = d->document->documentInfo()->save(doc);
259 int errorLine, errorColumn;
260 doc.
setContent(document, &errorMsg, &errorLine, &errorColumn);
261 d->document->documentInfo()->load(doc);
267 if (!d->document)
return QString();
268 return d->document->path();
273 if (!d->document)
return;
274 QString mimeType = KisMimeDatabase::mimeTypeForFile(value,
false);
275 d->document->setMimeType(mimeType.
toLatin1());
276 d->document->setPath(value);
281 if (!d->document)
return 0;
282 KisImageSP image = d->document->image();
283 if (!image)
return 0;
284 return image->height();
289 if (!d->document)
return;
290 if (!d->document->image())
return;
292 d->document->image()->bounds().y(),
293 d->document->image()->width(),
300 if (!d->document)
return "";
301 return d->document->documentInfo()->aboutInfo(
"title");
306 if (!d->document)
return;
307 d->document->documentInfo()->setAboutInfo(
"title", value);
313 if (!d->document)
return 0;
314 KisImageSP image = d->document->image();
315 if (!image)
return 0;
317 return qRound(d->document->image()->xRes() * 72);
322 if (!d->document)
return;
323 KisImageSP image = d->document->image();
326 KisFilterStrategy *strategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
327 KIS_SAFE_ASSERT_RECOVER_RETURN(strategy);
329 image->scaleImage(image->size(), value / 72.0, value / 72.0, strategy);
330 image->waitForDone();
336 if (!d->document)
return 0;
337 KisImageSP image = d->document->image();
338 if (!image)
return 0;
340 return Node::createNode(image, image->root());
345 if (!d->document)
return 0;
346 if (!d->document->image())
return 0;
347 if (!d->document->image()->globalSelection())
return 0;
348 return new Selection(d->document->image()->globalSelection());
353 if (!d->document)
return;
354 if (!d->document->image())
return;
356 d->document->image()->undoAdapter()->addCommand(
new KisSetGlobalSelectionCommand(d->document->image(), value->selection()));
359 d->document->image()->undoAdapter()->addCommand(
new KisSetGlobalSelectionCommand(d->document->image(),
nullptr));
366 if (!d->document)
return 0;
367 KisImageSP image = d->document->image();
368 if (!image)
return 0;
369 return image->width();
374 if (!d->document)
return;
375 if (!d->document->image())
return;
377 d->document->image()->bounds().y(),
379 d->document->image()->height());
385 if (!d->document)
return 0;
386 KisImageSP image = d->document->image();
387 if (!image)
return 0;
388 return image->bounds().x();
393 if (!d->document)
return;
394 if (!d->document->image())
return;
396 d->document->image()->bounds().y(),
397 d->document->image()->width(),
398 d->document->image()->height());
404 if (!d->document)
return 0;
405 KisImageSP image = d->document->image();
406 if (!image)
return 0;
407 return image->bounds().y();
412 if (!d->document)
return;
413 if (!d->document->image())
return;
416 d->document->image()->width(),
417 d->document->image()->height());
423 if (!d->document)
return 0.0;
424 if (!d->document->image())
return 0.0;
425 return d->document->image()->xRes()*72.0;
430 if (!d->document)
return;
431 KisImageSP image = d->document->image();
434 KisFilterStrategy *strategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
435 KIS_SAFE_ASSERT_RECOVER_RETURN(strategy);
437 image->scaleImage(image->size(),
xRes / 72.0, image->yRes(), strategy);
438 image->waitForDone();
443 if (!d->document)
return 0.0;
444 if (!d->document->image())
return 0.0;
445 return d->document->image()->yRes()*72.0;
450 if (!d->document)
return;
451 KisImageSP image = d->document->image();
454 KisFilterStrategy *strategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
455 KIS_SAFE_ASSERT_RECOVER_RETURN(strategy);
457 image->scaleImage(image->size(), image->xRes(),
yRes / 72.0, strategy);
458 image->waitForDone();
466 if (!d->document)
return ba;
467 KisImageSP image = d->document->image();
468 if (!image)
return ba;
470 KisPaintDeviceSP dev = image->projection();
471 ba.
resize(w * h * dev->pixelSize());
472 dev->readBytes(
reinterpret_cast<quint8*
>(ba.
data()), x, y, w, h);
478 bool retval = d->document->closePath(
false);
480 Q_FOREACH(KisView *view, KisPart::instance()->views()) {
481 if (view->document() == d->document) {
488 KisPart::instance()->removeDocument(d->document, !d->ownsDocument);
490 if (d->ownsDocument) {
501 if (!d->document)
return;
502 KisImageSP image = d->document->image();
504 QRect rc(x, y, w, h);
505 image->cropImage(rc);
506 image->waitForDone();
511 if (!d->document)
return false;
513 const QString outputFormatString = KisMimeDatabase::mimeTypeForFile(filename,
false);
516 return d->document->exportDocumentSync(filename, outputFormat, exportConfiguration.configuration());
521 if (!d->document)
return;
522 if (!d->document->image())
return;
523 d->document->image()->flatten(0);
524 d->document->image()->waitForDone();
529 if (!d->document)
return;
530 KisImageSP image = d->document->image();
538 image->resizeImage(rc);
539 image->waitForDone();
544 if (!d->document)
return;
545 KisImageSP image = d->document->image();
547 QRect rc = image->bounds();
551 KisFilterStrategy *actualStrategy = KisFilterStrategyRegistry::instance()->get(strategy);
552 if (!actualStrategy) actualStrategy = KisFilterStrategyRegistry::instance()->get(
"Bicubic");
554 image->scaleImage(rc.
size(), xres / 72.0, yres / 72.0, actualStrategy);
555 image->waitForDone();
560 if (!d->document)
return;
561 KisImageSP image = d->document->image();
563 image->rotateImage(radians);
564 image->waitForDone();
569 if (!d->document)
return;
570 KisImageSP image = d->document->image();
572 image->shear(angleX, angleY);
573 image->waitForDone();
578 if (!d->document)
return false;
579 if (d->document->path().isEmpty())
return false;
581 bool retval = d->document->save(
true, 0);
582 d->document->waitForSavingToComplete();
589 if (!d->document)
return false;
592 const QString outputFormatString = KisMimeDatabase::mimeTypeForFile(filename,
false);
594 QString oldPath = d->document->path();
595 d->document->setPath(filename);
596 bool retval = d->document->saveAs(filename, outputFormat,
true);
597 d->document->waitForSavingToComplete();
598 d->document->setPath(oldPath);
605 if (!d->document)
return 0;
606 if (!d->document->image())
return 0;
607 KisImageSP image = d->document->image();
611 if (nodeType.
toLower()==
"paintlayer") {
612 node =
new Node(image,
new KisPaintLayer(image,
name, OPACITY_OPAQUE_U8));
614 else if (nodeType.
toLower() ==
"grouplayer") {
615 node =
new Node(image,
new KisGroupLayer(image,
name, OPACITY_OPAQUE_U8));
617 else if (nodeType.
toLower() ==
"filelayer") {
618 node =
new Node(image,
new KisFileLayer(image,
name, OPACITY_OPAQUE_U8));
620 else if (nodeType.
toLower() ==
"filterlayer") {
621 node =
new Node(image,
new KisAdjustmentLayer(image,
name, 0, 0));
623 else if (nodeType.
toLower() ==
"filllayer") {
624 node =
new Node(image,
new KisGeneratorLayer(image,
name, 0, 0));
626 else if (nodeType.
toLower() ==
"clonelayer") {
627 node =
new Node(image,
new KisCloneLayer(0, image,
name, OPACITY_OPAQUE_U8));
629 else if (nodeType.
toLower() ==
"vectorlayer") {
630 node =
new Node(image,
new KisShapeLayer(d->document->shapeController(), image,
name, OPACITY_OPAQUE_U8));
632 else if (nodeType.
toLower() ==
"transparencymask") {
633 node =
new Node(image,
new KisTransparencyMask(image,
name));
635 else if (nodeType.
toLower() ==
"filtermask") {
636 node =
new Node(image,
new KisFilterMask(image,
name));
638 else if (nodeType.
toLower() ==
"transformmask") {
639 node =
new Node(image,
new KisTransformMask(image,
name));
641 else if (nodeType.
toLower() ==
"selectionmask") {
642 node =
new Node(image,
new KisSelectionMask(image,
name));
644 else if (nodeType.
toLower() ==
"colorizemask") {
645 node =
new Node(image,
new KisColorizeMask(image,
name));
653 if (!d->document)
return 0;
654 if (!d->document->image())
return 0;
655 KisImageSP image = d->document->image();
662 if (!d->document)
return 0;
663 if (!d->document->image())
return 0;
664 KisImageSP image = d->document->image();
671 if (!d->document)
return 0;
672 if (!d->document->image())
return 0;
673 KisImageSP image = d->document->image();
680 if (!d->document)
return 0;
681 if (!d->document->image())
return 0;
682 KisImageSP image = d->document->image();
684 KisGeneratorSP generator = KisGeneratorRegistry::instance()->value(generatorName);
687 KisFilterConfigurationSP config = generator->factoryConfiguration(KisGlobalResourcesInterface::instance());
699 if (!d->document)
return 0;
700 if (!d->document->image())
return 0;
701 KisImageSP image = d->document->image();
709 if (!d->document)
return 0;
710 if (!d->document->image())
return 0;
711 KisImageSP image = d->document->image();
721 if (!d->document->image())
724 if(!selection_source)
731 KisImageSP image = d->document->image();
743 if (!d->document->image())
746 KisImageSP image = d->document->image();
755 if (!d->document)
return 0;
756 if (!d->document->image())
return 0;
757 KisImageSP image = d->document->image();
764 if (!d->document)
return 0;
765 if (!d->document->image())
return 0;
766 KisImageSP image = d->document->image();
773 if (!d->document)
return 0;
774 if (!d->document->image())
return 0;
775 KisImageSP image = d->document->image();
782 if (!d->document)
return 0;
783 if (!d->document->image())
return 0;
784 KisImageSP image = d->document->image();
791 if (!d->document || !d->document->image())
return QImage();
792 return d->document->image()->convertToQImage(x, y, w, h, 0);
797 if (!d->document || !d->document->image())
return QImage();
798 return d->document->generatePreview(
QSize(w, h)).toImage();
804 if (!d->document || !d->document->image())
return;
805 d->document->image()->barrierLock();
810 if (!d->document || !d->document->image())
return;
811 d->document->image()->unlock();
816 if (!d->document || !d->document->image())
return;
817 KisLayerUtils::forceAllDelayedNodesUpdate(d->document->image()->rootLayer());
818 d->document->image()->waitForDone();
823 if (!d->document || !d->document->image())
return false;
824 return d->document->image()->tryBarrierLock();
829 if (!d->document || !d->document->image())
return;
830 d->document->image()->refreshGraphAsync();
831 d->document->image()->waitForDone();
837 warnScript <<
"DEPRECATED Document.horizontalGuides() - use Document.guidesConfig().horizontalGuides() instead";
839 if (!d->document || !d->document->image())
return lines;
840 KisCoordinatesConverter converter;
841 converter.setImage(d->document->image());
842 QTransform transform = converter.imageToDocumentTransform().inverted();
843 QList<qreal> untransformedLines = d->document->guidesConfig().horizontalGuideLines();
844 for (
int i = 0; i< untransformedLines.
size(); i++) {
845 qreal line = untransformedLines[i];
853 warnScript <<
"DEPRECATED Document.verticalGuides() - use Document.guidesConfig().verticalGuides() instead";
855 if (!d->document || !d->document->image())
return lines;
856 KisCoordinatesConverter converter;
857 converter.setImage(d->document->image());
858 QTransform transform = converter.imageToDocumentTransform().inverted();
859 QList<qreal> untransformedLines = d->document->guidesConfig().verticalGuideLines();
860 for (
int i = 0; i< untransformedLines.
size(); i++) {
861 qreal line = untransformedLines[i];
869 warnScript <<
"DEPRECATED Document.guidesVisible() - use Document.guidesConfig().visible() instead";
870 return d->document->guidesConfig().showGuides();
875 warnScript <<
"DEPRECATED Document.guidesLocked() - use Document.guidesConfig().locked() instead";
876 return d->document->guidesConfig().lockGuides();
881 if (!d->document)
return 0;
893 warnScript <<
"DEPRECATED Document.setHorizontalGuides() - use Document.guidesConfig().setHorizontalGuides() instead";
894 if (!d->document)
return;
895 KisGuidesConfig config = d->document->guidesConfig();
896 KisCoordinatesConverter converter;
897 converter.setImage(d->document->image());
898 QTransform transform = converter.imageToDocumentTransform();
900 for (
int i = 0; i< lines.
size(); i++) {
901 qreal line = lines[i];
902 transformedLines.
append(transform.map(
QPointF(line, line)).x());
904 config.setHorizontalGuideLines(transformedLines);
905 d->document->setGuidesConfig(config);
910 warnScript <<
"DEPRECATED Document.setVerticalGuides() - use Document.guidesConfig().setVerticalGuides() instead";
911 if (!d->document)
return;
912 KisGuidesConfig config = d->document->guidesConfig();
913 KisCoordinatesConverter converter;
914 converter.setImage(d->document->image());
915 QTransform transform = converter.imageToDocumentTransform();
917 for (
int i = 0; i< lines.
size(); i++) {
918 qreal line = lines[i];
919 transformedLines.
append(transform.map(
QPointF(line, line)).y());
921 config.setVerticalGuideLines(transformedLines);
922 d->document->setGuidesConfig(config);
927 warnScript <<
"DEPRECATED Document.setGuidesVisible() - use Document.guidesConfig().setVisible() instead";
928 if (!d->document)
return;
929 KisGuidesConfig config = d->document->guidesConfig();
930 config.setShowGuides(visible);
931 d->document->setGuidesConfig(config);
936 warnScript <<
"DEPRECATED Document.setGuidesLocked() - use Document.guidesConfig().setLocked() instead";
937 if (!d->document)
return;
938 KisGuidesConfig config = d->document->guidesConfig();
939 config.setLockGuides(locked);
940 d->document->setGuidesConfig(config);
945 if (!d->document)
return false;
946 return d->document->isModified();
951 if (!d->document)
return;
957 if (!d->document)
return QRect();
958 return d->document->image()->bounds();
966void Document::setOwnsDocument(
bool ownsDocument)
968 d->ownsDocument = ownsDocument;
975 KisView *activeView = KisPart::instance()->currentMainwindow()->activeView();
977 KoUpdaterPtr updater = 0;
978 if (activeView && d->document->fileBatchMode()) {
979 updater = activeView->viewManager()->createUnthreadedUpdater(
i18n(
"Import frames"));
982 KisAnimationImporter importer(d->document->image(), updater);
983 KisImportExportErrorCode
status = importer.import(files, firstFrame, step);
990 if (!d->document)
return false;
991 if (!d->document->image())
return false;
993 return d->document->image()->animationInterface()->framerate();
998 if (!d->document)
return;
999 if (!d->document->image())
return;
1001 d->document->image()->animationInterface()->setFramerate(fps);
1006 if (!d->document)
return;
1007 if (!d->document->image())
return;
1009 d->document->image()->animationInterface()->setDocumentRangeStartFrame(startTime);
1015 if (!d->document)
return false;
1016 if (!d->document->image())
return false;
1018 return d->document->image()->animationInterface()->documentPlaybackRange().start();
1024 if (!d->document)
return;
1025 if (!d->document->image())
return;
1027 d->document->image()->animationInterface()->setDocumentRangeEndFrame(endTime);
1033 if (!d->document)
return false;
1034 if (!d->document->image())
return false;
1036 return d->document->image()->animationInterface()->documentPlaybackRange().end();
1041 if (!d->document)
return false;
1042 if (!d->document->image())
return false;
1044 return d->document->image()->animationInterface()->totalLength();
1049 if (!d->document)
return;
1050 if (!d->document->image())
return;
1052 const KisTimeSpan newTimeRange = KisTimeSpan::fromTimeWithDuration(
start, (
stop-
start));
1053 d->document->image()->animationInterface()->setActivePlaybackRange(newTimeRange);
1058 if (!d->document)
return false;
1059 if (!d->document->image())
return false;
1061 return d->document->image()->animationInterface()->activePlaybackRange().start();
1066 if (!d->document)
return false;
1067 if (!d->document->image())
return false;
1069 return d->document->image()->animationInterface()->activePlaybackRange().end();
1074 if (!d->document)
return false;
1075 if (!d->document->image())
return false;
1077 return d->document->image()->animationInterface()->currentTime();
1082 if (!d->document)
return;
1083 if (!d->document->image())
return;
1085 return d->document->image()->animationInterface()->requestTimeSwitchWithUndo(time);
1094 KisImageSP image = d->document->image().toStrongRef();
1098 vKisAnnotationSP_it beginIt = image->beginAnnotations();
1099 vKisAnnotationSP_it endIt = image->endAnnotations();
1101 vKisAnnotationSP_it it = beginIt;
1102 while (it != endIt) {
1103 if (!(*it) || (*it)->type().isEmpty()) {
1104 qWarning() <<
"Warning: empty annotation";
1108 types << (*it)->type();
1117 KisImageSP image = d->document->image().toStrongRef();
1118 KisAnnotationSP
annotation = image->annotation(type);
1124 KisImageSP image = d->document->image().toStrongRef();
1125 KisAnnotationSP
annotation = image->annotation(type);
1136 KisAnnotation *a =
new KisAnnotation(key, description,
annotation);
1137 KisImageSP image = d->document->image().toStrongRef();
1138 image->addAnnotation(a);
1144 KisImageSP image = d->document->image().toStrongRef();
1145 image->removeAnnotation(type);
1150 d->document->setAutoSaveActive(active);
1155 return d->document->isAutoSaveActive();
1180 KisGuidesConfig *tmpConfig =
new KisGuidesConfig(d->document->guidesConfig());
1182 if (d->document && d->document->image()) {
1183 KisCoordinatesConverter converter;
1184 converter.setImage(d->document->image());
1186 QTransform transform = converter.imageToDocumentTransform().inverted();
1189 QList<qreal> untransformedLines = tmpConfig->horizontalGuideLines();
1190 for (
int i = 0; i< untransformedLines.
size(); i++) {
1191 qreal untransformedLine = untransformedLines[i];
1192 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).x());
1194 tmpConfig->setHorizontalGuideLines(transformedLines);
1196 transformedLines.
clear();
1197 untransformedLines = tmpConfig->verticalGuideLines();
1198 for (
int i = 0; i< untransformedLines.
size(); i++) {
1199 qreal untransformedLine = untransformedLines[i];
1200 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).y());
1202 tmpConfig->setVerticalGuideLines(transformedLines);
1206 tmpConfig->removeAllGuides();
1215 if (!d->document)
return;
1218 KisGuidesConfig tmpConfig =
guidesConfig->guidesConfig();
1220 if (d->document->image()) {
1221 KisCoordinatesConverter converter;
1222 converter.setImage(d->document->image());
1224 QTransform transform = converter.imageToDocumentTransform();
1227 QList<qreal> untransformedLines = tmpConfig.horizontalGuideLines();
1228 for (
int i = 0; i< untransformedLines.
size(); i++) {
1229 qreal untransformedLine = untransformedLines[i];
1230 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).x());
1232 tmpConfig.setHorizontalGuideLines(transformedLines);
1234 transformedLines.
clear();
1235 untransformedLines = tmpConfig.verticalGuideLines();
1236 for (
int i = 0; i< untransformedLines.
size(); i++) {
1237 qreal untransformedLine = untransformedLines[i];
1238 transformedLines.
append(transform.map(
QPointF(untransformedLine, untransformedLine)).x());
1240 tmpConfig.setVerticalGuideLines(transformedLines);
1244 tmpConfig.removeAllGuides();
1247 d->document->setGuidesConfig(tmpConfig);
1253 KisGridConfig *tmpConfig =
new KisGridConfig(d->document->gridConfig());
1260 if (!d->document)
return;
1261 KisGridConfig tmpConfig =
gridConfig->gridConfig();
1262 d->document->setGridConfig(tmpConfig);
1267 return d->document->getAudioLevel();
1272 d->document->setAudioVolume(level);
1278 Q_FOREACH(
QFileInfo fileInfo, d->document->getAudioTracks()) {
1286 bool returned =
true;
1300 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...
Filter: represents a filter and its configuration.
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