Skip to content

Commit

Permalink
Armature AlwaysOnTop option
Browse files Browse the repository at this point in the history
This option governs if the bones are seen on top of every object of the
scene. This is set to every bone of the armature when changed.

See Issue#13616
  • Loading branch information
vovythevov committed Nov 13, 2012
1 parent 4c4fba4 commit 1471531
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Expand Up @@ -281,7 +281,7 @@ class Test1KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera

//Axes->SetUserTransform(transform);
//}
if (key == "Control_L")
else if (key == "Control_L")
{
Armature->SetWidgetState( ! Armature->GetWidgetState() );
}
Expand All @@ -294,6 +294,14 @@ class Test1KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
}
Armature->SetShowAxes(state);
}

else if (key == "space")
{
std::cout<<"Changing Always on Top!"<<std::endl;

Armature->SetBonesAlwaysOnTop( ! Armature->GetBonesAlwaysOnTop());
}

}

vtkArmatureWidget* Armature;
Expand Down
28 changes: 28 additions & 0 deletions Libs/VTK/Widgets/vtkArmatureWidget.cxx
Expand Up @@ -179,6 +179,7 @@ vtkArmatureWidget::vtkArmatureWidget()
this->ShowAxes = vtkBoneWidget::Hidden;
this->ShowParenthood = true;
this->ShouldResetPoseToRest = true;
this->BonesAlwaysOnTop = 0;
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -502,6 +503,11 @@ ::SetBoneRepresentation(vtkBoneWidget* bone, int representationType)
break;
}
}

if (bone->GetBoneRepresentation())
{
bone->GetBoneRepresentation()->SetAlwaysOnTop(this->BonesAlwaysOnTop);
}
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -691,6 +697,28 @@ void vtkArmatureWidget::ResetPoseToRest()
}
}

//----------------------------------------------------------------------------
void vtkArmatureWidget::SetBonesAlwaysOnTop(int onTop)
{
if (onTop == this->BonesAlwaysOnTop)
{
return;
}
this->BonesAlwaysOnTop = onTop;

if (this->GetBonesRepresentationType() != vtkArmatureWidget::None)
{
for (NodeIteratorType it = this->Bones->begin();
it != this->Bones->end(); ++it)
{
(*it)->Bone->GetBoneRepresentation()->SetAlwaysOnTop(
this->BonesAlwaysOnTop);
}
}

this->Modified();
}

//----------------------------------------------------------------------------
void vtkArmatureWidget
::SetBoneWorldToParentTransform(vtkBoneWidget* bone, vtkBoneWidget* parent)
Expand Down
10 changes: 9 additions & 1 deletion Libs/VTK/Widgets/vtkArmatureWidget.h
Expand Up @@ -235,14 +235,21 @@ class VTK_BENDER_WIDGETS_EXPORT vtkArmatureWidget : public vtkAbstractWidget
// Description:
// Change the given bone parent to the new parent.
// If the new parent is null, the bone is added to the top level bones.
// Sa AddBone(), RemoveBone, ArmatureEventType
// @sa AddBone(), RemoveBone, ArmatureEventType
void ReparentBone(vtkBoneWidget* bone, vtkBoneWidget* newParent);

// Description:
// Reset the pose positions to the initial rest position with no rotations
// or translations.
void ResetPoseToRest();

// Description:
// Set if the bones are seen on top of every object of the scene.
// This can be set even if the bones do not have any representation.
// @sa vtkBoneRepresentation
void SetBonesAlwaysOnTop(int onTop);
vtkGetMacro(BonesAlwaysOnTop, int);

protected:
vtkArmatureWidget();
~vtkArmatureWidget();
Expand All @@ -267,6 +274,7 @@ class VTK_BENDER_WIDGETS_EXPORT vtkArmatureWidget : public vtkAbstractWidget
int ShowAxes;
int ShowParenthood;
bool ShouldResetPoseToRest;
int BonesAlwaysOnTop;

// Add/Remove all the necessaries observers to a bone
void AddBoneObservers(vtkBoneWidget* bone);
Expand Down

0 comments on commit 1471531

Please sign in to comment.