Skip to content

Commit

Permalink
Reduce Bone XML properties
Browse files Browse the repository at this point in the history
There were a few properties that were not used to read the scene for the
bone node. It is better to keep it to only the necessary.
The mrml scene loading is always performed in rest mode.

Also renaming WidgetInteractionColor to simply InteractionColor.

See Issue #13668
  • Loading branch information
vovythevov committed Dec 13, 2012
1 parent f0fa84f commit 65b25fc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 88 deletions.
8 changes: 1 addition & 7 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLArmatureNode.cxx
Expand Up @@ -127,8 +127,6 @@ void vtkMRMLArmatureNode::WriteXML(ostream& of, int nIndent)
vtkIndent indent(nIndent);
of << indent << " BonesRepresentationType=\""
<< this->BonesRepresentationType << "\"";
of << indent << " WidgetState=\""
<< this->ArmatureProperties->GetWidgetState() << "\"";
of << indent << " ShowAxes=\""
<< this->ArmatureProperties->GetShowAxes() << "\"";
of << indent << " ShowParenthood=\""
Expand All @@ -151,6 +149,7 @@ void vtkMRMLArmatureNode::ReadXMLAttributes(const char** atts)

this->Superclass::ReadXMLAttributes(atts);

this->SetWidgetState(vtkMRMLArmatureNode::Rest);
while (*atts != NULL)
{
const char* attName = *(atts++);
Expand All @@ -161,11 +160,6 @@ void vtkMRMLArmatureNode::ReadXMLAttributes(const char** atts)
this->SetBonesRepresentationType(
vtkMRMLNodeHelper::StringToInt(attValue));
}
else if (!strcmp(attName, "WidgetState"))
{
this->SetWidgetState(
vtkMRMLNodeHelper::StringToInt(attValue));
}
else if (!strcmp(attName, "ShowAxes"))
{
this->SetShowAxes(
Expand Down
16 changes: 8 additions & 8 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneDisplayNode.cxx
Expand Up @@ -52,10 +52,10 @@ void vtkMRMLBoneDisplayNode::WriteXML(ostream& of, int nIndent)
this->Superclass::WriteXML(of, nIndent);

vtkIndent indent(nIndent);
of << indent << " WidgetInteractionColor=\""
<< this->WidgetInteractionColor[0] << " "
<< this->WidgetInteractionColor[1] << " "
<< this->WidgetInteractionColor[2] << " " << "\"";
of << indent << " InteractionColor=\""
<< this->InteractionColor[0] << " "
<< this->InteractionColor[1] << " "
<< this->InteractionColor[2] << " " << "\"";
}

//----------------------------------------------------------------------------
Expand All @@ -70,11 +70,11 @@ void vtkMRMLBoneDisplayNode::ReadXMLAttributes(const char** atts)
const char* attName = *(atts++);
std::string attValue(*(atts++));

if (!strcmp(attName, "WidgetInteractionColor"))
if (!strcmp(attName, "InteractionColor"))
{
double rgb[3];
vtkMRMLNodeHelper::StringToVector3(attValue, rgb);
this->SetWidgetInteractionColor(rgb);
this->SetInteractionColor(rgb);
}
}
this->EndModify(disabledModify);
Expand Down Expand Up @@ -119,7 +119,7 @@ void vtkMRMLBoneDisplayNode::SetColor(double r, double g, double b)

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

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -166,7 +166,7 @@ ::PasteBoneDisplayNodeProperties(vtkBoneWidget* boneWidget)
this->GetColor(color);
}
double interactionColor[3];
this->GetWidgetInteractionColor(interactionColor);
this->GetInteractionColor(interactionColor);

