-
- return vvToolWidgetBase::reject();
-}
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-void vvToolRigidReg::GetArgsInfoFromGUI()
-{
- QFont font=QFont("Times New Roman",10);
- tab2textedit->setTextColor(QColor(255,0,0));
- tab2textedit->setCurrentFont(font);
- tab2textedit->update();
- QString str;
- QString file = QFileDialog::getOpenFileName(
- this,
- "Choose the Transformation Parameters file",
- mMainWindow->GetInputPathName(),
- "Text (*.conf *.txt *.rtf *.doc)");
- if (file.isEmpty())
- return;
- QFile Qfile1(file);
- // ifstream readfile;
- std::string configfile= file.toStdString();
- cmdline_parser_clitkAffineRegistration_configfile(const_cast<char*>(configfile.c_str()),&mArgsInfo,1,1,1);
- mArgsInfo.gradient_flag=1;
-
- //Read from File and display it on the TextBox 2
- ifstream readfile;
- std::vector<QString> Qstr;
- readfile.open(configfile.c_str());
- if (readfile.is_open())
- {
- while (!readfile.eof())
- {
- readfile >> configfile;
- Qstr.push_back(QString(configfile.c_str()));
- }
- readfile.close();
- }
- else {
- cout << "Unable to open file";
- }
- for(unsigned int i=0;i<Qstr.size();i++)
- {
- str=tab2textedit->toPlainText();
- str.append(Qstr.at(i));
- tab2textedit->setText(str);
- str.append("\n");
- tab2textedit->setText(str);
- }
-}
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-void vvToolRigidReg::InputIsSelected(std::vector<vvSlicerManager *> & l)
-{
- //inputs
- mInput1 = l[0];
- mInput2 = l[1];
-
- UpdateTextEditor(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(),textEdit_2);
-
- for(int i =0;i<4;i++)
- for(int j=0;j<4;j++)
- mInitialMatrix[i*4+j]=mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j);
-
- if(mInput1->GetFileName()==mInput2->GetFileName())
- {
- QMessageBox::information(this, "Warning","Your Reference and Target Images are the same");
- }
- mTwoInputs = true;
- SetOverlay(mInput2->GetImage());
- mImageSize=mInput1->GetImage()->GetSize();
- SetRotationCenter();
- SetSliderRanges();
-
- //connect all sigs to slots
- connect(resetbutton, SIGNAL(pressed()), this, SLOT(ResetTransform()));
- connect(tab2loadbutton, SIGNAL(pressed()), this, SLOT(GetArgsInfoFromGUI()));
- connect(tab2applybutton, SIGNAL(pressed()), this, SLOT(AutoRegister()));
-
-
- 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(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
- connect(ytrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
- connect(ztrans_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
-
-
- connect(xrot_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
- connect(yrot_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
- connect(zrot_slider, SIGNAL(valueChanged(int)), this, SLOT(UpdateTransform_sliders()));
-
- connect(xtrans_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
- connect(ytrans_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
- connect(ztrans_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
- connect(xrot_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
- connect(yrot_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
- connect(zrot_sb, SIGNAL(valueChanged(double)), this, SLOT(UpdateTransform_sb()));
-
- connect(loadbutton, SIGNAL(pressed()), this, SLOT(ReadFile()));
- connect(savebutton, SIGNAL(pressed()), this, SLOT(SaveFile()));
-
+ mInput = input;
+ HideInputSelector();
+ QTabWidget * tab = dynamic_cast<vvMainWindow*>(mMainWindow)->GetTab();
+ move(tab->mapToGlobal(tab->pos()));
+ resize(tab->width(), 0);
+
+ //default image rotation center is the center of the image
+ QString xcord,ycord,zcord;
+ std::vector<double> imageorigin;
+ 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]-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++)
+ // 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(clitk::Get4x4MatrixDoubleAsString(mInitialMatrix).c_str());
+ transformationLabel->setText(origTransformString);
+ SetTransform(mInitialMatrix);
+
+ //connect all sigs to slots
+ connect(resetbutton, SIGNAL(pressed()), this, SLOT(ResetTransform()));
+ connect(loadbutton, SIGNAL(pressed()), this, SLOT(LoadFile()));
+ connect(savebutton, SIGNAL(pressed()), this, SLOT(SaveFile()));
+
+ connect(xtrans_slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChange(int)));
+ connect(ytrans_slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChange(int)));
+ connect(ztrans_slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChange(int)));
+ connect(xrot_slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChange(int)));
+ connect(yrot_slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChange(int)));
+ connect(zrot_slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChange(int)));
+ connect(xtrans_sb, SIGNAL(valueChanged(double)), this, SLOT(SpinBoxChange(double)));
+ connect(ytrans_sb, SIGNAL(valueChanged(double)), this, SLOT(SpinBoxChange(double)));
+ connect(ztrans_sb, SIGNAL(valueChanged(double)), this, SLOT(SpinBoxChange(double)));
+ connect(xrot_sb, SIGNAL(valueChanged(double)), this, SLOT(SpinBoxChange(double)));
+ connect(yrot_sb, SIGNAL(valueChanged(double)), this, SLOT(SpinBoxChange(double)));
+ connect(zrot_sb, SIGNAL(valueChanged(double)), this, SLOT(SpinBoxChange(double)));
+
+ connect(stepTransSpinBox, SIGNAL(valueChanged(double)), this, SLOT(SetTranslationStep(double)));
+ connect(stepRotSpinBox, SIGNAL(valueChanged(double)), this, SLOT(SetRotationStep(double)));
+
+ connect(checkBoxDegrees, SIGNAL(stateChanged(int)), this, SLOT(ToggleSpinBoxAnglesUnit()));
+
+ connect(Xval, SIGNAL(editingFinished()), this, SLOT(ChangeOfRotationCenter()));
+ connect(Yval, SIGNAL(editingFinished()), this, SLOT(ChangeOfRotationCenter()));
+ connect(Zval, SIGNAL(editingFinished()), this, SLOT(ChangeOfRotationCenter()));
+
+ // Init step modifiers
+ stepTransSpinBox->setValue(1.);
+ stepRotSpinBox->setValue(1.);