14 #include "ui_QmitkUSControlsCustomDiPhASDeviceWidget.h" 15 #include <QMessageBox> 37 return "org.mitk.modules.us.USDiPhASDevice";
50 (this->
GetDevice()->GetControlInterfaceCustom().GetPointer());
52 if ( m_ControlInterface.IsNotNull() )
54 m_ControlInterface->passGUIOut([
this](QString str)->
void{
56 this->ui->CurrentState->setText(str);
61 MITK_WARN(
"QmitkUSAbstractCustomWidget")(
"QmitkUSControlsCustomDiPhASDeviceWidget")
62 <<
"Did not get a custom device control interface.";
67 m_OldReconstructionLines = 0;
69 m_ControlInterface->SetSilentUpdate(
true);
71 OnTransmitPhaseLengthChanged();
72 OnExcitationFrequencyChanged();
73 OnTransmitEventsChanged();
76 OnAveragingCountChanged();
81 OnReconstructedSamplesChanged();
82 OnReconstructedLinesChanged();
83 OnSpeedOfSoundChanged();
84 OnBandpassEnabledChanged();
87 OnUseBModeFilterChanged();
88 OnVerticalSpacingChanged();
89 OnScatteringCoefficientChanged();
90 OnCompensateScatteringChanged();
91 OnChangedSavingSettings();
92 OnCompensateEnergyChanged();
94 m_ControlInterface->SetSilentUpdate(
false);
103 connect(ui->CompensateEnergy, SIGNAL(stateChanged(
int)),
this, SLOT(OnCompensateEnergyChanged()));
104 connect(ui->UseBModeFilter, SIGNAL(stateChanged(
int)),
this, SLOT(OnUseBModeFilterChanged()));
105 connect(ui->StartStopRecord, SIGNAL(clicked()),
this, SLOT(OnRecordChanged()));
106 connect(ui->ScatteringCoefficient, SIGNAL(valueChanged(
int)),
this, SLOT(OnScatteringCoefficientChanged()));
107 connect(ui->CompensateScattering, SIGNAL(stateChanged(
int)),
this, SLOT(OnCompensateScatteringChanged()));
108 connect(ui->VerticalSpacing, SIGNAL(valueChanged(
double)),
this, SLOT(OnVerticalSpacingChanged()));
109 connect(ui->SaveBeamformed, SIGNAL(stateChanged(
int)),
this, SLOT(OnChangedSavingSettings()));
110 connect(ui->SaveRaw, SIGNAL(stateChanged(
int)),
this, SLOT(OnChangedSavingSettings()));
112 connect(ui->TransmitPhaseLength, SIGNAL(valueChanged(
double)),
this, SLOT(OnTransmitPhaseLengthChanged()));
113 connect(ui->ExcitationFrequency, SIGNAL(valueChanged(
double)),
this, SLOT(OnExcitationFrequencyChanged()));
114 connect(ui->TransmitEvents, SIGNAL(valueChanged(
int)),
this, SLOT(OnTransmitEventsChanged()));
115 connect(ui->Voltage, SIGNAL(valueChanged(
int)),
this, SLOT(OnVoltageChanged()));
116 connect(ui->Mode, SIGNAL(currentTextChanged(QString)),
this, SLOT(OnModeChanged()));
119 connect(ui->ScanDepth, SIGNAL(valueChanged(
double)),
this, SLOT(OnScanDepthChanged()));
120 connect(ui->AveragingCount, SIGNAL(valueChanged(
int)),
this, SLOT(OnAveragingCountChanged()));
121 connect(ui->TimeGainCompensationMinSlider, SIGNAL(valueChanged(
int)),
this, SLOT(OnTGCMinChanged()));
122 connect(ui->TimeGainCompensationMaxSlider, SIGNAL(valueChanged(
int)),
this, SLOT(OnTGCMaxChanged()));
123 connect(ui->DataType, SIGNAL(currentTextChanged(QString)),
this, SLOT(OnDataTypeChanged()));
126 connect(ui->PitchOfTransducer, SIGNAL(valueChanged(
double)),
this, SLOT(OnPitchChanged()));
127 connect(ui->ReconstructedSamplesPerLine, SIGNAL(valueChanged(
int)),
this, SLOT(OnReconstructedSamplesChanged()));
128 connect(ui->ReconstructedLines, SIGNAL(valueChanged(
int)),
this, SLOT(OnReconstructedLinesChanged()));
129 connect(ui->SpeedOfSound, SIGNAL(valueChanged(
int)),
this, SLOT(OnSpeedOfSoundChanged()));
132 connect(ui->BandpassEnabled, SIGNAL(currentTextChanged(QString)),
this, SLOT(OnBandpassEnabledChanged()));
133 connect(ui->LowCut, SIGNAL(valueChanged(
double)),
this, SLOT(OnLowCutChanged()));
134 connect(ui->HighCut, SIGNAL(valueChanged(
double)),
this, SLOT(OnHighCutChanged()));
139 void QmitkUSControlsCustomDiPhASDeviceWidget::OnCompensateEnergyChanged()
141 if (m_ControlInterface.IsNull()) {
return; }
142 bool CompensateEnergy = ui->CompensateEnergy->isChecked();
143 m_ControlInterface->SetCompensateEnergy(CompensateEnergy);
146 void QmitkUSControlsCustomDiPhASDeviceWidget::OnUseBModeFilterChanged()
148 if (m_ControlInterface.IsNull()) {
return; }
149 bool UseBModeFilter = ui->UseBModeFilter->isChecked();
150 m_ControlInterface->SetUseBModeFilter(UseBModeFilter);
153 void QmitkUSControlsCustomDiPhASDeviceWidget::OnRecordChanged()
155 if (m_ControlInterface.IsNull()) {
return; }
156 if (ui->StartStopRecord->text() ==
"Start Recording")
158 ui->StartStopRecord->setText(
"Stop Recording");
160 ui->UseBModeFilter->setEnabled(
false);
161 ui->ScatteringCoefficient->setEnabled(
false);
162 ui->CompensateScattering->setEnabled(
false);
163 ui->VerticalSpacing->setEnabled(
false);
164 ui->SaveBeamformed->setEnabled(
false);
165 ui->SaveRaw->setEnabled(
false);
166 ui->TransmitPhaseLength->setEnabled(
false);
167 ui->ExcitationFrequency->setEnabled(
false);
168 ui->TransmitEvents->setEnabled(
false);
169 ui->Voltage->setEnabled(
false);
170 ui->Mode->setEnabled(
false);
171 ui->ScanDepth->setEnabled(
false);
172 ui->AveragingCount->setEnabled(
false);
173 ui->TimeGainCompensationMinSlider->setEnabled(
false);
174 ui->TimeGainCompensationMaxSlider->setEnabled(
false);
175 ui->DataType->setEnabled(
false);
176 ui->PitchOfTransducer->setEnabled(
false);
177 ui->ReconstructedSamplesPerLine->setEnabled(
false);
178 ui->ReconstructedLines->setEnabled(
false);
179 ui->SpeedOfSound->setEnabled(
false);
180 ui->BandpassEnabled->setEnabled(
false);
181 ui->LowCut->setEnabled(
false);
182 ui->HighCut->setEnabled(
false);
183 ui->CompensateEnergy->setEnabled(
false);
185 m_ControlInterface->SetRecord(
true);
189 ui->StartStopRecord->setText(
"Start Recording");
191 ui->UseBModeFilter->setEnabled(
true);
192 ui->CompensateScattering->setEnabled(
true);
193 if(ui->CompensateScattering->isChecked())
194 ui->ScatteringCoefficient->setEnabled(
true);
195 ui->VerticalSpacing->setEnabled(
true);
196 ui->SaveBeamformed->setEnabled(
true);
197 ui->SaveRaw->setEnabled(
true);
198 ui->TransmitPhaseLength->setEnabled(
true);
199 ui->ExcitationFrequency->setEnabled(
true);
200 ui->TransmitEvents->setEnabled(
true);
201 ui->Voltage->setEnabled(
true);
202 ui->Mode->setEnabled(
true);
203 ui->ScanDepth->setEnabled(
true);
204 ui->AveragingCount->setEnabled(
true);
205 ui->TimeGainCompensationMinSlider->setEnabled(
true);
206 ui->TimeGainCompensationMaxSlider->setEnabled(
true);
207 ui->DataType->setEnabled(
true);
208 ui->PitchOfTransducer->setEnabled(
true);
209 ui->ReconstructedSamplesPerLine->setEnabled(
true);
210 ui->ReconstructedLines->setEnabled(
true);
211 ui->SpeedOfSound->setEnabled(
true);
212 ui->BandpassEnabled->setEnabled(
true);
213 ui->LowCut->setEnabled(
true);
214 ui->HighCut->setEnabled(
true);
215 ui->CompensateEnergy->setEnabled(
true);
217 m_ControlInterface->SetRecord(
false);
221 void QmitkUSControlsCustomDiPhASDeviceWidget::OnVerticalSpacingChanged()
223 if (m_ControlInterface.IsNull()) {
return; }
224 m_ControlInterface->SetVerticalSpacing(ui->VerticalSpacing->value());
227 void QmitkUSControlsCustomDiPhASDeviceWidget::OnScatteringCoefficientChanged()
229 if (m_ControlInterface.IsNull()) {
return; }
230 m_ControlInterface->SetScatteringCoefficient(ui->ScatteringCoefficient->value());
233 void QmitkUSControlsCustomDiPhASDeviceWidget::OnCompensateScatteringChanged()
235 if (m_ControlInterface.IsNull()) {
return; }
236 if (ui->CompensateScattering->isChecked())
237 ui->ScatteringCoefficient->setEnabled(
true);
239 ui->ScatteringCoefficient->setEnabled(
false);
241 m_ControlInterface->SetCompensateScattering(ui->CompensateScattering->isChecked());
244 void QmitkUSControlsCustomDiPhASDeviceWidget::OnChangedSavingSettings()
246 if (m_ControlInterface.IsNull()) {
return; }
251 settings.
saveRaw = ui->SaveRaw->isChecked();
253 m_ControlInterface->SetSavingSettings(settings);
257 void QmitkUSControlsCustomDiPhASDeviceWidget::OnTransmitPhaseLengthChanged()
259 if (m_ControlInterface.IsNull()) {
return; }
260 m_ControlInterface->SetTransmitPhaseLength(ui->TransmitPhaseLength->value());
262 void QmitkUSControlsCustomDiPhASDeviceWidget::OnExcitationFrequencyChanged()
264 if (m_ControlInterface.IsNull()) {
return; }
265 m_ControlInterface->SetExcitationFrequency(ui->ExcitationFrequency->value());
267 void QmitkUSControlsCustomDiPhASDeviceWidget::OnTransmitEventsChanged()
269 if (m_ControlInterface.IsNull()) {
return; }
271 m_ControlInterface->SetTransmitEvents(ui->TransmitEvents->value());
273 void QmitkUSControlsCustomDiPhASDeviceWidget::OnVoltageChanged()
275 if (m_ControlInterface.IsNull()) {
return; }
276 m_ControlInterface->SetVoltage(ui->Voltage->value());
278 void QmitkUSControlsCustomDiPhASDeviceWidget::OnModeChanged()
280 if (m_ControlInterface.IsNull()) {
return; }
281 QString Mode = ui->Mode->currentText();
282 bool silent = m_ControlInterface->GetSilentUpdate();
283 m_ControlInterface->SetSilentUpdate(
true);
285 if (Mode ==
"Ultrasound only") {
286 m_ControlInterface->SetMode(
false);
287 ui->TransmitEvents->setValue(1);
289 else if (Mode ==
"Interleaved") {
290 m_ControlInterface->SetMode(
true);
291 ui->TransmitEvents->setValue(1);
293 if (!silent) { m_ControlInterface->SetSilentUpdate(
false); }
294 OnTransmitEventsChanged();
298 void QmitkUSControlsCustomDiPhASDeviceWidget::OnScanDepthChanged()
300 if (m_ControlInterface.IsNull()) {
return; }
301 m_ControlInterface->SetScanDepth(ui->ScanDepth->value());
303 void QmitkUSControlsCustomDiPhASDeviceWidget::OnAveragingCountChanged()
305 if (m_ControlInterface.IsNull()) {
return; }
306 m_ControlInterface->SetAveragingCount(ui->AveragingCount->value());
308 void QmitkUSControlsCustomDiPhASDeviceWidget::OnTGCMinChanged()
310 if (m_ControlInterface.IsNull()) {
return; }
312 int tgcMin = ui->TimeGainCompensationMinSlider->value();
313 int tgcMax = ui->TimeGainCompensationMaxSlider->value();
314 if (tgcMin > tgcMax) {
315 ui->TimeGainCompensationMinSlider->setValue(tgcMax);
316 MITK_INFO <<
"User tried to set tgcMin>tgcMax.";
318 QString text(
"TGC min = " + QString::fromStdString(std::to_string(ui->TimeGainCompensationMinSlider->value())));
319 ui->TimeGainCompensationMinLabel->setText(text);
320 m_ControlInterface->SetTGCMin(ui->TimeGainCompensationMinSlider->value());
322 void QmitkUSControlsCustomDiPhASDeviceWidget::OnTGCMaxChanged()
324 if (m_ControlInterface.IsNull()) {
return; }
326 int tgcMin = ui->TimeGainCompensationMinSlider->value();
327 int tgcMax = ui->TimeGainCompensationMaxSlider->value();
328 if (tgcMin > tgcMax) {
329 ui->TimeGainCompensationMaxSlider->setValue(tgcMin);
330 MITK_INFO <<
"User tried to set tgcMin>tgcMax.";
332 QString text(
"TGC max = "+QString::fromStdString(std::to_string(ui->TimeGainCompensationMaxSlider->value())));
333 ui->TimeGainCompensationMaxLabel->setText(text);
334 m_ControlInterface->SetTGCMax(ui->TimeGainCompensationMaxSlider->value());
337 void QmitkUSControlsCustomDiPhASDeviceWidget::OnDataTypeChanged()
339 if (m_ControlInterface.IsNull()) {
return; }
340 QString DataType = ui->DataType->currentText();
341 if (DataType ==
"Image Data") {
342 m_ControlInterface->SetDataType(mitk::USDiPhASDeviceCustomControls::DataType::Image_uChar);
344 else if (DataType ==
"Beamformed Data") {
345 m_ControlInterface->SetDataType(mitk::USDiPhASDeviceCustomControls::DataType::Beamformed_Short);
350 void QmitkUSControlsCustomDiPhASDeviceWidget::OnPitchChanged()
352 if (m_ControlInterface.IsNull()) {
return; }
353 m_ControlInterface->SetPitch(ui->PitchOfTransducer->value());
355 void QmitkUSControlsCustomDiPhASDeviceWidget::OnReconstructedSamplesChanged()
357 if (m_ControlInterface.IsNull()) {
return; }
358 m_ControlInterface->SetReconstructedSamples(ui->ReconstructedSamplesPerLine->value());
360 void QmitkUSControlsCustomDiPhASDeviceWidget::OnReconstructedLinesChanged()
362 if (m_ControlInterface.IsNull()) {
return; }
363 if (m_OldReconstructionLines == 0)
364 m_OldReconstructionLines = ui->ReconstructedLines->value();
366 m_ControlInterface->SetReconstructedLines(ui->ReconstructedLines->value());
368 ui->PitchOfTransducer->setValue(ui->PitchOfTransducer->value()*((double)m_OldReconstructionLines / (
double)ui->ReconstructedLines->value()));
369 m_OldReconstructionLines = ui->ReconstructedLines->value();
371 void QmitkUSControlsCustomDiPhASDeviceWidget::OnSpeedOfSoundChanged()
373 if (m_ControlInterface.IsNull()) {
return; }
375 m_ControlInterface->SetSpeedOfSound(ui->SpeedOfSound->value());
379 void QmitkUSControlsCustomDiPhASDeviceWidget::OnBandpassEnabledChanged()
381 if (m_ControlInterface.IsNull()) {
return; }
383 if (ui->BandpassEnabled->currentText() ==
"On") {
384 m_ControlInterface->SetBandpassEnabled(
true);
387 m_ControlInterface->SetBandpassEnabled(
false);
390 void QmitkUSControlsCustomDiPhASDeviceWidget::OnLowCutChanged()
392 if (m_ControlInterface.IsNull()) {
return; }
394 unsigned int Low = ui->LowCut->value();
395 unsigned int High = ui->HighCut->value();
397 ui->LowCut->setValue(High);
398 MITK_INFO <<
"User tried to set LowCut>HighCut.";
401 m_ControlInterface->SetLowCut(ui->LowCut->value());
403 void QmitkUSControlsCustomDiPhASDeviceWidget::OnHighCutChanged()
405 if (m_ControlInterface.IsNull()) {
return; }
407 unsigned int Low = ui->LowCut->value();
408 unsigned int High = ui->HighCut->value();
410 ui->HighCut->setValue(Low);
411 MITK_INFO <<
"User tried to set LowCut>HighCut.";
414 m_ControlInterface->SetHighCut(ui->HighCut->value());
Custom controls for mitk::USDiPhASDevice.