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

#include <KisBatchUpdateLayerModificationCommand.h>

+ Inheritance diagram for KisBatchUpdateLayerModificationCommand:

Classes

struct  NodeTask
 
struct  Recipe
 

Public Types

using RecipeSP = QSharedPointer<Recipe>
 
- Public Types inherited from KisCommandUtils::FlipFlopCommand
enum  State { INITIALIZING , FINALIZING }
 

Public Member Functions

 KisBatchUpdateLayerModificationCommand (KisImageWSP image, RecipeSP recipe, KisCommandUtils::FlipFlopCommand::State state, KUndo2Command *parent=0)
 
void redo () override
 
void undo () override
 
- Public Member Functions inherited from KisCommandUtils::FlipFlopCommand
 FlipFlopCommand (bool finalizing=false, KUndo2Command *parent=0)
 
 FlipFlopCommand (State initialState, 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

KisImageWSP m_image
 
RecipeSP m_recipe
 
KisCommandUtils::FlipFlopCommand::State m_state
 

Additional Inherited Members

- Protected Member Functions inherited from KisCommandUtils::FlipFlopCommand
State getState () const
 
bool isFirstRedo () const
 
virtual void partA ()
 
virtual void partB ()
 

Detailed Description

Definition at line 18 of file KisBatchUpdateLayerModificationCommand.h.

Member Typedef Documentation

◆ RecipeSP

Constructor & Destructor Documentation

◆ KisBatchUpdateLayerModificationCommand()

KisBatchUpdateLayerModificationCommand::KisBatchUpdateLayerModificationCommand ( KisImageWSP image,
RecipeSP recipe,
KisCommandUtils::FlipFlopCommand::State state,
KUndo2Command * parent = 0 )

Member Function Documentation

◆ redo()

void KisBatchUpdateLayerModificationCommand::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::FlipFlopCommand.

Definition at line 21 of file KisBatchUpdateLayerModificationCommand.cpp.

22{
24 if (!image) {
25 return;
26 }
27
28 // TODO: reuse compression from the KisUpdateCommandEx and KisBatchNodeUpdate
29 // to avoid double updates
30
31 if (getState() == INITIALIZING) {
32 KIS_SAFE_ASSERT_RECOVER(m_recipe->removedNodesUpdateTargets.empty()) {
33 m_recipe->removedNodesUpdateTargets.clear();
34 }
35
36 for (auto it = m_recipe->nodesToRemove.begin();
37 it != m_recipe->nodesToRemove.end();
38 ++it) {
39
40 if (!it->doRedoUpdates) continue;
41 m_recipe->removedNodesUpdateTargets.emplace_back(image, it->node, image->bounds());
42 }
43 } else {
44 for (auto it = m_recipe->removedNodesUpdateTargets.begin();
45 it != m_recipe->removedNodesUpdateTargets.end();
46 ++it) {
47
48 it->update();
49 }
50 m_recipe->removedNodesUpdateTargets.clear();
51
52 for (auto it = m_recipe->nodesToAdd.begin();
53 it != m_recipe->nodesToAdd.end();
54 ++it) {
55
56 if (!it->doRedoUpdates) continue;
57 it->node->setDirty(image->bounds());
58 }
59 }
61}
QRect bounds() const override
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References KisImage::bounds(), KisCommandUtils::FlipFlopCommand::getState(), KisCommandUtils::FlipFlopCommand::INITIALIZING, KIS_SAFE_ASSERT_RECOVER, m_image, m_recipe, KisCommandUtils::FlipFlopCommand::redo(), and KisWeakSharedPtr< T >::toStrongRef().

◆ undo()

void KisBatchUpdateLayerModificationCommand::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::FlipFlopCommand.

Definition at line 63 of file KisBatchUpdateLayerModificationCommand.cpp.

64{
66
68 if (!image) {
69 return;
70 }
71
72 if (getState() == FINALIZING) {
73 KIS_SAFE_ASSERT_RECOVER(m_recipe->addedNodesUpdateTargets.empty()) {
74 m_recipe->addedNodesUpdateTargets.clear();
75 }
76
77 for (auto it = m_recipe->nodesToAdd.begin();
78 it != m_recipe->nodesToAdd.end();
79 ++it) {
80
81 if (!it->doUndoUpdates) continue;
82 m_recipe->addedNodesUpdateTargets.emplace_back(image, it->node, image->bounds());
83 }
84 } else {
85 for (auto it = m_recipe->addedNodesUpdateTargets.begin();
86 it != m_recipe->addedNodesUpdateTargets.end();
87 ++it) {
88
89 it->update();
90 }
91 m_recipe->addedNodesUpdateTargets.clear();
92
93 for (auto it = m_recipe->nodesToRemove.begin();
94 it != m_recipe->nodesToRemove.end();
95 ++it) {
96
97 if (!it->doUndoUpdates) continue;
98 image->refreshGraphAsync(it->node, image->bounds());
99 }
100 }
101}
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override

References KisImage::bounds(), KisCommandUtils::FlipFlopCommand::FINALIZING, KisCommandUtils::FlipFlopCommand::getState(), KIS_SAFE_ASSERT_RECOVER, m_image, m_recipe, KisImage::refreshGraphAsync(), KisWeakSharedPtr< T >::toStrongRef(), and KisCommandUtils::FlipFlopCommand::undo().

Member Data Documentation

◆ m_image

KisImageWSP KisBatchUpdateLayerModificationCommand::m_image
private

Definition at line 47 of file KisBatchUpdateLayerModificationCommand.h.

◆ m_recipe

RecipeSP KisBatchUpdateLayerModificationCommand::m_recipe
private

Definition at line 48 of file KisBatchUpdateLayerModificationCommand.h.

◆ m_state

KisCommandUtils::FlipFlopCommand::State KisBatchUpdateLayerModificationCommand::m_state
private

Definition at line 49 of file KisBatchUpdateLayerModificationCommand.h.


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