28 , m_TrackingDevice(nullptr)
29 , m_DeviceToWidgetIndexMap()
59 m_Controls =
new Ui::QmitkTrackingDeviceConfigurationWidgetControls;
74 const std::string currentDevice = this->GetCurrentDeviceName();
77 m_Controls->m_TrackingSystemWidget->setCurrentIndex(m_DeviceToWidgetIndexMap[currentDevice]);
99 for (
auto& item : m_DeviceToWidgetIndexMap)
101 m_Controls->m_TrackingSystemWidget->removeWidget(
m_Controls->m_TrackingSystemWidget->widget(item.second));
102 MITK_INFO <<
"removing widget for device '" << item.first <<
"'";
107 m_DeviceToWidgetIndexMap.clear();
111 std::vector<us::ServiceReference<mitk::TrackingDeviceTypeCollection> > deviceRefs =
114 if (deviceRefs.empty())
116 MITK_ERROR <<
"No tracking device type service found!";
121 std::vector<us::ServiceReference<mitk::TrackingDeviceWidgetCollection> > widgetRefs =
124 if (widgetRefs.empty())
126 MITK_ERROR <<
"No tracking device configuration widget service found!";
142 if (
m_Controls->m_TrackingDeviceChooser->findText(QString::fromStdString(name)) == -1)
144 m_Controls->m_TrackingDeviceChooser->addItem(QString::fromStdString(name));
145 QWidget* current = deviceWidgetCollection->GetTrackingDeviceWidgetClone(name);
146 if (current ==
nullptr)
148 MITK_WARN <<
"No widget for tracking device type " << name <<
" available. Please implement and register it!";
149 current =
new QWidget();
152 m_DeviceToWidgetIndexMap[name] =
m_Controls->m_TrackingSystemWidget->addWidget(current);
156 if (!m_DeviceToWidgetIndexMap.empty())
158 m_Controls->m_TrackingDeviceChooser->setCurrentIndex(0);
159 m_Controls->m_TrackingSystemWidget->setCurrentIndex(0);
162 context->UngetService(deviceServiceReference);
163 context->UngetService(widgetServiceReference);
171 if (currentWidget ==
nullptr)
177 currentWidget->repaint();
184 if (currentWidget ==
nullptr)
190 currentWidget->repaint();
197 if (currentWidget ==
nullptr)
214 std::string
id =
"org.mitk.modules.igt.ui.trackingdeviceconfigurationwidget";
216 std::string selectedDevice = this->GetCurrentDeviceName();
220 for (
int index = 0; index <
m_Controls->m_TrackingSystemWidget->count(); index++)
224 if (widget !=
nullptr)
233 propList->Set(
"SelectedDevice", selectedDevice);
238 settings.beginGroup(QString::fromStdString(
id));
239 settings.setValue(
"trackingDeviceChooser", QVariant(QString::fromStdString(selectedDevice)));
254 for (
int index = 0; index <
m_Controls->m_TrackingSystemWidget->count(); index++)
258 if (widget !=
nullptr)
264 std::string
id =
"org.mitk.modules.igt.ui.trackingdeviceconfigurationwidget";
265 std::string selectedDevice;
269 if (propList.IsNull())
271 MITK_ERROR <<
"Property list for this UI (" <<
id <<
") is not available, could not load UI settings!";
return;
274 propList->Get(
"SelectedDevice", selectedDevice);
276 if (selectedDevice.empty())
278 MITK_ERROR <<
"Loaded data from persistence service is invalid (SelectedDevice:" << selectedDevice <<
"): aborted to restore data!";
282 MITK_INFO <<
"Successfully restored UI settings";
288 settings.beginGroup(QString::fromStdString(
id));
290 selectedDevice = settings.value(
"trackingDeviceChooser",
"").toString().toStdString();
298 const auto& deviceIterator = m_DeviceToWidgetIndexMap.find(selectedDevice);
300 if (deviceIterator != m_DeviceToWidgetIndexMap.end())
315 const int index =
m_Controls->m_TrackingDeviceChooser->findText(QString::fromStdString(selectedDevice));
319 m_Controls->m_TrackingDeviceChooser->setCurrentIndex(index);
323 MITK_ERROR <<
"Failed to load UI setting for tracking device configuration";
327 m_Controls->m_TrackingSystemWidget->setCurrentIndex(m_DeviceToWidgetIndexMap[selectedDevice]);
330 std::string QmitkTrackingDeviceConfigurationWidget::GetCurrentDeviceName(
void)
const
332 return m_Controls->m_TrackingDeviceChooser->currentText().toStdString();
337 const auto& deviceIterator = m_DeviceToWidgetIndexMap.find(deviceName);
339 if (deviceIterator != m_DeviceToWidgetIndexMap.end())
341 QWidget* widget =
m_Controls->m_TrackingSystemWidget->widget(deviceIterator->second);
itk::SmartPointer< Self > Pointer
This class is a collection for information of all Tracking Device Types (derived from abstract Tracki...
std::vector< std::string > GetTrackingDeviceTypeNames()
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.