51 mActiveExecutable = this->getExecutable();
52 mActiveParameterFile0 = this->getParameterFile(
"0");
53 mActiveParameterFile1 = this->getParameterFile(
"1");
56 "Current Preset",
"Select Preset...",
58 connect(mCurrentPreset.get(), SIGNAL(changed()),
this, SLOT(currentPresetChangedSlot()));
60 this->currentPresetChangedSlot();
63 void ElastixParameters::addDefaultPresets()
68 par0->setValue(
"elastix/par/p_Rigid.txt");
70 this->addDefaultPreset(
"elastix/p_Rigid", exe->getValue(), QStringList() << par0->getValue());
73 void ElastixParameters::addDefaultPreset(QString name, QString executable, QStringList parameterFiles)
79 XmlOptionFile node = mOptions.
descend(
"preset",
"name", name);
80 node.
getElement().setAttribute(
"executable", executable);
81 for (
unsigned i=0; i<parameterFiles.size(); ++i)
83 QString parName = QString(
"parameterFile%1").arg(i);
84 QString parVal = parameterFiles[i];
85 node.getElement().setAttribute(parName, parVal);
89 void ElastixParameters::currentPresetChangedSlot()
91 this->reloadPresets();
93 XmlOptionFile node = mOptions.
descend(
"preset",
"name", mCurrentPreset->getValue());
94 mActiveExecutable->setValue(node.getElement().attribute(
"executable"));
96 mActiveParameterFile0->setValue(node.getElement().attribute(
"parameterFile0"));
97 mActiveParameterFile1->setValue(node.getElement().attribute(
"parameterFile1"));
102 QString ElastixParameters::getFullParameterFilename(QString filename)
109 return "org.custusx.registration.method.commandline";
114 return mCurrentPreset;
121 this->reloadPresets();
122 mCurrentPreset->setValue(
"Select Preset...");
125 void ElastixParameters::reloadPresets()
127 this->addDefaultPresets();
129 presets <<
"Select Preset...";
131 QDomNodeList presetNodeList = mOptions.
getElement().elementsByTagName(
"preset");
132 for (
int i = 0; i < presetNodeList.count(); ++i)
134 presets << presetNodeList.item(i).toElement().attribute(
"name");
136 presets.removeDuplicates();
138 mCurrentPreset->blockSignals(
true);
139 mCurrentPreset->setValueRange(presets);
140 mCurrentPreset->blockSignals(
false);
146 node.
getElement().setAttribute(
"executable", mActiveExecutable->getEmbeddedPath().getRelativeFilepath());
147 node.
getElement().setAttribute(
"parameterFile0", mActiveParameterFile0->getEmbeddedPath().getRelativeFilepath());
148 node.
getElement().setAttribute(
"parameterFile1", mActiveParameterFile1->getEmbeddedPath().getRelativeFilepath());
149 mCurrentPreset->setValue(name);
160 "Name of registration executable",
176 "Name of parameter file "+uid,
184 bool ElastixParameters::validParameterFile(QString file)
const
186 return QFileInfo(file).exists() && QFileInfo(file).isFile();
191 QString p0 = mActiveParameterFile0->getEmbeddedPath().getAbsoluteFilepath();
192 QString p1 = mActiveParameterFile1->getEmbeddedPath().getAbsoluteFilepath();
195 if (this->validParameterFile(p0))
197 if (this->validParameterFile(p1))
204 QString retval = QFileInfo(mActiveExecutable->getValue()).baseName();
206 for (
unsigned i=0; i<parFiles.size(); ++i)
207 retval +=
"/" + QFileInfo(parFiles[i]).baseName();
static QString getConfigUid()
void saveCurrentPreset(QString newName)
void removeCurrentPreset()
Remove the currently selected preset. Reload.
static QStringList getRootConfigPaths()
QDomElement getElement()
return the current element
void elastixParametersChanged()
ElastixParameters(XmlOptionFile options)
QStringList getActiveParameterFiles() const
StringPropertyBasePtr getCurrentPreset()
static QString findConfigFilePath(QString fileName, QString pathRelativeToConfigRoot, QString alternativeAbsolutePath="")
void changed()
emit when the underlying data value is changed: The user interface will be updated.
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
static FilePathPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList paths, QDomNode root=QDomNode())
void deleteNode()
Delete the current node.
static QStringList appendStringToAllElements(QStringList root, QString suffix)
bool isNull() const
checks if this is null
boost::shared_ptr< class FilePathProperty > FilePathPropertyPtr
XmlOptionFile tryDescend(QString element, QString attributeName, QString attributeValue) const
Helper class for xml files used to store ssc/cx data.
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
XmlOptionFile descend(QString element) const
step one level down in the xml tree
QString getPresetNameSuggesion() const
create a name describing the active state, can be used as name for a new preset.