X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolRigidReg.cxx;h=57d7bcb085329ba1d4d004fd8c5887824be80fe4;hb=83fa36c0b759b05d38f23acae0e0f72af0faf524;hp=1a2d1c7679a71c3bee66a7ad249b692cd59e4717;hpb=f08c6ee2ae829766aa8871f76feab9bca7d8afd1;p=clitk.git diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index 1a2d1c7..57d7bcb 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -230,13 +230,13 @@ void vvToolRigidReg::SpinBoxChange(double newVal) for(int i=0; i<3; i++) { if(transSBs[i] == QObject::sender()) { transSliders[i]->blockSignals(true); - transSliders[i]->setValue(itk::Math::Round(newVal)); + transSliders[i]->setValue(itk::Math::Round(newVal)); transSliders[i]->blockSignals(false); } if(rotSBs[i] == QObject::sender()) { double rad = (checkBoxDegrees->checkState()==Qt::Unchecked)?180./itk::Math::pi:1.; rotSliders[i]->blockSignals(true); - rotSliders[i]->setValue(itk::Math::Round(newVal*rad)); + rotSliders[i]->setValue(itk::Math::Round(newVal*rad)); rotSliders[i]->blockSignals(false); } } @@ -376,19 +376,29 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) std::vector transSBs, rotSBs; GetSlidersAndSpinBoxes(transSliders, rotSliders, transSBs, rotSBs); for(int i=0; i<3; i++) { + // Translations transSBs[i]->blockSignals(true); transSBs[i]->setValue( euler->GetParameters()[i+3] ); transSBs[i]->blockSignals(false); transSliders[i]->blockSignals(true); - transSliders[i]->setValue( itk::Math::Round(euler->GetParameters()[i+3]) ); + transSliders[i]->setValue( itk::Math::Round(euler->GetParameters()[i+3]) ); transSliders[i]->blockSignals(false); + + // Rotations double rad = (checkBoxDegrees->checkState()==Qt::Checked)?180./itk::Math::pi:1.; - rotSBs[i]->blockSignals(true); - rotSBs[i]->setValue( euler->GetParameters()[i]*rad ); - rotSBs[i]->blockSignals(false); - rotSliders[i]->blockSignals(true); - rotSliders[i]->setValue( itk::Math::Round(euler->GetParameters()[i]*180./itk::Math::pi) ); - rotSliders[i]->blockSignals(false); + double angleDiff = euler->GetParameters()[i]-rotSBs[i]->value()/rad+2*itk::Math::pi; + angleDiff = angleDiff - 2*itk::Math::pi*itk::Math::Round(angleDiff/(2*itk::Math::pi)); + if(angleDiff>1.e-4) { + rotSBs[i]->blockSignals(true); + rotSBs[i]->setValue( euler->GetParameters()[i]*rad ); + rotSBs[i]->blockSignals(false); + } + int iAngle = itk::Math::Round(euler->GetParameters()[i]*180./itk::Math::pi); + if((iAngle-rotSliders[i]->value()+360)%360!=0) { + rotSliders[i]->blockSignals(true); + rotSliders[i]->setValue(iAngle); + rotSliders[i]->blockSignals(false); + } } } //------------------------------------------------------------------------------