Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
45
46class VTK_MRML_EXPORT vtkMRMLSequenceNode : public vtkMRMLStorableNode
47{
48public:
51 void PrintSelf(ostream& os, vtkIndent indent) override;
52
55
57 void ReadXMLAttributes(const char** atts) override;
58
60 void WriteXML(ostream& of, int indent) override;
61
64 void Copy(vtkMRMLNode* node) override;
65
68 virtual void CopySequenceIndex(vtkMRMLNode* node);
69
72
74 const char* GetNodeTagName() override { return "Sequence"; };
75
77 void SetIndexName(const std::string& str);
79 vtkGetMacro(IndexName, std::string);
80
82 void SetIndexUnit(const std::string& str);
84 vtkGetMacro(IndexUnit, std::string);
85
87 void SetIndexType(int indexType);
88 void SetIndexTypeFromString(const char* indexTypeString);
90 vtkGetMacro(IndexType, int);
91 virtual std::string GetIndexTypeAsString();
92
95 vtkGetMacro(NumericIndexValueTolerance, double);
97 void SetNumericIndexValueTolerance(double tolerance);
98
100 static std::string GetIndexTypeAsString(int indexType);
101 static int GetIndexTypeFromString(const std::string& indexTypeString);
102
107 vtkMRMLNode* SetDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue);
108
111 bool UpdateDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue, bool shallowCopy = false);
112
114 void RemoveDataNodeAtValue(const std::string& indexValue);
115
118
121 vtkMRMLNode* GetDataNodeAtValue(const std::string& indexValue, bool exactMatchRequired = true);
122
124 vtkMRMLNode* GetNthDataNode(int itemNumber);
125
127 std::string GetNthIndexValue(int itemNumber);
128
131 int GetItemNumberFromIndexValue(const std::string& indexValue, bool exactMatchRequired = true);
132
134 bool UpdateIndexValue(const std::string& oldIndexValue, const std::string& newIndexValue);
135
138
140 std::string GetDataNodeClassName();
141
143 std::string GetDataNodeTagName();
144
148 vtkMRMLScene* GetSequenceScene(bool autoCreate = true);
149
153
157 std::string GetDefaultStorageNodeClassName(const char* filename = nullptr) override;
158
160 void UpdateScene(vtkMRMLScene* scene) override;
161
165 {
168 NumberOfIndexTypes // this line must be the last one
169 };
170
171protected:
176
179 int GetInsertPosition(const std::string& indexValue);
180
181 void ReadIndexValues(const std::string& indexText);
182
184
186 {
187 std::string IndexValue;
188 vtkWeakPointer<vtkMRMLNode> DataNode;
189 std::string DataNodeID; // only used temporarily, during scene load
190 };
191
192protected:
194 std::string IndexName;
195 std::string IndexUnit;
198
202
204 std::deque<IndexEntryType> IndexEntries;
205};
206
207#endif
friend class vtkMRMLScene
bool UpdateIndexValue(const std::string &oldIndexValue, const std::string &newIndexValue)
Change index value of an existing data node.
void UpdateSequenceIndex()
Update sequence index to point to nodes.
int GetNumberOfDataNodes()
Return the number of nodes stored in this sequence.
vtkMRMLNode * GetDataNodeAtValue(const std::string &indexValue, bool exactMatchRequired=true)
void UpdateScene(vtkMRMLScene *scene) override
Update node IDs in case of node ID conflicts on scene import.
vtkMRMLNode * CreateNodeInstance() override
Create instance of a sequence node.
void ReadIndexValues(const std::string &indexText)
std::string GetNthIndexValue(int itemNumber)
Index value of n-th data node.
void SetIndexName(const std::string &str)
Set index name (example: time)
std::string GetDefaultStorageNodeClassName(const char *filename=nullptr) override
static vtkMRMLSequenceNode * New()
~vtkMRMLSequenceNode() override
void Copy(vtkMRMLNode *node) override
Copy the node's attributes to this object.
vtkMRMLStorageNode * CreateDefaultStorageNode() override
std::string GetDataNodeTagName()
Return the human-readable type name of the data nodes (e.g., TransformNode). If there are no data nod...
void operator=(const vtkMRMLSequenceNode &)
vtkMRMLNode * DeepCopyNodeToScene(vtkMRMLNode *source, vtkMRMLScene *scene)
static std::string GetIndexTypeAsString(int indexType)
Helper functions for converting between string and code representation of the index type.
const char * GetNodeTagName() override
Get unique node XML tag name (like Volume, Model)
void SetIndexTypeFromString(const char *indexTypeString)
vtkMRMLNode * SetDataNodeAtValue(vtkMRMLNode *node, const std::string &indexValue)
void ReadXMLAttributes(const char **atts) override
Set node attributes from name/value pairs.
void SetIndexType(int indexType)
Set the type of the index (numeric, text, ...)
vtkMRMLSequenceNode(const vtkMRMLSequenceNode &)
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void SetIndexUnit(const std::string &str)
Set unit for the index (example: s)
vtkMRMLScene * GetSequenceScene(bool autoCreate=true)
bool UpdateDataNodeAtValue(vtkMRMLNode *node, const std::string &indexValue, bool shallowCopy=false)
std::string GetDataNodeClassName()
Return the class name of the data nodes (e.g., vtkMRMLTransformNode). If there are no data nodes yet ...
vtkMRMLNode * GetNthDataNode(int itemNumber)
Get the data node corresponding to the n-th index value.
static int GetIndexTypeFromString(const std::string &indexTypeString)
void SetNumericIndexValueTolerance(double tolerance)
Set tolerance value for comparing numeric index values.
virtual void CopySequenceIndex(vtkMRMLNode *node)
int GetItemNumberFromIndexValue(const std::string &indexValue, bool exactMatchRequired=true)
std::string IndexName
Describes index of the sequence node.
void PrintSelf(ostream &os, vtkIndent indent) override
std::deque< IndexEntryType > IndexEntries
List of data items (the scene may contain some more nodes, such as storage nodes)
int GetInsertPosition(const std::string &indexValue)
void RemoveDataNodeAtValue(const std::string &indexValue)
Remove data node corresponding to the specified index.
void RemoveAllDataNodes()
Remove all data nodes from the sequence.
virtual std::string GetIndexTypeAsString()
A superclass for other storage nodes.
vtkWeakPointer< vtkMRMLNode > DataNode