28#ifndef __vtkMRMLSubjectHierarchyNode_h
29#define __vtkMRMLSubjectHierarchyNode_h
35class vtkCallbackCommand;
154 void SetItemUID(vtkIdType itemID, std::string uidName, std::string uidValue);
160 std::string
GetItemUID(vtkIdType itemID, std::string uidName);
170 void SetItemAttribute(vtkIdType itemID, std::string attributeName, std::string attributeValue);
223 vtkIdType
CreateHierarchyItem(vtkIdType parentItemID, std::string name, std::string level,
int positionUnderParent = -1);
244 bool RemoveItem(vtkIdType itemID,
bool removeDataNode =
true,
bool recursive =
true);
258 void SetItemParent(vtkIdType itemID, vtkIdType parentItemID,
bool enableCircularCheck =
true);
273 void GetItemChildren(vtkIdType itemID, std::vector<vtkIdType>& childIDs,
bool recursive =
false);
283 bool MoveItem(vtkIdType itemID, vtkIdType beforeItemID);
324 void GetItemsByName(std::string name, vtkIdList* foundItemIds,
bool contains =
false);
337 void GetDataNodesInBranch(vtkIdType itemID, vtkCollection* dataNodeCollection,
const char* childClass =
nullptr);
394 static void DeserializeUIDList(std::string uidListString, std::vector<std::string>& deserializedUIDList);
425 void PrintItem(vtkIdType itemID, ostream& os, vtkIndent indent);
435 static void ItemEventCallback(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D,...
Abstract class that contains graphical display properties for displayable nodes.
friend class vtkMRMLScene
void SetItemUID(vtkIdType itemID, std::string uidName, std::string uidValue)
Set UID to the subject hierarchy item.
vtkIdType GetItemByDataNode(vtkMRMLNode *dataNode)
std::vector< std::string > GetItemUIDNames(vtkIdType itemID)
~vtkMRMLSubjectHierarchyNode() override
static const vtkIdType INVALID_ITEM_ID
static vtkMRMLSubjectHierarchyNode * New()
void WriteNodeBodyXML(ostream &of, int indent) override
Write this node's body to a MRML file in XML format.
int GetItemDisplayVisibility(vtkIdType itemID)
Get subject hierarchy item visibility.
bool HasItemAttribute(vtkIdType itemID, std::string attributeName)
bool GetItemExpanded(vtkIdType itemID)
Get expanded flag for a subject hierarchy item.
void SetItemAttribute(vtkIdType itemID, std::string attributeName, std::string attributeValue)
Add attribute to the subject hierarchy item.
vtkIdType GetItemByName(std::string name)
void SetItemLevel(vtkIdType itemID, std::string level)
Convenience function to set level attribute for a subject hierarchy item.
void SetItemParent(vtkIdType itemID, vtkIdType parentItemID, bool enableCircularCheck=true)
void operator=(const vtkMRMLSubjectHierarchyNode &)
std::string GenerateUniqueItemName(std::string name)
Generate unique item name.
@ SubjectHierarchyItemUIDAddedEvent
@ SubjectHierarchyItemModifiedEvent
@ SubjectHierarchyItemsShowInViewRequestedEvent
@ SubjectHierarchyItemReparentedEvent
@ SubjectHierarchyItemRemovedEvent
@ SubjectHierarchyItemOwnerPluginSearchRequested
@ SubjectHierarchyStartResolveEvent
Event invoked when item resolving starts (e.g. after scene import)
@ SubjectHierarchyItemAddedEvent
@ SubjectHierarchyEndResolveEvent
Event invoked when item resolving finished (e.g. after scene import)
@ SubjectHierarchyItemAboutToBeRemovedEvent
@ SubjectHierarchyItemTransformModifiedEvent
@ SubjectHierarchyItemChildrenReorderedEvent
Event invoked when order of child items of an item is modified.
@ SubjectHierarchyItemDisplayModifiedEvent
static const std::string SUBJECTHIERARCHY_NAME_VALUE_SEPARATOR
void PrintItem(vtkIdType itemID, ostream &os, vtkIndent indent)
Print subject hierarchy item info on stream.
void ShowItemsInView(vtkIdList *itemIDs, vtkMRMLAbstractViewNode *viewNode)
Show items in selected view (used for drag&drop of subject hierarchy items into the viewer)
bool RemoveItemUID(vtkIdType itemID, std::string uidName)
std::string GetItemOwnerPluginName(vtkIdType itemID)
Get owner plugin name (role) for a subject hierarchy item.
vtkIdType GetItemChildWithName(vtkIdType parentItemID, std::string name, bool recursive=false)
bool HasItemUID(vtkIdType itemID, std::string uidName)
bool ReparentItemByDataNode(vtkIdType itemID, vtkMRMLNode *newParentNode)
std::string GetItemUID(vtkIdType itemID, std::string uidName)
void SetItemName(vtkIdType itemID, std::string name)
Set name for a subject hierarchy item.
static vtkMRMLSubjectHierarchyNode * ResolveSubjectHierarchy(vtkMRMLScene *scene)
Ensure the consistency and validity of the SH node in the scene.
void SetItemOwnerPluginName(vtkIdType itemID, std::string ownerPluginName)
Set owner plugin name (role) for a subject hierarchy item.
vtkSmartPointer< vtkCallbackCommand > ItemEventCallbackCommand
Command handling events from subject hierarchy items.
int GetNumberOfItems()
Get number of items under the scene, excluding the scene.
void GetItemChildren(vtkIdType itemID, vtkIdList *childIDs, bool recursive=false)
Python accessibility function to get children of a subject hierarchy item.
std::string GetAttributeFromItemAncestor(vtkIdType itemID, std::string attributeName, std::string level="")
void GetItemChildren(vtkIdType itemID, std::vector< vtkIdType > &childIDs, bool recursive=false)
vtkIdType GetSceneItemID()
Get ID of root subject hierarchy item (which can be interpreted as the scene in terms of hierarchy)
void ItemModified(vtkIdType itemID)
void RemoveAllItems(bool removeDataNode=false)
bool IsAnyNodeInBranchTransformed(vtkIdType itemID, bool includeParentItem=true, vtkMRMLTransformNode *exceptionNode=nullptr)
bool ReorderItemChildren(vtkIdType parentItemID, vtkIdList *childIDs)
static vtkMRMLSubjectHierarchyNode * GetSubjectHierarchyNode(vtkMRMLScene *scene)
static void DeserializeUIDList(std::string uidListString, std::vector< std::string > &deserializedUIDList)
Deserialize a UID list string (stored in the UID map) into a vector of UID strings.
vtkIdType GetItemByUID(const char *uidName, const char *uidValue)
vtkMRMLSubjectHierarchyNode(const vtkMRMLSubjectHierarchyNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
bool RemoveItem(vtkIdType itemID, bool removeDataNode=true, bool recursive=true)
vtkIdType CreateFolderItem(vtkIdType parentItemID, std::string name)
vtkMRMLNode * GetParentDataNode(vtkMRMLNode *dataNode, bool recursive=false)
vtkMRMLNode * GetItemDataNode(vtkIdType itemID)
Get data node for a subject hierarchy item.
vtkIdType GetItemByPositionUnderParent(vtkIdType parentItemID, int position)
void GetItemsByName(std::string name, vtkIdList *foundItemIds, bool contains=false)
int GetItemPositionUnderParent(vtkIdType itemID)
bool RemoveItemChildren(vtkIdType itemID, bool removeDataNodes=true, bool recursive=true)
void Copy(vtkMRMLNode *node) override
Copy the node's attributes to this object.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void RequestOwnerPluginSearch(vtkMRMLNode *dataNode)
bool MoveItem(vtkIdType itemID, vtkIdType beforeItemID)
std::string GetItemAttribute(vtkIdType itemID, std::string attributeName)
vtkIdType GetItemByUIDList(const char *uidName, const char *uidValue)
void SetItemDataNode(vtkIdType itemID, vtkMRMLNode *dataNode)
vtkMRMLSubjectHierarchyNode()
std::string GetItemLevel(vtkIdType itemID)
Convenience function to get level attribute for a subject hierarchy item.
static void ItemEventCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
Callback function for all events from the subject hierarchy items.
std::vector< vtkIdType > GetItemsReferencedFromItemByDICOM(vtkIdType itemID)
vtkIdType GetItemAncestorAtLevel(vtkIdType itemID, std::string level)
static const std::string SUBJECTHIERARCHY_SEPARATOR
vtkIdType CreateItem(vtkIdType parentItemID, vtkMRMLNode *dataNode, const char *ownerPluginName=nullptr)
void GetItemsReferencingItemByDICOM(vtkIdType itemID, vtkIdList *referencingIdList)
static const std::string SUBJECTHIERARCHY_VERSION_ATTRIBUTE_NAME
void GetItemsReferencedFromItemByDICOM(vtkIdType itemID, vtkIdList *referencingIdList)
void GetDataNodesInBranch(vtkIdType itemID, vtkCollection *dataNodeCollection, const char *childClass=nullptr)
vtkIdType CreateStudyItem(vtkIdType parentItemID, std::string name)
bool RemoveItemAttribute(vtkIdType itemID, std::string attributeName)
std::vector< std::string > GetItemAttributeNames(vtkIdType itemID)
vtkMRMLNode * CreateNodeInstance() override
Create instance of the default node. Like New only virtual.
bool IsItemLevel(vtkIdType itemID, std::string level)
bool IsItemVirtualBranchParent(vtkIdType itemID)
vtkIdType CreateSubjectItem(vtkIdType parentItemID, std::string name)
static vtkIdType GetInvalidItemID()
Python accessor for the invalid ID.
std::vector< vtkIdType > GetItemsReferencingItemByDICOM(vtkIdType itemID)
vtkIdType GetItemParent(vtkIdType itemID)
virtual void ReadItemFromXML(const char **atts)
Read item from XML.
vtkIdType CreateHierarchyItem(vtkIdType parentItemID, std::string name, std::string level, int positionUnderParent=-1)
void SetItemDisplayVisibility(vtkIdType itemID, int visible)
int GetDisplayVisibilityForBranch(vtkIdType itemID)
void SetDisplayVisibilityForBranch(vtkIdType itemID, int visible)
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Contour)
int GetNumberOfItemChildren(vtkIdType itemID, bool recursive=false)
void RequestOwnerPluginSearch(vtkIdType itemID)
std::string GetItemName(vtkIdType itemID)
vtkMRMLDisplayNode * GetDisplayNodeForItem(vtkIdType itemID)
void SetItemExpanded(vtkIdType itemID, bool expanded)
Set expanded flag for a subject hierarchy item (only for internal use, do not set explicitly)
vtkMRMLAbstractViewNode * viewNode
vtkIdList * itemIDsToShow