Medical Imaging Interaction Toolkit  2024.06.99-fe296c79
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 Gets the limit on the size of the undo history.
61  //## The undo limit determines how many items can be stored
62  //## in the undo stack. If the value is 0 that means that
63  //## there is no limit.
64  virtual std::size_t GetUndoLimit() const = 0;
65 
66  //##Documentation
67  //## @brief Sets a limit on the size of the undo history.
68  //## If the limit is reached, the oldest undo items will
69  //## be dropped from the bottom of the undo stack.
70  //## The 0 value means that there is no limit.
71  //## @param limit the maximum number of items on the stack
72  virtual void SetUndoLimit(std::size_t limit) = 0;
73 
74  //##Documentation
75  //## @brief returns the ObjectEventId of the
76  //## top Element in the OperationHistory of the selected
77  //## UndoModel
78  virtual int GetLastObjectEventIdInList() = 0;
79 
80  //##Documentation
81  //## @brief returns the GroupEventId of the
82  //## top Element in the OperationHistory of the selected
83  //## UndoModel
84  virtual int GetLastGroupEventIdInList() = 0;
85 
86  //##Documentation
87  //## @brief returns the last specified OperationEvent in Undo-list
88  //## corresponding to the given values; if nothing found, then returns nullptr
89  //##
90  //## needed to get the old Position of an Element for declaring an UndoOperation
91  virtual OperationEvent *GetLastOfType(OperationActor *destination, OperationType opType) = 0;
92 
93  protected:
94  UndoModel(){};
95  ~UndoModel() override{};
96  };
97 
98 } // namespace mitk
99 #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:95
mitk::UndoModel::UndoModel
UndoModel()
Definition: mitkUndoModel.h:94
mitk::UndoStackItem
Represents an entry of the undo or redo stack.
Definition: mitkOperationEvent.h:35
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:139
mitk::UndoModel
superclass for all UndoModels
Definition: mitkUndoModel.h:32
mitkOperation.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15