Skip to content

Commit

Permalink
Prevent bone parent selection on head
Browse files Browse the repository at this point in the history
Previously, with linked bones, the active bone would jumpt to the bone
parent when clicking on the bone's head. This wasn't very natural.
To prevent this, the application check when clicking on a bone's tail
that none of its direct children is selected. If one is, then the call
to the event that would transfer the selection is skipped.

See Issue #13710
  • Loading branch information
vovythevov committed Dec 7, 2012
1 parent 45aae8a commit 7f45eaa
Showing 1 changed file with 35 additions and 2 deletions.
Expand Up @@ -712,8 +712,41 @@ ::UpdateBoneNodeFromWidget(vtkMRMLBoneNode* boneNode,
vtkMRMLArmatureNode* armatureNode = this->GetArmatureNode(boneNode);
if (armatureNode && boneNode->GetSelected())
{
armatureNode->InvokeEvent(
vtkMRMLArmatureNode::ArmatureBoneModified, boneNode->GetID());
bool shouldSelectBone = true;
if (boneNode->GetSelected() == vtkBoneWidget::TailSelected)
{
vtkMRMLAnnotationHierarchyNode* hierarchyNode
= vtkMRMLAnnotationHierarchyNode::SafeDownCast(
vtkMRMLHierarchyNode::GetAssociatedHierarchyNode(
boneNode->GetScene(), boneNode->GetID()));
if (hierarchyNode)
{
std::vector<vtkMRMLHierarchyNode*> children =
hierarchyNode->GetChildrenNodes();
for (std::vector<vtkMRMLHierarchyNode*>::iterator it =
children.begin(); it != children.end(); ++it)
{
vtkMRMLBoneNode* boneChild =
vtkMRMLBoneNode::SafeDownCast((*it)->GetAssociatedNode());
if (boneChild && boneChild->GetBoneLinkedWithParent())
{
vtkMRMLBoneDisplayNode* boneDisplayNode =
boneChild->GetBoneDisplayNode();
if (boneDisplayNode && boneDisplayNode->GetSelected())
{
shouldSelectBone = false;
break;
}
}
}
}
}

if (shouldSelectBone)
{
armatureNode->InvokeEvent(
vtkMRMLArmatureNode::ArmatureBoneModified, boneNode->GetID());
}
}
}

Expand Down

0 comments on commit 7f45eaa

Please sign in to comment.