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

#include <KisReselectActiveSelectionCommand.h>

+ Inheritance diagram for KisReselectActiveSelectionCommand:

Public Member Functions

 KisReselectActiveSelectionCommand (KisNodeSP activeNode, KisImageWSP image, KUndo2Command *parent=0)
 
void redo () override
 
void undo () override
 
- Public Member Functions inherited from KisReselectGlobalSelectionCommand
 KisReselectGlobalSelectionCommand (KisImageWSP image, KUndo2Command *parent=nullptr)
 
void populateChildCommands () override
 
 ~KisReselectGlobalSelectionCommand () override
 
- Public Member Functions inherited from KisCommandUtils::AggregateCommand
 AggregateCommand (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 AggregateCommand (KUndo2Command *parent=0)
 
- 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

KisNodeSP m_activeNode
 
KisSelectionMaskSP m_reselectedMask
 

Additional Inherited Members

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

Detailed Description

Definition at line 13 of file KisReselectActiveSelectionCommand.h.

Constructor & Destructor Documentation

◆ KisReselectActiveSelectionCommand()

KisReselectActiveSelectionCommand::KisReselectActiveSelectionCommand ( KisNodeSP activeNode,
KisImageWSP image,
KUndo2Command * parent = 0 )

Definition at line 16 of file KisReselectActiveSelectionCommand.cpp.

17 : KisReselectGlobalSelectionCommand(image, parent),
18 m_activeNode(activeNode)
19{
20}
KisReselectGlobalSelectionCommand(KisImageWSP image, KUndo2Command *parent=nullptr)

Member Function Documentation

◆ redo()

void KisReselectActiveSelectionCommand::redo ( )
overridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KisCommandUtils::AggregateCommand.

Definition at line 22 of file KisReselectActiveSelectionCommand.cpp.

23{
24 bool shouldReselectFGlobalSelection = true;
25
26 if (m_activeNode) {
28
29 if (!mask) {
30
31 KisLayerSP layer;
33 while (node && !(layer = dynamic_cast<KisLayer*>(node.data()))) {
34 node = node->parent();
35 }
36
37 if (layer && !layer->selectionMask()) {
38 KoProperties properties;
39 properties.setProperty("active", false);
40 properties.setProperty("visible", true);
41 QList<KisNodeSP> masks = layer->childNodes(QStringList("KisSelectionMask"), properties);
42
43 if (!masks.isEmpty()) {
44 mask = dynamic_cast<KisSelectionMask*>(masks.first().data());
45 }
46 } else if (layer && layer->selectionMask()) {
47 shouldReselectFGlobalSelection = false;
48 }
49 }
50
51 if (mask) {
52 mask->setActive(true);
53 shouldReselectFGlobalSelection = false;
54 m_reselectedMask = mask;
55 }
56 }
57
58 if (shouldReselectFGlobalSelection) {
60 }
61}
QList< QString > QStringList
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
KisNodeWSP parent
Definition kis_node.cpp:86
void setActive(bool active)

References KisNode::childNodes(), KisSharedPtr< T >::data(), m_activeNode, m_reselectedMask, KisNode::parent, KisCommandUtils::AggregateCommand::redo(), KisLayer::selectionMask(), KisSelectionMask::setActive(), and KoProperties::setProperty().

◆ undo()

void KisReselectActiveSelectionCommand::undo ( )
overridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KisCommandUtils::AggregateCommand.

Definition at line 63 of file KisReselectActiveSelectionCommand.cpp.

References KisSharedPtr< T >::clear(), m_reselectedMask, KisSelectionMask::setActive(), and KisCommandUtils::AggregateCommand::undo().

Member Data Documentation

◆ m_activeNode

KisNodeSP KisReselectActiveSelectionCommand::m_activeNode
private

Definition at line 22 of file KisReselectActiveSelectionCommand.h.

◆ m_reselectedMask

KisSelectionMaskSP KisReselectActiveSelectionCommand::m_reselectedMask
private

Definition at line 23 of file KisReselectActiveSelectionCommand.h.


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