MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
CSOUndoRedoManager.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13
15
16#pragma once
17
18#include "CSOUndoRedoCommands.h"
19
20#include <mlUndoContext.h>
21
23
24
26
30{
31
32public:
34 enum UNDO_MODE {
35 MODE_UNDOING = 0,
36 MODE_REDOING = 1,
37 MODE_NORMAL = 2
38 };
39
40
43
46
54
56 void undo();
58 void redo();
59
61 void openGroup(const std::string& description = "Contour Operation");
63 void closeGroup();
66
68 [[deprecated("Use clearAll() instead.")]]
69 void clearUndo()
70 {
71 clearAll();
72 }
74 [[deprecated("Use clearAll() instead.")]]
75 void clearRedo()
76 {
77 clearAll();
78 }
80 void clearAll();
81
88 {
89 return _currentGroupDepth;
90 }
91
93 bool canUndo() const;
95 bool canRedo() const;
96
98 int maxNumUndos() const;
102 {
103 setMaxNumUndos(static_cast<int>(newMaxNumUndos));
104 }
105
107 int numUndos() const;
109 int numRedos() const;
110
112 bool isInUndoMode() const;
114 bool isInRedoMode() const;
115
121
123 inline bool isEnabled()
124 {
125 return _isEnabled;
126 }
127
129 void setUndoContext(ml::UndoContextPtr undoContext);
130
131private:
132 static void _undoContextCB(void* userData, BaseEvent* event);
133
135 int _currentGroupDepth;
136
138 bool _isEnabled;
139
141 ml::UndoContextPtr _undoContext;
142
144 ml::UndoContextPtr _defaultUndoContext;
145
147 CSOList* _csoList;
148};
149
151
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
BaseEvent is the base class for all events emitted from EventSourceBase.
Base class for a CSOCommand for the undo/redo mechanism.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition CSOList.h:61
Manager class for maintaining the undo and the redo stacks.
bool isInRedoMode() const
Returns whether the manager is in redo mode.
void disableUndoRedo()
Disables this undo/redo manager; if it is disabled, the incoming commands are deleted and not added.
bool canRedo() const
Returns whether there are possible redos.
void openGroup(const std::string &description="Contour Operation")
Opens a group of commands that are undone/redone as one.
UNDO_MODE
The undo (and redo) modes.
int numUndos() const
Returns the number of stored undo steps.
CSOUndoRedoManager(CSOList *csoList)
Constructor.
void popUndoCommand()
Removes the last added undo command without executing it.
void clearAll()
Clears the undo and redo stack.
void enableUndoRedo()
Enables this undo/redo manager.
void closeGroup()
Closes a group of commands that are undone/redone as one.
bool isEnabled()
Returns whether this undo/redo manager is currently enabled.
void closeAllGroups()
Closes all undo/redo groups.
void undo()
Performs an undo of the last modification (if undo stack is not empty).
int maxNumUndos() const
Returns the maximum number of possible undos. If a -1 is returned, the undo stack has no limitation.
void redo()
Performs a redo (if the undo stack is not empty).
int getCurrentUndoGroupDepth()
Returns the current undo group depth.
bool isInUndoMode() const
Returns whether the manager is in undo mode.
void setUndoContext(ml::UndoContextPtr undoContext)
Sets a new undo context.
void setMaxNumUndos(MLint newMaxNumUndos)
void setMaxNumUndos(int newMaxNumUndos)
Sets the maximum number of possible undos. If a -1 is passed, the undo stack has no limitation.
~CSOUndoRedoManager()
Destructor.
int numRedos() const
Returns the number of stored redo steps.
bool canUndo() const
Returns whether there are possible undos.
void addCommand(CSOCommand *command)
Adds a command (modification).
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489