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