Medical Imaging Interaction Toolkit  2025.08.99-f7084adb
Medical Imaging Interaction Toolkit
mitkUndoModel.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 mitkUndoModel_h
14 #define mitkUndoModel_h
15 
16 #include "mitkCommon.h"
17 #include "mitkOperation.h"
18 #include <itkObject.h>
19 #include <itkObjectFactory.h>
20 
21 namespace mitk
22 {
23  class UndoStackItem;
24  class OperationEvent;
25  class OperationActor;
26 
27  //##Documentation
28  //## @brief superclass for all UndoModels
29  //##
30  //## all necessary operations, that all UndoModels share.
31  //## @ingroup Undo
32  class MITKCORE_EXPORT UndoModel : public itk::Object
33  {
34  public:
36 
37  // no New Macro because this is an abstract class!
38 
39  virtual bool SetOperationEvent(UndoStackItem *stackItem) = 0;
40 
41  virtual bool Undo() = 0;
42  virtual bool Undo(bool fine) = 0;
43 
44  virtual bool Redo() = 0;
45  virtual bool Redo(bool fine) = 0;
46 
47  //##Documentation
48  //## @brief clears undo and Redolist
49  virtual void Clear() = 0;
50 
51  //##Documentation
52  //## @brief clears the RedoList
53  virtual void ClearRedoList() = 0;
54 
55  //##Documentation
56  //## @brief true if RedoList is empty
57  virtual bool RedoListEmpty() = 0;
58 
59  //##Documentation
60  //## @brief true if UndoList is empty
61  virtual bool UndoListEmpty() = 0;
62 
63  //##Documentation
64  //## @brief Gets the limit on the size of the undo history.
65  //## The undo limit determines how many items can be stored
66  //## in the undo stack. If the value is 0 that means that
67  //## there is no limit.
68  virtual std::size_t GetUndoLimit() const = 0;
69 
70  //##Documentation
71  //## @brief Sets a limit on the size of the undo history.
72  //## If the limit is reached, the oldest undo items will
73  //## be dropped from the bottom of the undo stack.
74  //## The 0 value means that there is no limit.
75  //## @param limit the maximum number of items on the stack
76  virtual void SetUndoLimit(std::size_t limit) = 0;
77 
78  //##Documentation
79  //## @brief returns the ObjectEventId of the
80  //## top Element in the OperationHistory of the selected
81  //## UndoModel
82  virtual int GetLastObjectEventIdInList() = 0;
83 
84  //##Documentation
85  //## @brief returns the GroupEventId of the
86  //## top Element in the OperationHistory of the selected
87  //## UndoModel
88  virtual int GetLastGroupEventIdInList() = 0;
89 
90  //##Documentation
91  //## @brief returns the last specified OperationEvent in Undo-list
92  //## corresponding to the given values; if nothing found, then returns nullptr
93  //##
94  //## needed to get the old Position of an Element for declaring an UndoOperation
95  virtual OperationEvent *GetLastOfType(OperationActor *destination, OperationType opType) = 0;
96 
104  virtual unsigned int RemoveInvalidOperations() = 0;
105 
106  protected:
108  ~UndoModel() override{};
109  };
110 
111 } // namespace mitk
112 #endif
mitk::OperationActor
abstract class, that can be used by Undo to undo an operation.
Definition: mitkOperationActor.h:41
mitk::UndoModel::~UndoModel
~UndoModel() override
Definition: mitkUndoModel.h:108
mitk::UndoModel::UndoModel
UndoModel()
Definition: mitkUndoModel.h:107
mitk::UndoStackItem
Represents an entry of the undo or redo stack.
Definition: mitkOperationEvent.h:40
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitkCommon.h
mitk::OperationType
int OperationType
Definition: mitkOperation.h:23
mitk::OperationEvent
Represents a pair of operations: undo and the according redo.
Definition: mitkOperationEvent.h:148
mitk::UndoModel
superclass for all UndoModels
Definition: mitkUndoModel.h:32
mitkOperation.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15