Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkIGTLMessageSourceSelectionWidget.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found 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;
26  CreateQtPartControl(this);
27 }
28 
29 
31 {
32 
33 }
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)),
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 
81 {
82  return this->m_CurrentIGTLMessageSource;
83 }
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 }
mitk::IGTLMessageSource::Pointer AutoSelectFirstIGTLMessageSource()
Automatically selects the first available OpenIGTLink message source of the messageSourceSelectionWid...
QmitkIGTLMessageSourceSelectionWidget(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
void IGTLMessageSourceSelected(mitk::IGTLMessageSource::Pointer source)
This signal is emitted when a new OpenIGTLink message source is selected.
#define MITK_WARN
Definition: mitkLogMacros.h:19
mitk::IGTLMessageSource::Pointer GetSelectedIGTLMessageSource()
OpenIGTLink message source.
static const std::string US_PROPKEY_DEVICENAME
virtual void CreateConnections()
Creation of the connections.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Ui::QmitkIGTLMessageSourceSelectionWidgetControls * m_Controls