Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
41class vtkSegmentationCore_EXPORT vtkSegmentationHistory : public vtkObject
42{
43public:
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
63
67
71
75
78
81 void SetMaximumNumberOfStates(unsigned int maximumNumberOfStates);
82
84 vtkGetMacro(MaximumNumberOfStates, unsigned int);
85
88
89protected:
92 static void OnSegmentationModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
93
96
99
101 bool RestoreState(unsigned int stateIndex);
102
103protected:
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;
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
127private:
129 void operator=(const vtkSegmentationHistory&) = delete;
130};
131
132#endif
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:46
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...