Slicer  5.3
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 
46 
47 class VTK_MRML_EXPORT vtkMRMLSequenceNode : public vtkMRMLStorableNode
48 {
49 public:
50  static vtkMRMLSequenceNode *New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55  vtkMRMLNode* CreateNodeInstance() override;
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 
72  void UpdateSequenceIndex();
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 
118  void RemoveAllDataNodes();
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 
138  int GetNumberOfDataNodes();
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  {
167  NumericIndex = 0,
169  NumberOfIndexTypes // this line must be the last one
170  };
171 
172 protected:
174  ~vtkMRMLSequenceNode() override;
176  void operator=(const vtkMRMLSequenceNode&);
177 
180  int GetInsertPosition(const std::string& indexValue);
181 
182  void ReadIndexValues(const std::string& indexText);
183 
184  vtkMRMLNode* DeepCopyNodeToScene(vtkMRMLNode* source, vtkMRMLScene* scene);
185 
187  {
188  std::string IndexValue;
190  std::string DataNodeID; // only used temporarily, during scene load
191  };
192 
193 protected:
194 
196  std::string IndexName;
197  std::string IndexUnit;
199  double NumericIndexValueTolerance{0.001};
200 
203  vtkMRMLScene* SequenceScene{0};
204 
206  std::deque< IndexEntryType > IndexEntries;
207 };
208 
209 #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