Skip to content

Commit

Permalink
Use vtkMRMLBoneNode GetLength instead of recomputed it ourselves.
Browse files Browse the repository at this point in the history
In the meantime, changing the name from distance to length which
 makes more sense.

See Issue #13636
  • Loading branch information
vovythevov committed Nov 2, 2012
1 parent 83eda95 commit ed1460c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
8 changes: 8 additions & 0 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneNode.cxx
Expand Up @@ -184,6 +184,14 @@ void vtkMRMLBoneNode::CreateBoneDisplayNode()
this->AddAndObserveDisplayNodeID(boneDisplayNode->GetID());
}

//-- Length -----------------------------------------------------------------
//---------------------------------------------------------------------------
double vtkMRMLBoneNode::GetLength()
{
std::cout<<"this->BoneProperties->GetLength() "<<this->BoneProperties->GetLength()<<std::endl;
return this->BoneProperties->GetLength();
}

//-- Name -------------------------------------------------------------------
//---------------------------------------------------------------------------
void vtkMRMLBoneNode::SetBoneName(vtkStdString name)
Expand Down
4 changes: 4 additions & 0 deletions Modules/Loadable/Armatures/MRML/Core/vtkMRMLBoneNode.h
Expand Up @@ -99,6 +99,10 @@ class VTK_BENDER_ARMATURES_MRML_CORE_EXPORT vtkMRMLBoneNode
/// \sa CreateDefaultStorageNode()
void CreateBoneDisplayNode();

// -- Length ----------------------------------------------------------------
/// Get the bone length.
double GetLength();

// -- Name ----------------------------------------------------------------
/// Set/Get the bone roll.
void SetBoneName(vtkStdString name);
Expand Down
Expand Up @@ -208,7 +208,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="DirectionLabel">
<widget class="QLabel" name="LengthLabel">
<property name="text">
<string>Direction:</string>
</property>
Expand All @@ -227,12 +227,12 @@
<item row="2" column="0">
<widget class="QLabel" name="DistanceDisplayLabel">
<property name="text">
<string>Distance:</string>
<string>Length:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="DistanceSpinBox">
<widget class="QDoubleSpinBox" name="LengthSpinBox">
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
Expand Down
27 changes: 8 additions & 19 deletions Modules/Loadable/Armatures/qSlicerArmaturesModuleWidget.cxx
Expand Up @@ -119,7 +119,7 @@ ::setupUi(qSlicerWidget* armatureModuleWidget)
QObject::connect(this->BonePositionTypeComboBox,
SIGNAL(currentIndexChanged(QString)),
this, SLOT(onPositionTypeChanged()));
QObject::connect(this->DistanceSpinBox,
QObject::connect(this->LengthSpinBox,
SIGNAL(valueChanged(double)),
this, SLOT(onDistanceChanged(double)));
QObject::connect(this->DirectionCoordinatesWidget,
Expand Down Expand Up @@ -149,20 +149,6 @@ void qSlicerArmaturesModuleWidgetPrivate::onPositionTypeChanged()
this->setCoordinatesFromBoneNode(this->BoneNode);
}

//-----------------------------------------------------------------------------
double qSlicerArmaturesModuleWidgetPrivate::distance()
{
QVector3D head(this->HeadCoordinatesWidget->coordinates()[0],
this->HeadCoordinatesWidget->coordinates()[1],
this->HeadCoordinatesWidget->coordinates()[2]);

QVector3D tail(this->TailCoordinatesWidget->coordinates()[0],
this->TailCoordinatesWidget->coordinates()[1],
this->TailCoordinatesWidget->coordinates()[2]);

return QVector3D(tail - head).length();
}

//-----------------------------------------------------------------------------
void qSlicerArmaturesModuleWidgetPrivate::onDistanceChanged(double newDistance)
{
Expand Down Expand Up @@ -197,7 +183,7 @@ void qSlicerArmaturesModuleWidgetPrivate::blockPositionsSignals(bool block)
{
this->HeadCoordinatesWidget->blockSignals(block);
this->TailCoordinatesWidget->blockSignals(block);
this->DistanceSpinBox->blockSignals(block);
this->LengthSpinBox->blockSignals(block);
this->DirectionCoordinatesWidget->blockSignals(block);
}

Expand All @@ -219,7 +205,7 @@ ::onDirectionChanged(double* newDirection)
this->HeadCoordinatesWidget->coordinates()[2]);
QVector3D direction(newDirection[0], newDirection[1], newDirection[2]);

QVector3D newTail = head + direction * this->DistanceSpinBox->value();
QVector3D newTail = head + direction * this->LengthSpinBox->value();

this->TailCoordinatesWidget->setCoordinates(
newTail.x(), newTail.y(), newTail.z());
Expand Down Expand Up @@ -251,7 +237,6 @@ ::updatePositions(vtkMRMLBoneNode* boneNode)
bool enableTailWidget = false;

this->setCoordinatesFromBoneNode(boneNode);
this->DistanceSpinBox->setValue(this->distance());

QVector3D direction(this->direction());
this->DirectionCoordinatesWidget->setCoordinates(
Expand All @@ -271,10 +256,14 @@ ::updatePositions(vtkMRMLBoneNode* boneNode)
enableTailWidget = true;
}
}
else
{
this->LengthSpinBox->setValue(0.0);
}

this->HeadCoordinatesWidget->setEnabled(enableHeadWidget);
this->TailCoordinatesWidget->setEnabled(enableTailWidget);
this->DistanceSpinBox->setEnabled(enableTailWidget);
this->LengthSpinBox->setEnabled(enableTailWidget);
this->DirectionCoordinatesWidget->setEnabled(enableTailWidget);

this->updateAdvancedPositions(boneNode);
Expand Down
Expand Up @@ -52,7 +52,6 @@ class qSlicerArmaturesModuleWidgetPrivate
vtkSlicerArmaturesLogic* logic() const;
virtual void setupUi(qSlicerWidget* armatureModuleWidget);

double distance();
QVector3D direction();

void blockPositionsSignals(bool block);
Expand Down

0 comments on commit ed1460c

Please sign in to comment.