Medical Imaging Interaction Toolkit  2016.11.0
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,
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 //#define _USE_MATH_DEFINES
19 
20 //QT headers
21 #include <qmessagebox.h>
22 #include <qfiledialog.h>
23 #include <qcombobox.h>
24 
25 //itk headers
26 #include <itksys/SystemTools.hxx>
27 
28 const std::string QmitkToFPMDParameterWidget::VIEW_ID = "org.mitk.views.qmitktofpmdparameterwidget";
29 
30 QmitkToFPMDParameterWidget::QmitkToFPMDParameterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
31 {
32  this->m_IntegrationTime = 0;
33  this->m_ModulationFrequency = 0;
34  this->m_ToFImageGrabber = NULL;
35 
36  m_Controls = NULL;
37  CreateQtPartControl(this);
38 }
39 
41 {
42 }
43 
45 {
46  if (!m_Controls)
47  {
48  // create GUI widgets
49  m_Controls = new Ui::QmitkToFPMDParameterWidgetControls;
50  m_Controls->setupUi(parent);
51  this->CreateConnections();
52  }
53 }
54 
56 {
57  if ( m_Controls )
58  {
59  connect( m_Controls->m_IntegrationTimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeIntegrationTimeSpinBox(int)) );
60  connect( m_Controls->m_ModulationFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeModulationFrequencySpinBox(int)) );
61  }
62 }
63 
65 {
66  return this->m_ToFImageGrabber;
67 }
68 
70 {
71  this->m_ToFImageGrabber = aToFImageGrabber;
72 }
73 
75 {
76  this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value();
78 
79  this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value();
81 
82  //set the PMD calibration according to the check boxes
83  bool boolValue = false;
84  boolValue = m_Controls->m_FPNCalibCB->isChecked();
85  this->m_ToFImageGrabber->SetBoolProperty("SetFPNCalibration", boolValue);
86  boolValue = m_Controls->m_FPPNCalibCB->isChecked();
87  this->m_ToFImageGrabber->SetBoolProperty("SetFPPNCalibration", boolValue);
88  boolValue = m_Controls->m_LinearityCalibCB->isChecked();
89  this->m_ToFImageGrabber->SetBoolProperty("SetLinearityCalibration", boolValue);
90  boolValue = m_Controls->m_LensCorrection->isChecked();
91  this->m_ToFImageGrabber->SetBoolProperty("SetLensCalibration", boolValue);
92  boolValue = m_Controls->m_ExposureModeCB->isChecked();
93  this->m_ToFImageGrabber->SetBoolProperty("SetExposureMode", boolValue);
94 
95  //reset the GUI elements
96  m_Controls->m_IntegrationTimeSpinBox->setValue(this->m_ToFImageGrabber->GetIntegrationTime());
97  m_Controls->m_ModulationFrequencySpinBox->setValue(this->m_ToFImageGrabber->GetModulationFrequency());
98 }
99 
101 {
102  if (this->m_ToFImageGrabber != NULL)
103  {
104  // stop camera if active
105  bool active = m_ToFImageGrabber->IsCameraActive();
106  if (active)
107  {
109  }
110  this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value();
111  int validIntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime);
112  if(validIntegrationTime != m_IntegrationTime)
113  {
114  this->m_Controls->m_IntegrationTimeSpinBox->setValue(validIntegrationTime);
115  this->m_IntegrationTime = validIntegrationTime;
116  }
117  if (active)
118  {
120  }
121  }
122 }
123 
125 {
126  if (this->m_ToFImageGrabber != NULL)
127  {
128  // stop camera if active
129  bool active = m_ToFImageGrabber->IsCameraActive();
130  if (active)
131  {
133  }
134  this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value();
135  int validMFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency);
136  if(validMFrequency != m_ModulationFrequency)
137  {
138  this->m_Controls->m_ModulationFrequencySpinBox->setValue(validMFrequency);
139  this->m_ModulationFrequency = validMFrequency;
140  }
141  if (active)
142  {
144  }
145  }
146 }
147 
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)
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.
QmitkToFPMDParameterWidget(QWidget *p=0, Qt::WindowFlags f1=0)
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