Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSegmentationHistory.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
16  and was supported through the Applied Cancer Research Unit program of Cancer Care
17  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkSegmentationHistory_h
22 #define __vtkSegmentationHistory_h
23 
24 // VTK includes
25 #include <vtkObject.h>
26 #include <vtkSmartPointer.h>
27 
28 // STD includes
29 #include <deque>
30 #include <map>
31 #include <vector>
32 
33 #include "vtkSegmentationCoreConfigure.h"
34 
35 class vtkCallbackCommand;
36 class vtkDataObject;
37 class vtkSegment;
38 class vtkSegmentation;
39 
41 class vtkSegmentationCore_EXPORT vtkSegmentationHistory : public vtkObject
42 {
43 public:
44  static vtkSegmentationHistory* New();
45  vtkTypeMacro(vtkSegmentationHistory, vtkObject);
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
50  void SetSegmentation(vtkSegmentation* segmentation);
51 
53  vtkGetMacro(Segmentation, vtkSegmentation*);
54 
58  bool SaveState();
59 
62  bool RestorePreviousState();
63 
66  bool IsRestorePreviousStateAvailable();
67 
70  bool RestoreNextState();
71 
74  bool IsRestoreNextStateAvailable();
75 
77  void RemoveAllStates();
78 
81  void SetMaximumNumberOfStates(unsigned int maximumNumberOfStates);
82 
84  vtkGetMacro(MaximumNumberOfStates, unsigned int);
85 
87  int GetNumberOfStates();
88 
89 protected:
92  static void OnSegmentationModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
93 
95  void RemoveAllNextStates();
96 
98  void RemoveAllObsoleteStates();
99 
101  bool RestoreState(unsigned int stateIndex);
102 
103 protected:
105  ~vtkSegmentationHistory() override;
106 
107  typedef std::map<std::string, vtkSmartPointer<vtkSegment> > SegmentsMap;
108 
110  {
112  std::vector<std::string> SegmentIds; // order of segments
113  };
114 
117  std::deque<SegmentationState> SegmentationStates;
118  unsigned int MaximumNumberOfStates;
119 
120  // Index of the state in SegmentationStates that was restored last.
121  // If LastRestoredState == size of states then it means that the segmentation has changed
122  // since the last restored state.
123  unsigned int LastRestoredState;
124 
126 
127 private:
129  void operator=(const vtkSegmentationHistory&) = delete;
130 };
131 
132 #endif // __vtkSegmentation_h
This class encapsulates a segment that is part of a segmentation.
Definition: vtkSegment.h:45
std::map< std::string, vtkSmartPointer< vtkSegment > > SegmentsMap
vtkCallbackCommand * SegmentationModifiedCallbackCommand
std::deque< SegmentationState > SegmentationStates
This class encapsulates a segmentation that can contain multiple segments and multiple representation...