Medical Imaging Interaction Toolkit  2018.4.99-ef453c4b
Medical Imaging Interaction Toolkit
mitkUndoController.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79
14 #define UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79
15 
16 #include "mitkOperationEvent.h"
17 #include "mitkUndoModel.h"
18 #include <MitkCoreExports.h>
19 #include <map>
20 
21 namespace mitk
22 {
23  //## @ingroup Undo
25  {
26  public:
27  // different UndoModels:
28  enum UndoType
29  {
30  LIMITEDLINEARUNDO = 10,
31  VERBOSE_LIMITEDLINEARUNDO = 11,
32  TREEUNDO = 20
33  };
34 
35  typedef std::map<UndoType, UndoModel::Pointer> UndoModelMap;
36  typedef std::map<UndoType, UndoModel::Pointer>::iterator UndoModelMapIter;
37  //##Documentation
38  //## @brief Default UndoModel to use.
39  static const UndoType DEFAULTUNDOMODEL;
40 
41  //##Documentation
42  //## Constructor; Adds the new UndoType or if undoType exists ,
43  //## switches it to undoType; for UndoTypes see definitionmitkInteractionConst.h
44  UndoController(UndoType undoType = DEFAULTUNDOMODEL);
45  virtual ~UndoController();
46 
47  bool SetOperationEvent(UndoStackItem *operationEvent);
48 
49  //##Documentation
50  //## @brief calls the UndoMechanism to undo the last change
51  bool Undo();
52 
53  //##Documentation
54  //## @brief calls the UndoMechanism to undo the last change
55  //##
56  //## the UndoMechanism has the possibility to undo the last changes in two different ways:
57  //## first it can Undo a group of operations done at last (e.g. build up a new object; Undo leads to deleting that
58  // object);
59  //## or it can Undo a set of operations, that belong together(statechange with Action),
60  //## that way it is possible recall the last set point after you have finished to build up a new object
61  //## @param fine: if set to true, then undo all operations with the same objectEventId
62  //## if set to false, then undo all operations with the same GroupEventId
63  bool Undo(bool fine);
64 
65  //##Documentation
66  //## @brief calls the RedoMechanism to redo the operations undone
67  //##
68  //## read the Documentation of Undo!
69  bool Redo();
70 
71  //##Documentation
72  //## @brief calls the RedoMechanism to redo the operations undone
73  //##
74  //## read the Documentation of Undo!
75  //## only with the possibility to fine redo, like fine undo
76  bool Redo(bool fine);
77 
78  //##Documentation
79  //## @brief Clears the Undo and the RedoList
80  void Clear();
81 
82  //##Documentation
83  //## @brief Clears the RedoList
84  void ClearRedoList();
85 
86  //##Documentation
87  //## @brief returns true, if the RedoList is empty
88  bool RedoListEmpty();
89 
90  bool SwitchUndoModel(UndoType undoType);
91 
92  bool AddUndoModel(UndoType undoType);
93 
94  bool RemoveUndoModel(UndoType undoType);
95 
96  //##Documentation
97  //## @brief returns the ObjectEventId of the
98  //## top Element in the OperationHistory of the selected
99  //## UndoModel
100  int GetLastObjectEventIdInList();
101 
102  //##Documentation
103  //## @brief returns the GroupEventId of the
104  //## top Element in the OperationHistory of the selected
105  //## UndoModel
106  int GetLastGroupEventIdInList();
107 
108  //##Documentation
109  //## @brief returns the last specified OperationEvent in Undo-list
110  //## corresponding to the given value; if nothing found, then returns nullptr
111  OperationEvent *GetLastOfType(OperationActor *destination, OperationType opType);
112 
113  //##Documentation
114  //## @brief gives access to the currently used UndoModel
115  //## Introduced to access special functions of more specific UndoModels,
116  //## especially to retrieve text descriptions of the undo/redo stack
117  static UndoModel *GetCurrentUndoModel();
118 
119  private:
120  //##Documentation
121  //## current selected UndoModel
122  static UndoModel::Pointer m_CurUndoModel;
123  //##Documentation
124  //## current selected Type of m_CurUndoModel
125  static UndoType m_CurUndoType;
126  //##Documentation
127  //## different UndoModels to select and activate
128  static UndoModelMap m_UndoModelList;
129  };
130 } // namespace mitk
131 
132 #endif /* UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79 */
std::map< UndoType, UndoModel::Pointer > UndoModelMap
#define MITKCORE_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
std::map< UndoType, UndoModel::Pointer >::iterator UndoModelMapIter
abstract class, that can be used by Undo to undo an operation.
static const UndoType DEFAULTUNDOMODEL
Default UndoModel to use.
Represents an entry of the undo or redo stack.
superclass for all UndoModels
Definition: mitkUndoModel.h:32
int OperationType
Definition: mitkOperation.h:23
Represents a pair of operations: undo and the according redo.