Slicer 5.13
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
67 void SetScene(vtkMRMLScene* scene) override;
68
71 virtual void CopySequenceIndex(vtkMRMLNode* node);
72
75
77 const char* GetNodeTagName() override { return "Sequence"; };
78
80 void SetIndexName(const std::string& str);
82 vtkGetMacro(IndexName, std::string);
83
85 void SetIndexUnit(const std::string& str);
87 vtkGetMacro(IndexUnit, std::string);
88
90 void SetIndexType(int indexType);
91 void SetIndexTypeFromString(const char* indexTypeString);
93 vtkGetMacro(IndexType, int);
94 virtual std::string GetIndexTypeAsString();
95
98 vtkGetMacro(NumericIndexValueTolerance, double);
100 void SetNumericIndexValueTolerance(double tolerance);
101
103 static std::string GetIndexTypeAsString(int indexType);
104 static int GetIndexTypeFromString(const std::string& indexTypeString);
105
110 vtkMRMLNode* SetDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue);
111
114 bool UpdateDataNodeAtValue(vtkMRMLNode* node, const std::string& indexValue, bool shallowCopy = false);
115
117 void RemoveDataNodeAtValue(const std::string& indexValue);
118
121
124 vtkMRMLNode* GetDataNodeAtValue(const std::string& indexValue, bool exactMatchRequired = true);
125
127 vtkMRMLNode* GetNthDataNode(int itemNumber);
128
130 std::string GetNthIndexValue(int itemNumber);
131
134 int GetItemNumberFromIndexValue(const std::string& indexValue, bool exactMatchRequired = true);
135
137 bool UpdateIndexValue(const std::string& oldIndexValue, const std::string& newIndexValue);
138
141
143 std::string GetDataNodeClassName();
144
146 std::string GetDataNodeTagName();
147
151 vtkMRMLScene* GetSequenceScene(bool autoCreate = true);
152
156
160 std::string GetDefaultStorageNodeClassName(const char* filename = nullptr) override;
161
163 void UpdateScene(vtkMRMLScene* scene) override;
164
165 enum
166 {
171 };
172
176 {
179 NumberOfIndexTypes // this line must be the last one
180 };
181
182protected:
187
191
194 int GetInsertPosition(const std::string& indexValue);
195
196 void ReadIndexValues(const std::string& indexText);
197
199
201 {
202 std::string IndexValue;
203 vtkWeakPointer<vtkMRMLNode> DataNode;
204 std::string DataNodeID; // only used temporarily, during scene load
205 };
206
207protected:
209 std::string IndexName;
210 std::string IndexUnit;
213
217
219 std::deque<IndexEntryType> IndexEntries;
220};
221
222#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
void SequenceContentModified()
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)
void SetScene(vtkMRMLScene *scene) override
Set the scene and share its node factory with the internal sequence scene.
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