35 #include <QPushButton> 59 RegistrationBaseWidget(services, parent,
"org_custusx_registration_method_commandline_elastix_widget",
"ElastiX Registration"),
60 mRegisterButton(NULL),
61 mParameterFileWidget0(NULL),
62 mFilePreviewWidget(NULL),
63 mTimedAlgorithmProgressBar(NULL),
77 void ElastixWidget::createUI()
80 connect(mElastixManager.get(), SIGNAL(elastixChanged()),
this, SLOT(elastixChangedSlot()));
82 mRegisterButton =
new QPushButton(
"Register");
83 connect(mRegisterButton, SIGNAL(clicked()),
this, SLOT(registerSlot()));
85 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
86 topLayout->setMargin(0);
88 mOptionsWidget = this->createOptionsWidget();
89 mOptionsWidget->setVisible(
settings()->value(
"registration/elastixShowDetails").toBool());
92 mTimedAlgorithmProgressBar->
attach(mElastixManager->getExecuter());
94 QGridLayout* entryLayout =
new QGridLayout;
95 entryLayout->setColumnStretch(1, 1);
102 new LabeledComboBoxWidget(
this, mElastixManager->getParameters()->getCurrentPreset(), entryLayout, 2);
104 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
105 buttonsLayout->addWidget(mRegisterButton);
108 QIcon(
":/icons/open_icon_library/system-run-5.png"),
109 "Details",
"Show Elastix Settings Details",
110 SLOT(toggleDetailsSlot()),
113 topLayout->addLayout(entryLayout);
114 topLayout->addLayout(buttonsLayout);
115 topLayout->addWidget(mOptionsWidget, 1);
116 topLayout->addStretch();
117 topLayout->addWidget(mTimedAlgorithmProgressBar);
119 this->elastixChangedSlot();
122 void ElastixWidget::toggleDetailsSlot()
124 mOptionsWidget->setVisible(!mOptionsWidget->isVisible());
125 settings()->
setValue(
"registration/elastixShowDetails", mOptionsWidget->isVisible());
128 QWidget* ElastixWidget::createOptionsWidget()
130 QWidget* retval =
new QWidget(
this);
131 QGridLayout* layout =
new QGridLayout(retval);
132 layout->setMargin(0);
139 layout->addWidget(
new QLabel(
"Parameter File",
this), line, 0);
141 connect(mParameterFileWidget0, SIGNAL(fileSelected(QString)),
this, SLOT(userParameterFileSelected(QString)));
142 layout->addWidget(mParameterFileWidget0, line, 1, 1, 2);
145 QWidget* executableWidget =
sscCreateDataWidget(
this, mElastixManager->getParameters()->getActiveExecutable());
146 layout->addWidget(executableWidget, line, 0, 1, 3);
149 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
150 layout->addLayout(buttonsLayout, line, 0, 1, 3);
152 buttonsLayout->addWidget(
new CheckBoxWidget(
this, mElastixManager->getDisplayProcessMessages()));
153 buttonsLayout->addWidget(
new CheckBoxWidget(
this, mElastixManager->getDisableRendering()));
156 QIcon(
":/icons/preset_remove.png"),
157 "Delete the current preset",
"",
158 SLOT(deletePresetSlot()),
162 QIcon(
":/icons/preset_save.png"),
163 "Add the current setting as a preset",
"",
164 SLOT(savePresetSlot()),
171 mFilePreviewWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
172 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::userParameterFileSelected(QString filename)
205 mElastixManager->getParameters()->getActiveParameterFile0()->setValue(filename);
208 void ElastixWidget::recurseParameterFolders(QString root, QStringList* retval)
211 folder.setFilter(QDir::AllDirs|QDir::NoDotAndDotDot);
212 QFileInfoList info = folder.entryInfoList();
213 for (
int i=0; i<info.size(); ++i)
215 QString current = info[i].absoluteFilePath();
216 if (current.endsWith(
"/par"))
218 retval->append(current);
221 this->recurseParameterFolders(current, retval);
225 void ElastixWidget::elastixChangedSlot()
230 QStringList parfolders;
231 for (
int i=0; i<folders.size(); ++i)
232 this->recurseParameterFolders(folders[i], &parfolders);
234 mParameterFileWidget0->
setPaths(parfolders);
235 QStringList nameFilters;
244 void ElastixWidget::registerSlot()
246 mElastixManager->execute();
QStringList getRootPaths() const
return the root of the existing root, first if no existing.
QString getAbsoluteFilepath() const
return absolute filepath, select the existing root
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.
boost::shared_ptr< class RegServices > RegServicesPtr
Settings * settings()
Shortcut for accessing the settings instance.
void attach(TimedAlgorithmPtr algorithm)
Namespace for all CustusX production code.