Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkNPOptitrackWidget.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 
17 #include "QmitkNPOptitrackWidget.h"
18 
21 
22 #include <QFileDialog>
23 #include <QScrollBar>
24 #include <Poco/Path.h>
25 
26 const std::string QmitkNPOptitrackWidget::VIEW_ID = "org.mitk.views.NPOptitrackWidget";
27 
28 QmitkNPOptitrackWidget::QmitkNPOptitrackWidget(QWidget* parent, Qt::WindowFlags f)
30  , m_Controls(nullptr)
31 {
32 }
33 
35 {
37  CreateQtPartControl(this);
38  CreateConnections();
39 }
40 
42 {
43  delete m_Controls;
44 }
45 
46 void QmitkNPOptitrackWidget::CreateQtPartControl(QWidget *parent)
47 {
48  if (!m_Controls)
49  {
50  // create GUI widgets
51  m_Controls = new Ui::QmitkNPOptitrackWidget;
52  m_Controls->setupUi(parent);
53  }
54 }
55 
56 void QmitkNPOptitrackWidget::CreateConnections()
57 {
58  if (m_Controls)
59  {
60  connect((QObject*)(m_Controls->m_testConnectionOptitrack), SIGNAL(clicked()), this, SLOT(TestConnection()));
61  connect((QObject*)(m_Controls->m_SetOptitrackCalibrationFile), SIGNAL(clicked()), this, SLOT(SetOptitrackCalibrationFileClicked()));
62  }
63 }
64 
66 {
67  m_Controls->m_outputTextOptitrack->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>");
68 }
69 
71 {
72  m_Controls->m_outputTextOptitrack->setHtml(QString(s.c_str()));
73  m_Controls->m_outputTextOptitrack->verticalScrollBar()->setValue(m_Controls->m_outputTextOptitrack->verticalScrollBar()->maximum());
74 }
75 
77 {
78  // Create the Tracking Device
80  // Set the calibration File
81  tempTrackingDevice->SetCalibrationPath(m_OptitrackCalibrationFile);
82 
83  //Set the camera parameters
84  tempTrackingDevice->SetExp(m_Controls->m_OptitrackExp->value());
85  tempTrackingDevice->SetLed(m_Controls->m_OptitrackLed->value());
86  tempTrackingDevice->SetThr(m_Controls->m_OptitrackThr->value());
87 
89  return static_cast<mitk::TrackingDevice::Pointer>(tempTrackingDevice);
90 }
91 
93 {
94  return mitk::OptitrackTrackingDevice::New()->IsDeviceInstalled();
95 }
96 
98 {
99  std::string filename = QFileDialog::getOpenFileName(NULL, tr("Open Calibration File"), "/", "*.*").toLatin1().data();
100  if (filename == "") { return; }
101  else
102  {
104  Poco::Path myPath = Poco::Path(m_OptitrackCalibrationFile.c_str());
105  m_Controls->m_OptitrackCalibrationFile->setText("Calibration File: " + QString(myPath.getFileName().c_str()));
106  }
107 }
108 
110 {
111  QmitkNPOptitrackWidget* clonedWidget = new QmitkNPOptitrackWidget(parent);
112  clonedWidget->Initialize();
114  clonedWidget->m_Controls->m_OptitrackCalibrationFile->setText(m_Controls->m_OptitrackCalibrationFile->text());
115 
116  clonedWidget->m_Controls->m_OptitrackExp->setValue(m_Controls->m_OptitrackExp->value());
117  clonedWidget->m_Controls->m_OptitrackLed->setValue(m_Controls->m_OptitrackLed->value());
118  clonedWidget->m_Controls->m_OptitrackThr->setValue(m_Controls->m_OptitrackThr->value());
119  return clonedWidget;
120 }
itk::SmartPointer< Self > Pointer
virtual void AddOutput(std::string s)
Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget) ...
virtual void ResetOutput()
Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget) ...
virtual bool IsDeviceInstalled()
Optional method to investigate if drivers etc for your device are installed. The default value is "tr...
virtual void Initialize()
Subclass must implement this method to return a pointer to a copy of the object. Please don't forget ...
Ui::QmitkNPOptitrackWidget * m_Controls
Implementation of a configuration widget for NP Optitrack Tracking Devices.
static const std::string filename
virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice()
QmitkNPOptitrackWidget(QWidget *parent=0, Qt::WindowFlags f=0)
virtual QmitkNPOptitrackWidget * Clone(QWidget *parent) const
Subclass must implement this method to return a pointer to a copy of the object. Please don't forget ...
PERSISTENCE_GET_SERVICE_METHOD_MACRO void InitializeSuperclassWidget()
Abstract class to configure a tracking device. Inherited widgets should be registered in the Microser...
static const std::string VIEW_ID