Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkToFPMDParameterWidget.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 
13 //#define _USE_MATH_DEFINES
15 
16 //QT headers
17 #include <qmessagebox.h>
18 #include <qfiledialog.h>
19 #include <qcombobox.h>
20 
21 //itk headers
22 #include <itksys/SystemTools.hxx>
23 
24 const std::string QmitkToFPMDParameterWidget::VIEW_ID = "org.mitk.views.qmitktofpmdparameterwidget";
25 
26 QmitkToFPMDParameterWidget::QmitkToFPMDParameterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
27 {
28  this->m_IntegrationTime = 0;
29  this->m_ModulationFrequency = 0;
30  this->m_ToFImageGrabber = nullptr;
31 
32  m_Controls = nullptr;
33  CreateQtPartControl(this);
34 }
35 
37 {
38 }
39 
41 {
42  if (!m_Controls)
43  {
44  // create GUI widgets
45  m_Controls = new Ui::QmitkToFPMDParameterWidgetControls;
46  m_Controls->setupUi(parent);
47  this->CreateConnections();
48  }
49 }
50 
52 {
53  if ( m_Controls )
54  {
55  connect( m_Controls->m_IntegrationTimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeIntegrationTimeSpinBox(int)) );
56  connect( m_Controls->m_ModulationFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeModulationFrequencySpinBox(int)) );
57  }
58 }
59 
61 {
62  return this->m_ToFImageGrabber;
63 }
64 
66 {
67  this->m_ToFImageGrabber = aToFImageGrabber;
68 }
69 
71 {
72  this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value();
74 
75  this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value();
77 
78  //set the PMD calibration according to the check boxes
79  bool boolValue = false;
80  boolValue = m_Controls->m_FPNCalibCB->isChecked();
81  this->m_ToFImageGrabber->SetBoolProperty("SetFPNCalibration", boolValue);
82  boolValue = m_Controls->m_FPPNCalibCB->isChecked();
83  this->m_ToFImageGrabber->SetBoolProperty("SetFPPNCalibration", boolValue);
84  boolValue = m_Controls->m_LinearityCalibCB->isChecked();
85  this->m_ToFImageGrabber->SetBoolProperty("SetLinearityCalibration", boolValue);
86  boolValue = m_Controls->m_LensCorrection->isChecked();
87  this->m_ToFImageGrabber->SetBoolProperty("SetLensCalibration", boolValue);
88  boolValue = m_Controls->m_ExposureModeCB->isChecked();
89  this->m_ToFImageGrabber->SetBoolProperty("SetExposureMode", boolValue);
90 
91  //reset the GUI elements
92  m_Controls->m_IntegrationTimeSpinBox->setValue(this->m_ToFImageGrabber->GetIntegrationTime());
93  m_Controls->m_ModulationFrequencySpinBox->setValue(this->m_ToFImageGrabber->GetModulationFrequency());
94 }
95 
97 {
98  if (this->m_ToFImageGrabber != nullptr)
99  {
100  // stop camera if active
101  bool active = m_ToFImageGrabber->IsCameraActive();
102  if (active)
103  {
105  }
106  this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value();
107  int validIntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime);
108  if(validIntegrationTime != m_IntegrationTime)
109  {
110  this->m_Controls->m_IntegrationTimeSpinBox->setValue(validIntegrationTime);
111  this->m_IntegrationTime = validIntegrationTime;
112  }
113  if (active)
114  {
116  }
117  }
118 }
119 
121 {
122  if (this->m_ToFImageGrabber != nullptr)
123  {
124  // stop camera if active
125  bool active = m_ToFImageGrabber->IsCameraActive();
126  if (active)
127  {
129  }
130  this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value();
131  int validMFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency);
132  if(validMFrequency != m_ModulationFrequency)
133  {
134  this->m_Controls->m_ModulationFrequencySpinBox->setValue(validMFrequency);
135  this->m_ModulationFrequency = validMFrequency;
136  }
137  if (active)
138  {
140  }
141  }
142 }
143 
virtual void StopCamera()
Stops the continuous updating of the camera.
Ui::QmitkToFPMDParameterWidgetControls * m_Controls
member holding the UI elements of this widget
int SetIntegrationTime(int integrationTime)
Set the integration time used by the ToF camera. For default values see the corresponding device clas...
int m_ModulationFrequency
member for the current modulation frequency of the ToF device
virtual bool IsCameraActive()
Returns true if the camera is connected and started.
void OnChangeModulationFrequencySpinBox(int value)
slot updating the member m_ModulationFrequency and the parameter "modulation frequency" of the curren...
int m_IntegrationTime
member for the current integration time of the ToF device
virtual void StartCamera()
Starts the continuous updating of the camera. A separate thread updates the source data...
static const std::string VIEW_ID
void SetBoolProperty(const char *propertyKey, bool boolValue)
QmitkToFPMDParameterWidget(QWidget *p=nullptr, Qt::WindowFlags f1=nullptr)
mitk::ToFImageGrabber * GetToFImageGrabber()
returns the ToFImageGrabber which was configured after selecting a camera / player ...
virtual void CreateQtPartControl(QWidget *parent)
int SetModulationFrequency(int modulationFrequency)
Set the modulation frequency used by the ToF camera. For default values see the corresponding device ...
int GetIntegrationTime()
Get the integration time in used by the ToF camera.
void SetToFImageGrabber(mitk::ToFImageGrabber *aToFImageGrabber)
sets the ToFImageGrabber which was configured after selecting a camera / player
mitk::ToFImageGrabber * m_ToFImageGrabber
member holding the current ToFImageGrabber
Image source providing ToF images. Interface for filters provided in ToFProcessing module...
int GetModulationFrequency()
Get the modulation frequency used by the ToF camera.
void OnChangeIntegrationTimeSpinBox(int value)
slot updating the member m_IntegrationTime and the parameter "integration time" of the current ToFIma...
void ActivateAllParameters()
activate camera settings according to the parameters from GUI