Slicer  4.10
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 vtkSegment;
37 class vtkSegmentation;
38 
40 class vtkSegmentationCore_EXPORT vtkSegmentationHistory : public vtkObject
41 {
42 public:
43  static vtkSegmentationHistory* New();
44  vtkTypeMacro(vtkSegmentationHistory, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
46 
49  void SetSegmentation(vtkSegmentation* segmentation);
50 
52  vtkGetMacro(Segmentation, vtkSegmentation*);
53 
57  bool SaveState();
58 
61  bool RestorePreviousState();
62 
65  bool IsRestorePreviousStateAvailable();
66 
69  bool RestoreNextState();
70 
73  bool IsRestoreNextStateAvailable();
74 
76  void RemoveAllStates();
77 
80  void SetMaximumNumberOfStates(unsigned int maximumNumberOfStates);
81 
83  vtkGetMacro(MaximumNumberOfStates, unsigned int);
84 
85 protected:
88  static void OnSegmentationModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
89 
91  void RemoveAllNextStates();
92 
94  void RemoveAllObsoleteStates();
95 
97  bool RestoreState(unsigned int stateIndex);
98 
99 protected:
102  void operator=(const vtkSegmentationHistory&);
103 
106  void CopySegment(vtkSegment* destination, vtkSegment* source, vtkSegment* baseline);
107 
108 protected:
109  typedef std::map<std::string, vtkSmartPointer<vtkSegment> > SegmentsMap;
110 
112  {
114  std::vector<std::string> SegmentIds; // order of segments
115  };
116 
119  std::deque<SegmentationState> SegmentationStates;
120  unsigned int MaximumNumberOfStates;
121 
122  // Index of the state in SegmentationStates that was restored last.
123  // If index == size of states then it means that the segmentation has changed
124  // since the last restored state.
125  unsigned int LastRestoredState;
126 
128 };
129 
130 #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
Container type for segments. Maps segment IDs to segment objects.
vtkCallbackCommand * SegmentationModifiedCallbackCommand
std::deque< SegmentationState > SegmentationStates
This class encapsulates a segmentation that can contain multiple segments and multiple representation...