Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSelectionManager Class Reference

#include <kis_selection_manager.h>

+ Inheritance diagram for KisSelectionManager:

Public Slots

void clear ()
 
void clipboardDataChanged ()
 
void configChanged ()
 
void convertShapesToVectorSelection ()
 
void convertToRasterSelection ()
 
void convertToShape ()
 
void convertToVectorSelection ()
 
void copy ()
 
void copyMerged ()
 
void copySelectionToNewLayer ()
 
void copySharp ()
 
void cut ()
 
void cutSharp ()
 
void cutToNewLayer ()
 
void deselect ()
 
void editSelection ()
 
void enableSelectionActionsPanel (bool enabled)
 
void fillBackgroundColor ()
 
void fillBackgroundColorOpacity ()
 
void fillForegroundColor ()
 
void fillForegroundColorOpacity ()
 
void fillPattern ()
 
void fillPatternOpacity ()
 
void imageResizeToSelection ()
 
void invert ()
 
void paintSelectedShapes ()
 
void paste ()
 
void pasteAsReference ()
 
void pasteAt ()
 
void pasteInto ()
 
void pasteNew ()
 
void pasteShapeStyle ()
 
void reselect ()
 
void selectAll ()
 
void selectionChanged ()
 
void selectOpaqueOnNode (KisNodeSP node, SelectionAction action)
 
void shapeSelectionChanged ()
 
void slotStrokeSelection ()
 
void slotToggleSelectionDecoration ()
 
void toggleDisplaySelection ()
 
void updateGUI ()
 

Signals

void currentSelectionChanged ()
 
void displaySelectionChanged ()
 
void signalUpdateGUI ()
 
void strokeSelected ()
 

Public Member Functions

bool canReselectDeactivatedSelection ()
 
bool displaySelection ()
 
bool haveAnySelectionWithPixels ()
 Checks if the current selection is editable and has some pixels selected in the pixel selection.
 
bool havePixelsInClipboard ()
 
bool havePixelsSelected ()
 
bool haveRasterSelectionWithPixels ()
 
bool haveShapeSelectionWithShapes ()
 
bool haveShapesInClipboard ()
 
bool haveShapesSelected ()
 
 KisSelectionManager (KisViewManager *view)
 
void setup (KisActionManager *actionManager)
 
void setView (QPointer< KisView >imageView)
 
bool showSelectionAsMask () const
 
 ~KisSelectionManager () override
 

Properties

bool displaySelection
 
bool havePixelsSelected
 

Private Member Functions

void fill (const KoColor &color, bool fillWithPattern, const QString &transactionText)
 
void updateStatusBar ()
 

Private Attributes

KisNodeCommandsAdapterm_adapter {0}
 
KisActionm_clear {0}
 
KisClipboardm_clipboard {0}
 
KisActionm_copy {0}
 
KisActionm_copyMerged {0}
 
KisActionm_copyToNewLayer {0}
 
KisActionm_cut {0}
 
KisActionm_cutToNewLayer {0}
 
KisActionm_deselect {0}
 
KisDocumentm_doc {0}
 
KisActionm_enableSelectionActionsPanel {0}
 
KisActionm_fillBackgroundColor {0}
 
KisActionm_fillBackgroundColorOpacity {0}
 
KisActionm_fillForegroundColor {0}
 
KisActionm_fillForegroundColorOpacity {0}
 
KisActionm_fillPattern {0}
 
KisActionm_fillPatternOpacity {0}
 
KisActionm_imageResizeToSelection {0}
 
QPointer< KisViewm_imageView {0}
 
KisActionm_invert {0}
 
KisActionm_paste {0}
 
KisActionm_pasteAsReference {0}
 
KisActionm_pasteAt {0}
 
KisActionm_pasteInto {0}
 
KisActionm_pasteNew {0}
 
KisActionm_pasteShapeStyle {0}
 
QList< QAction * > m_pluginActions
 
KisActionm_reselect {0}
 
KisActionm_selectAll {0}
 
QPointer< KisSelectionDecorationm_selectionDecoration
 
KisActionm_strokeSelected {0}
 
KisActionm_strokeShapes {0}
 
KisActionm_toggleDisplaySelection {0}
 
KisActionm_toggleSelectionOverlayMode {0}
 
KisViewManagerm_view {0}
 

Detailed Description

The selection manager is responsible selections and the clipboard.

Definition at line 36 of file kis_selection_manager.h.

Constructor & Destructor Documentation

◆ KisSelectionManager()

KisSelectionManager::KisSelectionManager ( KisViewManager * view)

Definition at line 85 of file kis_selection_manager.cc.

86 : m_view(view)
88{
90}
static KisClipboard * instance()
KisNodeCommandsAdapter * m_adapter

References KisClipboard::instance(), and m_clipboard.

◆ ~KisSelectionManager()

KisSelectionManager::~KisSelectionManager ( )
override

Definition at line 92 of file kis_selection_manager.cc.

93{
94}

Member Function Documentation

◆ canReselectDeactivatedSelection()

bool KisSelectionManager::canReselectDeactivatedSelection ( )

If we have an active selection mask, then no reselection is possible

Definition at line 295 of file kis_selection_manager.cc.

296{
297 if (!m_view) return false;
298
299 KisLayerSP layer = m_view->activeLayer();
300
301 if (layer) {
306 if (layer->selectionMask()) return false;
307
308 KoProperties properties;
309 properties.setProperty("active", false);
310 properties.setProperty("visible", true);
311 QList<KisNodeSP> masks = layer->childNodes(QStringList("KisSelectionMask"), properties);
312
313 if (!masks.isEmpty()) {
314 return true;
315 }
316 }
317
318 KisImageSP image = m_view->image();
319 return image && image->canReselectGlobalSelection();
320}
QList< QString > QStringList
bool canReselectGlobalSelection()
Definition kis_image.cc:706
KisLayerSP activeLayer()
Convenience method to get at the active layer.
KisImageWSP image() const
Return the image this view is displaying.
void setProperty(const QString &name, const QVariant &value)
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:504
QList< KisNodeSP > childNodes(const QStringList &nodeTypes, const KoProperties &properties) const
Definition kis_node.cpp:439

