Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <QThread>
20 
22  : QWidget(parent, f)
23  , isInitialized(false)
24  , m_TestConnectionWorker(NULL)
25  , m_TestConnectionWorkerThread(NULL)
26  , m_ErrorMessage("")
27 {
28 }
29 
31 {
32  m_TestConnectionWorkerThread = new QThread();
34  CreateConnections();
35  m_ErrorMessage = "";
36  isInitialized = true;
37 }
38 
42 }
43 
45 {
47  AddOutput(output.toStdString());
48  MITK_INFO << "Test connection: " << connected;
49  this->setEnabled(true);
50 }
51 
53 {
54  this->setEnabled(false);
55  //construct a tracking device:
57  m_TestConnectionWorker->SetTrackingDevice(testTrackingDevice);
59 }
60 
61 void QmitkAbstractTrackingDeviceWidget::CreateConnections() {
62  connect(m_TestConnectionWorker, SIGNAL(ConnectionTested(bool, QString)), this, SLOT(TestConnectionFinished(bool, QString)));
63  connect(m_TestConnectionWorkerThread, SIGNAL(started()), m_TestConnectionWorker, SLOT(TestConnectionThreadFunc()));
64 
65  //move the worker to the thread
67 }
68 
70 {
71  QmitkAbstractTrackingDeviceWidget* clonedWidget = this->Clone(parent);
72  if (!clonedWidget->IsInitialized())
73  MITK_ERROR << "Your cloned widget is not initialized!";
74  clonedWidget->create();
75 
76  return clonedWidget;
77 }
void ConnectionTested(bool connected, QString output)
itk::SmartPointer< Self > Pointer
#define MITK_INFO
Definition: mitkLogMacros.h:22
#define MITK_ERROR
Definition: mitkLogMacros.h:24
QmitkTrackingDeviceConfigurationWidgetConnectionWorker * m_TestConnectionWorker
std::string m_ErrorMessage
current problem description
virtual void AddOutput(std::string)
Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget) ...
virtual QmitkAbstractTrackingDeviceWidget * Clone(QWidget *parent=0) const =0
Subclass must implement this method to return a pointer to a copy of the object. Please don't forget ...
void TestConnectionFinished(bool connected, QString output)
QmitkAbstractTrackingDeviceWidget * CloneForQt(QWidget *parent=0) const
Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with add...
virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice()=0
PERSISTENCE_GET_SERVICE_METHOD_MACRO void InitializeSuperclassWidget()
Abstract class to configure a tracking device. Inherited widgets should be registered in the Microser...
QmitkAbstractTrackingDeviceWidget(QWidget *parent=0, Qt::WindowFlags f=0)