Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLSequenceNode.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 ==============================================================================*/
17 
18 #ifndef __vtkMRMLSequenceNode_h
19 #define __vtkMRMLSequenceNode_h
20 
21 // MRML includes
22 #include <vtkMRML.h>
23 #include <vtkMRMLStorableNode.h>
24 
25 // std includes
26 #include <deque>
27 #include <set>
28 
29 
42 
43 class VTK_MRML_EXPORT vtkMRMLSequenceNode : public vtkMRMLStorableNode
44 {
45 public:
46  static vtkMRMLSequenceNode *New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
51  vtkMRMLNode* CreateNodeInstance() override;
52 
54  void ReadXMLAttributes( const char** atts) override;
55 
57  void WriteXML(ostream& of, int indent) override;
58 
61  void Copy(vtkMRMLNode* node) override;
62 
65  virtual void CopySequenceIndex(vtkMRMLNode *node);
66 
68  void UpdateSequenceIndex();
69 
71  const char* GetNodeTagName() override {return "Sequence";};
72 
74  void SetIndexName(const std::string& str);
76  vtkGetMacro(IndexName, std::string);
77 
79  void SetIndexUnit(const std::string& str);
81  vtkGetMacro(IndexUnit, std::string);
82 
84  void SetIndexType(int indexType);
85  void SetIndexTypeFromString(const char *indexTypeString);
87  vtkGetMacro(IndexType, int);
88  virtual std::string GetIndexTypeAsString();
89 
92  vtkGetMacro(NumericIndexValueTolerance, double);
94  void SetNumericIndexValueTolerance(double tolerance);
95 
97  static std::string GetIndexTypeAsString(int indexType);
98  static int GetIndexTypeFromString(const std::string &indexTypeString);
99 
104  vtkMRMLNode* SetDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue);
105 
108  bool UpdateDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue, bool shallowCopy = false);
109 
111  void RemoveDataNodeAtValue(const std::string& indexValue);
112 
114  void RemoveAllDataNodes();
115 
118  vtkMRMLNode* GetDataNodeAtValue(const std::string& indexValue, bool exactMatchRequired = true);
119 
121  vtkMRMLNode* GetNthDataNode(int itemNumber);
122 
124  std::string GetNthIndexValue(int itemNumber);
125 
128  int GetItemNumberFromIndexValue(const std::string& indexValue, bool exactMatchRequired = true);
129 
131  bool UpdateIndexValue(const std::string& oldIndexValue, const std::string& newIndexValue);
132 
134  int GetNumberOfDataNodes();
135 
137  std::string GetDataNodeClassName();
138 
140  std::string GetDataNodeTagName();
141 
145  vtkMRMLScene* GetSequenceScene(bool autoCreate=true);
146 
150 
154  std::string GetDefaultStorageNodeClassName(const char* filename = nullptr) override;
155 
157  void UpdateScene(vtkMRMLScene *scene) override;
158 
162  {
163  NumericIndex = 0,
165  NumberOfIndexTypes // this line must be the last one
166  };
167 
168 protected:
170  ~vtkMRMLSequenceNode() override;
172  void operator=(const vtkMRMLSequenceNode&);
173 
176  int GetInsertPosition(const std::string& indexValue);
177 
178  void ReadIndexValues(const std::string& indexText);
179 
180  vtkMRMLNode* DeepCopyNodeToScene(vtkMRMLNode* source, vtkMRMLScene* scene);
181 
183  {
184  std::string IndexValue;
186  std::string DataNodeID; // only used temporarily, during scene load
187  };
188 
189 protected:
190 
192  std::string IndexName;
193  std::string IndexUnit;
195  double NumericIndexValueTolerance{0.001};
196 
199  vtkMRMLScene* SequenceScene{0};
200 
202  std::deque< IndexEntryType > IndexEntries;
203 };
204 
205 #endif
std::deque< IndexEntryType > IndexEntries
List of data items (the scene may contain some more nodes, such as storage nodes) ...
virtual vtkMRMLStorageNode * CreateDefaultStorageNode()
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
MRML node for representing a sequence of MRML nodes.
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
std::string IndexName
Describes index of the sequence node.
virtual std::string GetDefaultStorageNodeClassName(const char *filename=nullptr)
void Copy(vtkMRMLNode *node) override
Copy node contents from another node of the same type. Reimplemented to copy default sequence storage...
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
A superclass for other storage nodes.
const char * GetNodeTagName() override
Get unique node XML tag name (like Volume, Model)
void UpdateScene(vtkMRMLScene *scene) override
Finds the storage node and read the data
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
void operator=(const vtkMRMLStorableNode &)
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
void PrintSelf(ostream &os, vtkIndent indent) override