MeVisLab Toolbox Reference
ml::CSOUndoRedoManager Class Reference

Manager class for maintaining the undo and the redo stacks. More...

#include <CSOUndoRedoManager.h>

Public Types

enum  UNDO_MODE { MODE_UNDOING = 0 , MODE_REDOING = 1 , MODE_NORMAL = 2 }
 The undo (and redo) modes. More...
 

Public Member Functions

 CSOUndoRedoManager (CSOList *csoList)
 Constructor. More...
 
 ~CSOUndoRedoManager ()
 Destructor. More...
 
void addCommand (CSOCommand *command)
 Adds a command (modification). More...
 
void popUndoCommand ()
 Removes the last added undo command without executing it. More...
 
void undo ()
 Performs an undo of the last modification (if undo stack is not empty). More...
 
void redo ()
 Performs a redo (if the undo stack is not empty). More...
 
void openGroup (const std::string &description="Contour Operation")
 Opens a group of commands that are undone/redone as one. More...
 
void closeGroup ()
 Closes a group of commands that are undone/redone as one. More...
 
void closeAllGroups ()
 Closes all undo/redo groups. More...
 
void clearUndo ()
 
void clearRedo ()
 
void clearAll ()
 Clears the undo and redo stack. More...
 
int getCurrentUndoGroupDepth ()
 Returns the current undo group depth. More...
 
bool canUndo () const
 Returns whether there are possible undoes. More...
 
bool canRedo () const
 Returns whether there are possible redoes. More...
 
int maxNumUndos () const
 Returns the maximum number of possible undos. If a -1 is returned, the undo stack has no limitation. More...
 
void setMaxNumUndos (int newMaxNumUndos)
 Sets the maximum number of possible undos. If a -1 is passed, the undo stack has no limitation. More...
 
void setMaxNumUndos (MLint newMaxNumUndos)
 
int numUndos () const
 Returns the number of stored undo steps. More...
 
int numRedos () const
 Returns the number of stored redo steps. More...
 
bool isInUndoMode () const
 Returns whether the manager is in undo-mode. More...
 
bool isInRedoMode () const
 Returns whether the manager is in redo-mode. More...
 
void enableUndoRedo ()
 Enables this undo/redo manager. More...
 
void disableUndoRedo ()
 Disables this undo/redo manager; if it is disabled, the incoming commands are deleted and not added. More...
 
bool isEnabled ()
 Returns whether this undo/redo manager is currently enabled. More...
 
void setUndoContext (ml::UndoContextPtr undoContext)
 Set a new undo context. More...
 

Detailed Description

Manager class for maintaining the undo and the redo stacks.

Definition at line 29 of file CSOUndoRedoManager.h.

Member Enumeration Documentation

◆ UNDO_MODE

The undo (and redo) modes.

Enumerator
MODE_UNDOING 

The manager is in undo-mode.

MODE_REDOING 

The manager is in redo-mode.

MODE_NORMAL 

The manager is no special mode and pushes commands onto the undo stack.

Definition at line 35 of file CSOUndoRedoManager.h.

Constructor & Destructor Documentation

◆ CSOUndoRedoManager()

ml::CSOUndoRedoManager::CSOUndoRedoManager ( CSOList csoList)

Constructor.

◆ ~CSOUndoRedoManager()

ml::CSOUndoRedoManager::~CSOUndoRedoManager ( )

Destructor.

Member Function Documentation

◆ addCommand()

void ml::CSOUndoRedoManager::addCommand ( CSOCommand command)

Adds a command (modification).

The inverse command is added to the undo stack while the command itself is added to the redo stack.

◆ canRedo()

bool ml::CSOUndoRedoManager::canRedo ( ) const

Returns whether there are possible redoes.

◆ canUndo()

bool ml::CSOUndoRedoManager::canUndo ( ) const

Returns whether there are possible undoes.

◆ clearAll()

void ml::CSOUndoRedoManager::clearAll ( )

Clears the undo and redo stack.

◆ clearRedo()

void ml::CSOUndoRedoManager::clearRedo ( )
Deprecated:
Clears the redo stack. This is deprecated and calls clearAll() instead.

◆ clearUndo()

void ml::CSOUndoRedoManager::clearUndo ( )
Deprecated:
Clears the undo stack. This is deprecated and calls clearAll() instead.

◆ closeAllGroups()

void ml::CSOUndoRedoManager::closeAllGroups ( )

Closes all undo/redo groups.

◆ closeGroup()

void ml::CSOUndoRedoManager::closeGroup ( )

Closes a group of commands that are undone/redone as one.

◆ disableUndoRedo()

void ml::CSOUndoRedoManager::disableUndoRedo ( )

Disables this undo/redo manager; if it is disabled, the incoming commands are deleted and not added.

◆ enableUndoRedo()

void ml::CSOUndoRedoManager::enableUndoRedo ( )

Enables this undo/redo manager.

◆ getCurrentUndoGroupDepth()

int ml::CSOUndoRedoManager::getCurrentUndoGroupDepth ( )
inline

Returns the current undo group depth.

This value must be 0 after a completed operation, otherwise there is a bug in the code using the undo/redo manager. The depth value an be > 0 if for example an undo group was opened and then an operation was prematurely terminated (by ESC of an editor). This value is used for testing purposes.

Definition at line 81 of file CSOUndoRedoManager.h.

◆ isEnabled()

bool ml::CSOUndoRedoManager::isEnabled ( )
inline

Returns whether this undo/redo manager is currently enabled.

Definition at line 111 of file CSOUndoRedoManager.h.

◆ isInRedoMode()

bool ml::CSOUndoRedoManager::isInRedoMode ( ) const

Returns whether the manager is in redo-mode.

◆ isInUndoMode()

bool ml::CSOUndoRedoManager::isInUndoMode ( ) const

Returns whether the manager is in undo-mode.

◆ maxNumUndos()

int ml::CSOUndoRedoManager::maxNumUndos ( ) const

Returns the maximum number of possible undos. If a -1 is returned, the undo stack has no limitation.

◆ numRedos()

int ml::CSOUndoRedoManager::numRedos ( ) const

Returns the number of stored redo steps.

◆ numUndos()

int ml::CSOUndoRedoManager::numUndos ( ) const

Returns the number of stored undo steps.

◆ openGroup()

void ml::CSOUndoRedoManager::openGroup ( const std::string &  description = "Contour Operation")

Opens a group of commands that are undone/redone as one.

◆ popUndoCommand()

void ml::CSOUndoRedoManager::popUndoCommand ( )

Removes the last added undo command without executing it.

This could be useful if you temporarily want to save a state of a CSOList in your C++ code.

◆ redo()

void ml::CSOUndoRedoManager::redo ( )

Performs a redo (if the undo stack is not empty).

◆ setMaxNumUndos() [1/2]

void ml::CSOUndoRedoManager::setMaxNumUndos ( int  newMaxNumUndos)

Sets the maximum number of possible undos. If a -1 is passed, the undo stack has no limitation.

◆ setMaxNumUndos() [2/2]

void ml::CSOUndoRedoManager::setMaxNumUndos ( MLint  newMaxNumUndos)
inline

Definition at line 92 of file CSOUndoRedoManager.h.

References setMaxNumUndos().

Referenced by setMaxNumUndos().

◆ setUndoContext()

void ml::CSOUndoRedoManager::setUndoContext ( ml::UndoContextPtr  undoContext)

Set a new undo context.

◆ undo()

void ml::CSOUndoRedoManager::undo ( )

Performs an undo of the last modification (if undo stack is not empty).


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