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)
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();
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();
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.
Namespace for all CustusX production code.