X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolRigidReg.cxx;h=28591ba05ed1b6c6cc8af79af440ef5eaea6eb37;hb=22de7e66d9b3cee9c6bde1e674bdde0532bc21a2;hp=78e0d6625dd0640404044d247fa292b1eaa8a2cf;hpb=c2e0628b1d9f0940ac192ff3683c3ede5d01ceb3;p=clitk.git diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index 78e0d66..28591ba 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -108,9 +108,9 @@ void vvToolRigidReg::InputIsSelected(vvSlicerManager *input) imageorigin=mInput->GetImage()->GetOrigin(); std::vector imageSize = mInput->GetImage()->GetSize(); std::vector imageSpacing = mInput->GetImage()->GetSpacing(); - xcord=xcord.setNum(imageorigin[0]+imageSize[0]*imageSpacing[0]/2, 'g', 3); - ycord=ycord.setNum(imageorigin[1]+imageSize[1]*imageSpacing[1]/2, 'g', 3); - zcord=zcord.setNum(imageorigin[2]+imageSize[2]*imageSpacing[2]/2, 'g', 3); + xcord=xcord.setNum(imageorigin[0]+(imageSize[0]-1)*imageSpacing[0]*0.5, 'g', 3); + ycord=ycord.setNum(imageorigin[1]+(imageSize[1]-1)*imageSpacing[1]*0.5, 'g', 3); + zcord=zcord.setNum(imageorigin[2]+(imageSize[2]-1)*imageSpacing[2]*0.5, 'g', 3); Xval->setText(xcord); Yval->setText(ycord); Zval->setText(zcord); @@ -370,25 +370,34 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) euler->SetMatrix(rotMat); euler->SetOffset(transVec); - // Modify GUI according to the new parameters std::vector transSliders, rotSliders; 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]->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); + } } } //------------------------------------------------------------------------------