Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
35class vtkCallbackCommand;
36class vtkDataObject;
37class vtkSegment;
38class vtkSegmentation;
39
40class vtkSegmentationCore_EXPORT vtkSegmentationHistory : public vtkObject
41{
42public:
44 vtkTypeMacro(vtkSegmentationHistory, vtkObject);
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
49 void SetSegmentation(vtkSegmentation* segmentation);
50
53
57 bool SaveState();
58
62
66
70
74
77
80 void SetMaximumNumberOfStates(unsigned int maximumNumberOfStates);
81
83 vtkGetMacro(MaximumNumberOfStates, unsigned int);
84
87
88protected:
91 static void OnSegmentationModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
92
95
98
100 bool RestoreState(unsigned int stateIndex);
101
102protected:
105
106 typedef std::map<std::string, vtkSmartPointer<vtkSegment> > SegmentsMap;
107
109 {
111 std::vector<std::string> SegmentIds; // order of segments
112 };
113
116 std::deque<SegmentationState> SegmentationStates;
118
119 // Index of the state in SegmentationStates that was restored last.
120 // If LastRestoredState == size of states then it means that the segmentation has changed
121 // since the last restored state.
122 unsigned int LastRestoredState;
123
125
126private:
128 void operator=(const vtkSegmentationHistory&) = delete;
129};
130
131#endif
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:45
static vtkSegmentationHistory * New()
std::map< std::string, vtkSmartPointer< vtkSegment > > SegmentsMap
~vtkSegmentationHistory() override
bool IsRestorePreviousStateAvailable()
std::deque< SegmentationState > SegmentationStates
int GetNumberOfStates()
Get the current number of states.
bool RestoreState(unsigned int stateIndex)
Restores a state defined by stateIndex.
vtkCallbackCommand * SegmentationModifiedCallbackCommand
void SetSegmentation(vtkSegmentation *segmentation)
bool IsRestoreNextStateAvailable()
static void OnSegmentationModified(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
void PrintSelf(ostream &os, vtkIndent indent) override
void RemoveAllStates()
Delete all states from memory.
void RemoveAllNextStates()
Delete all states that are more recent than the last restored state.
void SetMaximumNumberOfStates(unsigned int maximumNumberOfStates)
void RemoveAllObsoleteStates()
Delete all old states so that we keep only up to MaximumNumberOfStates states.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...