Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSelection::ChangeShapeSelectionCommand Struct Reference
+ Inheritance diagram for KisSelection::ChangeShapeSelectionCommand:

Public Member Functions

 ChangeShapeSelectionCommand (KisSelectionWSP selection, KisSelectionComponent *shapeSelection)
 
void redo () override
 
void undo () override
 
 ~ChangeShapeSelectionCommand () 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

bool m_firstRedo = true
 
bool m_isFlatten = false
 
QScopedPointer< KUndo2Commandm_reincarnationCommand
 
KisSelectionWSP m_selection
 
KisSelectionComponentm_shapeSelection = 0
 

Detailed Description

Definition at line 169 of file kis_selection.cc.

Constructor & Destructor Documentation

◆ ChangeShapeSelectionCommand()

KisSelection::ChangeShapeSelectionCommand::ChangeShapeSelectionCommand ( KisSelectionWSP selection,
KisSelectionComponent * shapeSelection )
inline

Definition at line 171 of file kis_selection.cc.

References m_isFlatten, and KisSelection::shapeSelection.

◆ ~ChangeShapeSelectionCommand()

KisSelection::ChangeShapeSelectionCommand::~ChangeShapeSelectionCommand ( )
inlineoverride

Definition at line 178 of file kis_selection.cc.

179 {
180 if (m_shapeSelection) {
181 Private::safeDeleteShapeSelection(m_shapeSelection, m_selection ? m_selection.data() : 0);
182 }
183
185 Private::safeDeleteShapeSelection(m_reincarnationCommand.take(), m_selection ? m_selection.data() : 0);
186 }
187 }
QScopedPointer< KUndo2Command > m_reincarnationCommand

References KisWeakSharedPtr< T >::data(), m_reincarnationCommand, m_selection, and m_shapeSelection.

Member Function Documentation

◆ redo()

void KisSelection::ChangeShapeSelectionCommand::redo ( )
inlineoverridevirtual

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 KUndo2Command.

Definition at line 207 of file kis_selection.cc.

208 {
210
211 if (m_firstRedo) {
212 QReadLocker l(&m_selection->m_d->shapeSelectionPointerLock);
213
214 if (bool(m_selection->m_d->shapeSelection) != bool(m_shapeSelection)) {
216 m_selection->m_d->pixelSelection->reincarnateWithDetachedHistory(m_isFlatten));
217 }
218 m_firstRedo = false;
219
220 }
221
224 }
225
226 {
227 QWriteLocker l(&m_selection->m_d->shapeSelectionPointerLock);
228 std::swap(m_selection->m_d->shapeSelection, m_shapeSelection);
229 }
230
231 if (!m_isFlatten) {
233 }
234 }
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
Private *const m_d
void requestCompressedProjectionUpdate(const QRect &rc)

References KIS_SAFE_ASSERT_RECOVER_RETURN, KisSelection::m_d, m_firstRedo, m_isFlatten, m_reincarnationCommand, m_selection, m_shapeSelection, and KisSelection::requestCompressedProjectionUpdate().

◆ undo()

void KisSelection::ChangeShapeSelectionCommand::undo ( )
inlineoverridevirtual

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 KUndo2Command.

Definition at line 189 of file kis_selection.cc.

190 {
192
195 }
196
197 {
198 QWriteLocker l(&m_selection->m_d->shapeSelectionPointerLock);
199 std::swap(m_selection->m_d->shapeSelection, m_shapeSelection);
200 }
201
202 if (!m_isFlatten) {
204 }
205 }

References KIS_SAFE_ASSERT_RECOVER_RETURN, KisSelection::m_d, m_isFlatten, m_reincarnationCommand, m_selection, m_shapeSelection, and KisSelection::requestCompressedProjectionUpdate().

Member Data Documentation

◆ m_firstRedo

bool KisSelection::ChangeShapeSelectionCommand::m_firstRedo = true
private

Definition at line 240 of file kis_selection.cc.

◆ m_isFlatten

bool KisSelection::ChangeShapeSelectionCommand::m_isFlatten = false
private

Definition at line 241 of file kis_selection.cc.

◆ m_reincarnationCommand

QScopedPointer<KUndo2Command> KisSelection::ChangeShapeSelectionCommand::m_reincarnationCommand
private

Definition at line 239 of file kis_selection.cc.

◆ m_selection

KisSelectionWSP KisSelection::ChangeShapeSelectionCommand::m_selection
private

Definition at line 237 of file kis_selection.cc.

◆ m_shapeSelection

KisSelectionComponent* KisSelection::ChangeShapeSelectionCommand::m_shapeSelection = 0
private

Definition at line 238 of file kis_selection.cc.


The documentation for this struct was generated from the following file: