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 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 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_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 84 of file kis_selection_manager.cc.

85 : m_view(view)
87{
89}
static KisClipboard * instance()
KisNodeCommandsAdapter * m_adapter

References KisClipboard::instance(), and m_clipboard.

◆ ~KisSelectionManager()

KisSelectionManager::~KisSelectionManager ( )
override

Definition at line 91 of file kis_selection_manager.cc.

92{
93}

Member Function Documentation

◆ canReselectDeactivatedSelection()

bool KisSelectionManager::canReselectDeactivatedSelection ( )

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

Definition at line 284 of file kis_selection_manager.cc.

285{
286 if (!m_view) return false;
287
288 KisLayerSP layer = m_view->activeLayer();
289
290 if (layer) {
295 if (layer->selectionMask()) return false;
296
297 KoProperties properties;
298 properties.setProperty("active", false);
299 properties.setProperty("visible", true);
300 QList<KisNodeSP> masks = layer->childNodes(QStringList("KisSelectionMask"), properties);
301
302 if (!masks.isEmpty()) {
303 return true;
304 }
305 }
306
307 KisImageSP image = m_view->image();
308 return image && image->canReselectGlobalSelection();
309}
QList< QString > QStringList
bool canReselectGlobalSelection()
Definition kis_image.cc:705
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:498
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 504 of file kis_selection_manager.cc.

505{
506 KisClearActionFactory factory;
507 factory.run(m_view);
508}
void run(KisViewManager *view) override

References m_view, and KisClearActionFactory::run().

◆ clipboardDataChanged

void KisSelectionManager::clipboardDataChanged ( )
slot

Definition at line 236 of file kis_selection_manager.cc.

237{
238 m_view->updateGUI();
239}

References m_view, and KisViewManager::updateGUI().

◆ 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 418 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 440 of file kis_selection_manager.cc.

441{
442 KisSelectionSP selection = m_view->selection();
443 if (!selection) return;
444
445 KisAction *action = m_view->actionManager()->actionByName("show-global-selection-mask");
447
448 if (!action->isChecked()) {
449 action->setChecked(true);
450 Q_EMIT action->toggled(true);
451 Q_EMIT action->triggered(true);
452 }
453
454 KisNodeSP node = selection->parentNode();
456
458
459 if (selection->hasShapeSelection()) {
460 KisShapeSelection *shapeSelection = dynamic_cast<KisShapeSelection*>(selection->shapeSelection());
461 KIS_SAFE_ASSERT_RECOVER_RETURN(shapeSelection);
462
464
465 QList<KoShape*> shapes = shapeSelection->shapes();
466
467 if (shapes.isEmpty()) {
468 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "no shapes");
469 return;
470 }
471
472 Q_FOREACH (KoShape *shape, shapes) {
474 }
475 } else {
476 KoToolManager::instance()->switchToolRequested("KisToolTransform");
477 }
478}
#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().

◆ fill()

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

◆ fillBackgroundColor

void KisSelectionManager::fillBackgroundColor ( )
slot

Definition at line 516 of file kis_selection_manager.cc.

517{
518 KisFillActionFactory factory;
519 factory.run("bg", m_view);
520}
void run(const QString &fillSource, KisViewManager *view)

References m_view, and KisFillActionFactory::run().

◆ fillBackgroundColorOpacity

void KisSelectionManager::fillBackgroundColorOpacity ( )
slot

Definition at line 534 of file kis_selection_manager.cc.

535{
536 KisFillActionFactory factory;
537 factory.run("bg_opacity", m_view);
538}

References m_view, and KisFillActionFactory::run().

◆ fillForegroundColor

void KisSelectionManager::fillForegroundColor ( )
slot

Definition at line 510 of file kis_selection_manager.cc.

511{
512 KisFillActionFactory factory;
513 factory.run("fg", m_view);
514}

References m_view, and KisFillActionFactory::run().

◆ fillForegroundColorOpacity

void KisSelectionManager::fillForegroundColorOpacity ( )
slot

Definition at line 528 of file kis_selection_manager.cc.

529{
530 KisFillActionFactory factory;
531 factory.run("fg_opacity", m_view);
532}

References m_view, and KisFillActionFactory::run().

◆ fillPattern

void KisSelectionManager::fillPattern ( )
slot

Definition at line 522 of file kis_selection_manager.cc.

523{
524 KisFillActionFactory factory;
525 factory.run("pattern", m_view);
526}

References m_view, and KisFillActionFactory::run().

◆ fillPatternOpacity

void KisSelectionManager::fillPatternOpacity ( )
slot

