22 #include <QApplication>
31 mActiveExecutable = this->getExecutable();
32 mActiveParameterFile0 = this->getParameterFile(
"0");
33 mActiveParameterFile1 = this->getParameterFile(
"1");
36 "Current Preset",
"Select Preset...",
38 connect(mCurrentPreset.get(), SIGNAL(changed()),
this, SLOT(currentPresetChangedSlot()));
40 this->currentPresetChangedSlot();
43 void ElastixParameters::addDefaultPresets()
57 par0->setValue(
"elastix/par/p_Rigid.txt");
59 this->addDefaultPreset(
"elastix/p_Rigid", exe->getValue(), QStringList() << par0->getValue());
62 void ElastixParameters::addDefaultPreset(QString name, QString executable, QStringList parameterFiles)
68 XmlOptionFile node = mOptions.
descend(
"preset",
"name", name);
69 node.
getElement().setAttribute(
"executable", executable);
70 for (
unsigned i=0; i<parameterFiles.size(); ++i)
72 QString parName = QString(
"parameterFile%1").arg(i);
73 QString parVal = parameterFiles[i];
74 node.getElement().setAttribute(parName, parVal);
78 void ElastixParameters::currentPresetChangedSlot()
80 this->reloadPresets();
82 XmlOptionFile node = mOptions.
descend(
"preset",
"name", mCurrentPreset->getValue());
83 mActiveExecutable->setValue(node.getElement().attribute(
"executable"));
85 mActiveParameterFile0->setValue(node.getElement().attribute(
"parameterFile0"));
86 mActiveParameterFile1->setValue(node.getElement().attribute(
"parameterFile1"));
91 QString ElastixParameters::getFullParameterFilename(QString filename)
98 return "org.custusx.registration.method.commandline";
103 return mCurrentPreset;
110 this->reloadPresets();
111 mCurrentPreset->setValue(
"Select Preset...");
114 void ElastixParameters::reloadPresets()
116 this->addDefaultPresets();
118 presets <<
"Select Preset...";
120 QDomNodeList presetNodeList = mOptions.
getElement().elementsByTagName(
"preset");
121 for (
int i = 0; i < presetNodeList.count(); ++i)
123 presets << presetNodeList.item(i).toElement().attribute(
"name");
125 presets.removeDuplicates();
127 mCurrentPreset->blockSignals(
true);
128 mCurrentPreset->setValueRange(presets);
129 mCurrentPreset->blockSignals(
false);
135 node.
getElement().setAttribute(
"executable", mActiveExecutable->getEmbeddedPath().getRelativeFilepath());
136 node.
getElement().setAttribute(
"parameterFile0", mActiveParameterFile0->getEmbeddedPath().getRelativeFilepath());
137 node.
getElement().setAttribute(
"parameterFile1", mActiveParameterFile1->getEmbeddedPath().getRelativeFilepath());
138 mCurrentPreset->setValue(name);
151 paths << qApp->applicationDirPath();
157 "Name of registration executable",
173 "Name of parameter file "+uid,
181 bool ElastixParameters::validParameterFile(QString file)
const
183 return QFileInfo(file).exists() && QFileInfo(file).isFile();
188 QString p0 = mActiveParameterFile0->getEmbeddedPath().getAbsoluteFilepath();
189 QString p1 = mActiveParameterFile1->getEmbeddedPath().getAbsoluteFilepath();
192 if (this->validParameterFile(p0))
194 if (this->validParameterFile(p1))
201 QString retval = QFileInfo(mActiveExecutable->getValue()).baseName();
203 for (
unsigned i=0; i<parFiles.size(); ++i)
204 retval +=
"/" + QFileInfo(parFiles[i]).baseName();