vtkCylinderBoneRepresentation* cylinderRep =
vtkCylinderBoneRepresentation::SafeDownCast(
Expand Down
6 changes: 3 additions & 3 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneDisplayNode.h
Expand Up @@ -75,8 +75,8 @@ class VTK_BENDER_ARMATURES_MRML_CORE_EXPORT vtkMRMLBoneDisplayNode
virtual void SetColor(double r, double g, double b);

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

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

double WidgetInteractionColor[3];
double InteractionColor[3];

vtkMRMLBoneDisplayNode(const vtkMRMLBoneDisplayNode&); /// not implemented
void operator=(const vtkMRMLBoneDisplayNode&); /// not implemented
Expand Down
72 changes: 2 additions & 70 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneNode.cxx
Expand Up @@ -95,16 +95,9 @@ void vtkMRMLBoneNode::WriteXML(ostream& of, int nIndent)
this->Superclass::WriteXML(of, nIndent);

vtkIndent indent(nIndent);
of << indent << " Length=\"" << this->BoneProperties->GetLength() << "\"";
of << indent << " Name=\"" << this->BoneProperties->GetName() << "\"";
of << indent << " State=\""
<< this->BoneProperties->GetWidgetState() << "\"";
of << indent << " Roll=\"" << this->BoneProperties->GetRoll() << "\"";

of << indent << " RepresentationType=\""
<< this->BoneRepresentationType << "\"";
of << indent << " RepresentationName=\""
<< this->BoneProperties->GetBoneRepresentation()->GetClassName() << "\"";
of << indent << " ShowAxes=\""
<< this->BoneProperties->GetShowAxes() << "\"";
of << indent << " ShowParenthood=\""
Expand All @@ -122,52 +115,6 @@ void vtkMRMLBoneNode::WriteXML(ostream& of, int nIndent)
of << indent << " WorldToParentRestTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldToParentRestTranslation());
of << indent << " ParentToBonetRestRotation=";
vtkMRMLNodeHelper::PrintQuotedVector(of,
this->BoneProperties->GetParentToBoneRestRotation().GetData(), 4);
of << indent << " ParentToBoneRestTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetParentToBoneRestTranslation());
of << indent << " WorldToBoneRestRotation=";
vtkMRMLNodeHelper::PrintQuotedVector(of,
this->BoneProperties->GetWorldToBoneRestRotation().GetData(), 4);
of << indent << " WorldToBoneHeadRestTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldToBoneHeadRestTranslation());
of << indent << " WorldToBoneTailRestTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldToBoneTailRestTranslation());

of << indent << " WorldHeadPose=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldHeadPose());
of << indent << " WorldTailPose=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldTailPose());
of << indent << " WorldToParentPoseRotation=";
vtkMRMLNodeHelper::PrintQuotedVector(of,
this->BoneProperties->GetWorldToParentPoseRotation().GetData(), 4);
of << indent << " WorldToParentPoseTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldToParentPoseTranslation());
of << indent << " ParentToBonetPoseRotation=";
vtkMRMLNodeHelper::PrintQuotedVector(of,
this->BoneProperties->GetParentToBonePoseRotation().GetData(), 4);
of << indent << " ParentToBonePoseTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetParentToBonePoseTranslation());
of << indent << " WorldToBonePoseRotation=";
vtkMRMLNodeHelper::PrintQuotedVector(of,
this->BoneProperties->GetWorldToBonePoseRotation().GetData(), 4);
of << indent << " WorldToBoneHeadPoseTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldToBoneHeadPoseTranslation());
of << indent << " WorldToBoneTailPoseTranslation=";
vtkMRMLNodeHelper::PrintQuotedVector3(of,
this->BoneProperties->GetWorldToBoneTailPoseTranslation());
of << indent << " RestToPoseRotation=";
vtkMRMLNodeHelper::PrintQuotedVector(of,
this->BoneProperties->GetRestToPoseRotation().GetData(), 4);

of << indent << " BoneLinkedWithParent=\""
<< this->GetBoneLinkedWithParent() << "\"";
Expand Down Expand Up @@ -197,16 +144,13 @@ void vtkMRMLBoneNode::ReadXMLAttributes(const char** atts)

this->Superclass::ReadXMLAttributes(atts);

this->SetWidgetState(vtkBoneWidget::Rest);
while (*atts != NULL)
{
const char* attName = *(atts++);
std::string attValue(*(atts++));

if (!strcmp(attName, "Name"))
{
this->SetName(attValue.c_str());
}
else if (!strcmp(attName, "State"))
if (!strcmp(attName, "State"))
{
this->BoneProperties->SetWidgetState(
vtkMRMLNodeHelper::StringToInt(attValue));
Expand Down Expand Up @@ -255,18 +199,6 @@ void vtkMRMLBoneNode::ReadXMLAttributes(const char** atts)
vtkMRMLNodeHelper::StringToVector3(attValue, translation);
this->BoneProperties->SetWorldToParentRestTranslation(translation);
}
else if (!strcmp(attName, "WorldToParentPoseRotation"))
{
double rotation[4];
vtkMRMLNodeHelper::StringToVector(attValue, rotation, 4);
this->BoneProperties->SetWorldToParentPoseRotation(rotation);
}
else if (!strcmp(attName, "WorldToParentPoseTranslation"))
{
double translation[3];
vtkMRMLNodeHelper::StringToVector3(attValue, translation);
this->BoneProperties->SetWorldToParentPoseTranslation(translation);
}
else if (!strcmp(attName, "BoneLinkedWithParent"))
{
this->SetBoneLinkedWithParent(
Expand Down

0 comments on commit 65b25fc

Please sign in to comment.