35 #include <QPushButton>
56 RegistrationBaseWidget(services, parent,
"org_custusx_registration_method_commandline_elastix_widget",
"ElastiX Registration")
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()));
77 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
78 topLayout->setMargin(0);
80 mOptionsWidget = this->createOptionsWidget();
81 mOptionsWidget->setVisible(
settings()->value(
"registration/elastixShowDetails").toBool());
84 mTimedAlgorithmProgressBar->
attach(mElastixManager->getExecuter());
86 QGridLayout* entryLayout =
new QGridLayout;
87 entryLayout->setColumnStretch(1, 1);
94 new LabeledComboBoxWidget(
this, mElastixManager->getParameters()->getCurrentPreset(), entryLayout, 2);
96 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
97 buttonsLayout->addWidget(mRegisterButton);
100 QIcon(
":/icons/open_icon_library/system-run-5.png"),
101 "Details",
"Show Elastix Settings Details",
102 SLOT(toggleDetailsSlot()),
105 topLayout->addLayout(entryLayout);
106 topLayout->addLayout(buttonsLayout);
107 topLayout->addWidget(mOptionsWidget, 1);
108 topLayout->addStretch();
109 topLayout->addWidget(mTimedAlgorithmProgressBar);
111 this->elastixChangedSlot();
114 void ElastixWidget::toggleDetailsSlot()
116 mOptionsWidget->setVisible(!mOptionsWidget->isVisible());
117 settings()->
setValue(
"registration/elastixShowDetails", mOptionsWidget->isVisible());
120 QWidget* ElastixWidget::createOptionsWidget()
122 QWidget* retval =
new QWidget(
this);
123 QGridLayout* layout =
new QGridLayout(retval);
124 layout->setMargin(0);
131 layout->addWidget(
new QLabel(
"Parameter File",
this), line, 0);
132 mParameterFileWidget0 =
new FileSelectWidget(
this);
133 connect(mParameterFileWidget0, SIGNAL(fileSelected(QString)),
this, SLOT(userParameterFileSelected(QString)));
134 layout->addWidget(mParameterFileWidget0, line, 1, 1, 2);
137 layout->addWidget(
new QLabel(
"Executable",
this), line, 0);
138 mExecutableEdit =
new QLineEdit(
this);
139 connect(mExecutableEdit, SIGNAL(editingFinished()),
this, SLOT(executableEditFinishedSlot()));
140 layout->addWidget(mExecutableEdit, line, 1);
142 QAction* browseExecutableAction =
new QAction(QIcon(
":/icons/open.png"),
"Browse",
this);
143 browseExecutableAction->setStatusTip(
"Select the elastiX executable");
144 connect(browseExecutableAction, SIGNAL(triggered()),
this, SLOT(browseExecutableSlot()));
145 QToolButton* button =
new QToolButton();
146 button->setDefaultAction(browseExecutableAction);
147 layout->addWidget(button, line, 2);
150 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
151 layout->addLayout(buttonsLayout, line, 0, 1, 3);
153 buttonsLayout->addWidget(
new CheckBoxWidget(
this, mElastixManager->getDisplayProcessMessages()));
154 buttonsLayout->addWidget(
new CheckBoxWidget(
this, mElastixManager->getDisableRendering()));
157 QIcon(
":/icons/preset_remove.png"),
158 "Delete the current preset",
"",
159 SLOT(deletePresetSlot()),
163 QIcon(
":/icons/preset_save.png"),
164 "Add the current setting as a preset",
"",
165 SLOT(savePresetSlot()),
170 mFilePreviewWidget =
new FilePreviewWidget(
this);
172 mFilePreviewWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
173 layout->addWidget(mFilePreviewWidget, line, 0, 1, 3);
182 void ElastixWidget::savePresetSlot()
186 QString newName = par->getPresetNameSuggesion();
189 QString text = QInputDialog::getText(
this,
"Save Preset",
190 "Custom Preset Name", QLineEdit::Normal,
192 if (!ok || text.isEmpty())
195 par->saveCurrentPreset(text);
198 void ElastixWidget::deletePresetSlot()
200 mElastixManager->getParameters()->removeCurrentPreset();
203 void ElastixWidget::executableEditFinishedSlot()
205 mElastixManager->getParameters()->setActiveExecutable(mExecutableEdit->text());
208 void ElastixWidget::browseExecutableSlot()
210 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Select Executable"),
"~");
211 if (fileName.isEmpty())
214 mElastixManager->getParameters()->setActiveExecutable(fileName);
217 void ElastixWidget::userParameterFileSelected(QString filename)
219 mElastixManager->getParameters()->setActiveParameterFile0(filename);
222 void ElastixWidget::elastixChangedSlot()
225 QStringList folders = par->getParameterFilesDir();
226 for (
int i=0; i<folders.size(); ++i)
228 QDir folder(folders[i]);
232 mParameterFileWidget0->
setPaths(folders);
233 QStringList nameFilters;
234 nameFilters <<
"*.*";
236 mParameterFileWidget0->
setFilename(par->getActiveParameterFile0());
240 mExecutableEdit->blockSignals(
true);
241 mExecutableEdit->setText(par->getActiveExecutable());
242 mExecutableEdit->blockSignals(
false);
245 void ElastixWidget::registerSlot()
247 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