Definition at line 540 of file kis_selection_manager.cc.

541{
542 KisFillActionFactory factory;
543 factory.run("pattern_opacity", m_view);
544}

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 266 of file kis_selection_manager.cc.

267{
268 KisSelectionSP selection = m_view->selection();
269 return selection && selection->hasNonEmptyPixelSelection();
270}
bool hasNonEmptyPixelSelection() const

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

◆ havePixelsInClipboard()

bool KisSelectionManager::havePixelsInClipboard ( )

Definition at line 247 of file kis_selection_manager.cc.

248{
249 return m_clipboard->hasClip();
250}
bool hasClip() const

References KisClipboard::hasClip(), and m_clipboard.

◆ havePixelsSelected()

bool KisSelectionManager::havePixelsSelected ( )

◆ haveRasterSelectionWithPixels()

bool KisSelectionManager::haveRasterSelectionWithPixels ( )

Definition at line 278 of file kis_selection_manager.cc.

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

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

◆ haveShapeSelectionWithShapes()

bool KisSelectionManager::haveShapeSelectionWithShapes ( )

Definition at line 272 of file kis_selection_manager.cc.

273{
274 KisSelectionSP selection = m_view->selection();
275 return selection && selection->hasNonEmptyShapeSelection();
276}

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

◆ haveShapesInClipboard()

bool KisSelectionManager::haveShapesInClipboard ( )

Definition at line 260 of file kis_selection_manager.cc.

261{
263 return paste.hasShapes();
264}
bool hasShapes()

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

◆ haveShapesSelected()

bool KisSelectionManager::haveShapesSelected ( )

Definition at line 252 of file kis_selection_manager.cc.

253{
254 if (m_view && m_view->canvasBase()) {
255 return m_view->canvasBase()->selectedShapesProxy()->selection()->count() > 0;
256 }
257 return false;
258}
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 424 of file kis_selection_manager.cc.

425{
426 if(m_invert)
427 m_invert->trigger();
428}

References m_invert.

◆ paintSelectedShapes

void KisSelectionManager::paintSelectedShapes ( )
slot

Definition at line 602 of file kis_selection_manager.cc.

603{
604 KisImageWSP image = m_view->image();
605 if (!image) return;
606
607 KisLayerSP layer = m_view->activeLayer();
608 if (!layer) return;
609
611
612 KisPaintLayerSP paintLayer = new KisPaintLayer(image, i18n("Stroked Shapes"), OPACITY_OPAQUE_U8);
613
614 KUndo2MagicString actionName = kundo2_i18n("Stroke Shapes");
615
616 m_adapter->beginMacro(actionName);
617 m_adapter->addNode(paintLayer.data(), layer->parent().data(), layer.data());
618
619 KisFigurePaintingToolHelper helper(actionName,
620 image,
621 paintLayer.data(),
625
626 Q_FOREACH (KoShape* shape, shapes) {
627 QTransform matrix = shape->absoluteTransformation() * QTransform::fromScale(image->xRes(), image->yRes());
628 QPainterPath mappedOutline = matrix.map(shape->outline());
629 helper.paintPainterPath(mappedOutline);
630 }
632}
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:630
QTransform absoluteTransformation() const
Definition KoShape.cpp:382
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 388 of file kis_selection_manager.cc.

389{
391 factory.run(m_view);
392}
void run(KisViewManager *view) override

References m_view, and KisPasteIntoActionFactory::run().

◆ pasteNew

void KisSelectionManager::pasteNew ( )
slot

Definition at line 400 of file kis_selection_manager.cc.

401{
403 factory.run(m_view);
404}
void run(KisViewManager *view) override

References m_view, and KisPasteNewActionFactory::run().

◆ pasteShapeStyle

void KisSelectionManager::pasteShapeStyle ( )
slot

◆ reselect

void KisSelectionManager::reselect ( )
slot

Definition at line 430 of file kis_selection_manager.cc.

References m_view, and KisReselectActionFactory::run().

◆ selectAll

void KisSelectionManager::selectAll ( )
slot

Definition at line 412 of file kis_selection_manager.cc.

References m_view, and KisSelectAllActionFactory::run().

◆ selectionChanged

void KisSelectionManager::selectionChanged ( )
slot

Definition at line 340 of file kis_selection_manager.cc.

341{
342 m_view->updateGUI();
344}
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 688 of file kis_selection_manager.cc.

689{
690 KisImageSP image = m_view->image();
691
693 return;
694 }
695
696 KUndo2MagicString actionName;
698 KisCanvas2 *canvas = m_view->canvasBase();
699
700
701 {
702 KisImageBarrierLock lock(image);
703
704 KisPaintDeviceSP device = node->projection();
705 if (!device) device = node->paintDevice();
706 if (!device) device = node->original();
707
708 if (!device) return;
709
710 QRect rc = device->exactBounds();
711 if (rc.isEmpty()) {
712
713 if (action == SELECTION_REPLACE || action == SELECTION_INTERSECT) {
716 }
717
718 return;
719 }
720
722
726 if (!canvas->imageView()->selection()) {
727 action = SELECTION_REPLACE;
728 }
729
730 switch (action) {
731 case SELECTION_ADD:
732 actionName = kundo2_i18n("Select Opaque (Add)");
733 break;
735 actionName = kundo2_i18n("Select Opaque (Subtract)");
736 break;
738 actionName = kundo2_i18n("Select Opaque (Intersect)");
739 break;
741 actionName = kundo2_i18n("Select Opaque (Symmetric Difference)");
742 break;
743 default:
744 actionName = kundo2_i18n("Select Opaque");
745 break;
746 }
747
748 qint32 x, y, w, h;
749 rc.getRect(&x, &y, &w, &h);
750
751 const KoColorSpace * cs = device->colorSpace();
752
753 KisHLineConstIteratorSP deviter = device->createHLineConstIteratorNG(x, y, w);
754 KisHLineIteratorSP selIter = tmpSel ->createHLineIteratorNG(x, y, w);
755
756 for (int row = y; row < h + y; ++row) {
757 do {
758 *selIter->rawData() = cs->opacityU8(deviter->oldRawData());
759 } while (deviter->nextPixel() && selIter->nextPixel());
760 deviter->nextRow();
761 selIter->nextRow();
762 }
763 }
764
765 KisSelectionToolHelper helper(canvas, actionName);
766 tmpSel->invalidateOutlineCache();
767 helper.selectPixelSelection(tmpSel, action);
768}
@ 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 95 of file kis_selection_manager.cc.

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

