14 #include <itkCommand.h> 16 int mitk::UndoStackItem::m_CurrObjectEventId = 0;
17 int mitk::UndoStackItem::m_CurrGroupEventId = 0;
32 return m_CurrObjectEventId;
37 return m_CurrGroupEventId;
42 ++m_CurrObjectEventId;
52 return m_ObjectEventId;
57 return m_GroupEventId;
85 std::string description)
87 m_Destination(destination),
88 m_Operation(operation),
89 m_UndoOperation(undoOperation),
93 if (
auto *
object = dynamic_cast<itk::Object *>(m_Destination))
95 itk::SimpleMemberCommand<OperationEvent>::Pointer command = itk::SimpleMemberCommand<OperationEvent>::New();
97 m_DeleteTag =
object->AddObserver(itk::DeleteEvent(), command);
106 if (
auto *
object = dynamic_cast<itk::Object *>(m_Destination))
108 object->RemoveObserver(m_DeleteTag);
113 delete m_UndoOperation;
120 if (m_Operation ==
nullptr)
124 m_Operation = m_UndoOperation;
125 m_UndoOperation = tempOperation;
133 if (m_Destination && m_Operation && !m_Invalid)
139 return m_Destination;
int GetObjectEventId()
Returns the ObjectEventId for this object.
Base class of all Operation-classes.
std::string GetDescription()
Returns the textual description of this object.
static int GetCurrGroupEventId()
For combining operations in groups.
OperationActor * GetDestination()
abstract class, that can be used by Undo to undo an operation.
bool m_Reversed
true, if operation and undooperation have been swaped/changed
virtual void ReverseAndExecute()
virtual void ReverseOperations()
~OperationEvent() override
Operation * GetOperation()
void ReverseAndExecute() override
int GetGroupEventId()
Returns the GroupEventId for this object.
Represents an entry of the undo or redo stack.
virtual void ExecuteOperation(Operation *operation)=0
UndoStackItem(std::string description="")
OperationEvent(OperationActor *destination, Operation *operation, Operation *undoOperation, std::string description="")
void ReverseOperations() override
static void IncCurrObjectEventId()
Increases the current ObjectEventId For example if a button click generates operations the ObjectEven...
static int GetCurrObjectEventId()
For combining operations in Objects.
static void IncCurrGroupEventId()
Increases the current GroupEventId For example if a button click generates operations the GroupEventI...