Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::UndoStackItem Class Referenceabstract

Represents an entry on the undo or redo stack. More...

#include <mitkOperationEvent.h>

Inheritance diagram for mitk::UndoStackItem:

Public Member Functions

 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...
 
virtual void ReverseOperations ()
 Swap the do/undo operations (toggle reversed state). More...
 
virtual void ReverseAndExecute ()
 Reverse the operations and execute them. More...
 
virtual bool IsValid () const =0
 Check whether this entry is still valid. More...
 

Static Public Member Functions

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

bool m_Reversed
 true, if operation and undooperation have been swapped/changed More...
 

Detailed Description

Represents an entry on the undo or redo stack.

This base class stores a textual description and a pair of IDs (ObjectEventId and GroupEventId) for grouping related operations. Static member functions manage creation and incrementing of these IDs.

The GroupEventId is intended for logical grouping of several related operations so they can be undone together with a single Undo(false) call.

See also
OperationEvent, UndoController, UndoModel

Definition at line 43 of file mitkOperationEvent.h.

Constructor & Destructor Documentation

◆ UndoStackItem()

mitk::UndoStackItem::UndoStackItem ( std::string  description = "")

Construct an UndoStackItem with an optional description.

Parameters
[in]descriptionHuman-readable description of this undo entry.

◆ ~UndoStackItem()

virtual mitk::UndoStackItem::~UndoStackItem ( )
virtual

Virtual destructor.

Member Function Documentation

◆ GetCurrGroupEventId()

static int mitk::UndoStackItem::GetCurrGroupEventId ( )
static

Get the current global GroupEventId.

Operations sharing the same GroupEventId are undone together when Undo(false) is called.

Returns
The current GroupEventId counter value.

◆ GetCurrObjectEventId()

static int mitk::UndoStackItem::GetCurrObjectEventId ( )
static

Get the current global ObjectEventId.

Operations sharing the same ObjectEventId belong to the same logical object change and are always undone together (both Undo(true) and Undo(false)).

Returns
The current ObjectEventId counter value.

◆ GetDescription()

std::string mitk::UndoStackItem::GetDescription ( )

Get the textual description of this undo entry.

Returns
The description string.

◆ GetGroupEventId()

int mitk::UndoStackItem::GetGroupEventId ( )

Get this item's GroupEventId.

Returns
The GroupEventId assigned at construction time.

◆ GetObjectEventId()

int mitk::UndoStackItem::GetObjectEventId ( )

Get this item's ObjectEventId.

Returns
The ObjectEventId assigned at construction time.

◆ IncCurrGroupEventId()

static void mitk::UndoStackItem::IncCurrGroupEventId ( )
static

Increment the global GroupEventId counter.

Call this to start a new logical group of operations. Multiple ObjectEventIds within the same GroupEventId are undone together by Undo(false).

◆ IncCurrObjectEventId()

static void mitk::UndoStackItem::IncCurrObjectEventId ( )
static

Increment the global ObjectEventId counter.

Call this when a new user interaction produces operations that should be grouped as a single object change. The ObjectEventId groups all operations from one event; the GroupEventId groups multiple ObjectEventIds for coarser undo granularity.

◆ IsValid()

virtual bool mitk::UndoStackItem::IsValid ( ) const
pure virtual

Check whether this entry is still valid.

Returns false if the destination object has been deleted or the operations are no longer valid.

Returns
True if the entry can still be undone/redone.

Implemented in mitk::OperationEvent.

◆ ReverseAndExecute()

virtual void mitk::UndoStackItem::ReverseAndExecute ( )
virtual

Reverse the operations and execute them.

Reimplemented in mitk::OperationEvent.

◆ ReverseOperations()

virtual void mitk::UndoStackItem::ReverseOperations ( )
virtual

Swap the do/undo operations (toggle reversed state).

Reimplemented in mitk::OperationEvent.

Member Data Documentation

◆ m_Reversed

bool mitk::UndoStackItem::m_Reversed
protected

true, if operation and undooperation have been swapped/changed

Definition at line 132 of file mitkOperationEvent.h.


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