Commit abcffae1 authored by finetjul's avatar finetjul
Browse files

ENH: Add support for parent/child annotations

Some annotations (e.g. bones) can have direct parent/child relationship
in the tree view.
It shouldn't impact the existing annotations.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21540 3bd1e089-480b-0410-8dfb-8563597acbee
parent 5278dcef
......@@ -227,6 +227,14 @@ QFlags<Qt::ItemFlag> qMRMLSceneAnnotationModel::nodeFlags(vtkMRMLNode* node, int
return flags;
}
//------------------------------------------------------------------------------
bool qMRMLSceneAnnotationModel::canBeAParent(vtkMRMLNode* node)const
{
bool res = this->Superclass::canBeAParent(node) ||
(node && node->IsA("vtkMRMLAnnotationNode"));
return res;
}
//------------------------------------------------------------------------------
vtkMRMLNode* qMRMLSceneAnnotationModel::parentNode(vtkMRMLNode* node)const
{
......@@ -243,7 +251,8 @@ vtkMRMLNode* qMRMLSceneAnnotationModel::parentNode(vtkMRMLNode* node)const
displayableNode->GetID())
{
// get the displayable hierarchy node associated with this displayable node
displayableHierarchyNode = vtkMRMLDisplayableHierarchyNode::GetDisplayableHierarchyNode(displayableNode->GetScene(), displayableNode->GetID());
displayableHierarchyNode = vtkMRMLDisplayableHierarchyNode::GetDisplayableHierarchyNode(
displayableNode->GetScene(), displayableNode->GetID());
if (displayableHierarchyNode)
{
......@@ -252,7 +261,15 @@ vtkMRMLNode* qMRMLSceneAnnotationModel::parentNode(vtkMRMLNode* node)const
// this is a hidden hierarchy node, so we do not want to display it
// instead, we will return the parent of the hidden hierarchy node
// to be used as the parent for the displayableNode
return displayableHierarchyNode->GetParentNode();
vtkMRMLDisplayableHierarchyNode* parent =
vtkMRMLDisplayableHierarchyNode::SafeDownCast(
displayableHierarchyNode->GetParentNode());
if (parent && parent->GetHideFromEditors() &&
parent->GetDisplayableNode())
{
return parent->GetDisplayableNode();
}
return parent;
}
return displayableHierarchyNode;
}
......
......@@ -59,6 +59,7 @@ public:
};
virtual vtkMRMLNode* parentNode(vtkMRMLNode* node)const;
virtual bool canBeAParent(vtkMRMLNode* node)const;
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment