+ vtkSmartPointer<vtkTransform> transform=vtkSmartPointer<vtkTransform>::New();
+ // TODO SR and BP: check on the list of transforms and not the first only
+ mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(matrix);
+ transform->Update();
+ Render();
+ dynamic_cast<vvMainWindow*>(mMainWindow)->ImageInfoChanged();
+
+ // Compute parameters from transfer using itk Euler transform
+ itk::Euler3DTransform<double>::CenterType center;
+ center[0] = Xval->text().toDouble();
+ center[1] = Yval->text().toDouble();
+ center[2] = Zval->text().toDouble();
+ itk::Euler3DTransform<double>::MatrixType rotMat;
+ itk::Euler3DTransform<double>::OutputVectorType transVec;
+ for(int i=0; i<3; i++) {
+ transVec[i] = matrix->GetElement(i,3);
+ for(int j=0; j<3; j++)
+ rotMat[i][j] = matrix->GetElement(i,j);
+ }
+ itk::Euler3DTransform<double>::Pointer euler;
+ euler = itk::Euler3DTransform<double>::New();
+ euler->SetCenter(center);
+ try {
+ euler->SetMatrix(rotMat);
+ } catch (itk::ExceptionObject) {
+ QString warning = "The matrice is a non-orthogonal rotation matrix.\nThe manual registration doesn't work.";
+ QMessageBox msgBox(QMessageBox::Warning, tr("Reset transform"),warning, 0, this);
+ msgBox.addButton(tr("OK"), QMessageBox::AcceptRole);
+ if (msgBox.exec() == QMessageBox::AcceptRole) {
+ //SetTransform(mInitialMatrix);
+ vvToolWidgetBase::close();
+ }
+ }
+ euler->SetOffset(transVec);
+
+ // Modify GUI according to the new parameters
+ std::vector<QSlider *> transSliders, rotSliders;
+ std::vector<QDoubleSpinBox *> 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<double,double>(euler->GetParameters()[i+3]) );
+ transSliders[i]->blockSignals(false);
+
+ // Rotations
+ double rad = (checkBoxDegrees->checkState()==Qt::Checked)?180./itk::Math::pi:1.;
+ double angleDiff = euler->GetParameters()[i]-rotSBs[i]->value()/rad+2*itk::Math::pi;
+ angleDiff = angleDiff - 2*itk::Math::pi*itk::Math::Round<double,double>(angleDiff/(2*itk::Math::pi));
+ if(abs(angleDiff)>1.e-4) {
+ rotSBs[i]->blockSignals(true);
+ rotSBs[i]->setValue( euler->GetParameters()[i]*rad );
+ rotSBs[i]->blockSignals(false);
+ }
+ int iAngle = itk::Math::Round<int,double>(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);
+ }
+ }