Skip to content

Commit

Permalink
Automatic selected and interaction color
Browse files Browse the repository at this point in the history
The selected color and the interaction color are automatically defined from
the normal color.

See Issue #13693
  • Loading branch information
vovythevov committed Nov 17, 2012
1 parent 21f0acd commit 13ba716
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneDisplayNode.cxx
Expand Up @@ -94,6 +94,28 @@ void vtkMRMLBoneDisplayNode::ProcessMRMLEvents(vtkObject* caller,
this->Superclass::ProcessMRMLEvents(caller, event, callData);
}

//---------------------------------------------------------------------------
void vtkMRMLBoneDisplayNode::SetColor(double color[3])
{
this->SetColor(color[0], color[1], color[2]);
}

//---------------------------------------------------------------------------
void vtkMRMLBoneDisplayNode::SetColor(double r, double g, double b)
{
this->Superclass::SetColor(r, g, b);

double h, s, v;
vtkMath::RGBToHSV(r, g, b, &h, &s, &v);
v *= 1.5; // enlight
vtkMath::HSVToRGB(h, s, v, &r, &g, &b);
this->SetSelectedColor(r, g, b);

v *= 1.2; // enlight
vtkMath::HSVToRGB(h, s, v, &r, &g, &b);
this->SetWidgetInteractionColor(r, g, b);
}

//----------------------------------------------------------------------------
void vtkMRMLBoneDisplayNode::PrintSelf(ostream& os, vtkIndent indent)
{
Expand Down Expand Up @@ -137,26 +159,28 @@ ::PasteBoneDisplayNodeProperties(vtkBoneWidget* boneWidget)
{
this->GetColor(color);
}
double interactionColor[3];
this->GetWidgetInteractionColor(interactionColor);

vtkCylinderBoneRepresentation* cylinderRep =
vtkCylinderBoneRepresentation::SafeDownCast(
boneWidget->GetBoneRepresentation());
if (cylinderRep)
{
cylinderRep->GetCylinderProperty()->SetColor(color);
cylinderRep->GetSelectedCylinderProperty()->SetColor(color);
cylinderRep->GetSelectedCylinderProperty()->SetColor(interactionColor);
}
vtkDoubleConeBoneRepresentation* doubleConeRep =
vtkDoubleConeBoneRepresentation::SafeDownCast(
boneWidget->GetBoneRepresentation());
if (doubleConeRep)
{
doubleConeRep->GetConesProperty()->SetColor(color);
doubleConeRep->GetSelectedConesProperty()->SetColor(color);
doubleConeRep->GetSelectedConesProperty()->SetColor(interactionColor);
}
boneWidget->GetBoneRepresentation()->GetLineProperty()->SetColor(color);
boneWidget->GetBoneRepresentation()->GetSelectedLineProperty()
->SetColor(color);
->SetColor(interactionColor);

// -- Opacity --
boneWidget->GetBoneRepresentation()->SetOpacity(this->GetOpacity());
Expand Down
11 changes: 11 additions & 0 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneDisplayNode.h
Expand Up @@ -69,6 +69,15 @@ class VTK_BENDER_ARMATURES_MRML_CORE_EXPORT vtkMRMLBoneDisplayNode
unsigned long event,
void* callData);

/// Reimplement the SetColor so the new color automatically defines
/// the selected color and the widget interaction color.
virtual void SetColor(double color[3]);
virtual void SetColor(double r, double g, double b);

/// Set/Get the color of the widget when interacting.
vtkSetVector3Macro(WidgetInteractionColor, double);
vtkGetVector3Macro(WidgetInteractionColor, double);

//--------------------------------------------------------------------------
// Bone methods
//--------------------------------------------------------------------------
Expand All @@ -85,6 +94,8 @@ class VTK_BENDER_ARMATURES_MRML_CORE_EXPORT vtkMRMLBoneDisplayNode
vtkMRMLBoneDisplayNode();
~vtkMRMLBoneDisplayNode();

double WidgetInteractionColor[3];

vtkMRMLBoneDisplayNode(const vtkMRMLBoneDisplayNode&); /// not implemented
void operator=(const vtkMRMLBoneDisplayNode&); /// not implemented
};
Expand Down

0 comments on commit 13ba716

Please sign in to comment.