MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkIGTLMessageSourceSelectionWidget.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
15//mitk headers
16#include <usGetModuleContext.h>
17#include <usServiceReference.h>
18
19
20
22 QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f)
23{
24 m_Controls = nullptr;
27}
28
29
34
36{
37 if ( !m_Controls )
38 {
39 // create GUI widgets
40 m_Controls = new Ui::QmitkIGTLMessageSourceSelectionWidgetControls;
41 // setup GUI widgets
42 m_Controls->setupUi(parent);
43 }
44
46}
47
49{
50 if ( m_Controls )
51 {
52 connect( m_Controls->m_ServiceListWidget,
53 SIGNAL(ServiceSelectionChanged(us::ServiceReferenceU)),
54 this, SLOT(IGTLMessageSourceSelected(us::ServiceReferenceU)) );
55
56 //initialize service list widget
57 std::string empty = "";
58 m_Controls->m_ServiceListWidget->Initialize<mitk::IGTLMessageSource>(
60 }
61}
62
64 {
65 if (!s) //nothing selected
66 {
67 //reset everything
68 this->m_CurrentIGTLMessageSource = nullptr;
70 return;
71 }
72
73 // Get storage
74 us::ModuleContext* context = us::GetModuleContext();
76 context->GetService<mitk::IGTLMessageSource>(s);
78 }
79
84
86{
87 if( m_Controls->m_ServiceListWidget->GetAllServiceReferences().size() != 0 )
88 {
89 us::ModuleContext* context = us::GetModuleContext();
91 context->GetService<mitk::IGTLMessageSource>(
92 m_Controls->m_ServiceListWidget->GetAllServiceReferences().at(0) );
93 }
94 else
95 {
96 this->m_CurrentIGTLMessageSource = nullptr;
97 MITK_WARN("CurrentIGTLMessageSource") << "There was no OpenIGTLink message source to select."
98 << "The OpenIGTLink message source must be selected manually.";
99 }
100
101 return this->m_CurrentIGTLMessageSource;
102}
virtual void CreateConnections()
Creation of the connections.
Ui::QmitkIGTLMessageSourceSelectionWidgetControls * m_Controls
mitk::IGTLMessageSource::Pointer GetSelectedIGTLMessageSource()
void IGTLMessageSourceSelected(mitk::IGTLMessageSource::Pointer source)
This signal is emitted when a new OpenIGTLink message source is selected.
QmitkIGTLMessageSourceSelectionWidget(QWidget *parent=nullptr, Qt::WindowFlags f={})
mitk::IGTLMessageSource::Pointer AutoSelectFirstIGTLMessageSource()
Automatically selects the first available OpenIGTLink message source of the messageSourceSelectionWid...
OpenIGTLink message source.
static const std::string US_PROPKEY_DEVICENAME