References clear(), clipboardDataChanged(), connect(), convertShapesToVectorSelection(), convertToRasterSelection(), convertToShape(), convertToVectorSelection(), copy(), KStandardAction::Copy, copyMerged(), copySelectionToNewLayer(), copySharp(), KisActionManager::createAction(), KisActionManager::createStandardAction(), cut(), KStandardAction::Cut, cutSharp(), cutToNewLayer(), deselect(), editSelection(), fillBackgroundColor(), fillBackgroundColorOpacity(), fillForegroundColor(), fillForegroundColorOpacity(), fillPattern(), fillPatternOpacity(), imageResizeToSelection(), m_clear, m_copy, m_copyMerged, m_copyToNewLayer, m_cut, m_cutToNewLayer, m_deselect, 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(), KisAction::setOperationID(), slotStrokeSelection(), slotToggleSelectionDecoration(), and toggleDisplaySelection().

◆ setView()

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

Definition at line 202 of file kis_selection_manager.cc.

203{
204 if (m_imageView && m_imageView->canvasBase()) {
205 disconnect(m_imageView->canvasBase()->toolProxy(), SIGNAL(toolChanged(QString)), this, SLOT(clipboardDataChanged()));
206
207 KoSelection *selection = m_imageView->canvasBase()->globalShapeManager()->selection();
208 selection->disconnect(this, SLOT(shapeSelectionChanged()));
209 KisSelectionDecoration *decoration = qobject_cast<KisSelectionDecoration*>(m_imageView->canvasBase()->decoration("selection").data());
210 if (decoration) {
211 disconnect(SIGNAL(currentSelectionChanged()), decoration);
212 }
213 m_imageView->image()->undoAdapter()->disconnect(this);
215 }
216
217 m_imageView = imageView;
218 if (m_imageView) {
219 connect(m_imageView->canvasBase()->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(shapeSelectionChanged()), Qt::UniqueConnection);
220
221 KisSelectionDecoration* decoration = qobject_cast<KisSelectionDecoration*>(m_imageView->canvasBase()->decoration("selection").data());
222 if (!decoration) {
223 decoration = new KisSelectionDecoration(m_imageView);
224 decoration->setVisible(true);
225 m_imageView->canvasBase()->addDecoration(decoration);
226 }
227 m_selectionDecoration = decoration;
228 connect(this, SIGNAL(currentSelectionChanged()), decoration, SLOT(selectionChanged()));
229 connect(m_imageView->image()->undoAdapter(), SIGNAL(selectionChanged()), SLOT(selectionChanged()));
230 connect(m_imageView->canvasBase()->toolProxy(), SIGNAL(toolChanged(QString)), SLOT(clipboardDataChanged()));
231
232 }
233}
QPointer< KisSelectionDecoration > m_selectionDecoration
QPointer< KisView > m_imageView

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

