Medical Imaging Interaction Toolkit  2018.4.99-c7ee88da
Medical Imaging Interaction Toolkit
QmitkAbstractTrackingDeviceWidget.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 #include <QThread>
16 
18  : QWidget(parent, f)
19  , m_TestConnectionWorker(nullptr)
20  , m_TestConnectionWorkerThread(nullptr)
21  , m_ErrorMessage("")
22  , isInitialized(false)
23 {
24 }
25 
27 {
28  m_TestConnectionWorkerThread = new QThread();
30  CreateConnections();
31  m_ErrorMessage = "";
32  isInitialized = true;
33 }
34 
38 }
39 
41 {
43  AddOutput(output.toStdString());
44  MITK_INFO << "Test connection: " << connected;
45  this->setEnabled(true);
46 }
47 
49 {
50  this->setEnabled(false);
51  //construct a tracking device:
52  mitk::TrackingDevice::Pointer testTrackingDevice = GetTrackingDevice();
53  m_TestConnectionWorker->SetTrackingDevice(testTrackingDevice);
55 }
56 
57 void QmitkAbstractTrackingDeviceWidget::CreateConnections() {
58  connect(m_TestConnectionWorker, SIGNAL(ConnectionTested(bool, QString)), this, SLOT(TestConnectionFinished(bool, QString)));
59  connect(m_TestConnectionWorkerThread, SIGNAL(started()), m_TestConnectionWorker, SLOT(TestConnectionThreadFunc()));
60 
61  //move the worker to the thread
63 }
64 
66 {
67  QmitkAbstractTrackingDeviceWidget* clonedWidget = this->Clone(parent);
68  if (!clonedWidget->IsInitialized())
69  MITK_ERROR << "Your cloned widget is not initialized!";
70  clonedWidget->create();
71 
72  return clonedWidget;
73 }
void ConnectionTested(bool connected, QString output)
#define MITK_INFO
Definition: mitkLogMacros.h:18
#define MITK_ERROR
Definition: mitkLogMacros.h:20
QmitkTrackingDeviceConfigurationWidgetConnectionWorker * m_TestConnectionWorker
std::string m_ErrorMessage
current problem description
QmitkAbstractTrackingDeviceWidget(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
virtual void AddOutput(std::string)
Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget) ...
virtual QmitkAbstractTrackingDeviceWidget * Clone(QWidget *parent=nullptr) const =0
Subclass must implement this method to return a pointer to a copy of the object. Please don&#39;t forget ...
void TestConnectionFinished(bool connected, QString output)
PERSISTENCE_GET_SERVICE_METHOD_MACRO void InitializeSuperclassWidget()
Abstract class to configure a tracking device. Inherited widgets should be registered in the Microser...
QmitkAbstractTrackingDeviceWidget * CloneForQt(QWidget *parent=nullptr) const
Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with add...
virtual mitk::TrackingDevice::Pointer GetTrackingDevice()=0