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

A linear undo model with one undo and one redo stack. More...

#include <mitkLimitedLinearUndo.h>

Inheritance diagram for mitk::LimitedLinearUndo:
Collaboration diagram for mitk::LimitedLinearUndo:

Public Types

typedef std::deque< UndoStackItem * > UndoContainer
 
typedef std::deque< UndoStackItem * >::reverse_iterator UndoContainerRevIter
 

Public Member Functions

 mitkClassMacro (LimitedLinearUndo, UndoModel)
 
Pointer Clone () const
 
bool SetOperationEvent (UndoStackItem *stackItem) override
 Store an operation event on the undo stack. More...
 
bool Undo () override
 Undoes the last changes. More...
 
bool Undo (bool) override
 Undoes the last changes. More...
 
virtual bool Undo (int oeid)
 Undoes all changes until ObjectEventID oeid. More...
 
bool Redo () override
 Redoes the last undone changes. More...
 
bool Redo (bool) override
 Redoes changes (parameter currently unused). More...
 
virtual bool Redo (int oeid)
 Redoes all changes until ObjectEventID oeid. More...
 
void Clear () override
 Clears both the UndoList and RedoList. More...
 
void ClearRedoList () override
 Clears the RedoList. More...
 
bool RedoListEmpty () override
 Returns true if the RedoList is empty. More...
 
bool UndoListEmpty () override
 Returns true if the UndoList is empty. More...
 
std::size_t GetUndoLimit () const override
 Gets the limit on the size of the undo history. More...
 
void SetUndoLimit (std::size_t limit) override
 Sets a limit on the size of the undo history. More...
 
int GetLastObjectEventIdInList () override
 Returns the ObjectEventId of the top element in the OperationHistory. More...
 
int GetLastGroupEventIdInList () override
 Returns the GroupEventId of the top element in the OperationHistory. More...
 
OperationEvent * GetLastOfType (OperationActor *destination, OperationType opType) override
 Returns the last OperationEvent in the Undo-list matching the given destination and operation type. More...
 
unsigned int RemoveInvalidOperations () override
 Removes invalid operations from the undo/redo stack. More...
 
- Public Member Functions inherited from mitk::UndoModel
 mitkClassMacroItkParent (UndoModel, itk::Object)
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 LimitedLinearUndo ()
 Constructor. More...
 
 ~LimitedLinearUndo () override
 Destructor. Deletes all undo and redo entries. More...
 
void ClearList (UndoContainer *list)
 Convenience method to free the memory of elements in the list and clear it. More...
 
- Protected Member Functions inherited from mitk::UndoModel
 UndoModel ()
 
 ~UndoModel () override
 

Protected Attributes

UndoContainer m_UndoList
 
UndoContainer m_RedoList
 

Detailed Description

A linear undo model with one undo and one redo stack.

Derived from UndoModel AND itk::Object. Invokes ITK-events to signal listening GUI elements whether each of the stacks is empty or not (to enable/disable buttons, etc.).

Definition at line 41 of file mitkLimitedLinearUndo.h.

Member Typedef Documentation

◆ UndoContainer

Definition at line 44 of file mitkLimitedLinearUndo.h.

◆ UndoContainerRevIter

typedef std::deque<UndoStackItem *>::reverse_iterator mitk::LimitedLinearUndo::UndoContainerRevIter

Definition at line 45 of file mitkLimitedLinearUndo.h.

Constructor & Destructor Documentation

◆ LimitedLinearUndo()

mitk::LimitedLinearUndo::LimitedLinearUndo ( )
protected

Constructor.

◆ ~LimitedLinearUndo()

mitk::LimitedLinearUndo::~LimitedLinearUndo ( )
overrideprotected

Destructor. Deletes all undo and redo entries.

Member Function Documentation

◆ Clear()

void mitk::LimitedLinearUndo::Clear ( )
overridevirtual

Clears both the UndoList and RedoList.

Implements mitk::UndoModel.

◆ ClearList()

void mitk::LimitedLinearUndo::ClearList ( UndoContainer *  list)
protected

Convenience method to free the memory of elements in the list and clear it.

◆ ClearRedoList()

void mitk::LimitedLinearUndo::ClearRedoList ( )
overridevirtual

Clears the RedoList.

Implements mitk::UndoModel.

◆ Clone()

Pointer mitk::LimitedLinearUndo::Clone ( ) const

◆ GetLastGroupEventIdInList()