References KisViewManager::activeLayer(), KisImage::canReselectGlobalSelection(), KisNode::childNodes(), KisViewManager::image(), m_view, KisLayer::selectionMask(), and KoProperties::setProperty().

◆ clear

void KisSelectionManager::clear ( )
slot

Definition at line 530 of file kis_selection_manager.cc.

531{
532 KisClearActionFactory factory;
533 factory.run(m_view);
534}
void run(KisViewManager *view) override

References m_view, and KisClearActionFactory::run().

◆ clipboardDataChanged

void KisSelectionManager::clipboardDataChanged ( )
slot

Definition at line 247 of file kis_selection_manager.cc.

248{
249 m_view->updateGUI();
250}

References m_view, and KisViewManager::updateGUI().

◆ configChanged

void KisSelectionManager::configChanged ( )
slot

Definition at line 523 of file kis_selection_manager.cc.

524{
525 KisConfig cfg(true);
526
527 m_enableSelectionActionsPanel->setChecked(cfg.selectionActionBar());
528}
KisAction * m_enableSelectionActionsPanel

References m_enableSelectionActionsPanel, and KisConfig::selectionActionBar().

◆ convertShapesToVectorSelection

void KisSelectionManager::convertShapesToVectorSelection ( )
slot

◆ convertToRasterSelection

void KisSelectionManager::convertToRasterSelection ( )
slot

◆ convertToShape

void KisSelectionManager::convertToShape ( )
slot

◆ convertToVectorSelection

void KisSelectionManager::convertToVectorSelection ( )
slot

◆ copy

◆ copyMerged

void KisSelectionManager::copyMerged ( )
slot

◆ copySelectionToNewLayer

void KisSelectionManager::copySelectionToNewLayer ( )
slot

◆ copySharp

void KisSelectionManager::copySharp ( )
slot

◆ currentSelectionChanged

void KisSelectionManager::currentSelectionChanged ( )
signal

◆ cut

◆ cutSharp

◆ cutToNewLayer

void KisSelectionManager::cutToNewLayer ( )
slot

◆ deselect

void KisSelectionManager::deselect ( )
slot

Definition at line 429 of file kis_selection_manager.cc.

References m_view, and KisDeselectActionFactory::run().

◆ displaySelection()

bool KisSelectionManager::displaySelection ( )

This function return if the selection should be displayed

◆ displaySelectionChanged

void KisSelectionManager::displaySelectionChanged ( )
signal

◆ editSelection

void KisSelectionManager::editSelection ( )
slot

Definition at line 451 of file kis_selection_manager.cc.

452{
453 KisSelectionSP selection = m_view->selection();
454 if (!selection) return;
455
456 KisAction *action = m_view->actionManager()->actionByName("show-global-selection-mask");
458
459 if (!action->isChecked()) {
460 action->setChecked(true);
461 Q_EMIT action->toggled(true);
462 Q_EMIT action->triggered(true);
463 }
464
465 KisNodeSP node = selection->parentNode();
467
469
470 if (selection->hasShapeSelection()) {
471 KisShapeSelection *shapeSelection = dynamic_cast<KisShapeSelection*>(selection->shapeSelection());
472 KIS_SAFE_ASSERT_RECOVER_RETURN(shapeSelection);
473
475
476 QList<KoShape*> shapes = shapeSelection->shapes();
477
478 if (shapes.isEmpty()) {
479 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "no shapes");
480 return;
481 }
482
483 Q_FOREACH (KoShape *shape, shapes) {
485 }
486 } else {
487 KoToolManager::instance()->switchToolRequested("KisToolTransform");
488 }
489}
#define KoInteractionTool_ID
KisAction * actionByName(const QString &name) const
KisSelectedShapesProxy selectedShapesProxy
void slotNonUiActivatedNode(KisNodeSP node)
KoSelection * selection() override
KisActionManager * actionManager() const
KisCanvas2 * canvasBase() const
Return the canvas base class.
KisSelectionSP selection()
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
void select(KoShape *shape)
QList< KoShape * > shapes() const
void switchToolRequested(const QString &id)
static KoToolManager * instance()
Return the toolmanager singleton.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
KisSelectionComponent * shapeSelection
bool hasShapeSelection() const
KisNodeWSP parentNode

References KisActionManager::actionByName(), KisViewManager::actionManager(), KisViewManager::canvasBase(), KisSelection::hasShapeSelection(), KoToolManager::instance(), KIS_SAFE_ASSERT_RECOVER_NOOP, KIS_SAFE_ASSERT_RECOVER_RETURN, KoInteractionTool_ID, m_view, KisViewManager::nodeManager(), KisSelection::parentNode, KoSelection::select(), KisCanvas2::selectedShapesProxy, KisViewManager::selection(), KisSelectedShapesProxy::selection(), KoShapeContainer::shapes(), KisSelection::shapeSelection, KisNodeManager::slotNonUiActivatedNode(), and KoToolManager::switchToolRequested().

◆ enableSelectionActionsPanel

void KisSelectionManager::enableSelectionActionsPanel ( bool enabled)
slot

Definition at line 515 of file kis_selection_manager.cc.

516{
517 KisConfig cfg(false);
518 cfg.setSelectionActionBar(visible);
519
521}
static KisConfigNotifier * instance()

References KisConfigNotifier::instance(), KisConfigNotifier::notifyConfigChanged(), and KisConfig::setSelectionActionBar().

◆ fill()

void KisSelectionManager::fill ( const KoColor & color,
bool fillWithPattern,
const QString & transactionText )
private

◆ fillBackgroundColor

void KisSelectionManager::fillBackgroundColor ( )
slot

Definition at line 542 of file kis_selection_manager.cc.

543{
544 KisFillActionFactory factory;
545 factory.run("bg", m_view);
546}
void run(const QString &fillSource, KisViewManager *view)