◆ shapeSelectionChanged

void KisSelectionManager::shapeSelectionChanged ( )
slot

Definition at line 577 of file kis_selection_manager.cc.

578{
580
581 KoSelection * selection = shapeManager->selection();
582 QList<KoShape*> selectedShapes = selection->selectedShapes();
583
584 KoShapeStrokeSP border(new KoShapeStroke(0, Qt::lightGray));
585 Q_FOREACH (KoShape* shape, shapeManager->shapes()) {
586 if (dynamic_cast<KisShapeSelection*>(shape->parent())) {
587 if (selectedShapes.contains(shape))
588 shape->setStroke(border);
589 else
590 shape->setStroke(KoShapeStrokeSP());
591 }
592 }
593 m_view->updateGUI();
594}
QSharedPointer< KoShapeStroke > KoShapeStrokeSP
KoShapeManager * globalShapeManager() const
QList< KoShape * > shapes
KoShapeContainer * parent() const
Definition KoShape.cpp:1039
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081

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 646 of file kis_selection_manager.cc.

647{
650 }
651 return false;
652}

References m_selectionDecoration, and KisSelectionDecoration::Mask.

◆ signalUpdateGUI

void KisSelectionManager::signalUpdateGUI ( )
signal

◆ slotStrokeSelection

void KisSelectionManager::slotStrokeSelection ( )
slot

Definition at line 653 of file kis_selection_manager.cc.

654{
655 KisImageWSP image = m_view->image();
656
657 if (!image ) {
658 return;
659 }
660
662 bool isVectorLayer = false;
663 if (currentNode->inherits("KisShapeLayer")) {
664 isVectorLayer = true;
665 }
666
667 QPointer<KisDlgStrokeSelection> dlg = new KisDlgStrokeSelection(image, m_view, isVectorLayer);
668
669 if (dlg->exec() == QDialog::Accepted) {
670 StrokeSelectionOptions params = dlg->getParams();
671 if (params.brushSelected){
673 factory.run(m_view, params);
674 }
675 else {
677 factory.run(m_view, params);
678 }
679 }
680 delete dlg;
681
682
683}
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 560 of file kis_selection_manager.cc.

561{
563
564 m_selectionDecoration->toggleVisibility();
565 m_toggleDisplaySelection->blockSignals(true);
566 m_toggleDisplaySelection->setChecked(m_selectionDecoration->visible());
567 m_toggleDisplaySelection->blockSignals(false);
568
570}

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

◆ updateGUI

void KisSelectionManager::updateGUI ( )
slot

Definition at line 311 of file kis_selection_manager.cc.

312{
313 Q_ASSERT(m_view);
314 Q_ASSERT(m_clipboard);
315 if (!m_view || !m_clipboard) return;
316
318 bool haveDevice = m_view->activeDevice();
319
320 KisLayerSP activeLayer = m_view->activeLayer();
321 KisImageWSP image = activeLayer ? activeLayer->image() : 0;
322
323 // FIXME: how about pasting shapes?
324 // TODO: check if these manual update actually work and not
325 // overridden by KisActionManager
327 m_pasteAsReference->setEnabled(haveDevice);
328
330 Q_EMIT signalUpdateGUI();
331}
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 333 of file kis_selection_manager.cc.

334{
335 if (m_view && m_view->statusBar()) {
337 }
338}
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 136 of file kis_selection_manager.h.

136{0};

◆ m_clear

KisAction* KisSelectionManager::m_clear {0}
private

Definition at line 150 of file kis_selection_manager.h.

150{0};

◆ m_clipboard

KisClipboard* KisSelectionManager::m_clipboard {0}
private

Definition at line 134 of file kis_selection_manager.h.

134{0};

◆ m_copy

KisAction* KisSelectionManager::m_copy {0}
private

Definition at line 138 of file kis_selection_manager.h.

138{0};

◆ m_copyMerged

KisAction* KisSelectionManager::m_copyMerged {0}
private

Definition at line 139 of file kis_selection_manager.h.

139{0};

◆ m_copyToNewLayer

KisAction* KisSelectionManager::m_copyToNewLayer {0}
private

Definition at line 153 of file kis_selection_manager.h.

153{0};

◆ m_cut

KisAction* KisSelectionManager::m_cut {0}
private

Definition at line 140 of file kis_selection_manager.h.