int mitk::LimitedLinearUndo::GetLastGroupEventIdInList ( )
overridevirtual

Returns the GroupEventId of the top element in the OperationHistory.

Implements mitk::UndoModel.

◆ GetLastObjectEventIdInList()

int mitk::LimitedLinearUndo::GetLastObjectEventIdInList ( )
overridevirtual

Returns the ObjectEventId of the top element in the OperationHistory.

Implements mitk::UndoModel.

◆ GetLastOfType()

OperationEvent* mitk::LimitedLinearUndo::GetLastOfType ( OperationActor *  destination,
OperationType  opType 
)
overridevirtual

Returns the last OperationEvent in the Undo-list matching the given destination and operation type.

Returns
The matching OperationEvent, or nullptr if nothing was found.

Implements mitk::UndoModel.

◆ GetUndoLimit()

std::size_t mitk::LimitedLinearUndo::GetUndoLimit ( ) const
overridevirtual

Gets 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.

Implements mitk::UndoModel.

◆ mitkClassMacro()

mitk::LimitedLinearUndo::mitkClassMacro ( LimitedLinearUndo  ,
UndoModel   
)

◆ New()

static Pointer mitk::LimitedLinearUndo::New ( )
static

◆ Redo() [1/3]

bool mitk::LimitedLinearUndo::Redo ( )
overridevirtual

Redoes the last undone changes.

Reads the top element of the Redo-Stack, executes the operation, swaps the OperationEvent-Operation with the Undo-Operation and sets it to the Undo-Stack.

Implements mitk::UndoModel.

◆ Redo() [2/3]

bool mitk::LimitedLinearUndo::Redo ( bool  )
overridevirtual

Redoes changes (parameter currently unused).

Implements mitk::UndoModel.

◆ Redo() [3/3]

virtual bool mitk::LimitedLinearUndo::Redo ( int  oeid)
virtual

Redoes all changes until ObjectEventID oeid.

◆ RedoListEmpty()

bool mitk::LimitedLinearUndo::RedoListEmpty ( )
overridevirtual

Returns true if the RedoList is empty.

Implements mitk::UndoModel.

◆ RemoveInvalidOperations()

unsigned int mitk::LimitedLinearUndo::RemoveInvalidOperations ( )
overridevirtual

Removes invalid operations from the undo/redo stack.

Iterates through m_UndoList and m_RedoList and removes invalid OperationEvents.

Returns
Number of invalid operations removed.

Implements mitk::UndoModel.

◆ SetOperationEvent()

bool mitk::LimitedLinearUndo::SetOperationEvent ( UndoStackItem *  stackItem)
overridevirtual

Store an operation event on the undo stack.

Clears the redo stack when a new operation is added. If the undo limit is reached, the oldest entry is removed.

Returns
True if the stack item was successfully added.

Implements mitk::UndoModel.

Reimplemented in mitk::VerboseLimitedLinearUndo.

◆ SetUndoLimit()

void mitk::LimitedLinearUndo::SetUndoLimit ( std::size_t  limit)
overridevirtual

Sets 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.

Implements mitk::UndoModel.

◆ Undo() [1/3]

bool mitk::LimitedLinearUndo::Undo ( )
overridevirtual

Undoes the last changes.

Reads the top element of the Undo-Stack, executes the operation, swaps the OperationEvent-Undo with the Operation and sets it to the Redo-Stack.

Implements mitk::UndoModel.

◆ Undo() [2/3]

bool mitk::LimitedLinearUndo::Undo ( bool  )
overridevirtual

Undoes the last changes.

If fine is true, undoes one object event ID; otherwise undoes one group event ID.

Implements mitk::UndoModel.

◆ Undo() [3/3]

virtual bool mitk::LimitedLinearUndo::Undo ( int  oeid)
virtual

Undoes all changes until ObjectEventID oeid.

◆ UndoListEmpty()

bool mitk::LimitedLinearUndo::UndoListEmpty ( )
overridevirtual

Returns true if the UndoList is empty.

Implements mitk::UndoModel.

Member Data Documentation

◆ m_RedoList

UndoContainer mitk::LimitedLinearUndo::m_RedoList
protected

Definition at line 154 of file mitkLimitedLinearUndo.h.

◆ m_UndoList

UndoContainer mitk::LimitedLinearUndo::m_UndoList
protected

Definition at line 152 of file mitkLimitedLinearUndo.h.


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