Slicer  4.10
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();
112  vtkMRMLNode* GetItemDataNode(vtkIdType itemID);
114  void SetItemName(vtkIdType itemID, std::string name);
117  std::string GetItemName(vtkIdType itemID);
119  void SetItemLevel(vtkIdType itemID, std::string level);
121  std::string GetItemLevel(vtkIdType itemID);
123  void SetItemOwnerPluginName(vtkIdType itemID, std::string ownerPluginName);
125  std::string GetItemOwnerPluginName(vtkIdType itemID);
127  void SetItemExpanded(vtkIdType itemID, bool expanded);
129  bool GetItemExpanded(vtkIdType itemID);
130 
132  void SetItemUID(vtkIdType itemID, std::string uidName, std::string uidValue);
135  std::string GetItemUID(vtkIdType itemID, std::string uidName);
136 
138  void SetItemAttribute(vtkIdType itemID, std::string attributeName, std::string attributeValue);
141  bool RemoveItemAttribute(vtkIdType itemID, std::string attributeName);
144  std::string GetItemAttribute(vtkIdType itemID, std::string attributeName);
147  std::vector<std::string> GetItemAttributeNames(vtkIdType itemID);
151  bool HasItemAttribute(vtkIdType itemID, std::string attributeName);
152 
155  void ItemModified(vtkIdType itemID);
156 
159  void RequestOwnerPluginSearch(vtkIdType itemID);
163  void RequestOwnerPluginSearch(vtkMRMLNode* dataNode);
164 
166  static vtkIdType GetInvalidItemID() { return INVALID_ITEM_ID; }
167 
173  void SetItemDataNode(vtkIdType itemID, vtkMRMLNode* dataNode);
174 
175 // Hierarchy related methods
176 public:
182  vtkIdType CreateItem(vtkIdType parentItemID, vtkMRMLNode* dataNode);
189  vtkIdType CreateHierarchyItem(vtkIdType parentItemID, std::string name, std::string level);
194  vtkIdType CreateSubjectItem(vtkIdType parentItemID, std::string name);
199  vtkIdType CreateStudyItem(vtkIdType parentItemID, std::string name);
204  vtkIdType CreateFolderItem(vtkIdType parentItemID, std::string name);
205 
210  bool RemoveItem(vtkIdType itemID, bool removeDataNode=true, bool recursive=true);
215  bool RemoveItemChildren(vtkIdType itemID, bool removeDataNodes=true, bool recursive=true);
220  void RemoveAllItems(bool removeDataNode=false);
221 
223  void SetItemParent(vtkIdType itemID, vtkIdType parentItemID);
226  vtkIdType GetItemParent(vtkIdType itemID);
229  int GetItemPositionUnderParent(vtkIdType itemID);
232  vtkIdType GetItemByPositionUnderParent(vtkIdType parentItemID, int position);
233 
238  void GetItemChildren(vtkIdType itemID, std::vector<vtkIdType>& childIDs, bool recursive=false);
240  void GetItemChildren(vtkIdType itemID, vtkIdList* childIDs, bool recursive=false);
241 
244  bool ReparentItemByDataNode(vtkIdType itemID, vtkMRMLNode* newParentNode);
248  bool MoveItem(vtkIdType itemID, vtkIdType beforeItemID);
249 
250 // Item finder methods
251 public:
256  vtkIdType GetItemByUID(const char* uidName, const char* uidValue);
257 
263  vtkIdType GetItemByUIDList(const char* uidName, const char* uidValue);
264 
268  vtkIdType GetItemByDataNode(vtkMRMLNode* dataNode);
269 
274  vtkIdType GetItemChildWithName(vtkIdType parentItemID, std::string name);
275 
281  void GetDataNodesInBranch(vtkIdType itemID, vtkCollection* dataNodeCollection, const char* childClass=NULL);
282 
287  vtkMRMLNode* GetParentDataNode(vtkMRMLNode* dataNode, bool recursive=false);
288 
289 // Utility functions
290 public:
292  void SetDisplayVisibilityForBranch(vtkIdType itemID, int visible);
293 
296  int GetDisplayVisibilityForBranch(vtkIdType itemID);
297 
301  bool IsItemLevel(vtkIdType itemID, std::string level);
302 
306  bool IsItemVirtualBranchParent(vtkIdType itemID);
307 
314  std::string GetAttributeFromItemAncestor(vtkIdType itemID, std::string attributeName, std::string level="");
315 
318  vtkIdType GetItemAncestorAtLevel(vtkIdType itemID, std::string level);
319 
322  bool IsAnyNodeInBranchTransformed(vtkIdType itemID, vtkMRMLTransformNode* exceptionNode=NULL);
323 
325  static void DeserializeUIDList(std::string uidListString, std::vector<std::string>& deserializedUIDList);
326 
331  std::vector<vtkIdType> GetItemsReferencedFromItemByDICOM(vtkIdType itemID);
334  void GetItemsReferencedFromItemByDICOM(vtkIdType itemID, vtkIdList* referencingIdList);
335 
340  std::vector<vtkIdType> GetItemsReferencingItemByDICOM(vtkIdType itemID);
343  void GetItemsReferencingItemByDICOM(vtkIdType itemID, vtkIdList* referencingIdList);
344 
346  std::string GenerateUniqueItemName(std::string name);
347 
349  int GetNumberOfItems();
350 
353  int GetNumberOfItemChildren(vtkIdType itemID, bool recursive=false);
354 
356  void PrintItem(vtkIdType itemID, ostream& os, vtkIndent indent);
357 
358 protected:
360  static void ItemEventCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
361 
362 protected:
367 
368  class vtkInternal;
369  vtkInternal* Internal;
370  friend class vtkInternal;
371 
373  vtkSmartPointer<vtkCallbackCommand> ItemEventCallbackCommand;
374 };
375 
376 #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.
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
Event invoked when item resolving starts (e.g. after scene import)
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:138