35 #include <QPushButton>
69 void ElastixWidget::createUI()
72 connect(mElastixManager.get(), SIGNAL(elastixChanged()),
this, SLOT(elastixChangedSlot()));
74 mRegisterButton =
new QPushButton(
"Register");
75 connect(mRegisterButton, SIGNAL(clicked()),
this, SLOT(registerSlot()));
78 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
79 topLayout->setMargin(0);
81 mOptionsWidget = this->createOptionsWidget();
82 mOptionsWidget->setVisible(
settings()->value(
"registration/elastixShowDetails").toBool());
85 mTimedAlgorithmProgressBar->
attach(mElastixManager->getExecuter());
87 QGridLayout* entryLayout =
new QGridLayout;
88 entryLayout->setColumnStretch(1, 1);
95 new LabeledComboBoxWidget(
this, mElastixManager->getParameters()->getCurrentPreset(), entryLayout, 2);
97 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
98 buttonsLayout->addWidget(mRegisterButton);
101 QIcon(
":/icons/open_icon_library/system-run-5.png"),
102 "Details",
"Show Elastix Settings Details",
103 SLOT(toggleDetailsSlot()),
106 topLayout->addLayout(entryLayout);
107 topLayout->addLayout(buttonsLayout);
108 topLayout->addWidget(mOptionsWidget, 1);
109 topLayout->addStretch();
110 topLayout->addWidget(mTimedAlgorithmProgressBar);
112 this->elastixChangedSlot();
115 void ElastixWidget::toggleDetailsSlot()
117 mOptionsWidget->setVisible(!mOptionsWidget->isVisible());
118 settings()->
setValue(
"registration/elastixShowDetails", mOptionsWidget->isVisible());
121 QWidget* ElastixWidget::createOptionsWidget()
123 QWidget* retval =
new QWidget(
this);
124 QGridLayout* layout =
new QGridLayout(retval);
125 layout->setMargin(0);
132 layout->addWidget(
new QLabel(
"Parameter File",
this), line, 0);
133 mParameterFileWidget0 =
new FileSelectWidget(
this);
134 connect(mParameterFileWidget0, SIGNAL(fileSelected(QString)),
this, SLOT(userParameterFileSelected(QString)));
135 layout->addWidget(mParameterFileWidget0, line, 1, 1, 2);
138 layout->addWidget(
new QLabel(
"Executable",
this), line, 0);
139 mExecutableEdit =
new QLineEdit(
this);
140 connect(mExecutableEdit, SIGNAL(editingFinished()),
this, SLOT(executableEditFinishedSlot()));
141 layout->addWidget(mExecutableEdit, line, 1);
143 QAction* browseExecutableAction =
new QAction(QIcon(
":/icons/open.png"),
"Browse",
this);
144 browseExecutableAction->setStatusTip(
"Select the elastiX executable");
145 connect(browseExecutableAction, SIGNAL(triggered()),
this, SLOT(browseExecutableSlot()));
146 QToolButton* button =
new QToolButton();
147 button->setDefaultAction(browseExecutableAction);
148 layout->addWidget(button, line, 2);
151 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
152 layout->addLayout(buttonsLayout, line, 0, 1, 3);
154 buttonsLayout->addWidget(
new CheckBoxWidget(
this, mElastixManager->getDisplayProcessMessages()));
155 buttonsLayout->addWidget(
new CheckBoxWidget(
this, mElastixManager->getDisableRendering()));
158 QIcon(
":/icons/preset_remove.png"),
159 "Delete the current preset",
"",
160 SLOT(deletePresetSlot()),
164 QIcon(
":/icons/preset_save.png"),
165 "Add the current setting as a preset",
"",
166 SLOT(savePresetSlot()),
171 mFilePreviewWidget =
new FilePreviewWidget(
this);
173 mFilePreviewWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
174 layout->addWidget(mFilePreviewWidget, line, 0, 1, 3);
186 "<h3>ElastiX Registration.</h3>"
187 "<p>Select two datasets you want to register to each other, "
188 "and a preset suitable for your images.</p>"
189 "<p><a http://elastix.isi.uu.nl/> ElastiX </a> is normally used for the registration "
190 "as an external application, although any program with the same input/output "
191 "can be used. Add parameter files to the folder config/elastix in order to show "
192 "them to CustusX.</p>"
193 "<p>If a nonlinear registration is selected, CustusX will attempt to import the "
194 "volume produced by ElastiX.</p>"
198 void ElastixWidget::savePresetSlot()
202 QString newName = par->getPresetNameSuggesion();
205 QString text = QInputDialog::getText(
this,
"Save Preset",
206 "Custom Preset Name", QLineEdit::Normal,
208 if (!ok || text.isEmpty())
211 par->saveCurrentPreset(text);
214 void ElastixWidget::deletePresetSlot()
216 mElastixManager->getParameters()->removeCurrentPreset();
219 void ElastixWidget::executableEditFinishedSlot()
221 mElastixManager->getParameters()->setActiveExecutable(mExecutableEdit->text());
224 void ElastixWidget::browseExecutableSlot()
226 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Select Executable"),
"~");
227 if (fileName.isEmpty())
230 mElastixManager->getParameters()->setActiveExecutable(fileName);
233 void ElastixWidget::userParameterFileSelected(QString filename)
235 mElastixManager->getParameters()->setActiveParameterFile0(filename);
238 void ElastixWidget::elastixChangedSlot()
241 QStringList folders = par->getParameterFilesDir();
242 for (
int i=0; i<folders.size(); ++i)
244 QDir folder(folders[i]);
248 mParameterFileWidget0->
setPaths(folders);
249 QStringList nameFilters;
250 nameFilters <<
"*.*";
252 mParameterFileWidget0->
setFilename(par->getActiveParameterFile0());
256 mExecutableEdit->blockSignals(
true);
257 mExecutableEdit->setText(par->getActiveExecutable());
258 mExecutableEdit->blockSignals(
false);
261 void ElastixWidget::registerSlot()
263 mElastixManager->execute();
Show progress for a TimedBaseAlgorithm.
boost::shared_ptr< ElastixParameters > ElastixParametersPtr
void setValue(const QString &key, const QVariant &value)
Manager for interfacing to the ElastiX registration package.
Settings * settings()
Shortcut for accessing the settings instance.
void attach(TimedAlgorithmPtr algorithm)
PatientModelServicePtr patientModelService
RegistrationServicePtr registrationService