43 #include <QApplication>
52 mActiveExecutable = this->getExecutable();
53 mActiveParameterFile0 = this->getParameterFile(
"0");
54 mActiveParameterFile1 = this->getParameterFile(
"1");
57 "Current Preset",
"Select Preset...",
59 connect(mCurrentPreset.get(), SIGNAL(changed()),
this, SLOT(currentPresetChangedSlot()));
61 this->currentPresetChangedSlot();
64 void ElastixParameters::addDefaultPresets()
78 par0->setValue(
"elastix/par/p_Rigid.txt");
80 this->addDefaultPreset(
"elastix/p_Rigid", exe->getValue(), QStringList() << par0->getValue());
83 void ElastixParameters::addDefaultPreset(QString name, QString executable, QStringList parameterFiles)
89 XmlOptionFile node = mOptions.
descend(
"preset",
"name", name);
90 node.
getElement().setAttribute(
"executable", executable);
91 for (
unsigned i=0; i<parameterFiles.size(); ++i)
93 QString parName = QString(
"parameterFile%1").arg(i);
94 QString parVal = parameterFiles[i];
95 node.getElement().setAttribute(parName, parVal);
99 void ElastixParameters::currentPresetChangedSlot()
101 this->reloadPresets();
103 XmlOptionFile node = mOptions.
descend(
"preset",
"name", mCurrentPreset->getValue());
104 mActiveExecutable->setValue(node.getElement().attribute(
"executable"));
106 mActiveParameterFile0->setValue(node.getElement().attribute(
"parameterFile0"));
107 mActiveParameterFile1->setValue(node.getElement().attribute(
"parameterFile1"));
112 QString ElastixParameters::getFullParameterFilename(QString filename)
119 return "org.custusx.registration.method.commandline";
124 return mCurrentPreset;
131 this->reloadPresets();
132 mCurrentPreset->setValue(
"Select Preset...");
135 void ElastixParameters::reloadPresets()
137 this->addDefaultPresets();
139 presets <<
"Select Preset...";
141 QDomNodeList presetNodeList = mOptions.
getElement().elementsByTagName(
"preset");
142 for (
int i = 0; i < presetNodeList.count(); ++i)
144 presets << presetNodeList.item(i).toElement().attribute(
"name");
146 presets.removeDuplicates();
148 mCurrentPreset->blockSignals(
true);
149 mCurrentPreset->setValueRange(presets);
150 mCurrentPreset->blockSignals(
false);
156 node.
getElement().setAttribute(
"executable", mActiveExecutable->getEmbeddedPath().getRelativeFilepath());
157 node.
getElement().setAttribute(
"parameterFile0", mActiveParameterFile0->getEmbeddedPath().getRelativeFilepath());
158 node.
getElement().setAttribute(
"parameterFile1", mActiveParameterFile1->getEmbeddedPath().getRelativeFilepath());
159 mCurrentPreset->setValue(name);
172 paths << qApp->applicationDirPath();
178 "Name of registration executable",
194 "Name of parameter file "+uid,
202 bool ElastixParameters::validParameterFile(QString file)
const
204 return QFileInfo(file).exists() && QFileInfo(file).isFile();
209 QString p0 = mActiveParameterFile0->getEmbeddedPath().getAbsoluteFilepath();
210 QString p1 = mActiveParameterFile1->getEmbeddedPath().getAbsoluteFilepath();
213 if (this->validParameterFile(p0))
215 if (this->validParameterFile(p1))
222 QString retval = QFileInfo(mActiveExecutable->getValue()).baseName();
224 for (
unsigned i=0; i<parFiles.size(); ++i)
225 retval +=
"/" + QFileInfo(parFiles[i]).baseName();
static QString getConfigUid()
void saveCurrentPreset(QString newName)
void removeCurrentPreset()
Remove the currently selected preset. Reload.
static bool isRunFromBuildFolder()
static QStringList getRootConfigPaths()
QDomElement getElement()
return the current element
void elastixParametersChanged()
ElastixParameters(XmlOptionFile options)
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
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 QString findExecutableInStandardLocations(QString filename)
look for an exe in the same folder as the executable or bundle.
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.
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.