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

#include <kis_set_global_selection_command.h>

+ Inheritance diagram for KisSetGlobalSelectionCommand:

Public Member Functions

 KisSetGlobalSelectionCommand (KisImageWSP image, KisSelectionSP selection)
 
void populateChildCommands () override
 
- Public Member Functions inherited from KisCommandUtils::AggregateCommand
 AggregateCommand (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 AggregateCommand (KUndo2Command *parent=0)
 
void redo () override
 
void undo () override
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () const
 
bool hasParent () const
 
virtual int id () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual bool mergeWith (const KUndo2Command *other)
 
virtual void redoMergedCommands ()
 
void setEndTime ()
 
virtual void setEndTime (const QTime &time)
 
void setExtraData (KUndo2CommandExtraData *data)
 
void setText (const KUndo2MagicString &text)
 
void setTime ()
 
virtual void setTime (const QTime &time)
 
virtual void setTimedID (int timedID)
 
KUndo2MagicString text () const
 
virtual QTime time () const
 
virtual int timedId () const
 
virtual bool timedMergeWith (KUndo2Command *other)
 
virtual void undoMergedCommands ()
 
virtual ~KUndo2Command ()
 

Private Attributes

KisImageWSP m_image
 
KisSelectionSP m_newSelection
 
KisSelectionSP m_oldSelection
 

Additional Inherited Members

- Protected Member Functions inherited from KisCommandUtils::AggregateCommand
void addCommand (KUndo2Command *cmd)
 

Detailed Description

This command sets the global selection of the image. No saving of the previous selection for "Reselect" action happens

Definition at line 18 of file kis_set_global_selection_command.h.

Constructor & Destructor Documentation

◆ KisSetGlobalSelectionCommand()

KisSetGlobalSelectionCommand::KisSetGlobalSelectionCommand ( KisImageWSP image,
KisSelectionSP selection )

Constructor

Parameters
imagethe image to set the global selection on
selectionthe selection that will be set a global selection, null selection will remove the selection

Definition at line 30 of file kis_set_global_selection_command.cpp.

31 : m_image(image)
32{
33 KisImageSP imageSP = m_image.toStrongRef();
34 if (!image) {
35 return;
36 }
38 m_newSelection = selection;
39}
KisSelectionSP globalSelection() const
Definition kis_image.cc:695
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.

References KisImage::globalSelection(), m_image, m_newSelection, m_oldSelection, and KisWeakSharedPtr< T >::toStrongRef().

Member Function Documentation

◆ populateChildCommands()

void KisSetGlobalSelectionCommand::populateChildCommands ( )
overridevirtual

Implements KisCommandUtils::AggregateCommand.

Definition at line 41 of file kis_set_global_selection_command.cpp.

42{
45
47
48 KisSelectionMaskSP selectionMask = image->rootLayer()->selectionMask();
49 if (selectionMask) {
50 addCommand(new KisImageLayerRemoveCommand(image, selectionMask, false, false));
51 }
52
53 if (m_newSelection) {
54 selectionMask = new KisSelectionMask(image, i18n("Selection Mask"));
55 selectionMask->initSelection(image->rootLayer());
56
57 // If we do not set the selection now, the setActive call coming next
58 // can be very, very expensive, depending on the size of the image.
59 selectionMask->setSelection(m_newSelection);
60
61 addCommand(new KisImageLayerAddCommand(image, selectionMask,
62 image->root(), image->root()->lastChild(),
63 false, false));
64 addCommand(new KisActivateSelectionMaskCommand(selectionMask, true));
65
66 }
67
68
71}
The command for adding a layer.
KisGroupLayerSP rootLayer() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
void addCommand(KUndo2Command *cmd)
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:498
void initSelection(KisSelectionSP copyFrom, KisLayerSP parentLayer)
initSelection initializes the selection for the mask from the given selection's projection.
Definition kis_mask.cc:157
KisNodeSP lastChild() const
Definition kis_node.cpp:367
void setSelection(KisSelectionSP selection)
Set the selection of this adjustment layer to a copy of selection.

References KisCommandUtils::AggregateCommand::addCommand(), KisCommandUtils::FlipFlopCommand::FINALIZING, KisCommandUtils::FlipFlopCommand::INITIALIZING, KisMask::initSelection(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisNode::lastChild(), m_image, m_newSelection, KisNodeFacade::root, KisImage::rootLayer(), KisLayer::selectionMask(), KisSelectionMask::setSelection(), and KisWeakSharedPtr< T >::toStrongRef().

Member Data Documentation

◆ m_image

KisImageWSP KisSetGlobalSelectionCommand::m_image
private

Definition at line 33 of file kis_set_global_selection_command.h.

◆ m_newSelection

KisSelectionSP KisSetGlobalSelectionCommand::m_newSelection
private

Definition at line 34 of file kis_set_global_selection_command.h.

◆ m_oldSelection

KisSelectionSP KisSetGlobalSelectionCommand::m_oldSelection
private

Definition at line 35 of file kis_set_global_selection_command.h.


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