00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #ifndef UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79 00020 #define UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79 00021 00022 #include "mitkCommon.h" 00023 #include "mitkUndoModel.h" 00024 #include "mitkOperationEvent.h" 00025 #include <map> 00026 00027 00028 namespace mitk { 00029 00030 //## @ingroup Undo 00031 class MITK_CORE_EXPORT UndoController 00032 { 00033 public: 00034 //different UndoModels: 00035 enum UndoType{LIMITEDLINEARUNDO=10, VERBOSE_LIMITEDLINEARUNDO=11, TREEUNDO=20}; 00036 00037 typedef std::map<UndoType, UndoModel::Pointer> UndoModelMap; 00038 typedef std::map<UndoType, UndoModel::Pointer>::iterator UndoModelMapIter; 00039 //##Documentation 00040 //## @brief Default UndoModel to use. 00041 static const UndoType DEFAULTUNDOMODEL; 00042 00043 //##Documentation 00044 //## Constructor; Adds the new UndoType or if undoType exists , 00045 //## switches it to undoType; for UndoTypes see definitionmitkInteractionConst.h 00046 UndoController(UndoType undoType = DEFAULTUNDOMODEL); 00047 virtual ~UndoController(); 00048 00049 bool SetOperationEvent(UndoStackItem* operationEvent); 00050 00051 //##Documentation 00052 //## @brief calls the UndoMechanism to undo the last change 00053 bool Undo(); 00054 00055 //##Documentation 00056 //## @brief calls the UndoMechanism to undo the last change 00057 //## 00058 //## the UndoMechanism has the possibility to undo the last changes in two different ways: 00059 //## first it can Undo a group of operations done at last (e.g. build up a new object; Undo leads to deleting that object); 00060 //## or it can Undo a set of operations, that belong together(statechange with Action), 00061 //## that way it is possible recall the last set point after you have finished to build up a new object 00062 //## @param fine: if set to true, then undo all operations with the same objectEventId 00063 //## if set to false, then undo all operations with the same GroupEventId 00064 bool Undo(bool fine); 00065 00066 //##Documentation 00067 //## @brief calls the RedoMechanism to redo the operations undone 00068 //## 00069 //## read the Documentation of Undo! 00070 bool Redo(); 00071 00072 //##Documentation 00073 //## @brief calls the RedoMechanism to redo the operations undone 00074 //## 00075 //## read the Documentation of Undo! 00076 //## only with the possibility to fine redo, like fine undo 00077 bool Redo(bool fine); 00078 00079 //##Documentation 00080 //## @brief Clears the Undo and the RedoList 00081 void Clear(); 00082 00083 //##Documentation 00084 //## @brief Clears the RedoList 00085 void ClearRedoList(); 00086 00087 //##Documentation 00088 //## @brief returns true, if the RedoList is empty 00089 bool RedoListEmpty(); 00090 00091 bool SwitchUndoModel(UndoType undoType); 00092 00093 bool AddUndoModel(UndoType undoType); 00094 00095 bool RemoveUndoModel(UndoType undoType); 00096 00097 //##Documentation 00098 //## @brief returns the ObjectEventId of the 00099 //## top Element in the OperationHistory of the selected 00100 //## UndoModel 00101 int GetLastObjectEventIdInList(); 00102 00103 //##Documentation 00104 //## @brief returns the GroupEventId of the 00105 //## top Element in the OperationHistory of the selected 00106 //## UndoModel 00107 int GetLastGroupEventIdInList(); 00108 00109 00110 //##Documentation 00111 //## @brief returns the last specified OperationEvent in Undo-list 00112 //## corresponding to the given value; if nothing found, then returns NULL 00113 OperationEvent* GetLastOfType(OperationActor* destination, OperationType opType); 00114 00115 //##Documentation 00116 //## @brief gives access to the currently used UndoModel 00117 //## Introduced to access special functions of more specific UndoModels, 00118 //## especially to retrieve text descriptions of the undo/redo stack 00119 static UndoModel* GetCurrentUndoModel(); 00120 00121 private: 00122 //##Documentation 00123 //## current selected UndoModel 00124 static UndoModel::Pointer m_CurUndoModel; 00125 //##Documentation 00126 //## current selected Type of m_CurUndoModel 00127 static UndoType m_CurUndoType; 00128 //##Documentation 00129 //## different UndoModels to select and activate 00130 static UndoModelMap m_UndoModelList; 00131 00132 }; 00133 }//namespace mitk 00134 00135 #endif /* UNDOCONTROLLER_H_HEADER_INCLUDED_C16EFF79 */