From: bharath Date: Wed, 2 Jun 2010 19:28:15 +0000 (+0000) Subject: removal transformation order, added storing and retrival of transforms, minor textedi... X-Git-Tag: v1.2.0~624 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=367f3d5c15e1793b0fe02fc5ff68f96647ae47f1;p=clitk.git removal transformation order, added storing and retrival of transforms, minor textedit changes --- diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index ec94832..41c2264 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -44,13 +44,14 @@ vvToolRigidReg::vvToolRigidReg(vvMainWindowBase * parent, Qt::WindowFlags f): { // GUI Initialization Ui_vvToolRigidReg::setupUi(mToolWidget); + QSize qsize; + qsize.setHeight(170); + qsize.setWidth(650); + textEdit->setFixedSize(qsize); // Set how many inputs are needed for this tool AddInputSelector("Select the Reference Image"); AddInputSelector("Select the Target Image"); - mOrder=QString("Rotation Order: "); - - } //------------------------------------------------------------------------------ @@ -62,8 +63,8 @@ vvToolRigidReg::~vvToolRigidReg() //------------------------------------------------------------------------------ bool vvToolRigidReg::close() -{ - +{ + return vvToolWidgetBase::close(); } //------------------------------------------------------------------------------ @@ -71,13 +72,7 @@ bool vvToolRigidReg::close() //------------------------------------------------------------------------------ void vvToolRigidReg::reject() { - mInput2->Reload(); - for(int i=0;iNumberOfSlicers();i++) - { - mInput1->GetSlicer(i)->RemoveActor("overlay",0); - mInput1->SetColorMap(0); - mInput1->Render(); - } + ResetTransform(); return vvToolWidgetBase::reject(); } //------------------------------------------------------------------------------ @@ -88,9 +83,13 @@ void vvToolRigidReg::InputIsSelected(std::vector & l) //inputs mInput1 = l[0]; mInput2 = l[1]; + if(mInput1->GetFileName()==mInput2->GetFileName()) + { + QMessageBox::information(this, "Warning","Your Reference and Target Images are the same"); + } mTwoInputs = true; SetOverlay(); - this->mImageSize=mCurrentSlicerManager->GetImage()->GetSize(); + mImageSize=mInput1->GetImage()->GetSize(); SetRotationCenter(); SetSliderRanges(); @@ -101,17 +100,8 @@ void vvToolRigidReg::InputIsSelected(std::vector & l) connect(Xval, SIGNAL(editingFinished()), this, SLOT(SetXvalue())); connect(Yval, SIGNAL(editingFinished()), this, SLOT(SetYvalue())); connect(Zval, SIGNAL(editingFinished()), this, SLOT(SetZvalue())); - - connect(xtrans_slider, SIGNAL(sliderReleased()), this, SLOT(SetOrderXtrans())); - connect(ytrans_slider, SIGNAL(sliderReleased()), this, SLOT(SetOrderYtrans())); - connect(ztrans_slider, SIGNAL(sliderReleased()), this, SLOT(SetOrderZtrans())); - connect(xrot_slider, SIGNAL(sliderReleased()), this, SLOT(SetOrderXrot())); - connect(yrot_slider, SIGNAL(sliderReleased()), this, SLOT(SetOrderYrot())); - connect(zrot_slider, SIGNAL(sliderReleased()), this, SLOT(SetOrderZrot())); - - connect(xtrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateXtranslider())); - + connect(ytrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateYtranslider())); connect(ztrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateZtranslider())); @@ -137,24 +127,46 @@ void vvToolRigidReg::InputIsSelected(std::vector & l) //------------------------------------------------------------------------------ void vvToolRigidReg::apply() { - std::ostringstream osstream; - osstream << "Transformed_" - << mInput2->GetSlicer(0)->GetFileName() << ".mhd"; - AddImage(mInput2->GetImage(),osstream.str()); - QApplication::restoreOverrideCursor(); - close(); + QMessageBox mb( "Keep Overlay", + "Do you want to keep the overlay on?\n" + "You can switch it off anytime by pressing 'x'", + QMessageBox::Information, + QMessageBox::Yes | QMessageBox::Default, + QMessageBox::No, + QMessageBox::Cancel | QMessageBox::Escape ); + mb.setButtonText( QMessageBox::Yes, "Yes" ); + mb.setButtonText( QMessageBox::No, "No" ); + switch( mb.exec() ) { + case QMessageBox::Yes: + hide(); + break; + case QMessageBox::No: + mInput2->Reload(); + mInput2->Render(); + mInput1->Reload(); + mInput1->Render(); + for(int i=0;iNumberOfSlicers();i++) + { + mInput1->RemoveActor("overlay",0); + mInput1->SetColorMap(0); + mInput1->Render(); + hide(); + } + break; + case QMessageBox::Cancel: + break; + } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolRigidReg::SetOverlay() { - mCurrentSlicerManager=mInput2; - for (int i =0; iNumberOfSlicers(); i++) { - mInput1->GetSlicer(i)->SetOverlay(mInput2->GetImage()); - mInput1->GetSlicer(i)->SetActorVisibility("overlay",0,true); - mInput1->SetColorMap(); - mInput1->Render(); + for (int i =0; iNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->SetOverlay(mInput2->GetImage()); + mCurrentSlicerManager->GetSlicer(i)->SetActorVisibility("overlay",0,true); + mCurrentSlicerManager->SetColorMap(); + mCurrentSlicerManager->Render(); } } //------------------------------------------------------------------------------ @@ -181,7 +193,7 @@ void vvToolRigidReg::SetZvalue() //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolRigidReg::SetTransform(double tX, double tY, double tZ, double aX, double aY, double aZ) +void vvToolRigidReg::SetTransform(double tX, double tY, double tZ, double aX, double aY, double aZ,bool update) { vtkSmartPointer transform = mCurrentSlicerManager->GetImage()->GetTransform(); @@ -200,14 +212,16 @@ void vvToolRigidReg::SetTransform(double tX, double tY, double tZ, double aX, do } //Translations if (tX!=0||tY!=0||tZ!=0) - transform->Translate(tX,tY,tZ); + transform->Translate(tX*mInput1->GetImage()->GetSpacing()[0],tY*mInput1->GetImage()->GetSpacing()[1],tZ*mInput1->GetImage()->GetSpacing()[2]); transform->Update(); - - for (int i=0; iNumberOfSlicers(); i++) { - mCurrentSlicerManager->GetImage()->UpdateReslice(); - mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); - mCurrentSlicerManager->GetSlicer(i)->Render(); + if(update) + { + for (int i=0; iNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetImage()->UpdateReslice(); + mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); + mCurrentSlicerManager->GetSlicer(i)->Render(); + } } } //------------------------------------------------------------------------------ @@ -217,27 +231,27 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) { vtkSmartPointer transform =mCurrentSlicerManager->GetImage()->GetTransform(); transform->SetMatrix(matrix); - // mCurrentSlicerManager->GetImage()->SetTransform(transform); transform->PostMultiply(); transform->Concatenate(matrix); transform->Update(); mCurrentSlicerManager->GetImage()->SetTransform(transform); + for (int i=0; iNumberOfSlicers(); i++) { - mCurrentSlicerManager->GetImage()->UpdateReslice(); - mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); - mCurrentSlicerManager->GetSlicer(i)->Render(); - } + mCurrentSlicerManager->GetImage()->UpdateReslice(); + mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); + mCurrentSlicerManager->GetSlicer(i)->Render(); + } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ - void vvToolRigidReg::UpdateTextEditor(vtkMatrix4x4 *matrix,QString SetOrder) + void vvToolRigidReg::UpdateTextEditor(vtkMatrix4x4 *matrix) { QString str1,str2,str3; - QColor color; textEdit->clear(); textEdit->setAcceptRichText(true); + str2=textEdit->toPlainText(); str2.append("Rotation Center(mm): \n"); textEdit->setText(str2); @@ -273,16 +287,16 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) str2=textEdit->toPlainText(); - str2.append("Transformation Matrix:\n"); + str2.append("Transformation Matrix(mm):\n"); textEdit->setText(str2); - for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { str2=textEdit->toPlainText(); - str2.append("\t"+str1.setNum(matrix->Element[i][j])); + // str2.append("\t"+str1.setNum(matrix->Element[i][j])); + str2.append(QString("%1\t").arg(str1.setNum(matrix->Element[i][j]),20)); textEdit->setText(str2); } str2=textEdit->toPlainText(); @@ -295,78 +309,18 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) textEdit->toPlainText().toAscii(); str2=textEdit->toPlainText(); - mOrder+=SetOrder+QString(" "); - str2.append(mOrder); textEdit->setText(str2); } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvToolRigidReg::SetOrderXtrans() -{ - if(mOrder.size()-mOrder.lastIndexOf("Tx")<10) //see if the same Transformation Parameter has been used back to back - mOrder.chop(mOrder.size()-mOrder.lastIndexOf("Tx")); - UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Tx: ")+xtrans_sb->text()); -} -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -void vvToolRigidReg::SetOrderYtrans() -{ - if(mOrder.size()-mOrder.lastIndexOf("Ty")<10) - mOrder.chop(mOrder.size()-mOrder.lastIndexOf("Ty")); - UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Ty: ")+ytrans_sb->text()); -} - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -void vvToolRigidReg::SetOrderZtrans() -{ - if(mOrder.size()-mOrder.lastIndexOf("Tz")<10) - mOrder.chop(mOrder.size()-mOrder.lastIndexOf("Tz")); - UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Tz: ")+ztrans_sb->text()); -} - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -void vvToolRigidReg::SetOrderXrot() -{ - if(mOrder.size()-mOrder.lastIndexOf("Rx")<10) - mOrder.chop(mOrder.size()-mOrder.lastIndexOf("Rx")); - UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Rx: ")+xrot_sb->text()); -} - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -void vvToolRigidReg::SetOrderYrot() -{ - if(mOrder.size()-mOrder.lastIndexOf("Ry")<10) //see if the same Transformation Parameter has been used back to back - mOrder.chop(mOrder.size()-mOrder.lastIndexOf("Ry")); - UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Ry: ")+yrot_sb->text()); -} - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -void vvToolRigidReg::SetOrderZrot() -{ - if(mOrder.size()-mOrder.lastIndexOf("Rz")<10) //see if the same Transformation Parameter has been used back to back - mOrder.chop(mOrder.size()-mOrder.lastIndexOf("Rz")); - UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Rz: ")+zrot_sb->text()); -} -//------------------------------------------------------------------------------ - //------------------------------------------------------------------------------ void vvToolRigidReg::UpdateXtransb() { int diff=0; diff=xtrans_sb->value()-xtrans_slider->value(); - this->SetTransform(diff, 0, 0, 0, 0, 0); + this->SetTransform(diff, 0, 0, 0, 0, 0,true); xtrans_slider->setValue(xtrans_sb->value()); - // UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Tx:")+xtrans_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -376,9 +330,9 @@ void vvToolRigidReg::UpdateXtranslider() { int diff=0; diff=xtrans_slider->value()-xtrans_sb->value(); - this->SetTransform(diff, 0, 0, 0, 0, 0); + this->SetTransform(diff, 0, 0, 0, 0, 0,true); xtrans_sb->setValue(xtrans_slider->value()); - //UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Tx:")+xtrans_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -388,9 +342,9 @@ void vvToolRigidReg::UpdateYtransb() int diff=0; diff=ytrans_sb->value()-ytrans_slider->value(); - this->SetTransform(0, diff, 0, 0, 0, 0); + this->SetTransform(0, diff, 0, 0, 0, 0,true); ytrans_slider->setValue(ytrans_sb->value()); -// UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Ty:")+ytrans_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -400,9 +354,9 @@ void vvToolRigidReg::UpdateYtranslider() { int diff=0; diff=ytrans_slider->value()-ytrans_sb->value(); - this->SetTransform(0, diff, 0, 0, 0, 0); + this->SetTransform(0, diff, 0, 0, 0, 0,true); ytrans_sb->setValue(ytrans_slider->value()); -// UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Ty:")+ytrans_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -412,9 +366,9 @@ void vvToolRigidReg::UpdateZtransb() int diff=0; diff=ztrans_sb->value()-ztrans_slider->value(); - this->SetTransform(0, 0, diff, 0, 0, 0); + this->SetTransform(0, 0, diff, 0, 0, 0,true); ztrans_slider->setValue(ztrans_sb->value()); - // UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Tz:")+ztrans_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -424,9 +378,9 @@ void vvToolRigidReg::UpdateZtranslider() { int diff=0; diff=ztrans_slider->value()-ztrans_sb->value(); - this->SetTransform(0, 0, diff, 0, 0, 0); + this->SetTransform(0, 0, diff, 0, 0, 0,true); ztrans_sb->setValue(ztrans_slider->value()); -// UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Tz:")+ztrans_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -436,9 +390,9 @@ void vvToolRigidReg::UpdateXrotsb() int diff=0; diff=xrot_sb->value()-xrot_slider->value(); - this->SetTransform(0, 0, 0, diff, 0, 0); + this->SetTransform(0, 0, 0, diff, 0, 0,true); xrot_slider->setValue(xrot_sb->value()); - // UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Rx:")+xrot_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -448,9 +402,9 @@ void vvToolRigidReg::UpdateXrotslider() { int diff=0; diff=xrot_slider->value()-xrot_sb->value(); - this->SetTransform(0, 0, 0, diff, 0, 0); + this->SetTransform(0, 0, 0, diff, 0, 0,true); xrot_sb->setValue(xrot_slider->value()); - // UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Rx:")+xrot_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -460,9 +414,9 @@ void vvToolRigidReg::UpdateYrotsb() int diff=0; diff=yrot_sb->value()-yrot_slider->value(); - this->SetTransform(0, 0, 0, 0, diff, 0); + this->SetTransform(0, 0, 0, 0, diff, 0,true); yrot_slider->setValue(yrot_sb->value()); - // UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Ry:")+yrot_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -472,9 +426,9 @@ void vvToolRigidReg::UpdateYrotslider() { int diff=0; diff=yrot_slider->value()-yrot_sb->value(); - this->SetTransform(0, 0, 0, 0, diff, 0); + this->SetTransform(0, 0, 0, 0, diff, 0,true); yrot_sb->setValue(yrot_slider->value()); -// UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Ry:")+yrot_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -484,9 +438,9 @@ void vvToolRigidReg::UpdateZrotsb() int diff=0; diff=zrot_sb->value()-zrot_slider->value(); - this->SetTransform(0, 0, 0, 0, 0,diff); + this->SetTransform(0, 0, 0, 0, 0,diff,true); zrot_slider->setValue(zrot_sb->value()); - // UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Rz:")+zrot_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -496,9 +450,9 @@ void vvToolRigidReg::UpdateZrotslider() { int diff=0; diff=zrot_slider->value()-zrot_sb->value(); - this->SetTransform(0, 0, 0, 0, 0, diff); + this->SetTransform(0, 0, 0, 0, 0, diff,true); zrot_sb->setValue(zrot_slider->value()); -// UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),QString("Rz:")+zrot_sb->text()); + UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); } //------------------------------------------------------------------------------ @@ -506,34 +460,34 @@ void vvToolRigidReg::UpdateZrotslider() void vvToolRigidReg::SaveFile() { QString s = QFileDialog::getSaveFileName(this, tr("Save File"), - "/home/bharath/clitk3_27Apr/clitk3/build/bin/text.txt", + "/home", tr("Text (*.txt *.doc *.rtf)")); QFile file(s); if (file.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&file); - out << textEdit->toPlainText() ; + out<toPlainText() ; } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolRigidReg::ReadFile() -{ - QString parameters=QString("Tx: Ty: Tz:"); +{ + vtkMatrix4x4 *matrix=vtkMatrix4x4::New(); vtkSmartPointer transform = mCurrentSlicerManager->GetImage()->GetTransform(); - - QString s = QFileDialog::getOpenFileName( this, "Choose a file", - "/home/bharath/clitk3_27Apr/clitk3/build/bin/", + "/home", "Text (*.txt *.rtf *.doc)"); + if (s.isEmpty()) + return; + QFile file(s); ifstream readfile; - std::string x; + std::string x= s.toStdString(); std::vector Qstr; - - readfile.open("text.txt"); + readfile.open(x.c_str()); if (readfile.is_open()) { while (!readfile.eof()) @@ -543,58 +497,59 @@ void vvToolRigidReg::ReadFile() } readfile.close(); } - else cout << "Unable to open file"; - - //Obtain the Rotation Center + else { + cout << "Unable to open file"; + } + //Set the transformation matrix + int index =7; + for(int i=0;i<4;i++) + { + for(int j=0;j<4;j++) + { + matrix->Element[i][j]=Qstr.at(index).toDouble(); + index++; + } + } + transform->SetMatrix(matrix); + // SetTransform(matrix); + double * orientations=new double[3]; + double * translations=new double[3]; + transform->GetOrientation(orientations); + transform->PostMultiply(); + + //Obtain the Rotation Center Xval->setText(Qstr.at(2)); Yval->setText(Qstr.at(3)); Zval->setText(Qstr.at(4)); - -// InitializeSliders(); - double * orientations=new double[4]; - double * translations=new double[3]; - transform->PostMultiply(); - //Works currently wit the ROtation order Y Z X + + //In the Order or Y X Z // + //now postmultiply for the rotations + SetTransform(0,0,0,0,0,-orientations[2],false); + SetTransform(0,0,0,-orientations[0],0,0,false); + SetTransform(0,0,0,0,-orientations[1],0,false); + transform->GetPosition(translations); - transform->GetOrientation(orientations); - /* xtrans_slider->setValue(Qstr.at(10).toDouble()); - UpdateXtranslider(); - ytrans_slider->setValue(Qstr.at(14).toDouble()); - UpdateYtranslider(); - ztrans_slider->setValue(Qstr.at(18).toDouble()); - UpdateZtranslider(); -*/ - DD(translations[0]); - DD(translations[1]); - DD(translations[2]); + transform->Identity(); + + /* DD(translations[0]/mInput1->GetImage()->GetSpacing()[0]); + DD(translations[1]/mInput1->GetImage()->GetSpacing()[1]); + DD(translations[2]/mInput1->GetImage()->GetSpacing()[2]); DD(orientations[0]); DD(orientations[1]); - DD(orientations[2]); - DD(orientations[3]); - DD(*transform->GetMatrix()); - //Obtain the Transformation Matrix - /*QString str; - str=QString(value.at(10).c_str()); - DD(str.toStdString()); - */ -// DD(value[6]); - // DD(value[10]); - //put the streamed values in matrix array - /* for(int i=0;i<4;i++) - { - for(int j=0;j<4;j++) - { - matrix->Element[i][j]=value[i*4+j]; - } - } - SetTransform( matrix);*/ - - /*xtrans_slider->setValue(value.at(10)); - ytrans_slider->setValue(value.at(14)); - ztrans_slider->setValue(value.at(18)); - UpdateXtranslider(); - UpdateYtranslider(); - UpdateZtranslider();*/ + DD(orientations[2]);*/ + //set the sliders and spin box values + xtrans_slider->setValue(round(translations[0]/mInput1->GetImage()->GetSpacing()[0])); + UpdateXtranslider(); + ytrans_slider->setValue(round(translations[1]/mInput1->GetImage()->GetSpacing()[1])); + UpdateYtranslider(); + ztrans_slider->setValue(round(translations[2]/mInput1->GetImage()->GetSpacing()[2])); + UpdateZtranslider(); + yrot_slider->setValue(round(orientations[1])); + UpdateYrotslider(); + xrot_slider->setValue(round(orientations[0])); + UpdateXrotslider(); + zrot_slider->setValue(round(orientations[2])); + UpdateZrotslider(); } //------------------------------------------------------------------------------ @@ -603,13 +558,14 @@ void vvToolRigidReg::ResetTransform() { vtkMatrix4x4 *matrix = vtkMatrix4x4::New(); matrix->Identity(); - + mInput1->Reload(); + mInput1->Render(); + mInput2->Reload(); + mInput2->Render(); SetRotationCenter(); SetSliderRanges(); SetTransform(matrix); - mOrder.clear(); - mOrder=QString("Rotation Order: "); - UpdateTextEditor(matrix,mOrder); + UpdateTextEditor(matrix); } //------------------------------------------------------------------------------ @@ -619,11 +575,11 @@ void vvToolRigidReg::SetRotationCenter() //default image rotation center is the center of the image QString xcord,ycord,zcord; std::vector imageorigin; - imageorigin=mCurrentSlicerManager->GetImage()->GetOrigin(); + imageorigin=mInput1->GetImage()->GetOrigin(); - xcord=xcord.setNum(imageorigin[0]+mImageSize[0]*mCurrentSlicerManager->GetImage()->GetSpacing()[0]/2, 'g', 3); - ycord=ycord.setNum(imageorigin[1]+mImageSize[1]*mCurrentSlicerManager->GetImage()->GetSpacing()[1]/2, 'g', 3); - zcord=zcord.setNum(imageorigin[2]+mImageSize[2]*mCurrentSlicerManager->GetImage()->GetSpacing()[2]/2, 'g', 3); + xcord=xcord.setNum(imageorigin[0]+mImageSize[0]*mInput1->GetImage()->GetSpacing()[0]/2, 'g', 3); + ycord=ycord.setNum(imageorigin[1]+mImageSize[1]*mInput1->GetImage()->GetSpacing()[1]/2, 'g', 3); + zcord=zcord.setNum(imageorigin[2]+mImageSize[2]*mInput1->GetImage()->GetSpacing()[2]/2, 'g', 3); Xval->setText(xcord); Yval->setText(ycord);