Slicer  4.8
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
vtkMRMLHierarchyNode.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkMRMLHierarchyNode.h,v $
10  Date: $Date: 2006/03/19 17:12:29 $
11  Version: $Revision: 1.13 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkMRMLHierarchyNode_h
16 #define __vtkMRMLHierarchyNode_h
17 
18 // MRML includes
19 #include "vtkMRMLNode.h"
20 
21 // VTK includes
22 class vtkCollection;
23 
24 // STD includes
25 #include <vector>
26 
28 class VTK_MRML_EXPORT vtkMRMLHierarchyNode : public vtkMRMLNode
29 {
30 public:
31  static vtkMRMLHierarchyNode *New();
33  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
34 
35  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
36 
39  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
40 
43  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
44 
47  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
48 
51  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "Hierarchy";}
52 
54  virtual void SetSceneReferences() VTK_OVERRIDE;
55 
59  virtual void UpdateReferences() VTK_OVERRIDE;
60 
63  virtual void UpdateScene(vtkMRMLScene *scene) VTK_OVERRIDE;
64 
67  virtual void UpdateReferenceID(const char *oldID, const char *newID) VTK_OVERRIDE;
68 
71  vtkMRMLHierarchyNode* GetParentNode();
72 
75  vtkMRMLHierarchyNode* GetTopParentNode();
76 
79  virtual char* GetParentNodeID()
80  {
81  return GetParentNodeIDReference();
82  }
83 
84  virtual void SetParentNodeID(const char* ref);
85 
88  void GetAllChildrenNodes(std::vector< vtkMRMLHierarchyNode *> &childrenNodes);
89 
94  std::vector< vtkMRMLHierarchyNode *> GetChildrenNodes();
95 
98  {
99  return static_cast<int>(this->GetChildrenNodes().size());
100  }
101 
103  vtkMRMLHierarchyNode *GetNthChildNode(int index);
104 
106  int GetIndexInParent();
107 
109  void SetIndexInParent(int index);
110 
113  void MoveInParent(int increment);
114 
116  void RemoveHierarchyChildrenNodes();
117 
119  void RemoveAllHierarchyChildrenNodes();
120 
122  enum
123  {
124  ChildNodeAddedEvent = 15550,
125  ChildNodeRemovedEvent = 15551
126  };
127 
129 
132  virtual char* GetAssociatedNodeID()
133  {
134  return GetAssociatedNodeIDReference();
135  }
136 
137  virtual void SetAssociatedNodeID(const char* ref);
138 
139 
141  virtual vtkMRMLNode* GetAssociatedNode();
142 
143 
146  virtual void GetAssociatedChildrenNodes(vtkCollection *children, const char* childClass=NULL);
147 
150  static vtkMRMLHierarchyNode* GetAssociatedHierarchyNode(vtkMRMLScene *scene,
151  const char *associatedNodeID);
154  //vtkSetMacro(SortingValue, double);
156  //nodes (since the order of that associated node could have changed as well)
157  void SetSortingValue(double value);
158  vtkGetMacro(SortingValue, double);
159 
160 
164  vtkGetMacro(AllowMultipleChildren, int);
165  vtkSetMacro(AllowMultipleChildren, int);
166  vtkBooleanMacro(AllowMultipleChildren, int);
167 
168 protected:
172  void operator=(const vtkMRMLHierarchyNode&);
173 
174 
177  void SetParentNodeIDReference(const char* id);
178  vtkGetStringMacro(ParentNodeIDReference);
179 
180  char *ParentNodeIDReference;
181 
183  static void HierarchyIsModified(vtkMRMLScene *scene);
184 
185 
187 
189  static void AssociatedHierarchyIsModified(vtkMRMLScene *scene);
193 
194  void SetAssociatedNodeIDReference(const char*);
195  vtkGetStringMacro(AssociatedNodeIDReference);
196 
197  typedef std::map<std::string, std::vector< vtkMRMLHierarchyNode *> > HierarchyChildrenNodesType;
198 
199  static std::map< vtkMRMLScene*, HierarchyChildrenNodesType> SceneHierarchyChildrenNodes;
200  static std::map< vtkMRMLScene*, vtkMTimeType> SceneHierarchyChildrenNodesMTime;
201 
206  static int UpdateAssociatedToHierarchyMap(vtkMRMLScene *scene);
207 
208  typedef std::map<std::string, vtkMRMLHierarchyNode *> AssociatedHierarchyNodesType;
209 
210  static std::map< vtkMRMLScene*, AssociatedHierarchyNodesType> SceneAssociatedHierarchyNodes;
211 
212  static std::map< vtkMRMLScene*, vtkMTimeType> SceneAssociatedHierarchyNodesMTime;
213 
214  double SortingValue;
215 
216  static double MaximumSortingValue;
217 
218  void UpdateChildrenMap();
219 
222 
228  void InvokeHierarchyModifiedEvent(vtkMRMLNode *node = NULL);
229 };
230 
231 #endif
232 
233 
234 
235 
static std::map< vtkMRMLScene *, vtkMTimeType > SceneHierarchyChildrenNodesMTime
std::map< std::string, std::vector< vtkMRMLHierarchyNode * > > HierarchyChildrenNodesType
static double MaximumSortingValue
static std::map< vtkMRMLScene *, vtkMTimeType > SceneAssociatedHierarchyNodesMTime
virtual void UpdateReferences()
The method should remove all pointers and observations to all nodes that are not in the scene anymore...
static std::map< vtkMRMLScene *, HierarchyChildrenNodesType > SceneHierarchyChildrenNodes
void operator=(const vtkMRMLNode &)
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
virtual void UpdateReferenceID(const char *oldID, const char *newID)
Update the stored reference to another node in the scene.
virtual char * GetAssociatedNodeID()
String ID of the corresponding displayable MRML node.
Abstract class representing a hierarchy member.
virtual void SetSceneReferences()
Update the references of the node to the scene.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
int GetNumberOfChildrenNodes()
Returns the number of immediate children in the hierarchy.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
std::map< std::string, vtkMRMLHierarchyNode * > AssociatedHierarchyNodesType
virtual char * GetParentNodeID()
String ID of the parent hierarchy MRML node.
static std::map< vtkMRMLScene *, AssociatedHierarchyNodesType > SceneAssociatedHierarchyNodes
int AllowMultipleChildren
is this a node that&#39;s only supposed to have one child?
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
char * AssociatedNodeIDReference
String ID of the associated MRML node.
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:171