References m_view, and KisFillActionFactory::run().

◆ fillBackgroundColorOpacity

void KisSelectionManager::fillBackgroundColorOpacity ( )
slot

Definition at line 560 of file kis_selection_manager.cc.

561{
562 KisFillActionFactory factory;
563 factory.run("bg_opacity", m_view);
564}

References m_view, and KisFillActionFactory::run().

◆ fillForegroundColor

void KisSelectionManager::fillForegroundColor ( )
slot

Definition at line 536 of file kis_selection_manager.cc.

537{
538 KisFillActionFactory factory;
539 factory.run("fg", m_view);
540}

References m_view, and KisFillActionFactory::run().

◆ fillForegroundColorOpacity

void KisSelectionManager::fillForegroundColorOpacity ( )
slot

Definition at line 554 of file kis_selection_manager.cc.

555{
556 KisFillActionFactory factory;
557 factory.run("fg_opacity", m_view);
558}

References m_view, and KisFillActionFactory::run().

◆ fillPattern

void KisSelectionManager::fillPattern ( )
slot

Definition at line 548 of file kis_selection_manager.cc.

549{
550 KisFillActionFactory factory;
551 factory.run("pattern", m_view);
552}

References m_view, and KisFillActionFactory::run().

◆ fillPatternOpacity

void KisSelectionManager::fillPatternOpacity ( )
slot

Definition at line 566 of file kis_selection_manager.cc.

567{
568 KisFillActionFactory factory;
569 factory.run("pattern_opacity", m_view);
570}

References m_view, and KisFillActionFactory::run().

◆ haveAnySelectionWithPixels()

bool KisSelectionManager::haveAnySelectionWithPixels ( )

Checks if the current selection is editable and has some pixels selected in the pixel selection.

Definition at line 277 of file kis_selection_manager.cc.

278{
279 KisSelectionSP selection = m_view->selection();
280 return selection && selection->hasNonEmptyPixelSelection();
281}
bool hasNonEmptyPixelSelection() const

References KisSelection::hasNonEmptyPixelSelection(), m_view, and KisViewManager::selection().

◆ havePixelsInClipboard()

bool KisSelectionManager::havePixelsInClipboard ( )

Definition at line 258 of file kis_selection_manager.cc.

259{
260 return m_clipboard->hasClip();
261}
bool hasClip() const

References KisClipboard::hasClip(), and m_clipboard.

◆ havePixelsSelected()

bool KisSelectionManager::havePixelsSelected ( )

◆ haveRasterSelectionWithPixels()

bool KisSelectionManager::haveRasterSelectionWithPixels ( )

Definition at line 289 of file kis_selection_manager.cc.

290{
291 KisSelectionSP selection = m_view->selection();
292 return selection && selection->hasNonEmptyPixelSelection() && !selection->hasNonEmptyShapeSelection();
293}
bool hasNonEmptyShapeSelection() const

References KisSelection::hasNonEmptyPixelSelection(), KisSelection::hasNonEmptyShapeSelection(), m_view, and KisViewManager::selection().

◆ haveShapeSelectionWithShapes()

bool KisSelectionManager::haveShapeSelectionWithShapes ( )

Definition at line 283 of file kis_selection_manager.cc.

284{
285 KisSelectionSP selection = m_view->selection();
286 return selection && selection->hasNonEmptyShapeSelection();
287}

References KisSelection::hasNonEmptyShapeSelection(), m_view, and KisViewManager::selection().

◆ haveShapesInClipboard()

bool KisSelectionManager::haveShapesInClipboard ( )

Definition at line 271 of file kis_selection_manager.cc.

272{
274 return paste.hasShapes();
275}
bool hasShapes()

References KoSvgPaste::hasShapes(), and paste().

◆ haveShapesSelected()

bool KisSelectionManager::haveShapesSelected ( )

Definition at line 263 of file kis_selection_manager.cc.

264{
265 if (m_view && m_view->canvasBase()) {
266 return m_view->canvasBase()->selectedShapesProxy()->selection()->count() > 0;
267 }
268 return false;
269}
int count() const
return the selection count, i.e. the number of all selected shapes

References KisViewManager::canvasBase(), KoSelection::count(), m_view, KisCanvas2::selectedShapesProxy, and KisSelectedShapesProxy::selection().

◆ imageResizeToSelection

void KisSelectionManager::imageResizeToSelection ( )
slot

◆ invert

void KisSelectionManager::invert ( )
slot

Definition at line 435 of file kis_selection_manager.cc.

436{
437 if(m_invert)
438 m_invert->trigger();
439}

References m_invert.

◆ paintSelectedShapes

void KisSelectionManager::paintSelectedShapes ( )
slot

Definition at line 628 of file kis_selection_manager.cc.

