Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLSubjectHierarchyNode.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6  Queen's University, Kingston, ON, Canada. All Rights Reserved.
7 
8  See COPYRIGHT.txt
9  or http://www.slicer.org/copyright/copyright.txt for details.
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18  and was supported through the Applied Cancer Research Unit program of Cancer Care
19  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20 
21 ==============================================================================*/
22 
23 // .NAME vtkMRMLSubjectHierarchyNode
24 // .SECTION Description
25 // MRML node to represent subject hierarchy tree
26 //
27 
28 #ifndef __vtkMRMLSubjectHierarchyNode_h
29 #define __vtkMRMLSubjectHierarchyNode_h
30 
31 // MRML includes
32 #include <vtkMRMLNode.h>
34 
35 class vtkCallbackCommand;
37 
52 class VTK_MRML_EXPORT vtkMRMLSubjectHierarchyNode : public vtkMRMLNode
53 {
54 public:
55  static const vtkIdType INVALID_ITEM_ID;
56 
57  // Separator characters for (de)serializing the UID and the attributes map
58  static const std::string SUBJECTHIERARCHY_SEPARATOR;
59  static const std::string SUBJECTHIERARCHY_NAME_VALUE_SEPARATOR;
60 
61  // Attribute name to identify subject hierarchy 2.0 nodes in scene MRML files
62  static const std::string SUBJECTHIERARCHY_VERSION_ATTRIBUTE_NAME;
63 
64  enum
65  {
66  SubjectHierarchyItemAddedEvent = 62000,
80  SubjectHierarchyEndResolveEvent
81  };
82 
83 public:
84  static vtkMRMLSubjectHierarchyNode *New();
86  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
87 
88  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
89 
91  virtual void ReadItemFromXML(const char** atts);
93  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
95  virtual void WriteNodeBodyXML(ostream& of, int indent) VTK_OVERRIDE;
96 
98  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
99 
101  virtual const char* GetNodeTagName() VTK_OVERRIDE;
102 
103 // Get/Set methods
104 public:
107  static vtkMRMLSubjectHierarchyNode* GetSubjectHierarchyNode(vtkMRMLScene* scene);
108 
110  vtkIdType GetSceneItemID();
115  vtkMRMLNode* GetItemDataNode(vtkIdType itemID);
117  void SetItemName(vtkIdType itemID, std::string name);
120  std::string GetItemName(vtkIdType itemID);
122  void SetItemLevel(vtkIdType itemID, std::string level);
124  std::string GetItemLevel(vtkIdType itemID);
126  void SetItemOwnerPluginName(vtkIdType itemID, std::string ownerPluginName);
128  std::string GetItemOwnerPluginName(vtkIdType itemID);
130  void SetItemExpanded(vtkIdType itemID, bool expanded);
132  bool GetItemExpanded(vtkIdType itemID);
133 
135  void SetItemUID(vtkIdType itemID, std::string uidName, std::string uidValue);
138  std::string GetItemUID(vtkIdType itemID, std::string uidName);
139 
141  void SetItemAttribute(vtkIdType itemID, std::string attributeName, std::string attributeValue);
144  bool RemoveItemAttribute(vtkIdType itemID, std::string attributeName);
147  std::string GetItemAttribute(vtkIdType itemID, std::string attributeName);
150  std::vector<std::string> GetItemAttributeNames(vtkIdType itemID);
154  bool HasItemAttribute(vtkIdType itemID, std::string attributeName);
155 
158  void ItemModified(vtkIdType itemID);
159 
162  void RequestOwnerPluginSearch(vtkIdType itemID);
166  void RequestOwnerPluginSearch(vtkMRMLNode* dataNode);
167 
169  static vtkIdType GetInvalidItemID() { return INVALID_ITEM_ID; }
170 
171 // Hierarchy related methods
172 public:
178  vtkIdType CreateItem(vtkIdType parentItemID, vtkMRMLNode* dataNode);
185  vtkIdType CreateHierarchyItem(vtkIdType parentItemID, std::string name, std::string level);
190  vtkIdType CreateSubjectItem(vtkIdType parentItemID, std::string name);
195  vtkIdType CreateStudyItem(vtkIdType parentItemID, std::string name);
200  vtkIdType CreateFolderItem(vtkIdType parentItemID, std::string name);
201 
206  bool RemoveItem(vtkIdType itemID, bool removeDataNode=true, bool recursive=true);
211  bool RemoveItemChildren(vtkIdType itemID, bool removeDataNodes=true, bool recursive=true);
216  void RemoveAllItems(bool removeDataNode=false);
217 
219  void SetItemParent(vtkIdType itemID, vtkIdType parentItemID);
222  vtkIdType GetItemParent(vtkIdType itemID);
225  int GetItemPositionUnderParent(vtkIdType itemID);
228  vtkIdType GetItemByPositionUnderParent(vtkIdType parentItemID, int position);
229 
234  void GetItemChildren(vtkIdType itemID, std::vector<vtkIdType>& childIDs, bool recursive=false);
236  void GetItemChildren(vtkIdType itemID, vtkIdList* childIDs, bool recursive=false);
237 
240  bool ReparentItemByDataNode(vtkIdType itemID, vtkMRMLNode* newParentNode);
244  bool MoveItem(vtkIdType itemID, vtkIdType beforeItemID);
245 
246 // Item finder methods
247 public:
252  vtkIdType GetItemByUID(const char* uidName, const char* uidValue);
253 
259  vtkIdType GetItemByUIDList(const char* uidName, const char* uidValue);
260 
264  vtkIdType GetItemByDataNode(vtkMRMLNode* dataNode);
265 
270  vtkIdType GetItemChildWithName(vtkIdType parentItemID, std::string name);
271 
277  void GetDataNodesInBranch(vtkIdType itemID, vtkCollection* dataNodeCollection, const char* childClass=NULL);
278 
283  vtkMRMLNode* GetParentDataNode(vtkMRMLNode* dataNode, bool recursive=false);
284 
285 // Utility functions
286 public:
288  void SetDisplayVisibilityForBranch(vtkIdType itemID, int visible);
289 
292  int GetDisplayVisibilityForBranch(vtkIdType itemID);
293 
297  bool IsItemLevel(vtkIdType itemID, std::string level);
298 
302  bool IsItemVirtualBranchParent(vtkIdType itemID);
303 
310  std::string GetAttributeFromItemAncestor(vtkIdType itemID, std::string attributeName, std::string level="");
311 
314  vtkIdType GetItemAncestorAtLevel(vtkIdType itemID, std::string level);
315 
318  bool IsAnyNodeInBranchTransformed(vtkIdType itemID, vtkMRMLTransformNode* exceptionNode=NULL);
319 
321  static void DeserializeUIDList(std::string uidListString, std::vector<std::string>& deserializedUIDList);
322 
327  std::vector<vtkIdType> GetItemsReferencedFromItemByDICOM(vtkIdType itemID);
330  void GetItemsReferencedFromItemByDICOM(vtkIdType itemID, vtkIdList* referencingIdList);
331 
336  std::vector<vtkIdType> GetItemsReferencingItemByDICOM(vtkIdType itemID);
339  void GetItemsReferencingItemByDICOM(vtkIdType itemID, vtkIdList* referencingIdList);
340 
342  std::string GenerateUniqueItemName(std::string name);
343 
345  int GetNumberOfItems();
346 
349  int GetNumberOfItemChildren(vtkIdType itemID, bool recursive=false);
350 
352  void PrintItem(vtkIdType itemID, ostream& os, vtkIndent indent);
353 
354 protected:
356  static void ItemEventCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
357 
358 protected:
363 
364  class vtkInternal;
365  vtkInternal* Internal;
366  friend class vtkInternal;
367 
369  vtkSmartPointer<vtkCallbackCommand> ItemEventCallbackCommand;
370 };
371 
372 #endif
static const std::string SUBJECTHIERARCHY_VERSION_ATTRIBUTE_NAME
MRML node for representing a transformation between this node space and a parent node space...
LRU Cache.
Event invoked when item resolving starts (e.g. after scene import)
vtkSmartPointer< vtkCallbackCommand > ItemEventCallbackCommand
Command handling events from subject hierarchy items.
void operator=(const vtkMRMLNode &)
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
MRML node to represent a complete subject hierarchy tree.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
static const std::string SUBJECTHIERARCHY_NAME_VALUE_SEPARATOR
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
static const std::string SUBJECTHIERARCHY_SEPARATOR
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135