Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_selection_action_factories.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2012 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QMimeData>
10
11#include <klocalizedstring.h>
12#include <kundo2command.h>
13
14#include <KisMainWindow.h>
15#include <KisDocument.h>
16#include <KisPart.h>
17#include <KoPathShape.h>
18#include <KoShapeController.h>
19#include <KoShapeRegistry.h>
21#include <KoShapeManager.h>
22#include <KoSelection.h>
24#include <KoShapeStroke.h>
25#include <KoDocumentInfo.h>
26#include <KoCanvasBase.h>
27
28#include "KisViewManager.h"
30#include "kis_clipboard.h"
31#include "kis_pixel_selection.h"
32#include "kis_paint_layer.h"
33#include "kis_image.h"
34#include "KisImageBarrierLock.h"
35#include "kis_fill_painter.h"
36#include "kis_transaction.h"
37#include "kis_iterator_ng.h"
39#include "kis_group_layer.h"
42#include "kis_tool_proxy.h"
43#include "kis_canvas2.h"
48#include "kis_shape_selection.h"
49#include "kis_shape_layer.h"
52#include "kis_time_span.h"
54#include "kis_node_manager.h"
55#include "kis_layer_utils.h"
56#include <kis_selection_mask.h>
58
64
67
68namespace ActionHelper {
69
71 KisPaintDeviceSP device,
72 bool makeSharpClip = false,
73 const KisTimeSpan &range = KisTimeSpan())
74 {
75 Q_UNUSED(range); // TODO: Allow multiple frame operation across a timespan.
76
77 KisImageWSP image = view->image();
78 if (!image) return;
79
80 KisSelectionSP selection = view->selection();
81
82 QRect rc = (selection) ? selection->selectedExactRect() : image->bounds();
83
84 const KoColorSpace *cs = device->colorSpace();
85
86 // We need to allow for trimming from non-transparent defaultPixel layers.
87 // Default color should be phased out of use when the area in question is not aligned with image bounds.
88 // Otherwise, we can maintain default pixel.
89 const bool hasNonTransparentDefaultPixel = device->defaultPixel() != KoColor::createTransparent(device->colorSpace());
90 const bool needsTransparentPixel = selection && rc != image->bounds() && hasNonTransparentDefaultPixel;
91
92 if (selection) {
93 // Apply selection mask.
94 KisPaintDeviceSP selectionProjection = selection->projection();
95 const KoColorSpace *selCs = selection->projection()->colorSpace();
96
97 KisSequentialIterator layerIt(device, rc);
98 KisSequentialConstIterator selectionIt(selectionProjection, rc);
99
100 while (layerIt.nextPixel() && selectionIt.nextPixel()) {
101
107 if (makeSharpClip) {
108 qreal dstAlpha = cs->opacityF(layerIt.rawData());
109 qreal sel = selCs->opacityF(selectionIt.oldRawData());
110 qreal newAlpha = sel * dstAlpha / (1.0 - dstAlpha + sel * dstAlpha);
111 float mask = newAlpha / dstAlpha;
112
113 cs->applyAlphaNormedFloatMask(layerIt.rawData(), &mask, 1);
114 } else {
115 cs->applyAlphaU8Mask(layerIt.rawData(), selectionIt.oldRawData(), 1);
116 }
117 }
118 }
119
120
121
122 if ( needsTransparentPixel ) {
124 device->purgeDefaultPixels();
125 }
126
127 device->crop(rc);
128 }
129
131 {
132 KisImageWSP image = view->image();
133
134 KisImageSP clipImage = new KisImage(0, image->width(), image->height(), image->colorSpace(), "ClipImage");
135 clipImage->setResolution(image->xRes(), image->yRes());
136 Q_FOREACH (KisNodeSP node, nodes) {
137 clipImage->addNode(node, clipImage->root());
138 }
139
140 clipImage->refreshGraphAsync();
141 clipImage->waitForDone();
142
143 return clipImage;
144 }
145}
146
148{
149 KisImageWSP image = view->image();
150 if (!image) return;
151
152 if (view->canvasBase()->toolProxy()->selectAll()) {
153 return;
154 }
155
156 KisProcessingApplicator *ap = beginAction(view, kundo2_i18n("Select All"));
157
159 [image] () {
160 return !image->globalSelection() ?
162 }),
165
166 struct SelectAll : public KisTransactionBasedCommand {
167 SelectAll(KisImageSP image) : m_image(image) {}
168 KisImageSP m_image;
169 KUndo2Command* paint() override {
170 KisSelectionSP selection = m_image->globalSelection();
171 KisSelectionTransaction transaction(selection->pixelSelection());
172 selection->pixelSelection()->clear();
173 selection->pixelSelection()->select(m_image->bounds());
174 return transaction.endAndTake();
175 }
176 };
177
178 ap->applyCommand(new SelectAll(image),
181
182 endAction(ap, KisOperationConfiguration(id()).toXML());
183}
184
186{
187 KisImageWSP image = view->image();
188 if (!image) return;
189
190 if (view->canvasBase()->toolProxy()->hasSelection()) {
191 // see KisCutCopyActionFactory::run
192 KisImageBarrierLock lock(image, std::try_to_lock);
193 if (!lock.owns_lock()) return;
194
195 view->canvasBase()->toolProxy()->deselect();
196 return;
197 }
198
200
201 KisProcessingApplicator *ap = beginAction(view, cmd->text());
203 endAction(ap, KisOperationConfiguration(id()).toXML());
204}
205
207{
208 KisImageWSP image = view->image();
209 if (!image) return;
210
212
213 KisProcessingApplicator *ap = beginAction(view, cmd->text());
215 endAction(ap, KisOperationConfiguration(id()).toXML());
216}
217
218void KisFillActionFactory::run(const QString &fillSource, KisViewManager *view)
219{
220 KisNodeSP node = view->activeNode();
221 if (!node || !node->hasEditablePaintDevice()) return;
222
223 KisImageWSP image = view->image();
224
225 KisSelectionSP selection = view->selection();
226
227 bool usePattern = false;
228 bool useBgColor = false;
229 if (fillSource.contains("pattern")) {
230 usePattern = true;
231 } else if (fillSource.contains("bg")) {
232 useBgColor = true;
233 }
234
235 KisResourcesSnapshotSP resources =
237 if (!fillSource.contains("opacity")) {
238 resources->setOpacity(1.0);
239 }
240
243 kundo2_i18n("Flood Fill Layer"), false, image.data()
244 );
245 strategy->setSupportsWrapAroundMode(true);
246 KisStrokeId fillStrokeId = image->startStroke(strategy);
247 KIS_SAFE_ASSERT_RECOVER_RETURN(fillStrokeId);
248
249 QSharedPointer<QRect> dirtyRect = QSharedPointer<QRect>(new QRect);
250
251 FillProcessingVisitor *visitor = new FillProcessingVisitor(nullptr, selection, resources);
252 visitor->setSeedPoint(QPoint(0, 0));
253 visitor->setSelectionOnly(true);
254 visitor->setOutDirtyRect(dirtyRect);
255 visitor->setUsePattern(usePattern);
256 visitor->setUseBgColor(useBgColor);
257
258 image->addJob(
259 fillStrokeId,
261 KUndo2CommandSP(new KisProcessingCommand(visitor, node)),
262 false,
265 )
266 );
267
268 image->addJob(
269 fillStrokeId,
271 KUndo2CommandSP(new KisUpdateCommand(node, dirtyRect, image.data())),
272 false,
275 )
276 );
277
278 image->endStroke(fillStrokeId);
279
281}
282
284{
285 // XXX: "Add saving of XML data for Clear action"
286
288}
289
291{
292 // XXX: "Add saving of XML data for Image Resize To Selection action"
293
294 KisSelectionSP selection = view->selection();
295 if (!selection) return;
296
297 view->image()->cropImage(selection->selectedExactRect());
298}
299
301{
302 KisImageSP image = view->image();
303 if (!image) return;
304
305 if (!view->blockUntilOperationsFinished(image)) return;
306
307 // Reference layers is a fake node, so it isn't added to the layer stack, this results in KisSelectedShapesProxy not
308 // being aware of the active shapeManager and its selected shapes.
309 const auto currentToolHasSelection =
310 view->canvasBase()->toolProxy()->hasSelection();
311
312 const bool haveShapesSelected =
314
315 KisSelectionSP selection = view->selection();
316
317 const bool skipShapes = selection && !currentToolHasSelection;
318
319 if (!skipShapes && !flags.testFlag(SharpClip) && (haveShapesSelected || currentToolHasSelection)) {
320 // XXX: "Add saving of XML data for Cut/Copy of shapes"
321
327 KisImageBarrierLock lock(image, std::try_to_lock);
328 if (!lock.owns_lock()) return;
329
330 if (flags & CutClip) {
331 view->canvasBase()->toolProxy()->cut();
332 } else {
333 view->canvasBase()->toolProxy()->copy();
334 }
335 } else if (selection) {
336 KisNodeList selectedNodes = view->nodeManager()->selectedNodes();
337
338 KisNodeList masks;
339 Q_FOREACH (KisNodeSP node, selectedNodes) {
340 if (node->inherits("KisMask")) {
341 masks.append(node);
342 }
343 }
344
345 selectedNodes = KisLayerUtils::sortAndFilterMergeableInternalNodes(selectedNodes);
346
347 KisNodeList nodes;
348 Q_FOREACH (KisNodeSP node, selectedNodes) {
349 KisNodeSP dupNode;
350 if (node->inherits("KisShapeLayer") || node->inherits("KisFileLayer")) {
351 KisPaintDeviceSP dev = new KisPaintDevice(*node->projection());
352 // might have to change node's name (vector to paint layer)
353 dupNode = new KisPaintLayer(image, node->name(), node->opacity(), dev);
354 } else {
355 dupNode = node->clone();
356 }
357 nodes.append(dupNode);
358 }
359
360 Q_FOREACH (KisNodeSP node, nodes) {
361 KisLayerUtils::recursiveApplyNodes(node, [image, view, flags] (KisNodeSP node) {
362 if (node && node->paintDevice()) {
363 node->paintDevice()->burnKeyframe();
364 }
365
366 KisTimeSpan range;
367
369 if (channel) {
370 const int currentTime = image->animationInterface()->currentTime();
371 range = channel->affectedFrames(currentTime);
372 }
373
374 if (node && node->paintDevice() && !node->inherits("KisMask")) {
375 ActionHelper::trimDevice(view, node->paintDevice(), flags.testFlag(SharpClip), range);
376 }
377 });
378 }
379
380 KisImageSP tempImage = ActionHelper::makeImage(view, nodes);
381 KisClipboard::instance()->setLayers(nodes, tempImage);
382
383
384 KUndo2MagicString actionName = flags & CutClip ?
385 kundo2_i18n("Cut") :
386 kundo2_i18n("Copy");
387 KisProcessingApplicator *ap = beginAction(view, actionName);
388
389 if (flags & CutClip) {
390 selectedNodes.append(masks);
391 Q_FOREACH (KisNodeSP node, selectedNodes) {
392 KisLayerUtils::recursiveApplyNodes(node, [selection, masks, ap] (KisNodeSP node){
393
394 if (!node->hasEditablePaintDevice()) {
395 return;
396 }
397
398 // applied on masks if selected explicitly (when CTRL-X(cut) is used for deletion)
399 if (node->inherits("KisMask") && !masks.contains(node)) {
400 return;
401 }
402
403 struct ClearSelection : public KisTransactionBasedCommand {
404 ClearSelection(KisNodeSP node, KisSelectionSP sel)
405 : m_node(node), m_sel(sel) {}
406 KisNodeSP m_node;
407 KisSelectionSP m_sel;
408
409 KUndo2Command* paint() override {
410 KisSelectionSP cutSelection = m_sel;
411 // Shrinking the cutting area was previously used
412 // for getting seamless cut-paste. Now we use makeSharpClip
413 // instead.
414 // QRect originalRect = cutSelection->selectedExactRect();
415 // static const int preciseSelectionThreshold = 16;
416 //
417 // if (originalRect.width() > preciseSelectionThreshold ||
418 // originalRect.height() > preciseSelectionThreshold) {
419 // cutSelection = new KisSelection(*m_sel);
420 // delete cutSelection->flatten();
421 //
422 // KisSelectionFilter* filter = new KisShrinkSelectionFilter(1, 1, false);
423 //
424 // QRect processingRect = filter->changeRect(originalRect);
425 // filter->process(cutSelection->pixelSelection(), processingRect);
426 // }
427
428 KisTransaction transaction(m_node->paintDevice());
429 m_node->paintDevice()->clearSelection(cutSelection);
430 m_node->setDirty(cutSelection->selectedRect());
431 return transaction.endAndTake();
432 }
433 };
434
435 KUndo2Command *command = new ClearSelection(node, selection);
437
438 });
439 }
440 }
441
442 KisOperationConfiguration config(id());
443 config.setProperty("will-cut", flags.testFlag(CutClip));
444 config.setProperty("use-sharp-clip", flags.testFlag(SharpClip));
445 endAction(ap, config.toXML());
446 } else if (!flags.testFlag(SharpClip)) {
447 if (flags & CutClip) {
449 } else {
451 }
452 }
453}
454
456{
457 KisImageWSP image = view->image();
458 if (!image) return;
459 if (!view->blockUntilOperationsFinished(image)) return;
460
461 image->barrierLock();
462 KisPaintDeviceSP dev = new KisPaintDevice(*image->root()->projection());
463 ActionHelper::trimDevice(view, dev);
464
465 KisNodeSP node = new KisPaintLayer(image, "Projection", OPACITY_OPAQUE_U8, dev);
466 KisNodeList nodes{node};
467
468 KisImageSP tempImage = ActionHelper::makeImage(view, nodes);
469 KisClipboard::instance()->setLayers(nodes, tempImage);
470 image->unlock();
471
472 KisProcessingApplicator *ap = beginAction(view, kundo2_i18n("Copy Merged"));
473 endAction(ap, KisOperationConfiguration(id()).toXML());
474}
475
477{
479
480 runFilter(filter, view, config);
481}
482
484{
485 KisSelectionSP selection = view->selection();
486
487 if (selection->hasShapeSelection()) {
488 view->showFloatingMessage(i18nc("floating message",
489 "Selection is already in a vector format "),
490 QIcon(), 2000, KisFloatingMessage::Low);
491 return;
492 }
493
494 if (!selection->outlineCacheValid()) {
495 view->image()->addSpontaneousJob(new KisUpdateOutlineJob(selection, false, Qt::transparent));
496 if (!view->blockUntilOperationsFinished(view->image())) {
497 return;
498 }
499 }
500
501 QPainterPath selectionOutline = selection->outlineCache();
502 QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
503
504 KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(selectionOutline));
506
510 if(!shape->userData()) {
512 }
513
514 KisProcessingApplicator *ap = beginAction(view, kundo2_i18n("Convert to Vector Selection"));
515
516 ap->applyCommand(view->canvasBase()->shapeController()->addShape(shape, 0),
519
520 endAction(ap, KisOperationConfiguration(id()).toXML());
521}
522
524{
525 KisSelectionSP selection = view->selection();
526
527 if (!selection->hasShapeSelection()) {
528 view->showFloatingMessage(i18nc("floating message",
529 "Selection is already in a raster format "),
530 QIcon(), 2000, KisFloatingMessage::Low);
531 return;
532 }
533
534 KisProcessingApplicator *ap = beginAction(view, kundo2_i18n("Convert to Vector Selection"));
535
536 struct RasterizeSelection : public KisTransactionBasedCommand {
537 RasterizeSelection(KisSelectionSP sel)
538 : m_sel(sel) {}
539 KisSelectionSP m_sel;
540
541 KUndo2Command* paint() override {
542 // just create an empty transaction: it will rasterize the
543 // selection and Q_EMIT the necessary signals
544
545 KisTransaction transaction(m_sel->pixelSelection());
546 return transaction.endAndTake();
547 }
548 };
549
550 ap->applyCommand(new RasterizeSelection(selection),
553
554 endAction(ap, KisOperationConfiguration(id()).toXML());
555}
556
558{
559 const QList<KoShape*> originalShapes = view->canvasBase()->shapeManager()->selection()->selectedShapes();
560
561 bool hasSelectionShapes = false;
562 QList<KoShape*> clonedShapes;
563
564 Q_FOREACH (KoShape *shape, originalShapes) {
565 if (dynamic_cast<KisShapeSelectionMarker*>(shape->userData())) {
566 hasSelectionShapes = true;
567 continue;
568 }
569
570 clonedShapes << shape->cloneShapeAndBakeAbsoluteTransform();
571 }
572
573 if (clonedShapes.isEmpty()) {
574 if (hasSelectionShapes) {
575 view->showFloatingMessage(i18nc("floating message",
576 "The shape already belongs to a selection"),
577 QIcon(), 2000, KisFloatingMessage::Low);
578 }
579 return;
580 }
581
582 KisSelectionToolHelper helper(view->canvasBase(), kundo2_i18n("Convert shapes to vector selection"));
583 helper.addSelectionShapes(clonedShapes);
584}
585
587{
588 KisSelectionSP selection = view->selection();
589 if (!selection->outlineCacheValid()) {
590 return;
591 }
592
593 QPainterPath selectionOutline = selection->outlineCache();
594 QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
595
596 KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(selectionOutline));
598
599 KoColor fgColor = view->canvasBase()->resourceManager()->resource(KoCanvasResource::ForegroundColor).value<KoColor>();
600 KoShapeStrokeSP border(new KoShapeStroke(1.0, fgColor.toQColor()));
601 shape->setStroke(border);
602
603 KUndo2Command *cmd = view->canvasBase()->shapeController()->addShapeDirect(shape, 0);
605}
606
608{
609 KisImageWSP image = view->image();
610 if (!image) {
611 return;
612 }
613
614 KisSelectionSP selection = view->selection();
615 if (!selection) {
616 return;
617 }
618
619 int size = params.lineSize;
620
621 KisPixelSelectionSP pixelSelection = selection->projection();
622 if (!pixelSelection->outlineCacheValid()) {
623 pixelSelection->recalculateOutlineCache();
624 }
625
626 QPainterPath outline = pixelSelection->outlineCache();
627 QColor color = params.color.toQColor();
628
630 if (!currentNode->inherits("KisShapeLayer") && currentNode->paintDevice()) {
633 KisToolShapeUtils::FillStyle fillStyle = params.fillStyle();
634
635 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Polyline"),
636 image,
637 currentNode,
638 rManager ,
639 strokeStyle,
640 fillStyle);
641 helper.setFGColorOverride(params.color);
642 helper.setSelectionOverride(0);
643 QPen pen(Qt::red, size);
644 pen.setJoinStyle(Qt::RoundJoin);
645
646 if (fillStyle != KisToolShapeUtils::FillStyleNone) {
647 helper.paintPainterPathQPenFill(outline, pen, params.fillColor);
648 }
649 else {
650 helper.paintPainterPathQPen(outline, pen, params.fillColor);
651 }
652 }
653 else if (currentNode->inherits("KisShapeLayer")) {
654
655 QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
656
657 KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(outline));
659
660 KoShapeStrokeSP border(new KoShapeStroke(size, color));
661 shape->setStroke(border);
662
663 KUndo2Command *cmd = view->canvasBase()->shapeController()->addShapeDirect(shape, 0);
665 }
666}
667
669{
670 KisImageWSP image = view->image();
671 if (!image) {
672 return;
673 }
674
675 KisSelectionSP selection = view->selection();
676 if (!selection) {
677 return;
678 }
679
680 KisPixelSelectionSP pixelSelection = selection->projection();
681 if (!pixelSelection->outlineCacheValid()) {
682 pixelSelection->recalculateOutlineCache();
683 }
684
686 if (!currentNode->inherits("KisShapeLayer") && currentNode->paintDevice())
687 {
689 QPainterPath outline = pixelSelection->outlineCache();
692 KoColor color = params.color;
693
694 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Polyline"),
695 image,
696 currentNode,
697 rManager,
698 strokeStyle,
699 fillStyle);
700 helper.setFGColorOverride(color);
701 helper.setSelectionOverride(0);
702 helper.paintPainterPath(outline);
703 }
704}
const quint8 OPACITY_OPAQUE_U8
#define KoPathShapeId
Definition KoPathShape.h:20
void setOutDirtyRect(QSharedPointer< QRect > outDirtyRect)
void setSeedPoint(const QPoint &seedPoint)
void setSelectionOnly(bool selectionOnly)
void setUseBgColor(bool useBgColor)
void setUsePattern(bool usePattern)
KUndo2MagicString text() const
KisCoordinatesConverter * coordinatesConverter
KoShapeManager shapeManager
KisToolProxy toolProxy
KoCanvasResourceProvider * resourceManager()
void setLayers(KisNodeList nodes, KisImageSP image, bool forceCopy=false)
static KisClipboard * instance()
void paintPainterPathQPenFill(const QPainterPath, const QPen &pen, const KoColor &color)
void setSelectionOverride(KisSelectionSP m_selection)
void paintPainterPath(const QPainterPath &path)
void paintPainterPathQPen(const QPainterPath, const QPen &pen, const KoColor &color)
void waitForDone()
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
const KoColorSpace * colorSpace() const
KisImageAnimationInterface * animationInterface() const
void unlock()
Definition kis_image.cc:805
void barrierLock(bool readOnly=false)
Wait until all the queued background jobs are completed and lock the image.
Definition kis_image.cc:756
qint32 width() const
void addJob(KisStrokeId id, KisStrokeJobData *data) override
void cropImage(const QRect &newRect)
start asynchronous operation on cropping the image
Definition kis_image.cc:870
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
double xRes() const
double yRes() const
qint32 height() const
KisSelectionSP globalSelection() const
Definition kis_image.cc:695
QRect bounds() const override
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob)
void endStroke(KisStrokeId id) override
void setResolution(double xres, double yres)
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
static const KoID Raster
virtual KisTimeSpan affectedFrames(int time) const
Get the set of frames affected by any changes to the value or content of the active keyframe at the g...
KisNodeList selectedNodes()
KisProcessingApplicator * beginAction(KisViewManager *view, const KUndo2MagicString &actionName)
void endAction(KisProcessingApplicator *applicator, const QString &xmlData)
void crop(qint32 x, qint32 y, qint32 w, qint32 h)
void setDefaultPixel(const KoColor &defPixel)
const KoColorSpace * colorSpace() const
void clearSelection(KisSelectionSP selection)
KoColor defaultPixel() const
static void runSingleCommandStroke(KisImageSP image, KUndo2Command *cmd, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
runSingleCommandStroke creates a stroke and runs cmd in it. The text() field of cmd is used as a titl...
void applyCommand(KUndo2Command *command, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
void addSelectionShapes(QList< KoShape * > shapes, SelectionAction action=SELECTION_DEFAULT)
ALWAYS_INLINE quint8 * rawData()
ALWAYS_INLINE const quint8 * oldRawData() const
KUndo2Command * endAndTake()
bool blockUntilOperationsFinished(KisImageSP image)
blockUntilOperationsFinished blocks the GUI of the application until execution of actions on image is...
KisCanvas2 * canvasBase() const
Return the canvas base class.
KisNodeSP activeNode()
KisSelectionSP selection()
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
KisSelectionManager * selectionManager()
KisImageWSP image() const
Return the image this view is displaying.
KisCanvasResourceProvider * canvasResourceProvider()
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
QPointer< KoShapeController > shapeController
QPointer< KoCanvasResourceProvider > resourceManager
virtual void applyAlphaU8Mask(quint8 *pixels, const quint8 *alpha, qint32 nPixels) const =0
virtual qreal opacityF(const quint8 *pixel) const =0
virtual void applyAlphaNormedFloatMask(quint8 *pixels, const float *alpha, qint32 nPixels) const =0
static KoColor createTransparent(const KoColorSpace *cs)
Definition KoColor.cpp:681
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
static KoPathShape * createShapeFromPainterPath(const QPainterPath &path)
Creates path shape from given QPainterPath.
const QList< KoShape * > selectedShapes() const
KoSelection * selection
KoShapeUserData * userData() const
Definition KoShape.cpp:710
KoShape * cloneShapeAndBakeAbsoluteTransform() const
creates a deep copy of the shape/shapes tree and bakes the absolute transform of this into the result...
Definition KoShape.cpp:207
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081
void setUserData(KoShapeUserData *userData)
Definition KoShape.cpp:705
void setShapeId(const QString &id)
Definition KoShape.cpp:1062
void copy() const
Forwarded to the current KoToolBase.
void deselect()
Forwarded to the current KoToolBase.
void cut()
Forwarded to the current KoToolBase.
bool hasSelection() const
returns true if the current tool holds a selection
void deleteSelection()
Forwarded to the current KoToolBase.
bool selectAll()
Forwarded to the current KoToolBase.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
QSharedPointer< KUndo2Command > KUndo2CommandSP
Definition kis_types.h:262
KUndo2MagicString kundo2_i18n(const char *text)
KisImageSP makeImage(KisViewManager *view, KisNodeList nodes)
void trimDevice(KisViewManager *view, KisPaintDeviceSP device, bool makeSharpClip=false, const KisTimeSpan &range=KisTimeSpan())
KisNodeList sortAndFilterMergeableInternalNodes(KisNodeList nodes, bool allowMasks)
void recursiveApplyNodes(NodePointer node, Functor func)
@ ForegroundColor
The active foreground color selected for this canvas.
virtual KisPaintDeviceSP projection() const =0
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
virtual KisPaintDeviceSP paintDevice() const =0
QString name() const
quint8 opacity() const
bool hasEditablePaintDevice() const
void run(KisViewManager *view) override
The LambdaCommand struct is a shorthand for creation of AggregateCommand commands using C++ lambda fe...
void run(KisViewManager *view) override
void run(Flags flags, KisViewManager *view)
void run(KisViewManager *view) override
void run(const QString &fillSource, KisViewManager *view)
void runFilter(KisSelectionFilter *filter, KisViewManager *view, const KisOperationConfiguration &config)
void runFromXML(KisViewManager *view, const KisOperationConfiguration &config) override
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
virtual KisNodeSP clone() const =0
virtual void setDirty()
Definition kis_node.cpp:577
void recalculateOutlineCache() override
void clear(const QRect &r)
void select(const QRect &r, quint8 selectedness=MAX_SELECTED)
void toXML(QDomDocument &, QDomElement &) const override
virtual void setProperty(const QString &name, const QVariant &value)
void run(KisViewManager *view) override
void run(KisViewManager *view) override
void run(KisViewManager *view) override
KisPixelSelectionSP projection() const
bool outlineCacheValid() const
KisPixelSelectionSP pixelSelection
QRect selectedRect() const
bool hasShapeSelection() const
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.
QPainterPath outlineCache() const
void run(KisViewManager *view, const StrokeSelectionOptions &params)
void run(KisViewManager *view, const StrokeSelectionOptions &params)
KisToolShapeUtils::FillStyle fillStyle() const