MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkNDIAuroraWidget.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14
17
18#include <QScrollBar>
19#include <QSettings>
20
21const std::string QmitkNDIAuroraWidget::VIEW_ID = "org.mitk.views.NDIAuroraWidget";
22
23QmitkNDIAuroraWidget::QmitkNDIAuroraWidget(QWidget* parent, Qt::WindowFlags f)
25 , m_Controls(nullptr)
26{
27}
28
30{
32 CreateQtPartControl(this);
33 CreateConnections();
34}
35
40
41void QmitkNDIAuroraWidget::CreateQtPartControl(QWidget *parent)
42{
43 if (!m_Controls)
44 {
45 // create GUI widgets
46 m_Controls = new Ui::QmitkNDIAuroraWidget;
47 m_Controls->setupUi(parent);
48 }
49}
50
51void QmitkNDIAuroraWidget::CreateConnections()
52{
53 if (m_Controls)
54 {
55 connect((QObject*)(m_Controls->m_testConnectionAurora), SIGNAL(clicked()), this, SLOT(TestConnection()));
56 connect((QObject*)(m_Controls->m_AutoScanAurora), SIGNAL(clicked()), this, SLOT(AutoScanPorts()));
57 //set a few UI components depending on Windows / Linux
58#ifdef WIN32
59 m_Controls->portTypeLabelAurora->setVisible(false);
60 m_Controls->portTypeAurora->setVisible(false);
61#else
62 m_Controls->comPortLabelAurora->setText("Port Nr:");
63 m_Controls->m_portSpinBoxAurora->setPrefix("");
64#endif
65 }
66}
67
69{
70 m_Controls->m_outputTextAurora->setHtml("<body style=\" font-family:\'MS Shell Dlg 2\'; font-size:7pt; font-weight:400; font-style:normal;\" bgcolor=black><span style=\"color:#ffffff;\"><u>output:</u>");
71}
72
74{
75 m_Controls->m_outputTextAurora->setHtml(QString(s.c_str()));
76 m_Controls->m_outputTextAurora->verticalScrollBar()->setValue(m_Controls->m_outputTextAurora->verticalScrollBar()->maximum());
77}
78
79mitk::TrackingDevice::Pointer QmitkNDIAuroraWidget::GetTrackingDevice()
80{
81 mitk::NDITrackingDevice::Pointer tempTrackingDevice = mitk::NDITrackingDevice::New();
82
83 //get port
84 int port = 0;
85 port = m_Controls->m_portSpinBoxAurora->value();
86
87 //build prefix (depends on linux/win)
88 QString prefix = "";
89#ifdef WIN32
90 prefix = "COM";
91 tempTrackingDevice->SetPortNumber(static_cast<mitk::SerialCommunication::PortNumber>(port)); //also set the com port for compatibility
92#else
93 prefix = m_Controls->portTypeAurora->currentText();
94#endif
95
96 //build port name string
97 QString portName = prefix + QString::number(port);
98
99 tempTrackingDevice->SetDeviceName(portName.toStdString()); //set the port name
100 tempTrackingDevice->SetBaudRate(mitk::SerialCommunication::BaudRate115200);//set baud rate
101 tempTrackingDevice->SetType(mitk::NDIAuroraTypeInformation::GetTrackingDeviceName());
102 return static_cast<mitk::TrackingDevice::Pointer>(tempTrackingDevice);
103}
104
106{
107 std::string id = "org.mitk.modules.igt.ui.trackingdeviceconfigurationwidget";
108 if (this->GetPersistenceService()) // now save the settings using the persistence service
109 {
110 mitk::PropertyList::Pointer propList = this->GetPersistenceService()->GetPropertyList(id);
111 propList->Set("AuroraPortWin", m_Controls->m_portSpinBoxAurora->value());
112 propList->Set("PortTypeAurora", m_Controls->portTypeAurora->currentIndex());
113 }
114 else // QSettings as a fallback if the persistence service is not available
115 {
116 QSettings settings;
117 settings.beginGroup(QString::fromStdString(id));
118 settings.setValue("portSpinBoxAurora", QVariant(m_Controls->m_portSpinBoxAurora->value()));
119 settings.setValue("portTypeAurora", QVariant(m_Controls->portTypeAurora->currentIndex()));
120 settings.endGroup();
121 }
122}
123
125{
126 std::string id = "org.mitk.modules.igt.ui.trackingdeviceconfigurationwidget";
127 if (this->GetPersistenceService())
128 {
129 int port = 0;
130 int portType = 0;
131 mitk::PropertyList::Pointer propList = this->GetPersistenceService()->GetPropertyList(id);
132 if (propList.IsNull())
133 {
134 MITK_ERROR << "Property list for this UI (" << id << ") is not available, could not load UI settings!"; return;
135 }
136
137 propList->Get("AuroraPortWin", port);
138 propList->Get("PortTypeAurora", portType);
139 this->SetPortTypeToGUI(portType);
140 this->SetPortValueToGUI(port);
141 }
142 else
143 {
144 // QSettings as a fallback if the persistence service is not available
145 QSettings settings;
146 settings.beginGroup(QString::fromStdString(id));
147
148 m_Controls->m_portSpinBoxAurora->setValue(settings.value("portSpinBoxAurora", 0).toInt());
149 m_Controls->portTypeAurora->setCurrentIndex(settings.value("portTypeAurora", 0).toInt());
150
151 settings.endGroup();
152 }
153}
154
156 m_Controls->m_portSpinBoxAurora->setValue(portValue);
157}
159 m_Controls->portTypeAurora->setCurrentIndex(portType);
160}
161
163{
164 QmitkNDIAuroraWidget* clonedWidget = new QmitkNDIAuroraWidget(parent);
165 clonedWidget->Initialize();
166
167 clonedWidget->SetPortTypeToGUI(m_Controls->portTypeAurora->currentIndex());
168 clonedWidget->SetPortValueToGUI(m_Controls->m_portSpinBoxAurora->value());
169 return clonedWidget;
170}
Abstract class of a configuration widget for NDI Devices. For implementations see NDIAuroraWidget or ...
Implementation of a configuration widget for NDI Aurora Devices.
void Initialize() override
Subclass must implement this method to return a pointer to a copy of the object. Please don't forget ...
mitk::TrackingDevice::Pointer GetTrackingDevice() override
QmitkNDIAuroraWidget(QWidget *parent=nullptr, Qt::WindowFlags f={})
Ui::QmitkNDIAuroraWidget * m_Controls
QmitkNDIAuroraWidget * Clone(QWidget *parent) const override
Subclass must implement this method to return a pointer to a copy of the object. Please don't forget ...
void LoadUISettings() override
Optional method to store and load settings of your widget (see QmitkNDIPolarisWidget)
static const std::string VIEW_ID
void ResetOutput() override
Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget)
void SetPortTypeToGUI(int portType) override
void SetPortValueToGUI(int portValue) override
void AddOutput(std::string s) override
Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget)
void StoreUISettings() override
Optional method to store and load settings of your widget (see QmitkNDIPolarisWidget)