629{
630 KisImageWSP image = m_view->image();
631 if (!image) return;
632
633 KisLayerSP layer = m_view->activeLayer();
634 if (!layer) return;
635
637
638 KisPaintLayerSP paintLayer = new KisPaintLayer(image, i18n("Stroked Shapes"), OPACITY_OPAQUE_U8);
639
640 KUndo2MagicString actionName = kundo2_i18n("Stroke Shapes");
641
642 m_adapter->beginMacro(actionName);
643 m_adapter->addNode(paintLayer.data(), layer->parent().data(), layer.data());
644
645 KisFigurePaintingToolHelper helper(actionName,
646 image,
647 paintLayer.data(),
651
652 Q_FOREACH (KoShape* shape, shapes) {
653 QTransform matrix = shape->absoluteTransformation() * QTransform::fromScale(image->xRes(), image->yRes());
654 QPainterPath mappedOutline = matrix.map(shape->outline());
655 helper.paintPainterPath(mappedOutline);
656 }
658}
const quint8 OPACITY_OPAQUE_U8
KoShapeManager shapeManager
KoCanvasResourceProvider * resourceManager()
double xRes() const
double yRes() const
void addNode(KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis, KisImageLayerAddCommand::Flags flags=KisImageLayerAddCommand::DoRedoUpdates|KisImageLayerAddCommand::DoUndoUpdates)
void beginMacro(const KUndo2MagicString &macroName)
KisCanvasResourceProvider * canvasResourceProvider()
const QList< KoShape * > selectedShapes() const
KoSelection * selection
virtual QPainterPath outline() const
Definition KoShape.cpp:554
QTransform absoluteTransformation() const
Definition KoShape.cpp:330
KUndo2MagicString kundo2_i18n(const char *text)
KisNodeWSP parent
Definition kis_node.cpp:86

References KoShape::absoluteTransformation(), KisViewManager::activeLayer(), KisNodeCommandsAdapter::addNode(), KisNodeCommandsAdapter::beginMacro(), KisViewManager::canvasBase(), KisViewManager::canvasResourceProvider(), KisSharedPtr< T >::data(), KisWeakSharedPtr< T >::data(), KisNodeCommandsAdapter::endMacro(), KisToolShapeUtils::FillStyleNone, KisViewManager::image(), kundo2_i18n(), m_adapter, m_view, OPACITY_OPAQUE_U8, KoShape::outline(), KisFigurePaintingToolHelper::paintPainterPath(), KisNode::parent, KisCanvasResourceProvider::resourceManager(), KoSelection::selectedShapes(), KoShapeManager::selection, KisCanvas2::shapeManager, KisToolShapeUtils::StrokeStyleForeground, KisImage::xRes(), and KisImage::yRes().

◆ paste

void KisSelectionManager::paste ( )
slot

◆ pasteAsReference

void KisSelectionManager::pasteAsReference ( )
slot

◆ pasteAt

void KisSelectionManager::pasteAt ( )
slot

◆ pasteInto

void KisSelectionManager::pasteInto ( )
slot

Definition at line 399 of file kis_selection_manager.cc.

400{
402 factory.run(m_view);
403}
void run(KisViewManager *view) override

References m_view, and KisPasteIntoActionFactory::run().

◆ pasteNew

void KisSelectionManager::pasteNew ( )
slot

Definition at line 411 of file kis_selection_manager.cc.

412{
414 factory.run(m_view);
415}
void run(KisViewManager *view) override

References m_view, and KisPasteNewActionFactory::run().

◆ pasteShapeStyle

void KisSelectionManager::pasteShapeStyle ( )
slot

◆ reselect

void KisSelectionManager::reselect ( )
slot

Definition at line 441 of file kis_selection_manager.cc.

References m_view, and KisReselectActionFactory::run().

◆ selectAll

void KisSelectionManager::selectAll ( )
slot

Definition at line 423 of file kis_selection_manager.cc.

References m_view, and KisSelectAllActionFactory::run().

◆ selectionChanged

void KisSelectionManager::selectionChanged ( )
slot

Definition at line 351 of file kis_selection_manager.cc.

352{
353 m_view->updateGUI();
355}
void currentSelectionChanged()

References currentSelectionChanged(), m_view, and KisViewManager::updateGUI().

◆ selectOpaqueOnNode

void KisSelectionManager::selectOpaqueOnNode ( KisNodeSP node,
SelectionAction action )
slot

If there is nothing selected, just create a new selection

Definition at line 714 of file kis_selection_manager.cc.

715{
716 KisImageSP image = m_view->image();
717
719 return;
720 }
721
722 KUndo2MagicString actionName;
724 KisCanvas2 *canvas = m_view->canvasBase();
725
726
727 {
728 KisImageBarrierLock lock(image);
729
730 KisPaintDeviceSP device = node->projection();
731 if (!device) device = node->paintDevice();
732 if (!device) device = node->original();
733
734 if (!device) return;
735
736 QRect rc = device->exactBounds();
737 if (rc.isEmpty()) {
738
739 if (action == SELECTION_REPLACE || action == SELECTION_INTERSECT) {
742 }
743
744 return;
745 }
746
748
752 if (!canvas->imageView()->selection()) {
753 action = SELECTION_REPLACE;
754 }
755
756 switch (action) {
757 case SELECTION_ADD:
758 actionName = kundo2_i18n("Select Opaque (Add)");
759 break;
761 actionName = kundo2_i18n("Select Opaque (Subtract)");
762 break;
764 actionName = kundo2_i18n("Select Opaque (Intersect)");
765 break;
767 actionName = kundo2_i18n("Select Opaque (Symmetric Difference)");
768 break;
769 default:
770 actionName = kundo2_i18n("Select Opaque");
771 break;
772 }
773
774 qint32 x, y, w, h;
775 rc.getRect(&x, &y, &w, &h);
776
777 const KoColorSpace * cs = device->colorSpace();
778
779 KisHLineConstIteratorSP deviter = device->createHLineConstIteratorNG(x, y, w);
780 KisHLineIteratorSP selIter = tmpSel ->createHLineIteratorNG(x, y, w);
781
782 for (int row = y; row < h + y; ++row) {
783 do {
784 *selIter->rawData() = cs->opacityU8(deviter->oldRawData());
785 } while (deviter->nextPixel() && selIter->nextPixel());
786 deviter->nextRow();
787 selIter->nextRow();
788 }
789 }
790
791 KisSelectionToolHelper helper(canvas, actionName);
792 tmpSel->invalidateOutlineCache();
793 helper.selectPixelSelection(tmpSel, action);
794}
@ SELECTION_REPLACE
@ SELECTION_INTERSECT
@ SELECTION_SYMMETRICDIFFERENCE
@ SELECTION_SUBTRACT
@ SELECTION_ADD
virtual const quint8 * oldRawData() const =0
virtual bool nextPixel()=0
QPointer< KisView > imageView() const
virtual void nextRow()=0
QRect exactBounds() const
KisHLineIteratorSP createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
const KoColorSpace * colorSpace() const
KisHLineConstIteratorSP createHLineConstIteratorNG(qint32 x, qint32 y, qint32 w) 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...
bool blockUntilOperationsFinished(KisImageSP image)
blockUntilOperationsFinished blocks the GUI of the application until execution of actions on image is...
virtual quint8 opacityU8(const quint8 *pixel) const =0
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
KisSharedPtr< KisPixelSelection > KisPixelSelectionSP
Definition kis_types.h:159
virtual KisPaintDeviceSP projection() const =0
virtual KisPaintDeviceSP original() const =0
virtual KisPaintDeviceSP paintDevice() const =0

