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
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
46
47class VTK_MRML_EXPORT vtkMRMLSequenceNode : public vtkMRMLStorableNode
48{
49public:
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
56
58 void ReadXMLAttributes( const char** atts) override;
59
61 void WriteXML(ostream& of, int indent) override;
62
65 void Copy(vtkMRMLNode* node) override;
66
69 virtual void CopySequenceIndex(vtkMRMLNode *node);
70
73
75 const char* GetNodeTagName() override {return "Sequence";};
76
78 void SetIndexName(const std::string& str);
80 vtkGetMacro(IndexName, std::string);
81
83 void SetIndexUnit(const std::string& str);
85 vtkGetMacro(IndexUnit, std::string);
86
88 void SetIndexType(int indexType);
89 void SetIndexTypeFromString(const char *indexTypeString);
91 vtkGetMacro(IndexType, int);
92 virtual std::string GetIndexTypeAsString();
93
96 vtkGetMacro(NumericIndexValueTolerance, double);
98 void SetNumericIndexValueTolerance(double tolerance);
99
101 static std::string GetIndexTypeAsString(int indexType);
102 static int GetIndexTypeFromString(const std::string &indexTypeString);
103
108 vtkMRMLNode* SetDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue);
109
112 bool UpdateDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue, bool shallowCopy = false);
113
115 void RemoveDataNodeAtValue(const std::string& indexValue);
116
119
122 vtkMRMLNode* GetDataNodeAtValue(const std::string& indexValue, bool exactMatchRequired = true);
123
125 vtkMRMLNode* GetNthDataNode(int itemNumber);
126
128 std::string GetNthIndexValue(int itemNumber);
129
132 int GetItemNumberFromIndexValue(const std::string& indexValue, bool exactMatchRequired = true);
133
135 bool UpdateIndexValue(const std::string& oldIndexValue, const std::string& newIndexValue);
136
139
141 std::string GetDataNodeClassName();
142
144 std::string GetDataNodeTagName();
145
149 vtkMRMLScene* GetSequenceScene(bool autoCreate=true);
150
154
158 std::string GetDefaultStorageNodeClassName(const char* filename = nullptr) override;
159
161 void UpdateScene(vtkMRMLScene *scene) override;
162
166 {
169 NumberOfIndexTypes // this line must be the last one
170 };
171
172protected:
177
180 int GetInsertPosition(const std::string& indexValue);
181
182 void ReadIndexValues(const std::string& indexText);
183
185
187 {
188 std::string IndexValue;
189 vtkWeakPointer<vtkMRMLNode> DataNode;
190 std::string DataNodeID; // only used temporarily, during scene load
191 };
192
193protected:
194
196 std::string IndexName;
197 std::string IndexUnit;
200
204
206 std::deque< IndexEntryType > IndexEntries;
207};
208
209#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)
std::deque< IndexEntryType > IndexEntries
List of data items (the scene may contain some more nodes, such as storage nodes)
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
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