17 #include <QFileDialog> 18 #include <QMessageBox> 28 "org.mitk.views.QmitkUSNewVideoDeviceWidget";
47 m_Controls =
new Ui::QmitkUSNewVideoDeviceWidgetControls;
59 connect(
m_Controls->m_BtnCancel, SIGNAL(clicked()),
this,
61 connect(
m_Controls->m_RadioDeviceSource, SIGNAL(clicked()),
this,
63 connect(
m_Controls->m_RadioFileSource, SIGNAL(clicked()),
this,
65 connect(
m_Controls->m_RadioOIGTLClientSource, SIGNAL(clicked()),
this,
67 connect(
m_Controls->m_RadioOIGTLServerSource, SIGNAL(clicked()),
this,
69 connect(
m_Controls->m_OpenFileButton, SIGNAL(clicked()),
this,
72 connect(
m_Controls->m_BtnSave, SIGNAL(clicked()),
this,
74 connect(
m_Controls->m_BtnLoadConfiguration, SIGNAL(clicked()),
this,
82 connect(
m_Controls->m_Probes, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(
OnProbeChanged(
const QString &)));
83 connect(
m_Controls->m_Depths, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(
OnDepthChanged(
const QString &)));
102 if (
m_Controls->m_RadioDeviceSource->isChecked())
106 m_Controls->m_Manufacturer->text().toStdString(),
108 newDevice->SetComment(
m_Controls->m_Comment->text().toStdString());
110 else if (
m_Controls->m_RadioFileSource->isChecked())
113 m_Controls->m_FilePathSelector->text().toStdString(),
114 m_Controls->m_Manufacturer->text().toStdString(),
116 newDevice->SetComment(
m_Controls->m_Comment->text().toStdString());
118 else if (
m_Controls->m_RadioOIGTLClientSource->isChecked())
120 std::string host =
m_Controls->m_OIGTLClientHost->text().toStdString();
121 int port =
m_Controls->m_OIGTLClientPort->value();
125 m_Controls->m_Model->text().toStdString(), host, port,
false);
131 std::string host =
m_Controls->m_OIGTLServerHost->text().toStdString();
132 int port =
m_Controls->m_OIGTLServerPort->value();
136 m_Controls->m_Model->text().toStdString(), host, port,
true);
143 mitk::USImageVideoSource::Pointer imageSource =
145 newDevice->GetUSImageSource().GetPointer());
146 if (imageSource.IsNotNull())
153 if (
m_Controls->m_CheckResolutionOverride->isChecked())
155 int width =
m_Controls->m_ResolutionWidth->value();
156 int height =
m_Controls->m_ResolutionHeight->value();
157 imageSource->OverrideResolution(width, height);
158 imageSource->SetResolutionOverride(
true);
170 newDevice->DeleteAllProbes();
171 newDevice->AddNewProbe(probe);
173 newDevice->Initialize();
200 mitk::USImageVideoSource::Pointer imageSource =
203 if (imageSource.IsNotNull())
209 if (
m_Controls->m_CheckResolutionOverride->isChecked())
211 int width =
m_Controls->m_ResolutionWidth->value();
212 int height =
m_Controls->m_ResolutionHeight->value();
213 imageSource->OverrideResolution(width, height);
214 imageSource->SetResolutionOverride(
true);
236 m_Controls->m_RadioDeviceSource->isChecked());
238 m_Controls->m_RadioOIGTLClientSource->isChecked());
240 m_Controls->m_RadioOIGTLClientSource->isChecked());
242 m_Controls->m_RadioOIGTLServerSource->isChecked());
244 m_Controls->m_RadioOIGTLServerSource->isChecked());
249 QString fileName = QFileDialog::getOpenFileName(
nullptr,
"Open Video File");
250 if (fileName.isNull())
255 m_Controls->m_FilePathSelector->setText(fileName);
257 m_Controls->m_RadioFileSource->setChecked(
true);
266 if (device->GetDeviceClass().compare(
"org.mitk.modules.us.USVideoDevice") != 0 &&
267 device->GetDeviceClass().compare(
"IGTL Client") != 0)
270 mitkThrow() <<
"NewVideoDeviceWidget recieved an incompatible device type " 271 "to edit. Type was: " << device->GetDeviceClass();
288 m_Controls->m_BtnDone->setText(
"Add Video Device");
291 m_Controls->m_Manufacturer->setText(
"Unknown Manufacturer");
292 m_Controls->m_Model->setText(
"Unknown Model");
306 QListWidgetItem* result =
new QListWidgetItem;
308 device->GetManufacturer() +
"|" + device->GetName();
309 result->setText(text.c_str());
317 std::string probeName = (*it)->GetName();
318 m_Controls->m_Probes->addItem(QString::fromUtf8(probeName.data(), probeName.size()));
323 m_Controls->m_BtnDone->setText(
"Apply Changes");
334 if (!
m_Controls->m_Probes->currentText().isEmpty())
336 QString depths =
m_Controls->m_AddDepths->text();
337 if( depths.isEmpty() )
340 std::string probename =
m_Controls->m_Probes->currentText().toStdString();
343 QStringList singleDepths = depths.split(
',');
344 for (
int i = 0; i < singleDepths.size(); i++)
346 currentProbe->SetDepth(singleDepths.at(i).toInt());
350 m_Controls->m_BtnRemoveDepth->setEnabled(
true);
357 if (!
m_Controls->m_Probes->currentText().isEmpty() && !
m_Controls->m_Depths->currentText().isEmpty())
359 std::string probename =
m_Controls->m_Probes->currentText().toStdString();
360 int indexOfDepthToRemove =
m_Controls->m_Depths->currentIndex();
362 currentProbe->RemoveDepth(
m_Controls->m_Depths->currentText().toInt());
363 m_Controls->m_Depths->removeItem(indexOfDepthToRemove);
368 m_Controls->m_BtnRemoveDepth->setEnabled(
false);
377 if (!
m_Controls->m_Probes->currentText().isEmpty())
379 std::string probename =
m_Controls->m_Probes->currentText().toStdString();
380 int indexOfProbeToRemove =
m_Controls->m_Probes->currentIndex();
382 m_Controls->m_Probes->removeItem(indexOfProbeToRemove);
386 m_Controls->m_BtnRemoveProbe->setEnabled(
false);
387 m_Controls->m_BtnAddDepths->setEnabled(
false);
390 m_Controls->m_BtnRemoveDepth->setEnabled(
false);
399 if (!probename.isEmpty())
401 std::string name = probename.toStdString();
403 if( probe.IsNotNull() )
405 std::map<int, mitk::Vector3D> depths = probe->GetDepthsAndSpacing();
407 for (std::map<int, mitk::Vector3D>::iterator it = depths.begin(); it != depths.end(); it++)
409 m_Controls->m_Depths->addItem(QString::number(it->first));
419 m_Controls->m_BtnRemoveDepth->setEnabled(
false);
428 m_Controls->m_BtnRemoveDepth->setEnabled(
false);
434 if (probe.IsNotNull())
437 m_Controls->m_XSpacingSpinBox->setValue(spacing[0]);
438 m_Controls->m_YSpacingSpinBox->setValue(spacing[1]);
449 m_Controls->m_BtnRemoveDepth->setEnabled(
true);
453 m_Controls->m_BtnRemoveProbe->setEnabled(
true);
459 MITK_INFO <<
"OnDepthChanged(int, mitk::USProbe)";
460 if( depth.isEmpty() )
465 QString probeName =
m_Controls->m_Probes->currentText();
472 QString fileName = QFileDialog::getSaveFileName(
nullptr,
"Save Configuration ...",
"",
"XML files (*.xml)");
473 if( fileName.isNull() )
487 msgBox.setText(
"Error when writing the configuration to the selected file. Could not write device information.");
496 QString fileName = QFileDialog::getOpenFileName(
this,
"Open ultrasound device configuration ...");
497 if (fileName.isNull())
507 msgBox.setText(
"Error when parsing the selected file. Could not load stored device information.");
546 m_Controls->m_Probes->addItem(QString::fromStdString(config.
probes.at(index)->GetName()));
551 else if (config.
deviceType.compare(
"oigtl") == 0)
562 m_Controls->m_RadioOIGTLServerSource->setChecked(
true);
563 m_Controls->m_OIGTLServerHost->setText(QString::fromStdString(config.
host));
568 m_Controls->m_RadioOIGTLClientSource->setChecked(
true);
569 m_Controls->m_OIGTLClientHost->setText(QString::fromStdString(config.
host));
593 m_Controls->m_Probes->addItem(QString::fromStdString(config.
probes.at(index)->GetName()));
599 MITK_WARN <<
"Unknown device type detected. The device type must be of type |video|";
604 MITK_WARN <<
"Unknown fileversion. Only fileversion 1.0 is known to the system.";
610 QString probeName =
m_Controls->m_ProbeNameLineEdit->text();
611 probeName = probeName.trimmed();
612 if (probeName.isEmpty())
621 msgBox.setText(
"Probe name already exists. Please choose another name for the probe.");
629 m_Controls->m_Probes->addItem(QString::fromStdString(probeName.toStdString()));
632 m_Controls->m_BtnRemoveProbe->setEnabled(
true);
641 MITK_INFO <<
"Changing x-spacing to: " << value;
642 QString probeName =
m_Controls->m_Probes->currentText();
643 int depth =
m_Controls->m_Depths->currentText().toInt();
649 msgBox.setText(
"An error occurred when changing the spacing. \ 650 The specified probe does not exist. \ 651 Please restart the configuration process.");
658 probe->SetSpacingForGivenDepth(depth, spacing);
663 MITK_INFO <<
"Changing y-spacing to: " << value;
664 QString probeName =
m_Controls->m_Probes->currentText();
665 int depth =
m_Controls->m_Depths->currentText().toInt();
671 msgBox.setText(
"An error occurred when changing the spacing. \ 672 The specified probe does not exist. \ 673 Please restart the configuration process.");
680 probe->SetSpacingForGivenDepth(depth, spacing);
685 MITK_INFO <<
"Changing cropping top to: " << value;
686 QString probeName =
m_Controls->m_Probes->currentText();
692 msgBox.setText(
"An error occurred when changing the probe cropping. \ 693 The specified probe does not exist. \ 694 Please restart the configuration process.");
700 probe->SetProbeCropping(value, cropping.
bottom, cropping.
left, cropping.
right);
705 MITK_INFO <<
"Changing cropping right to: " << value;
706 QString probeName =
m_Controls->m_Probes->currentText();
712 msgBox.setText(
"An error occurred when changing the probe cropping. \ 713 The specified probe does not exist. \ 714 Please restart the configuration process.");
720 probe->SetProbeCropping(cropping.
top, cropping.
bottom, cropping.
left, value);
725 MITK_INFO <<
"Changing cropping bottom to: " << value;
726 QString probeName =
m_Controls->m_Probes->currentText();
732 msgBox.setText(
"An error occurred when changing the probe cropping. \ 733 The specified probe does not exist. \ 734 Please restart the configuration process.");
740 probe->SetProbeCropping(cropping.
top, value, cropping.
left, cropping.
right);
745 MITK_INFO <<
"Changing cropping left to: " << value;
746 QString probeName =
m_Controls->m_Probes->currentText();
752 msgBox.setText(
"An error occurred when changing the probe cropping. \ 753 The specified probe does not exist. \ 754 Please restart the configuration process.");
760 probe->SetProbeCropping(cropping.
top, cropping.
bottom, value, cropping.
right);
784 device->DeleteAllProbes();
785 for( std::vector<mitk::USProbe::Pointer>::iterator it =
m_ConfigProbes.begin();
788 if ((*it)->IsDepthAndSpacingEmpty())
792 device->AddNewProbe((*it));
798 for( std::vector<mitk::USProbe::Pointer>::iterator it =
m_ConfigProbes.begin();
801 if( probeName.compare((*it)->GetName()) == 0)
820 if (
m_Controls->m_RadioOIGTLServerSource->isChecked())
823 config.
host =
m_Controls->m_OIGTLServerHost->text().toStdString();
829 config.
host =
m_Controls->m_OIGTLClientHost->text().toStdString();
854 m_Controls->m_XSpacingSpinBox->setEnabled(enable);
855 m_Controls->m_YSpacingSpinBox->setEnabled(enable);
856 m_Controls->m_XSpacingLabel->setEnabled(enable);
857 m_Controls->m_YSpacingLabel->setEnabled(enable);
859 m_Controls->m_CroppingTopSpinBox->setEnabled(enable);
860 m_Controls->m_CroppingRightSpinBox->setEnabled(enable);
861 m_Controls->m_CroppingBottomSpinBox->setEnabled(enable);
862 m_Controls->m_CroppingLeftSpinBox->setEnabled(enable);
863 m_Controls->m_CroppingTopLabel->setEnabled(enable);
864 m_Controls->m_CroppingBottomLabel->setEnabled(enable);
865 m_Controls->m_CroppingLeftLabel->setEnabled(enable);
866 m_Controls->m_CroppingRightLabel->setEnabled(enable);
USDeviceConfigData & GetUSDeviceConfigData()
static Pointer New()
Method for creation through the object factory.
This class can be pointed to a video file or a videodevice and delivers USImages. ...
std::string filepathVideoSource
std::vector< mitk::USProbe::Pointer > probes
bool useResolutionOverride
bool ReadUltrasoundDeviceConfiguration()
void SetFilename(std::string filename)
Sets the filename of the ultrasound device configuration file which should be created.
void SetFilename(std::string filename)
bool WriteUltrasoundDeviceConfiguration(mitk::USDeviceReaderXML::USDeviceConfigData &config)
Writes the configuration settings of an ultrasound device to a xml-file.
void SetColorOutput(bool isColor)
Sets the output image to rgb or grayscale. Output is color by default and can be set to color by pass...
Struct to define a probe specific ultrasound image cropping.