Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79
18 #define UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79
19 
20 #include "mitkOperationEvent.h"
21 #include "mitkUndoModel.h"
22 #include <MitkCoreExports.h>
23 #include <map>
24 
25 namespace mitk
26 {
27  //## @ingroup Undo
29  {
30  public:
31  // different UndoModels:
32  enum UndoType
33  {
34  LIMITEDLINEARUNDO = 10,
35  VERBOSE_LIMITEDLINEARUNDO = 11,
36  TREEUNDO = 20
37  };
38 
39  typedef std::map<UndoType, UndoModel::Pointer> UndoModelMap;
40  typedef std::map<UndoType, UndoModel::Pointer>::iterator UndoModelMapIter;
41  //##Documentation
42  //## @brief Default UndoModel to use.
43  static const UndoType DEFAULTUNDOMODEL;
44 
45  //##Documentation
46  //## Constructor; Adds the new UndoType or if undoType exists ,
47  //## switches it to undoType; for UndoTypes see definitionmitkInteractionConst.h
48  UndoController(UndoType undoType = DEFAULTUNDOMODEL);
49  virtual ~UndoController();
50 
51  bool SetOperationEvent(UndoStackItem *operationEvent);
52 
53  //##Documentation
54  //## @brief calls the UndoMechanism to undo the last change
55  bool Undo();
56 
57  //##Documentation
58  //## @brief calls the UndoMechanism to undo the last change
59  //##
60  //## the UndoMechanism has the possibility to undo the last changes in two different ways:
61  //## first it can Undo a group of operations done at last (e.g. build up a new object; Undo leads to deleting that
62  // object);
63  //## or it can Undo a set of operations, that belong together(statechange with Action),
64  //## that way it is possible recall the last set point after you have finished to build up a new object
65  //## @param fine: if set to true, then undo all operations with the same objectEventId
66  //## if set to false, then undo all operations with the same GroupEventId
67  bool Undo(bool fine);
68 
69  //##Documentation
70  //## @brief calls the RedoMechanism to redo the operations undone
71  //##
72  //## read the Documentation of Undo!
73  bool Redo();
74 
75  //##Documentation
76  //## @brief calls the RedoMechanism to redo the operations undone
77  //##
78  //## read the Documentation of Undo!
79  //## only with the possibility to fine redo, like fine undo
80  bool Redo(bool fine);
81 
82  //##Documentation
83  //## @brief Clears the Undo and the RedoList
84  void Clear();
85 
86  //##Documentation
87  //## @brief Clears the RedoList
88  void ClearRedoList();
89 
90  //##Documentation
91  //## @brief returns true, if the RedoList is empty
92  bool RedoListEmpty();
93 
94  bool SwitchUndoModel(UndoType undoType);
95 
96  bool AddUndoModel(UndoType undoType);
97 
98  bool RemoveUndoModel(UndoType undoType);
99 
100  //##Documentation
101  //## @brief returns the ObjectEventId of the
102  //## top Element in the OperationHistory of the selected
103  //## UndoModel
104  int GetLastObjectEventIdInList();
105 
106  //##Documentation
107  //## @brief returns the GroupEventId of the
108  //## top Element in the OperationHistory of the selected
109  //## UndoModel
110  int GetLastGroupEventIdInList();
111 
112  //##Documentation
113  //## @brief returns the last specified OperationEvent in Undo-list
114  //## corresponding to the given value; if nothing found, then returns NULL
115  OperationEvent *GetLastOfType(OperationActor *destination, OperationType opType);
116 
117  //##Documentation
118  //## @brief gives access to the currently used UndoModel
119  //## Introduced to access special functions of more specific UndoModels,
120  //## especially to retrieve text descriptions of the undo/redo stack
121  static UndoModel *GetCurrentUndoModel();
122 
123  private:
124  //##Documentation
125  //## current selected UndoModel
126  static UndoModel::Pointer m_CurUndoModel;
127  //##Documentation
128  //## current selected Type of m_CurUndoModel
129  static UndoType m_CurUndoType;
130  //##Documentation
131  //## different UndoModels to select and activate
132  static UndoModelMap m_UndoModelList;
133  };
134 } // namespace mitk
135 
136 #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:36
int OperationType
Definition: mitkOperation.h:27
Represents a pair of operations: undo and the according redo.