References KisViewManager::blockUntilOperationsFinished(), KisViewManager::canvasBase(), KisPaintDevice::colorSpace(), KisPaintDevice::createHLineConstIteratorNG(), KisPaintDevice::createHLineIteratorNG(), KisPaintDevice::exactBounds(), KisViewManager::image(), KisCanvas2::imageView(), KisPixelSelection::invalidateOutlineCache(), KIS_ASSERT_RECOVER_RETURN, kundo2_i18n(), m_view, KisBaseConstIteratorNG::nextPixel(), KisHLineConstIteratorNG::nextRow(), KisBaseConstAccessor::oldRawData(), KoColorSpace::opacityU8(), KisBaseNode::original(), KisBaseNode::paintDevice(), KisBaseNode::projection(), KisProcessingApplicator::runSingleCommandStroke(), KisViewManager::selection(), SELECTION_ADD, SELECTION_INTERSECT, SELECTION_REPLACE, SELECTION_SUBTRACT, SELECTION_SYMMETRICDIFFERENCE, and KisSelectionToolHelper::selectPixelSelection().

◆ setup()

void KisSelectionManager::setup ( KisActionManager * actionManager)

Definition at line 96 of file kis_selection_manager.cc.

97{
98 m_cut = actionManager->createStandardAction(KStandardAction::Cut, this, SLOT(cut()));
99 m_copy = actionManager->createStandardAction(KStandardAction::Copy, this, SLOT(copy()));
100 m_paste = actionManager->createStandardAction(KStandardAction::Paste, this, SLOT(paste()));
101
102 KisAction *action = actionManager->createAction("copy_sharp");
103 connect(action, SIGNAL(triggered()), this, SLOT(copySharp()));
104
105 action = actionManager->createAction("cut_sharp");
106 connect(action, SIGNAL(triggered()), this, SLOT(cutSharp()));
107
108 m_pasteNew = actionManager->createAction("paste_new");
109 connect(m_pasteNew, SIGNAL(triggered()), this, SLOT(pasteNew()));
110
111 m_pasteAt = actionManager->createAction("paste_at");
112 connect(m_pasteAt, SIGNAL(triggered()), this, SLOT(pasteAt()));
113
114 m_pasteInto = actionManager->createAction("paste_into");
115 connect(m_pasteInto, SIGNAL(triggered()), this, SLOT(pasteInto()));
116
117 m_pasteAsReference = actionManager->createAction("paste_as_reference");
118 connect(m_pasteAsReference, SIGNAL(triggered()), this, SLOT(pasteAsReference()));
119
120 m_pasteShapeStyle = actionManager->createAction("paste_shape_style");
121 connect(m_pasteShapeStyle, SIGNAL(triggered()), this, SLOT(pasteShapeStyle()));
122
123 m_copyMerged = actionManager->createAction("copy_merged");
124 connect(m_copyMerged, SIGNAL(triggered()), this, SLOT(copyMerged()));
125
126 m_selectAll = actionManager->createAction("select_all");
127 connect(m_selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
128
129 m_deselect = actionManager->createAction("deselect");
130 connect(m_deselect, SIGNAL(triggered()), this, SLOT(deselect()));
131
132 m_clear = actionManager->createAction("clear");
133 connect(m_clear, SIGNAL(triggered()), SLOT(clear()));
134
135 m_reselect = actionManager->createAction("reselect");
136 connect(m_reselect, SIGNAL(triggered()), this, SLOT(reselect()));
137
138 m_invert = actionManager->createAction("invert_selection");
139 m_invert->setOperationID("invertselection");
140
142
143 m_copyToNewLayer = actionManager->createAction("copy_selection_to_new_layer");
144 connect(m_copyToNewLayer, SIGNAL(triggered()), this, SLOT(copySelectionToNewLayer()));
145
146 m_cutToNewLayer = actionManager->createAction("cut_selection_to_new_layer");
147 connect(m_cutToNewLayer, SIGNAL(triggered()), this, SLOT(cutToNewLayer()));
148
149 m_fillForegroundColor = actionManager->createAction("fill_selection_foreground_color");
150 connect(m_fillForegroundColor, SIGNAL(triggered()), this, SLOT(fillForegroundColor()));
151
152 m_fillBackgroundColor = actionManager->createAction("fill_selection_background_color");
153 connect(m_fillBackgroundColor, SIGNAL(triggered()), this, SLOT(fillBackgroundColor()));
154
155 m_fillPattern = actionManager->createAction("fill_selection_pattern");
156 connect(m_fillPattern, SIGNAL(triggered()), this, SLOT(fillPattern()));
157
158 m_fillForegroundColorOpacity = actionManager->createAction("fill_selection_foreground_color_opacity");
159 connect(m_fillForegroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillForegroundColorOpacity()));
160
161 m_fillBackgroundColorOpacity = actionManager->createAction("fill_selection_background_color_opacity");
162 connect(m_fillBackgroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillBackgroundColorOpacity()));
163
164 m_fillPatternOpacity = actionManager->createAction("fill_selection_pattern_opacity");
165 connect(m_fillPatternOpacity, SIGNAL(triggered()), this, SLOT(fillPatternOpacity()));
166
167 m_strokeShapes = actionManager->createAction("stroke_shapes");
168 connect(m_strokeShapes, SIGNAL(triggered()), this, SLOT(paintSelectedShapes()));
169
170 m_toggleDisplaySelection = actionManager->createAction("toggle_display_selection");
171 connect(m_toggleDisplaySelection, SIGNAL(triggered()), this, SLOT(toggleDisplaySelection()));
172 m_toggleDisplaySelection->setChecked(true);
173
174 m_imageResizeToSelection = actionManager->createAction("resizeimagetoselection");
175 connect(m_imageResizeToSelection, SIGNAL(triggered()), this, SLOT(imageResizeToSelection()));
176
177 action = actionManager->createAction("edit_selection");
178 connect(action, SIGNAL(triggered()), SLOT(editSelection()));
179
180 action = actionManager->createAction("convert_to_vector_selection");
181 connect(action, SIGNAL(triggered()), SLOT(convertToVectorSelection()));
182
183 action = actionManager->createAction("convert_to_raster_selection");
184 connect(action, SIGNAL(triggered()), SLOT(convertToRasterSelection()));
185
186 action = actionManager->createAction("convert_shapes_to_vector_selection");
187 connect(action, SIGNAL(triggered()), SLOT(convertShapesToVectorSelection()));
188
189 action = actionManager->createAction("convert_selection_to_shape");
190 connect(action, SIGNAL(triggered()), SLOT(convertToShape()));
191
192 KisConfig cfg(true);
193 m_enableSelectionActionsPanel = actionManager->createAction("enable_sap");
194 m_enableSelectionActionsPanel->setChecked(cfg.selectionActionBar());
195 connect(m_enableSelectionActionsPanel, SIGNAL(triggered(bool)), SLOT(enableSelectionActionsPanel(bool)));
196
197 action = actionManager->createAction("configure_sap");
198 action->setVisible(false);
199
200 m_toggleSelectionOverlayMode = actionManager->createAction("toggle-selection-overlay-mode");
201 connect(m_toggleSelectionOverlayMode, SIGNAL(triggered()), SLOT(slotToggleSelectionDecoration()));
202
203 m_strokeSelected = actionManager->createAction("stroke_selection");
204 connect(m_strokeSelected, SIGNAL(triggered()), SLOT(slotStrokeSelection()));
205
206 QClipboard *cb = QApplication::clipboard();
207 connect(cb, SIGNAL(dataChanged()), SLOT(clipboardDataChanged()));
208
209 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(configChanged()));
210}
KisAction * createAction(const QString &name)
KisAction * createStandardAction(KStandardAction::StandardAction, const QObject *receiver, const char *member)
void registerOperation(KisOperation *operation)
void setOperationID(const QString &id)
KisAction * m_fillBackgroundColorOpacity
KisAction * m_toggleSelectionOverlayMode
KisAction * m_fillForegroundColorOpacity
void enableSelectionActionsPanel(bool enabled)

