imageorigin=mInput->GetImage()->GetOrigin();
std::vector<int> imageSize = mInput->GetImage()->GetSize();
std::vector<double> 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);
//backup original matrix
for(int j=0; j<4; j++)
for(int i=0; i<4; i++)
- mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j));
+ // TODO SR and BP: check on the list of transforms and not the first only
+ mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j));
QString origTransformString = dynamic_cast<vvMainWindow*>(mMainWindow)->Get4x4MatrixDoubleAsString(mInitialMatrix);
transformationLabel->setText(origTransformString);
SetTransform(mInitialMatrix);
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<double,double>(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<double,double>(newVal*rad));
rotSliders[i]->blockSignals(false);
}
}
// Compute transform and set
- vtkSmartPointer<vtkTransform> transform_final=mInput->GetImage()->GetTransform();
+ // TODO SR and BP: check on the list of transforms and not the first only
+ vtkSmartPointer<vtkTransform> transform_final=mInput->GetImage()->GetTransform()[0];
transform_final->Identity();
transform_final->PostMultiply();
QFile file(filename);
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
- vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix();
+ // TODO SR and BP: check on the list of transforms and not the first only
+ vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix();
QString matrixStr = dynamic_cast<vvMainWindow*>(mMainWindow)->Get4x4MatrixDoubleAsString(matrix,16);
QTextStream out(&file);
out << matrixStr;
//------------------------------------------------------------------------------
void vvToolRigidReg::ChangeOfRotationCenter()
{
- SetTransform(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix());
+ // TODO SR and BP: check on the list of transforms and not the first only
+ SetTransform(mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix());
}
//------------------------------------------------------------------------------
void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix)
{
vtkSmartPointer<vtkTransform> transform=vtkSmartPointer<vtkTransform>::New();
- mCurrentSlicerManager->GetImage()->GetTransform()->SetMatrix(matrix);
+ // 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();
euler->SetMatrix(rotMat);
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(euler->GetParameters()[i+3]) );
+ 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.;
- 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<double,double>(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<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);
+ }
}
}
//------------------------------------------------------------------------------