14 #include <QVBoxLayout> 15 #include <QHBoxLayout> 34 mConfigFilesComboBox(new QComboBox()),
35 mConfigFileLineEdit(new QLineEdit()),
36 mReferenceComboBox(new QComboBox()),
38 mTrackingService(trackingService),
39 mStateService(stateService)
43 mConfigFilesComboBox->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Expanding);
49 this->createTrackingSystemSelector();
57 QGridLayout* layout =
new QGridLayout(
this);
59 layout->addWidget(
new QLabel(
"Configuration: "), row, 0, 1, 1);
60 layout->addWidget(mConfigFilesComboBox, row, 1, 1, 1);
62 layout->addWidget(
new QLabel(
"File name: "), row, 0, 1, 1);
63 layout->addWidget(mConfigFileLineEdit, row, 1, 1, 1);
67 layout->addWidget(mToolListWidget, row, 0, 1, 2);
68 layout->setRowStretch(row, 1);
73 QHBoxLayout* refLayout =
new QHBoxLayout;
74 refLayout->addWidget(
new QLabel(
"Reference: "));
75 refLayout->addWidget(mReferenceComboBox);
76 refLayout->setMargin(0);
77 layout->addLayout(refLayout, row, 0, 1, 2);
80 connect(mConfigFilesComboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(configChangedSlot()));
81 connect(mToolListWidget, SIGNAL(listSizeChanged()),
this, SLOT(toolsChangedSlot()));
85 connect(mConfigFileLineEdit, SIGNAL(textEdited(
const QString&)),
this, SLOT(configEditedSlot()));
86 connect(mToolListWidget, SIGNAL(userChangedList()),
this, SLOT(configEditedSlot()));
87 connect(mReferenceComboBox, SIGNAL(activated(
int)),
this, SLOT(configEditedSlot()));
89 this->onApplicationStateChanged();
97 QString cleanPath = QDir(configAbsoluteFilePath).absolutePath();
98 int currentIndex = mConfigFilesComboBox->findData(cleanPath, Qt::ToolTipRole);
102 if (!configAbsoluteFilePath.isEmpty())
103 reportWarning(
"Tool configuration doesn't exist: " + cleanPath);
105 mConfigFilesComboBox->setCurrentIndex(currentIndex);
113 retval = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(), Qt::ToolTipRole).
toString();
117 void ToolConfigureGroupBox::createTrackingSystemSelector()
119 QString defaultValue =
"";
122 "Select tracking system to use",
124 config->getSupportedTrackingSystems(),
126 connect(mTrackingSystemSelector.get(), SIGNAL(changed()),
this, SLOT(filterToolsSlot()));
131 return mTrackingSystemSelector;
146 config->saveConfiguration(current);
149 this->populateConfigurations();
154 void ToolConfigureGroupBox::onApplicationStateChanged()
156 QString application = mStateService->getApplicationStateName();
157 this->setTitle(
"Tool configurations for "+ application);
158 this->populateConfigurations();
161 void ToolConfigureGroupBox::configChangedSlot()
163 QString uid = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(),
168 bool isNewConfig = mConfigFilesComboBox->currentText().contains(
"<new config>");
173 data.
mName =
"MyConfig";
176 mConfigFileLineEdit->setText(data.
mName);
177 mConfigFileLineEdit->setEnabled(isNewConfig);
178 mConfigFileLineEdit->setToolTip(data.
mUid);
185 void ToolConfigureGroupBox::configEditedSlot()
190 void ToolConfigureGroupBox::toolsChangedSlot()
192 this->populateReference();
193 this->filterToolsSlot();
196 void ToolConfigureGroupBox::filterToolsSlot()
198 QString ts = mTrackingSystemSelector->getValue();
199 mToolListWidget->
filterSlot(QStringList() << ts);
203 void ToolConfigureGroupBox::populateConfigurations()
205 mConfigFilesComboBox->clear();
208 QStringList configurations = config->getConfigurationsGivenApplication();
210 foreach(QString filename, configurations)
213 this->addConfigurationToComboBox(configuration.
mName, configuration.
mUid);
215 QString newConfig =
"<new config>";
216 this->addConfigurationToComboBox(newConfig, newConfig);
218 int currentIndex = mConfigFilesComboBox->findText(newConfig);
219 mConfigFilesComboBox->setCurrentIndex(currentIndex);
222 int ToolConfigureGroupBox::addConfigurationToComboBox(QString displayName, QString absoluteFilePath)
224 mConfigFilesComboBox->addItem(displayName);
225 int index = mConfigFilesComboBox->findText(displayName);
226 mConfigFilesComboBox->setItemData(index, absoluteFilePath, Qt::ToolTipRole);
235 QString application = mStateService->getApplicationStateName();
237 QString filename = mConfigFileLineEdit->text();
238 QString filepath = config->getConfigurationApplicationsPath();
240 retval.
mUid = QString(
"%1/%2.xml").arg(filepath).arg(filename);
245 retval.
mReferenceTool = mReferenceComboBox->itemData(mReferenceComboBox->currentIndex(), Qt::ToolTipRole).
toString();
255 QString ToolConfigureGroupBox::getCurrentConfigFilePath()
257 QString configAbsoluteFilePath = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(), Qt::ToolTipRole).
toString();
258 return configAbsoluteFilePath;
261 void ToolConfigureGroupBox::populateReference()
263 mReferenceComboBox->clear();
265 int currentIndex = -1;
270 QStringList selectedTools = mToolListWidget->
getTools();
271 foreach(QString
string, selectedTools)
273 if (config->getTool(
string).mIsReference)
274 currentIndex = this->addRefrenceToComboBox(
string);
278 QString reference = config->getConfiguration(this->getCurrentConfigFilePath()).mReferenceTool;
279 currentIndex = this->addRefrenceToComboBox(reference);
285 mReferenceComboBox->setCurrentIndex(currentIndex);
288 int ToolConfigureGroupBox::addRefrenceToComboBox(QString absoluteRefereneFilePath)
292 QFile file(absoluteRefereneFilePath);
293 QFileInfo info(file);
294 QString refUid = info.dir().dirName();
296 QStringList selectedTools = mToolListWidget->
getTools();
297 if (!selectedTools.count(absoluteRefereneFilePath))
300 if (refUid.isEmpty())
303 if (mReferenceComboBox->findText(refUid) < 0)
304 mReferenceComboBox->addItem(refUid);
305 index = mReferenceComboBox->findText(refUid);
306 mReferenceComboBox->setItemData(index, info.absoluteFilePath(), Qt::ToolTipRole);
tsPOLARIS
NDIs Polaris tracker.
void applicationStateChanged()
boost::shared_ptr< class StateService > StateServicePtr
std::string toString(T const &value)
converts any type to a string
boost::shared_ptr< class TrackingService > TrackingServicePtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
void reportWarning(QString msg)
QString mTrackingSystemName
QString mTrackingSystemImplementation
QString mUid
absolute path and filename for the new config file
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
QString mClinicalApplication
QString enum2string(const ENUM &val)
Namespace for all CustusX production code.