References clear(), clipboardDataChanged(), configChanged(), convertShapesToVectorSelection(), convertToRasterSelection(), convertToShape(), convertToVectorSelection(), copy(), KStandardAction::Copy, copyMerged(), copySelectionToNewLayer(), copySharp(), KisActionManager::createAction(), KisActionManager::createStandardAction(), cut(), KStandardAction::Cut, cutSharp(), cutToNewLayer(), deselect(), editSelection(), enableSelectionActionsPanel(), fillBackgroundColor(), fillBackgroundColorOpacity(), fillForegroundColor(), fillForegroundColorOpacity(), fillPattern(), fillPatternOpacity(), imageResizeToSelection(), KisConfigNotifier::instance(), m_clear, m_copy, m_copyMerged, m_copyToNewLayer, m_cut, m_cutToNewLayer, m_deselect, m_enableSelectionActionsPanel, m_fillBackgroundColor, m_fillBackgroundColorOpacity, m_fillForegroundColor, m_fillForegroundColorOpacity, m_fillPattern, m_fillPatternOpacity, m_imageResizeToSelection, m_invert, m_paste, m_pasteAsReference, m_pasteAt, m_pasteInto, m_pasteNew, m_pasteShapeStyle, m_reselect, m_selectAll, m_strokeSelected, m_strokeShapes, m_toggleDisplaySelection, m_toggleSelectionOverlayMode, paintSelectedShapes(), paste(), KStandardAction::Paste, pasteAsReference(), pasteAt(), pasteInto(), pasteNew(), pasteShapeStyle(), KisActionManager::registerOperation(), reselect(), selectAll(), KisConfig::selectionActionBar(), KisAction::setOperationID(), slotStrokeSelection(), slotToggleSelectionDecoration(), and toggleDisplaySelection().

◆ setView()

void KisSelectionManager::setView ( QPointer< KisView > imageView)

Definition at line 213 of file kis_selection_manager.cc.

214{
215 if (m_imageView && m_imageView->canvasBase()) {
216 disconnect(m_imageView->canvasBase()->toolProxy(), SIGNAL(toolChanged(QString)), this, SLOT(clipboardDataChanged()));
217
218 KoSelection *selection = m_imageView->canvasBase()->globalShapeManager()->selection();
219 selection->disconnect(this, SLOT(shapeSelectionChanged()));
220 KisSelectionDecoration *decoration = qobject_cast<KisSelectionDecoration*>(m_imageView->canvasBase()->decoration("selection").data());
221 if (decoration) {
222 disconnect(SIGNAL(currentSelectionChanged()), decoration);
223 }
224 m_imageView->image()->undoAdapter()->disconnect(this);
226 }
227
228 m_imageView = imageView;
229 if (m_imageView) {
230 connect(m_imageView->canvasBase()->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(shapeSelectionChanged()), Qt::UniqueConnection);
231
232 KisSelectionDecoration* decoration = qobject_cast<KisSelectionDecoration*>(m_imageView->canvasBase()->decoration("selection").data());
233 if (!decoration) {
234 decoration = new KisSelectionDecoration(m_imageView);
235 decoration->setVisible(true);
236 m_imageView->canvasBase()->addDecoration(decoration);
237 }
238 m_selectionDecoration = decoration;
239 connect(this, SIGNAL(currentSelectionChanged()), decoration, SLOT(selectionChanged()));
240 connect(m_imageView->image()->undoAdapter(), SIGNAL(selectionChanged()), SLOT(selectionChanged()));
241 connect(m_imageView->canvasBase()->toolProxy(), SIGNAL(toolChanged(QString)), SLOT(clipboardDataChanged()));
242
243 }
244}
QPointer< KisSelectionDecoration > m_selectionDecoration
QPointer< KisView > m_imageView