140{0};

◆ m_cutToNewLayer

KisAction* KisSelectionManager::m_cutToNewLayer {0}
private

Definition at line 147 of file kis_selection_manager.h.

147{0};

◆ m_deselect

KisAction* KisSelectionManager::m_deselect {0}
private

Definition at line 149 of file kis_selection_manager.h.

149{0};

◆ m_doc

KisDocument* KisSelectionManager::m_doc {0}
private

Definition at line 132 of file kis_selection_manager.h.

132{0};

◆ m_fillBackgroundColor

KisAction* KisSelectionManager::m_fillBackgroundColor {0}
private

Definition at line 155 of file kis_selection_manager.h.

155{0};

◆ m_fillBackgroundColorOpacity

KisAction* KisSelectionManager::m_fillBackgroundColorOpacity {0}
private

Definition at line 158 of file kis_selection_manager.h.

158{0};

◆ m_fillForegroundColor

KisAction* KisSelectionManager::m_fillForegroundColor {0}
private

Definition at line 154 of file kis_selection_manager.h.

154{0};

◆ m_fillForegroundColorOpacity

KisAction* KisSelectionManager::m_fillForegroundColorOpacity {0}
private

Definition at line 157 of file kis_selection_manager.h.

157{0};

◆ m_fillPattern

KisAction* KisSelectionManager::m_fillPattern {0}
private

Definition at line 156 of file kis_selection_manager.h.

156{0};

◆ m_fillPatternOpacity

KisAction* KisSelectionManager::m_fillPatternOpacity {0}
private

Definition at line 159 of file kis_selection_manager.h.

159{0};

◆ m_imageResizeToSelection

KisAction* KisSelectionManager::m_imageResizeToSelection {0}
private

Definition at line 160 of file kis_selection_manager.h.

160{0};

◆ m_imageView

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

Definition at line 133 of file kis_selection_manager.h.

133{0};

◆ m_invert

KisAction* KisSelectionManager::m_invert {0}
private

Definition at line 152 of file kis_selection_manager.h.

152{0};

◆ m_paste

KisAction* KisSelectionManager::m_paste {0}
private

Definition at line 141 of file kis_selection_manager.h.

141{0};

◆ m_pasteAsReference

KisAction* KisSelectionManager::m_pasteAsReference {0}
private

Definition at line 144 of file kis_selection_manager.h.

144{0};

◆ m_pasteAt

KisAction* KisSelectionManager::m_pasteAt {0}
private

Definition at line 142 of file kis_selection_manager.h.

142{0};

◆ m_pasteInto

KisAction* KisSelectionManager::m_pasteInto {0}
private

Definition at line 143 of file kis_selection_manager.h.

143{0};

◆ m_pasteNew

KisAction* KisSelectionManager::m_pasteNew {0}
private

Definition at line 145 of file kis_selection_manager.h.

145{0};

◆ m_pasteShapeStyle

KisAction* KisSelectionManager::m_pasteShapeStyle {0}
private

Definition at line 146 of file kis_selection_manager.h.

146{0};

◆ m_pluginActions

QList<QAction*> KisSelectionManager::m_pluginActions
private

Definition at line 167 of file kis_selection_manager.h.

◆ m_reselect

KisAction* KisSelectionManager::m_reselect {0}
private

Definition at line 151 of file kis_selection_manager.h.

151{0};

◆ m_selectAll

KisAction* KisSelectionManager::m_selectAll {0}
private

Definition at line 148 of file kis_selection_manager.h.

148{0};

◆ m_selectionDecoration

QPointer<KisSelectionDecoration> KisSelectionManager::m_selectionDecoration
private

Definition at line 168 of file kis_selection_manager.h.

◆ m_strokeSelected

KisAction* KisSelectionManager::m_strokeSelected {0}
private

Definition at line 164 of file kis_selection_manager.h.

164{0};

◆ m_strokeShapes

KisAction* KisSelectionManager::m_strokeShapes {0}
private

Definition at line 161 of file kis_selection_manager.h.

161{0};

◆ m_toggleDisplaySelection

KisAction* KisSelectionManager::m_toggleDisplaySelection {0}
private

Definition at line 162 of file kis_selection_manager.h.

162{0};

◆ m_toggleSelectionOverlayMode

KisAction* KisSelectionManager::m_toggleSelectionOverlayMode {0}
private

Definition at line 163 of file kis_selection_manager.h.

163{0};

◆ m_view

KisViewManager* KisSelectionManager::m_view {0}
private

Definition at line 131 of file kis_selection_manager.h.

131{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: