Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkUSControlsBModeWidget.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 #include "ui_QmitkUSControlsBModeWidget.h"
19 
21  : QWidget(parent), ui(new Ui::QmitkUSControlsBModeWidget),
22  m_ControlInterface(controlInterface)
23 {
24  ui->setupUi(this);
25 
26  if ( ! m_ControlInterface )
27  {
28  this->setDisabled(true);
29  /*ui->scanningDepthComboBox->setEnabled(false);
30  ui->scanningGainSlider->setEnabled(false);
31  ui->scanningRejectionSlider->setEnabled(false);*/
32  return;
33  }
34 
35  if ( ! m_ControlInterface->GetIsActive() ) { m_ControlInterface->SetIsActive(true); }
36 
37  // get possible scanning depth values and set combo box values according to them
38  std::vector<double> scanningDepths = m_ControlInterface->GetScanningDepthValues();
39  double curDepthValue = m_ControlInterface->GetScanningDepth();
40  for (auto it = scanningDepths.begin(); it != scanningDepths.end(); it++)
41  {
42  ui->scanningDepthComboBox->addItem(QString::number(*it, 'f', 2));
43 
44  // set current index to last inserted element if this element is equal
45  // to the current depth value got from the interface
46  if (curDepthValue == *it) ui->scanningDepthComboBox->setCurrentIndex(ui->scanningDepthComboBox->count()-1);
47  }
48 
49  // get possible scanning frequency values and set combo box values according to them
50  std::vector<double> scanningFrequencies = m_ControlInterface->GetScanningFrequencyValues();
51  double curFrequencyValue = m_ControlInterface->GetScanningFrequency();
52  for (auto it = scanningFrequencies.begin(); it != scanningFrequencies.end(); it++)
53  {
54  ui->scanningFrequencyComboBox->addItem(QString::number(*it, 'f', 2) + QString(" MHz"));
55 
56  // set current index to last inserted element if this element is equal
57  // to the current depth value got from the interface
58  if (curFrequencyValue == *it) ui->scanningFrequencyComboBox->setCurrentIndex(ui->scanningFrequencyComboBox->count()-1);
59  }
60 
61  ui->scanningPowerSlider->setMinimum(m_ControlInterface->GetScanningPowerMin());
62  ui->scanningPowerSlider->setMaximum(m_ControlInterface->GetScanningPowerMax());
63  ui->scanningPowerSlider->setTickInterval(m_ControlInterface->GetScanningPowerTick());
64  ui->scanningPowerSlider->setValue(m_ControlInterface->GetScanningPower());
65 
66  ui->scanningGainSlider->setMinimum(m_ControlInterface->GetScanningGainMin());
67  ui->scanningGainSlider->setMaximum(m_ControlInterface->GetScanningGainMax());
68  ui->scanningGainSlider->setTickInterval(m_ControlInterface->GetScanningGainTick());
69  ui->scanningGainSlider->setValue(m_ControlInterface->GetScanningGain());
70 
71  ui->scanningRejectionSlider->setMinimum(m_ControlInterface->GetScanningRejectionMin());
72  ui->scanningRejectionSlider->setMaximum(m_ControlInterface->GetScanningRejectionMax());
73  ui->scanningRejectionSlider->setTickInterval(m_ControlInterface->GetScanningRejectionTick());
74  ui->scanningRejectionSlider->setValue(m_ControlInterface->GetScanningRejection());
75 
76  ui->scanningDynamicRangeSlider->setMinimum(m_ControlInterface->GetScanningDynamicRangeMin());
77  ui->scanningDynamicRangeSlider->setMaximum(m_ControlInterface->GetScanningDynamicRangeMax());
78  ui->scanningDynamicRangeSlider->setTickInterval(m_ControlInterface->GetScanningDynamicRangeTick());
79  ui->scanningDynamicRangeSlider->setValue(m_ControlInterface->GetScanningDynamicRange());
80 
81  connect( ui->scanningFrequencyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFrequencyControlIndexChanged(int)) );
82  connect( ui->scanningDepthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnDepthControlActivated(int)) );
83  connect( ui->scanningPowerSlider, SIGNAL(valueChanged(int)), this, SLOT(OnPowerControlValueChanged(int)) );
84  connect( ui->scanningGainSlider, SIGNAL(valueChanged(int)), this, SLOT(OnGainControlValueChanged(int)) );
85  connect( ui->scanningRejectionSlider, SIGNAL(valueChanged(int)), this, SLOT(OnRejectionControlValueChanged(int)) );
86  connect( ui->scanningDynamicRangeSlider, SIGNAL(valueChanged(int)), this, SLOT(OnDynamicRangeControlValueChanged(int)) );
87 }
88 
90 {
91  delete ui;
92 }
93 
94 // slots
95 void QmitkUSControlsBModeWidget::OnFrequencyControlIndexChanged(int)
96 {
97  QString currentText = ui->scanningFrequencyComboBox->currentText();
98  m_ControlInterface->SetScanningFrequency((currentText.left(currentText.size()-5)).toDouble());
99 }
100 
101 void QmitkUSControlsBModeWidget::OnDepthControlActivated(int)
102 {
103  m_ControlInterface->SetScanningDepth(ui->scanningDepthComboBox->currentText().toDouble());
104 }
105 
106 void QmitkUSControlsBModeWidget::OnPowerControlValueChanged(int value)
107 {
108  m_ControlInterface->SetScanningPower(static_cast<double>(value));
109 }
110 
111 void QmitkUSControlsBModeWidget::OnGainControlValueChanged(int value)
112 {
113  m_ControlInterface->SetScanningGain(static_cast<double>(value));
114 }
115 
116 void QmitkUSControlsBModeWidget::OnRejectionControlValueChanged(int value)
117 {
118  m_ControlInterface->SetScanningRejection(static_cast<double>(value));
119 }
120 
121 void QmitkUSControlsBModeWidget::OnDynamicRangeControlValueChanged(int value)
122 {
123  m_ControlInterface->SetScanningDynamicRange(static_cast<double>(value));
124 }
QmitkUSControlsBModeWidget(mitk::USControlInterfaceBMode::Pointer controlInterface, QWidget *parent=nullptr)
itk::SmartPointer< Self > Pointer
Widget for b mode controls of ultrasound devices. This class handles the mitk::USControlInterfaceBMod...