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->createGUISelectors();
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);
71 layout->addWidget(mToolListWidget, row, 0, 1, 2);
72 layout->setRowStretch(row, 1);
77 QHBoxLayout* refLayout =
new QHBoxLayout;
78 refLayout->addWidget(
new QLabel(
"Reference: "));
79 refLayout->addWidget(mReferenceComboBox);
80 refLayout->setMargin(0);
81 layout->addLayout(refLayout, row, 0, 1, 2);
84 connect(mConfigFilesComboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(configChangedSlot()));
85 connect(mToolListWidget, SIGNAL(listSizeChanged()),
this, SLOT(toolsChangedSlot()));
89 connect(mConfigFileLineEdit, SIGNAL(textEdited(
const QString&)),
this, SLOT(configEditedSlot()));
90 connect(mToolListWidget, SIGNAL(userChangedList()),
this, SLOT(configEditedSlot()));
91 connect(mReferenceComboBox, SIGNAL(activated(
int)),
this, SLOT(configEditedSlot()));
93 this->onApplicationStateChanged();
101 QString cleanPath = QDir(configAbsoluteFilePath).absolutePath();
102 int currentIndex = mConfigFilesComboBox->findData(cleanPath, Qt::ToolTipRole);
106 if (!configAbsoluteFilePath.isEmpty())
107 reportWarning(
"Tool configuration doesn't exist: " + cleanPath);
109 mConfigFilesComboBox->setCurrentIndex(currentIndex);
117 retval = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(), Qt::ToolTipRole).toString();
121 void ToolConfigureGroupBox::createGUISelectors()
123 QString defaultValue =
"";
128 "Select tracking system to use",
130 config->getSupportedTrackingSystems(),
132 connect(mTrackingSystemSelector.get(), &
StringProperty::changed,
this, &ToolConfigureGroupBox::filterToolsSlot);
134 mTrackingSystemImplementationSelector =
StringProperty::initialize(
"trackingSystemImplementation",
"Tracking System Implementation",
135 "Select tracking system implementation to use",
137 this->getTrackingSystemImplementationList(),
139 connect(mTrackingSystemImplementationSelector.get(), &
StringProperty::changed,
this, &ToolConfigureGroupBox::trackingSystemImplementationChangedSlot);
142 "Apply ref tool position to other tools for transforms received over OpenIGTLink.",
145 connect(mApplyRefToTools.get(), &
BoolProperty::changed,
this, &ToolConfigureGroupBox::applyRefToToolsChangedSlot);
148 QStringList ToolConfigureGroupBox::getTrackingSystemImplementationList()
151 std::vector<TrackerConfigurationPtr> configs = mTrackingService->getConfigurations();
153 for (
unsigned i=0; i<configs.size(); ++i)
155 retval << configs[i]->getTrackingSystemImplementation();
160 void ToolConfigureGroupBox::trackingSystemImplementationChangedSlot()
162 QString systemImplementation = mTrackingSystemImplementationSelector->getValue();
163 mTrackingService->setCurrentTrackingSystemImplementation(systemImplementation);
165 mApplyRefToTools->setEnabled(
true);
167 mApplyRefToTools->setEnabled(
false);
172 void ToolConfigureGroupBox::applyRefToToolsChangedSlot()
179 return mTrackingSystemSelector;
194 config->saveConfiguration(current);
197 this->populateConfigurations();
202 void ToolConfigureGroupBox::onApplicationStateChanged()
204 QString application = mStateService->getApplicationStateName();
205 this->setTitle(
"Tool configurations for "+ application);
206 this->populateConfigurations();
209 void ToolConfigureGroupBox::configChangedSlot()
211 QString uid = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(),
212 Qt::ToolTipRole).toString();
216 bool isNewConfig = mConfigFilesComboBox->currentText().contains(
"<new config>");
221 data.
mName =
"MyConfig";
224 mConfigFileLineEdit->setText(data.
mName);
225 mConfigFileLineEdit->setEnabled(isNewConfig);
226 mConfigFileLineEdit->setToolTip(data.
mUid);
234 void ToolConfigureGroupBox::configEditedSlot()
239 void ToolConfigureGroupBox::toolsChangedSlot()
241 this->populateReference();
242 this->filterToolsSlot();
245 void ToolConfigureGroupBox::filterToolsSlot()
247 QString ts = mTrackingSystemSelector->getValue();
248 mToolListWidget->
filterSlot(QStringList() << ts);
252 void ToolConfigureGroupBox::populateConfigurations()
254 mConfigFilesComboBox->clear();
257 QStringList configurations = config->getConfigurationsGivenApplication();
259 foreach(QString filename, configurations)
262 this->addConfigurationToComboBox(configuration.
mName, configuration.
mUid);
264 QString newConfig =
"<new config>";
265 this->addConfigurationToComboBox(newConfig, newConfig);
267 int currentIndex = mConfigFilesComboBox->findText(newConfig);
268 mConfigFilesComboBox->setCurrentIndex(currentIndex);
271 int ToolConfigureGroupBox::addConfigurationToComboBox(QString displayName, QString absoluteFilePath)
273 mConfigFilesComboBox->addItem(displayName);
274 int index = mConfigFilesComboBox->findText(displayName);
275 mConfigFilesComboBox->setItemData(index, absoluteFilePath, Qt::ToolTipRole);
284 QString application = mStateService->getApplicationStateName();
286 QString filename = mConfigFileLineEdit->text();
287 QString filepath = config->getConfigurationApplicationsPath();
289 retval.
mUid = QString(
"%1/%2.xml").arg(filepath).arg(filename);
295 retval.
mReferenceTool = mReferenceComboBox->itemData(mReferenceComboBox->currentIndex(), Qt::ToolTipRole).toString();
305 QString ToolConfigureGroupBox::getCurrentConfigFilePath()
307 QString configAbsoluteFilePath = mConfigFilesComboBox->itemData(mConfigFilesComboBox->currentIndex(), Qt::ToolTipRole).toString();
308 return configAbsoluteFilePath;
311 void ToolConfigureGroupBox::populateReference()
313 mReferenceComboBox->clear();
315 int currentIndex = -1;
320 QStringList selectedTools = mToolListWidget->
getTools();
321 foreach(QString
string, selectedTools)
323 if (config->getTool(
string).mIsReference)
324 currentIndex = this->addRefrenceToComboBox(
string);
328 QString reference = config->getConfiguration(this->getCurrentConfigFilePath()).mReferenceTool;
329 currentIndex = this->addRefrenceToComboBox(reference);
335 mReferenceComboBox->setCurrentIndex(currentIndex);
338 int ToolConfigureGroupBox::addRefrenceToComboBox(QString absoluteRefereneFilePath)
342 QFile file(absoluteRefereneFilePath);
343 QFileInfo info(file);
344 QString refUid = info.dir().dirName();
346 QStringList selectedTools = mToolListWidget->
getTools();
347 if (!selectedTools.count(absoluteRefereneFilePath))
350 if (refUid.isEmpty())
353 if (mReferenceComboBox->findText(refUid) < 0)
354 mReferenceComboBox->addItem(refUid);
355 index = mReferenceComboBox->findText(refUid);
356 mReferenceComboBox->setItemData(index, info.absoluteFilePath(), Qt::ToolTipRole);
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
tsPOLARIS
NDIs Polaris tracker.
void applicationStateChanged()
boost::shared_ptr< class StateService > StateServicePtr
boost::shared_ptr< class TrackingService > TrackingServicePtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
void reportWarning(QString msg)
const char * TRACKING_SYSTEM_IMPLEMENTATION_IGTLINK
QString mTrackingSystemName
QString mTrackingSystemImplementation
QString mUid
absolute path and filename for the new config file
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())
QString mClinicalApplication
QString enum2string(const ENUM &val)
Namespace for all CustusX production code.