References clipboardDataChanged(), currentSelectionChanged(), m_imageView, m_selectionDecoration, selectionChanged(), KisSelectionDecoration::setVisible(), and shapeSelectionChanged().

◆ shapeSelectionChanged

void KisSelectionManager::shapeSelectionChanged ( )
slot

Definition at line 603 of file kis_selection_manager.cc.

604{
606
607 KoSelection * selection = shapeManager->selection();
608 QList<KoShape*> selectedShapes = selection->selectedShapes();
609
610 KoShapeStrokeSP border(new KoShapeStroke(0, Qt::lightGray));
611 Q_FOREACH (KoShape* shape, shapeManager->shapes()) {
612 if (dynamic_cast<KisShapeSelection*>(shape->parent())) {
613 if (selectedShapes.contains(shape))
614 shape->setStroke(border);
615 else
616 shape->setStroke(KoShapeStrokeSP());
617 }
618 }
619 m_view->updateGUI();
620}
QSharedPointer< KoShapeStroke > KoShapeStrokeSP
KoShapeManager * globalShapeManager() const
QList< KoShape * > shapes
KoShapeContainer * parent() const
Definition KoShape.cpp:857
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:899

References KisViewManager::canvasBase(), KisCanvas2::globalShapeManager(), m_view, KoShape::parent(), KoSelection::selectedShapes(), KoShapeManager::selection, KoShape::setStroke(), KoShapeManager::shapes, and KisViewManager::updateGUI().

◆ showSelectionAsMask()

bool KisSelectionManager::showSelectionAsMask ( ) const

Definition at line 672 of file kis_selection_manager.cc.

673{
676 }
677 return false;
678}

References m_selectionDecoration, and KisSelectionDecoration::Mask.

◆ signalUpdateGUI

void KisSelectionManager::signalUpdateGUI ( )
signal

◆ slotStrokeSelection

void KisSelectionManager::slotStrokeSelection ( )
slot

Definition at line 679 of file kis_selection_manager.cc.

680{
681 KisImageWSP image = m_view->image();
682
683 if (!image ) {
684 return;
685 }
686
688 bool isVectorLayer = false;
689 if (currentNode->inherits("KisShapeLayer")) {
690 isVectorLayer = true;
691 }
692
693 QPointer<KisDlgStrokeSelection> dlg = new KisDlgStrokeSelection(image, m_view, isVectorLayer);
694
695 if (dlg->exec() == QDialog::Accepted) {
696 StrokeSelectionOptions params = dlg->getParams();
697 if (params.brushSelected){
699 factory.run(m_view, params);
700 }
701 else {
703 factory.run(m_view, params);
704 }
705 }
706 delete dlg;
707
708
709}
void run(KisViewManager *view, const StrokeSelectionOptions &params)
void run(KisViewManager *view, const StrokeSelectionOptions &params)

References StrokeSelectionOptions::brushSelected, KisViewManager::canvasResourceProvider(), KoCanvasResource::CurrentKritaNode, KisViewManager::image(), m_view, KoCanvasResourceProvider::resource(), KisCanvasResourceProvider::resourceManager(), KisStrokeSelectionActionFactory::run(), and KisStrokeBrushSelectionActionFactory::run().

◆ slotToggleSelectionDecoration

◆ strokeSelected

void KisSelectionManager::strokeSelected ( )
signal

◆ toggleDisplaySelection

void KisSelectionManager::toggleDisplaySelection ( )
slot

Definition at line 586 of file kis_selection_manager.cc.

587{
589
590 m_selectionDecoration->toggleSlectionVisibility();
591 m_toggleDisplaySelection->blockSignals(true);
592 m_toggleDisplaySelection->setChecked(m_selectionDecoration->visible());
593 m_toggleDisplaySelection->blockSignals(false);
594
596}

References displaySelectionChanged(), KIS_ASSERT_RECOVER_RETURN, m_selectionDecoration, and m_toggleDisplaySelection.

◆ updateGUI

void KisSelectionManager::updateGUI ( )
slot

Definition at line 322 of file kis_selection_manager.cc.

323{
324 Q_ASSERT(m_view);
325 Q_ASSERT(m_clipboard);
326 if (!m_view || !m_clipboard) return;
327
329 bool haveDevice = m_view->activeDevice();
330
331 KisLayerSP activeLayer = m_view->activeLayer();
332 KisImageWSP image = activeLayer ? activeLayer->image() : 0;
333
334 // FIXME: how about pasting shapes?
335 // TODO: check if these manual update actually work and not
336 // overridden by KisActionManager
338 m_pasteAsReference->setEnabled(haveDevice);
339
341 Q_EMIT signalUpdateGUI();
342}
KisPaintDeviceSP activeDevice()
Convenience method to get at the active paint device.
KisImageWSP image

References KisViewManager::activeDevice(), KisViewManager::activeLayer(), havePixelsInClipboard(), KisBaseNode::image, m_clipboard, m_pasteAsReference, m_pasteNew, m_view, signalUpdateGUI(), and updateStatusBar().

◆ updateStatusBar()

void KisSelectionManager::updateStatusBar ( )
private

Definition at line 344 of file kis_selection_manager.cc.

345{
346 if (m_view && m_view->statusBar()) {
348 }
349}
void setSelection(KisImageWSP image)
KisStatusBar * statusBar() const
Return the wrapper class around the statusbar.

References KisViewManager::image(), m_view, KisStatusBar::setSelection(), and KisViewManager::statusBar().

Member Data Documentation

◆ m_adapter

KisNodeCommandsAdapter* KisSelectionManager::m_adapter {0}
private

Definition at line 138 of file kis_selection_manager.h.

138{0};

◆ m_clear

KisAction* KisSelectionManager::m_clear {0}
private

