Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::OperationEvent Class Reference

Pairs a do-operation with its inverse undo-operation. More...

#include <mitkOperationEvent.h>

Inheritance diagram for mitk::OperationEvent:
Collaboration diagram for mitk::OperationEvent:

Public Member Functions

 OperationEvent (OperationActor *destination, Operation *operation, Operation *undoOperation, std::string description="")
 Construct an OperationEvent. More...
 
 ~OperationEvent () override
 Destructor. More...
 
Operation * GetOperation ()
 Get the current do-operation. More...
 
OperationActor * GetDestination ()
 Get the destination actor for the operations. More...
 
void ReverseOperations () override
 Swap the do-operation and undo-operation. More...
 
void ReverseAndExecute () override
 Reverse the operations and execute the (now current) do-operation. More...
 
bool IsValid () const override
 Check whether this event is still valid. More...
 
- Public Member Functions inherited from mitk::UndoStackItem
 UndoStackItem (std::string description="")
 Construct an UndoStackItem with an optional description. More...
 
virtual ~UndoStackItem ()
 Virtual destructor. More...
 
int GetGroupEventId ()
 Get this item's GroupEventId. More...
 
int GetObjectEventId ()
 Get this item's ObjectEventId. More...
 
std::string GetDescription ()
 Get the textual description of this undo entry. More...
 

Protected Member Functions

void OnObjectDeleted ()
 

Additional Inherited Members

- Static Public Member Functions inherited from mitk::UndoStackItem
static int GetCurrGroupEventId ()
 Get the current global GroupEventId. More...
 
static int GetCurrObjectEventId ()
 Get the current global ObjectEventId. More...
 
static void IncCurrObjectEventId ()
 Increment the global ObjectEventId counter. More...
 
static void IncCurrGroupEventId ()
 Increment the global GroupEventId counter. More...
 
- Protected Attributes inherited from mitk::UndoStackItem
bool m_Reversed
 true, if operation and undooperation have been swapped/changed More...
 

Detailed Description

Pairs a do-operation with its inverse undo-operation.

Extends UndoStackItem with the actual operation accounting for the undo/redo framework. Holds two Operation objects and the OperationActor (destination) on which they are executed. The operations are swapped when the event moves between undo and redo stacks.

This class owns the memory of both operations and deletes them in its destructor. If the destination (an OperationActor, often an itk::Object) is deleted, this event becomes invalid; always check IsValid() before executing operations.

See also
UndoStackItem, Operation, OperationActor, UndoController

Definition at line 165 of file mitkOperationEvent.h.

Constructor & Destructor Documentation

◆ OperationEvent()

mitk::OperationEvent::OperationEvent ( OperationActor *  destination,
Operation *  operation,
Operation *  undoOperation,
std::string  description = "" 
)

Construct an OperationEvent.

If the destination is an itk::Object, a delete observer is registered to detect when it is destroyed.

Parameters
[in]destinationThe OperationActor that executes the operations.
[in]operationThe do-operation (ownership transferred).
[in]undoOperationThe inverse undo-operation (ownership transferred).
[in]descriptionOptional human-readable description.

◆ ~OperationEvent()

mitk::OperationEvent::~OperationEvent ( )
override

Destructor.

Removes the delete observer (if destination is still valid) and frees both Operation objects.

Member Function Documentation

◆ GetDestination()

OperationActor* mitk::OperationEvent::GetDestination ( )

Get the destination actor for the operations.

Returns
Pointer to the OperationActor.

◆ GetOperation()

Operation* mitk::OperationEvent::GetOperation ( )

Get the current do-operation.

Returns
Pointer to the Operation (may have been swapped with the undo op).

◆ IsValid()

bool mitk::OperationEvent::IsValid ( ) const
overridevirtual

Check whether this event is still valid.

Returns false if the destination has been deleted or either operation reports itself as invalid.

Returns
True if the event can be executed.

Implements mitk::UndoStackItem.

◆ OnObjectDeleted()

void mitk::OperationEvent::OnObjectDeleted ( )
protected

◆ ReverseAndExecute()

void mitk::OperationEvent::ReverseAndExecute ( )
overridevirtual

Reverse the operations and execute the (now current) do-operation.

Used when an event is moved from the undo stack to the redo stack.

Reimplemented from mitk::UndoStackItem.

◆ ReverseOperations()

void mitk::OperationEvent::ReverseOperations ( )
overridevirtual

Swap the do-operation and undo-operation.

Called by the undo model when this event is moved between the undo and redo stacks.

Reimplemented from mitk::UndoStackItem.


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