14#include "ui_QmitkUSControlsCustomVideoDeviceWidget.h"
17#include <mitkException.h>
55 (this->
GetDevice()->GetControlInterfaceCustom().GetPointer());
57 if (m_ControlInterface.IsNotNull())
60 std::vector<mitk::USProbe::Pointer> probes = m_ControlInterface->GetProbes();
61 for (std::vector<mitk::USProbe::Pointer>::iterator it = probes.begin(); it != probes.end(); it++)
63 std::string probeName = (*it)->GetName();
64 ui->m_ProbeIdentifier->addItem(QString::fromUtf8(probeName.data(), probeName.size()));
67 m_ControlInterface->SetDefaultProbeAsCurrentProbe();
69 SetDepthsForProbe( ui->m_ProbeIdentifier->currentText().toStdString() );
70 m_ControlInterface->SetNewDepth( ui->m_UsDepth->currentText().toDouble() );
72 connect(ui->m_UsDepth, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(OnDepthChanged()));
73 connect(ui->m_ProbeIdentifier, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(OnProbeChanged()));
77 ui->crop_left->setValue(cropping.
left);
78 ui->crop_right->setValue(cropping.
right);
79 ui->crop_bot->setValue(cropping.
bottom);
80 ui->crop_top->setValue(cropping.
top);
85 MITK_WARN(
"QmitkUSAbstractCustomWidget")(
"QmitkUSControlsCustomVideoDeviceWidget")
86 <<
"Did not get a custom video device control interface.";
89 ui->crop_left->setEnabled(m_ControlInterface.IsNotNull());
90 ui->crop_right->setEnabled(m_ControlInterface.IsNotNull());
91 ui->crop_bot->setEnabled(m_ControlInterface.IsNotNull());
92 ui->crop_top->setEnabled(m_ControlInterface.IsNotNull());
99 connect(ui->crop_left, SIGNAL(valueChanged(
int)),
this, SLOT(OnCropAreaChanged()));
100 connect(ui->crop_right, SIGNAL(valueChanged(
int)),
this, SLOT(OnCropAreaChanged()));
101 connect(ui->crop_top, SIGNAL(valueChanged(
int)),
this, SLOT(OnCropAreaChanged()));
102 connect(ui->crop_bot, SIGNAL(valueChanged(
int)),
this, SLOT(OnCropAreaChanged()));
106void QmitkUSControlsCustomVideoDeviceWidget::OnCropAreaChanged()
108 if (m_ControlInterface.IsNull()) {
return; }
111 cropping.
left = ui->crop_left->value();
112 cropping.
top = ui->crop_top->value();
113 cropping.
right = ui->crop_right->value();
114 cropping.
bottom = ui->crop_bot->value();
118 m_ControlInterface->SetCropArea(cropping);
119 m_ControlInterface->UpdateProbeCropping(cropping);
122 catch (mitk::Exception&)
125 m_ControlInterface->UpdateProbeCropping(
m_Cropping);
135 msgBox.setInformativeText(
"The crop area you specified is invalid.\nPlease make sure that no more pixels are cropped than are available.");
136 msgBox.setStandardButtons(QMessageBox::Ok);
138 MITK_WARN <<
"User tried to crop beyond limits of the image";
142void QmitkUSControlsCustomVideoDeviceWidget::OnDepthChanged()
144 double depth = ui->m_UsDepth->currentText().toDouble();
145 MITK_INFO <<
"OnDepthChanged() " << depth;
146 m_ControlInterface->SetNewDepth(depth);
149void QmitkUSControlsCustomVideoDeviceWidget::OnProbeChanged()
151 std::string probename = ui->m_ProbeIdentifier->currentText().toStdString();
152 m_ControlInterface->SetNewProbeIdentifier(probename);
153 SetDepthsForProbe(probename);
156 ui->crop_left->setValue(cropping.
left);
157 ui->crop_right->setValue(cropping.
right);
158 ui->crop_bot->setValue(cropping.
bottom);
159 ui->crop_top->setValue(cropping.
top);
164 bool oldState = target->blockSignals(
true);
165 target->setValue(value);
166 target->blockSignals(oldState);
169void QmitkUSControlsCustomVideoDeviceWidget::SetDepthsForProbe(std::string probename)
171 ui->m_UsDepth->clear();
172 std::vector<int> depths = m_ControlInterface->GetDepthsForProbe(probename);
173 for (std::vector<int>::iterator it = depths.begin(); it != depths.end(); it++)
175 ui->m_UsDepth->addItem(QString::number(*it));
Custom controls for mitk::USVideoDevice. Controls image cropping of the corresponding mitk::USImageVi...
static std::string GetDeviceClassStatic()
Defines a region of interest by distances to the four image borders.
Struct to define a probe specific ultrasound image cropping.