35 #include <QVBoxLayout>
36 #include <QHBoxLayout>
55 mConfigFilesComboBox(new QComboBox()),
56 mConfigFileLineEdit(new QLineEdit()),
57 mReferenceComboBox(new QComboBox()),
62 mConfigFilesComboBox->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Expanding);
68 this->createTrackingSystemSelector();
76 QGridLayout* layout =
new QGridLayout(
this);
78 layout->addWidget(
new QLabel(
"Configuration: "), row, 0, 1, 1);
79 layout->addWidget(mConfigFilesComboBox, row, 1, 1, 1);
81 layout->addWidget(
new QLabel(
"File name: "), row, 0, 1, 1);
82 layout->addWidget(mConfigFileLineEdit, row, 1, 1, 1);
86 layout->addWidget(mToolListWidget, row, 0, 1, 2);
87 layout->setRowStretch(row, 1);
92 QHBoxLayout* refLayout =
new QHBoxLayout;
93 refLayout->addWidget(
new QLabel(
"Reference: "));
94 refLayout->addWidget(mReferenceComboBox);
95 refLayout->setMargin(0);
96 layout->addLayout(refLayout, row, 0, 1, 2);
99 connect(mConfigFilesComboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(configChangedSlot()));
100 connect(mToolListWidget, SIGNAL(listSizeChanged()),
this, SLOT(toolsChangedSlot()));
104 connect(mConfigFileLineEdit, SIGNAL(textEdited(
const QString&)),
this, SLOT(configEditedSlot()));
105 connect(mToolListWidget, SIGNAL(userChangedList()),
this, SLOT(configEditedSlot()));
106 connect(mReferenceComboBox, SIGNAL(activated(
int)),
this, SLOT(configEditedSlot()));
108 this->onApplicationStateChanged();
116 QString cleanPath = QDir(configAbsoluteFilePath).absolutePath();
117 int currentIndex = mConfigFilesComboBox->findData(cleanPath, Qt::ToolTipRole);
121 if (!configAbsoluteFilePath.isEmpty())
122 reportWarning(
"Tool configuration doesn't exist: " + cleanPath);
124 mConfigFilesComboBox->setCurrentIndex(currentIndex);
132 retval = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(), Qt::ToolTipRole).toString();
136 void ToolConfigureGroupBox::createTrackingSystemSelector()
138 QString defaultValue =
"";
141 "Select tracking system to use",
143 config->getSupportedTrackingSystems(),
145 connect(mTrackingSystemSelector.get(), SIGNAL(changed()),
this, SLOT(filterToolsSlot()));
150 return mTrackingSystemSelector;
165 config->saveConfiguration(current);
168 this->populateConfigurations();
173 void ToolConfigureGroupBox::onApplicationStateChanged()
175 QString application =
stateService()->getApplicationStateName();
176 this->setTitle(
"Tool configurations for "+ application);
177 this->populateConfigurations();
180 void ToolConfigureGroupBox::configChangedSlot()
182 QString uid = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(),
183 Qt::ToolTipRole).toString();
186 TrackerConfiguration::Configuration data = config->getConfiguration(uid);
187 bool isNewConfig = mConfigFilesComboBox->currentText().contains(
"<new config>");
192 data.mName =
"MyConfig";
195 mConfigFileLineEdit->setText(data.mName);
196 mConfigFileLineEdit->setEnabled(isNewConfig);
197 mConfigFileLineEdit->setToolTip(data.mUid);
199 mTrackingSystemSelector->setValue(data.mTrackingSystem);
203 void ToolConfigureGroupBox::configEditedSlot()
208 void ToolConfigureGroupBox::toolsChangedSlot()
210 this->populateReference();
211 this->filterToolsSlot();
214 void ToolConfigureGroupBox::filterToolsSlot()
216 QString ts = mTrackingSystemSelector->getValue();
217 mToolListWidget->
filterSlot(QStringList() << ts);
221 void ToolConfigureGroupBox::populateConfigurations()
223 mConfigFilesComboBox->clear();
226 QStringList configurations = config->getConfigurationsGivenApplication();
228 foreach(QString filename, configurations)
230 TrackerConfiguration::Configuration configuration = config->getConfiguration(filename);
231 this->addConfigurationToComboBox(configuration.mName, configuration.mUid);
233 QString newConfig =
"<new config>";
234 this->addConfigurationToComboBox(newConfig, newConfig);
236 int currentIndex = mConfigFilesComboBox->findText(newConfig);
237 mConfigFilesComboBox->setCurrentIndex(currentIndex);
240 int ToolConfigureGroupBox::addConfigurationToComboBox(QString displayName, QString absoluteFilePath)
242 mConfigFilesComboBox->addItem(displayName);
243 int index = mConfigFilesComboBox->findText(displayName);
244 mConfigFilesComboBox->setItemData(index, absoluteFilePath, Qt::ToolTipRole);
249 TrackerConfiguration::Configuration ToolConfigureGroupBox::getCurrentConfiguration()
251 TrackerConfiguration::Configuration retval;
253 QString application =
stateService()->getApplicationStateName();
255 QString filename = mConfigFileLineEdit->text();
256 QString filepath = config->getConfigurationApplicationsPath();
258 retval.mUid = QString(
"%1/%2.xml").arg(filepath).arg(filename);
259 retval.mClinicalApplication = application;
260 retval.mTrackingSystem = mTrackingSystemSelector->getValue();
261 retval.mTools = mToolListWidget->
getTools();
262 retval.mReferenceTool = mReferenceComboBox->itemData(mReferenceComboBox->currentIndex(), Qt::ToolTipRole).toString();
267 void ToolConfigureGroupBox::populateReference()
269 mReferenceComboBox->clear();
271 int currentIndex = -1;
276 QStringList selectedTools = mToolListWidget->
getTools();
277 foreach(QString
string, selectedTools)
279 if (config->getTool(
string).mIsReference)
280 currentIndex = this->addRefrenceToComboBox(
string);
284 QString configAbsoluteFilePath = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(), Qt::ToolTipRole).toString();
285 QString reference = config->getConfiguration(configAbsoluteFilePath).mReferenceTool;
286 currentIndex = this->addRefrenceToComboBox(reference);
292 mReferenceComboBox->setCurrentIndex(currentIndex);
295 int ToolConfigureGroupBox::addRefrenceToComboBox(QString absoluteRefereneFilePath)
299 QFile file(absoluteRefereneFilePath);
300 QFileInfo info(file);
301 QString refUid = info.dir().dirName();
303 QStringList selectedTools = mToolListWidget->
getTools();
304 if (!selectedTools.count(absoluteRefereneFilePath))
307 if (refUid.isEmpty())
310 if (mReferenceComboBox->findText(refUid) < 0)
311 mReferenceComboBox->addItem(refUid);
312 index = mReferenceComboBox->findText(refUid);
313 mReferenceComboBox->setItemData(index, info.absoluteFilePath(), Qt::ToolTipRole);
tsPOLARIS
NDIs Polaris tracker.
void applicationStateChanged()
cxLogicManager_EXPORT StateServicePtr stateService()
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
void reportWarning(QString msg)
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())
cxLogicManager_EXPORT TrackingServicePtr trackingService()
QString enum2string(const ENUM &val)