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