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

Abstract superclass for all undo models. More...

#include <mitkUndoModel.h>

Inheritance diagram for mitk::UndoModel:
Collaboration diagram for mitk::UndoModel:

Public Member Functions

 mitkClassMacroItkParent (UndoModel, itk::Object)
 
virtual bool SetOperationEvent (UndoStackItem *stackItem)=0
 Store an operation event on the undo stack. More...
 
virtual bool Undo ()=0
 Undo the last operation (fine-grained by ObjectEventId). More...
 
virtual bool Undo (bool fine)=0
 Undo the last operation with control over granularity. More...
 
virtual bool Redo ()=0
 Redo the last undone operation (fine-grained by ObjectEventId). More...
 
virtual bool Redo (bool fine)=0
 Redo the last undone operation with control over granularity. More...
 
virtual void Clear ()=0
 Clear both the undo and redo lists. More...
 
virtual void ClearRedoList ()=0
 Clear the redo list only. More...
 
virtual bool RedoListEmpty ()=0
 Check whether the redo list is empty. More...
 
virtual bool UndoListEmpty ()=0
 Check whether the undo list is empty. More...
 
virtual std::size_t GetUndoLimit () const =0
 Get the limit on the size of the undo history. More...
 
virtual void SetUndoLimit (std::size_t limit)=0
 Set a limit on the size of the undo history. More...
 
virtual int GetLastObjectEventIdInList ()=0
 Return the ObjectEventId of the top element in the undo history. More...
 
virtual int GetLastGroupEventIdInList ()=0
 Return the GroupEventId of the top element in the undo history. More...
 
virtual OperationEvent * GetLastOfType (OperationActor *destination, OperationType opType)=0
 Return the last OperationEvent matching the given destination and type. More...
 
virtual unsigned int RemoveInvalidOperations ()=0
 Remove invalid operations from the undo/redo stack. More...
 

Protected Member Functions

 UndoModel ()
 
 ~UndoModel () override
 

Detailed Description

Abstract superclass for all undo models.

Defines the interface that all UndoModel implementations must provide, including undo/redo operations, stack management, and history queries.

Definition at line 35 of file mitkUndoModel.h.

Constructor & Destructor Documentation

◆ UndoModel()

mitk::UndoModel::UndoModel ( )
inlineprotected

Definition at line 152 of file mitkUndoModel.h.

◆ ~UndoModel()

mitk::UndoModel::~UndoModel ( )
inlineoverrideprotected

Definition at line 153 of file mitkUndoModel.h.

Member Function Documentation

◆ Clear()

virtual void mitk::UndoModel::Clear ( )
pure virtual

Clear both the undo and redo lists.

Implemented in mitk::LimitedLinearUndo.

◆ ClearRedoList()

virtual void mitk::UndoModel::ClearRedoList ( )
pure virtual

Clear the redo list only.

Implemented in mitk::LimitedLinearUndo.

◆ GetLastGroupEventIdInList()

virtual int mitk::UndoModel::GetLastGroupEventIdInList ( )
pure virtual

Return the GroupEventId of the top element in the undo history.

Returns
The GroupEventId of the most recent undo stack entry.

Implemented in mitk::LimitedLinearUndo.

◆ GetLastObjectEventIdInList()

virtual int mitk::UndoModel::GetLastObjectEventIdInList ( )
pure virtual

Return the ObjectEventId of the top element in the undo history.

Returns
The ObjectEventId of the most recent undo stack entry.

Implemented in mitk::LimitedLinearUndo.

◆ GetLastOfType()

virtual OperationEvent* mitk::UndoModel::GetLastOfType ( OperationActor *  destination,
OperationType  opType 
)
pure virtual

Return the last OperationEvent matching the given destination and type.

Useful for retrieving the old position of an element when declaring an UndoOperation.

Parameters
[in]destinationThe target OperationActor.
[in]opTypeThe operation type to search for.
Returns
The matching OperationEvent, or nullptr if not found.

Implemented in mitk::LimitedLinearUndo.

◆ GetUndoLimit()

virtual std::size_t mitk::UndoModel::GetUndoLimit ( ) const
pure virtual

Get the limit on the size of the undo history.

The undo limit determines how many items can be stored in the undo stack. A value of 0 means there is no limit.

Returns
The maximum number of items on the undo stack, or 0 for unlimited.

Implemented in mitk::LimitedLinearUndo.

◆ mitkClassMacroItkParent()

mitk::UndoModel::mitkClassMacroItkParent ( UndoModel  ,
itk::Object   
)

◆ Redo() [1/2]

virtual bool mitk::UndoModel::Redo ( )
pure virtual

Redo the last undone operation (fine-grained by ObjectEventId).

Returns
True if the redo was performed successfully.

Implemented in mitk::LimitedLinearUndo.

◆ Redo() [2/2]

virtual bool mitk::UndoModel::Redo ( bool  fine)
pure virtual

Redo the last undone operation with control over granularity.

Parameters
[in]fineIf true, redo by ObjectEventId; if false, redo by GroupEventId.
Returns
True if the redo was performed successfully.

Implemented in mitk::LimitedLinearUndo.

◆ RedoListEmpty()

virtual bool mitk::UndoModel::RedoListEmpty ( )
pure virtual

Check whether the redo list is empty.

Returns
True if the redo list contains no entries.

Implemented in mitk::LimitedLinearUndo.

◆ RemoveInvalidOperations()

virtual unsigned int mitk::UndoModel::RemoveInvalidOperations ( )
pure virtual

Remove invalid operations from the undo/redo stack.

Iterates through all stored OperationEvents and removes those that are no longer valid.

Returns
The number of invalid operations removed.

Implemented in mitk::LimitedLinearUndo.

◆ SetOperationEvent()

virtual bool mitk::UndoModel::SetOperationEvent ( UndoStackItem *  stackItem)
pure virtual

Store an operation event on the undo stack.

Parameters
[in]stackItemThe undo stack item to store.
Returns
True if the item was stored successfully.

Implemented in mitk::VerboseLimitedLinearUndo, and mitk::LimitedLinearUndo.

◆ SetUndoLimit()

virtual void mitk::UndoModel::SetUndoLimit ( std::size_t  limit)
pure virtual

Set a limit on the size of the undo history.

If the limit is reached, the oldest undo items will be dropped from the bottom of the undo stack. A value of 0 means there is no limit.

Parameters
[in]limitThe maximum number of items on the stack.

Implemented in mitk::LimitedLinearUndo.

◆ Undo() [1/2]

virtual bool mitk::UndoModel::Undo ( )
pure virtual

Undo the last operation (fine-grained by ObjectEventId).

Returns
True if the undo was performed successfully.

Implemented in mitk::LimitedLinearUndo.

◆ Undo() [2/2]

virtual bool mitk::UndoModel::Undo ( bool  fine)
pure virtual

Undo the last operation with control over granularity.

Parameters
[in]fineIf true, undo by ObjectEventId; if false, undo by GroupEventId.
Returns
True if the undo was performed successfully.

Implemented in mitk::LimitedLinearUndo.

◆ UndoListEmpty()

virtual bool mitk::UndoModel::UndoListEmpty ( )
pure virtual

Check whether the undo list is empty.

Returns
True if the undo list contains no entries.

Implemented in mitk::LimitedLinearUndo.


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