Definition at line 152 of file kis_selection_manager.h.

152{0};

◆ m_clipboard

KisClipboard* KisSelectionManager::m_clipboard {0}
private

Definition at line 136 of file kis_selection_manager.h.

136{0};

◆ m_copy

KisAction* KisSelectionManager::m_copy {0}
private

Definition at line 140 of file kis_selection_manager.h.

140{0};

◆ m_copyMerged

KisAction* KisSelectionManager::m_copyMerged {0}
private

Definition at line 141 of file kis_selection_manager.h.

141{0};

◆ m_copyToNewLayer

KisAction* KisSelectionManager::m_copyToNewLayer {0}
private

Definition at line 155 of file kis_selection_manager.h.

155{0};

◆ m_cut

KisAction* KisSelectionManager::m_cut {0}
private

Definition at line 142 of file kis_selection_manager.h.

142{0};

◆ m_cutToNewLayer

KisAction* KisSelectionManager::m_cutToNewLayer {0}
private

Definition at line 149 of file kis_selection_manager.h.

149{0};

◆ m_deselect

KisAction* KisSelectionManager::m_deselect {0}
private

Definition at line 151 of file kis_selection_manager.h.

151{0};

◆ m_doc

KisDocument* KisSelectionManager::m_doc {0}
private

Definition at line 134 of file kis_selection_manager.h.

134{0};

◆ m_enableSelectionActionsPanel

KisAction* KisSelectionManager::m_enableSelectionActionsPanel {0}
private

Definition at line 167 of file kis_selection_manager.h.

167{0};

◆ m_fillBackgroundColor

KisAction* KisSelectionManager::m_fillBackgroundColor {0}
private

Definition at line 157 of file kis_selection_manager.h.

157{0};

◆ m_fillBackgroundColorOpacity

KisAction* KisSelectionManager::m_fillBackgroundColorOpacity {0}
private

Definition at line 160 of file kis_selection_manager.h.

160{0};

◆ m_fillForegroundColor

KisAction* KisSelectionManager::m_fillForegroundColor {0}
private

Definition at line 156 of file kis_selection_manager.h.

156{0};

◆ m_fillForegroundColorOpacity

KisAction* KisSelectionManager::m_fillForegroundColorOpacity {0}
private

Definition at line 159 of file kis_selection_manager.h.

159{0};

◆ m_fillPattern

KisAction* KisSelectionManager::m_fillPattern {0}
private

Definition at line 158 of file kis_selection_manager.h.

158{0};

◆ m_fillPatternOpacity

KisAction* KisSelectionManager::m_fillPatternOpacity {0}
private

Definition at line 161 of file kis_selection_manager.h.

161{0};

◆ m_imageResizeToSelection

KisAction* KisSelectionManager::m_imageResizeToSelection {0}
private

Definition at line 162 of file kis_selection_manager.h.

162{0};

◆ m_imageView

QPointer<KisView> KisSelectionManager::m_imageView {0}
private

Definition at line 135 of file kis_selection_manager.h.

135{0};

◆ m_invert

KisAction* KisSelectionManager::m_invert {0}
private

Definition at line 154 of file kis_selection_manager.h.

154{0};

◆ m_paste

KisAction* KisSelectionManager::m_paste {0}
private

Definition at line 143 of file kis_selection_manager.h.

143{0};

◆ m_pasteAsReference

KisAction* KisSelectionManager::m_pasteAsReference {0}
private

Definition at line 146 of file kis_selection_manager.h.

146{0};

◆ m_pasteAt

KisAction* KisSelectionManager::m_pasteAt {0}
private

Definition at line 144 of file kis_selection_manager.h.

144{0};

◆ m_pasteInto

KisAction* KisSelectionManager::m_pasteInto {0}
private

Definition at line 145 of file kis_selection_manager.h.

145{0};

◆ m_pasteNew

KisAction* KisSelectionManager::m_pasteNew {0}
private

Definition at line 147 of file kis_selection_manager.h.

147{0};

◆ m_pasteShapeStyle

KisAction* KisSelectionManager::m_pasteShapeStyle {0}
private

Definition at line 148 of file kis_selection_manager.h.

148{0};

◆ m_pluginActions

QList<QAction*> KisSelectionManager::m_pluginActions
private

Definition at line 170 of file kis_selection_manager.h.

◆ m_reselect

KisAction* KisSelectionManager::m_reselect {0}
private

Definition at line 153 of file kis_selection_manager.h.

153{0};

◆ m_selectAll

KisAction* KisSelectionManager::m_selectAll {0}
private

Definition at line 150 of file kis_selection_manager.h.

150{0};

◆ m_selectionDecoration

QPointer<KisSelectionDecoration> KisSelectionManager::m_selectionDecoration
private

Definition at line 171 of file kis_selection_manager.h.

◆ m_strokeSelected

KisAction* KisSelectionManager::m_strokeSelected {0}
private

Definition at line 166 of file kis_selection_manager.h.

166{0};

◆ m_strokeShapes

KisAction* KisSelectionManager::m_strokeShapes {0}
private

Definition at line 163 of file kis_selection_manager.h.

163{0};

◆ m_toggleDisplaySelection

KisAction* KisSelectionManager::m_toggleDisplaySelection {0}
private

Definition at line 164 of file kis_selection_manager.h.

164{0};

◆ m_toggleSelectionOverlayMode

KisAction* KisSelectionManager::m_toggleSelectionOverlayMode {0}
private

Definition at line 165 of file kis_selection_manager.h.

165{0};

◆ m_view

KisViewManager* KisSelectionManager::m_view {0}
private

Definition at line 133 of file kis_selection_manager.h.

133{0};

Property Documentation

◆ displaySelection

bool KisSelectionManager::displaySelection
read

Definition at line 40 of file kis_selection_manager.h.

◆ havePixelsSelected

bool KisSelectionManager::havePixelsSelected
read

Definition at line 41 of file kis_selection_manager.h.


The documentation for this class was generated from the following files: