21 #include <QFileDialog>
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,
76 connect(
m_Controls->m_Probes, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(
OnProbeChanged(
const QString &)));
88 if (
m_Controls->m_RadioDeviceSource->isChecked())
92 m_Controls->m_Manufacturer->text().toStdString(),
94 newDevice->SetComment(
m_Controls->m_Comment->text().toStdString());
96 else if (
m_Controls->m_RadioFileSource->isChecked())
99 m_Controls->m_FilePathSelector->text().toStdString(),
100 m_Controls->m_Manufacturer->text().toStdString(),
102 newDevice->SetComment(
m_Controls->m_Comment->text().toStdString());
104 else if (
m_Controls->m_RadioOIGTLClientSource->isChecked())
106 std::string host =
m_Controls->m_OIGTLClientHost->text().toStdString();
107 int port =
m_Controls->m_OIGTLClientPort->value();
112 m_Controls->m_Model->text().toStdString(), host, port,
false);
113 device->Initialize();
121 std::string host =
m_Controls->m_OIGTLServerHost->text().toStdString();
122 int port =
m_Controls->m_OIGTLServerPort->value();
127 m_Controls->m_Model->text().toStdString(), host, port,
true);
128 device->Initialize();
138 newDevice->GetUSImageSource().GetPointer());
141 MITK_ERROR <<
"There is no USImageVideoSource at the current device.";
142 mitkThrow() <<
"There is no USImageVideoSource at the current device.";
146 imageSource->SetColorOutput(!
m_Controls->m_CheckGreyscale->isChecked());
149 if (
m_Controls->m_CheckResolutionOverride->isChecked())
151 int width =
m_Controls->m_ResolutionWidth->value();
152 int height =
m_Controls->m_ResolutionHeight->value();
153 imageSource->OverrideResolution(width, height);
154 imageSource->SetResolutionOverride(
true);
156 if (!
m_Controls->m_ProbesInformation->text().isEmpty())
164 newDevice->AddNewProbe(probe);
166 newDevice->Initialize();
179 if (!
m_Controls->m_ProbesInformation->text().isEmpty()){
187 MITK_ERROR <<
"There is no USImageVideoSource at the current device.";
188 mitkThrow() <<
"There is no USImageVideoSource at the current device.";
192 imageSource->SetColorOutput(!
m_Controls->m_CheckGreyscale->isChecked());
195 if (
m_Controls->m_CheckResolutionOverride->isChecked())
197 int width =
m_Controls->m_ResolutionWidth->value();
198 int height =
m_Controls->m_ResolutionHeight->value();
199 imageSource->OverrideResolution(width, height);
200 imageSource->SetResolutionOverride(
true);
221 m_Controls->m_RadioDeviceSource->isChecked());
223 m_Controls->m_RadioOIGTLClientSource->isChecked());
225 m_Controls->m_RadioOIGTLClientSource->isChecked());
227 m_Controls->m_RadioOIGTLServerSource->isChecked());
229 m_Controls->m_RadioOIGTLServerSource->isChecked());
234 QString fileName = QFileDialog::getOpenFileName(NULL,
"Open Video File");
235 if (fileName.isNull())
240 m_Controls->m_FilePathSelector->setText(fileName);
242 m_Controls->m_RadioFileSource->setChecked(
true);
251 if (device->GetDeviceClass().compare(
"org.mitk.modules.us.USVideoDevice") !=
255 mitkThrow() <<
"NewVideoDeviceWidget recieved an incompatible device type "
256 "to edit. Type was: " << device->GetDeviceClass();
267 m_Controls->m_GroupBoxEditProbes->setEnabled(
false);
271 m_Controls->m_BtnDone->setText(
"Add Video Device");
274 m_Controls->m_Manufacturer->setText(
"Unknown Manufacturer");
275 m_Controls->m_Model->setText(
"Unknown Model");
287 QListWidgetItem* result =
new QListWidgetItem;
289 device->GetDeviceManufacturer() +
"|" + device->GetDeviceModel();
290 result->setText(text.c_str());
297 m_Controls->m_GroupBoxVideoSource->setEnabled(
false);
300 m_Controls->m_GroupBoxEditProbes->setEnabled(
true);
301 std::vector<mitk::USProbe::Pointer> probes =
m_TargetDevice->GetAllProbes();
302 for (std::vector<mitk::USProbe::Pointer>::iterator it = probes.begin(); it != probes.end(); it++)
304 std::string probeName = (*it)->GetName();
305 m_Controls->m_Probes->addItem(QString::fromUtf8(probeName.data(), probeName.size()));
310 m_Controls->m_BtnDone->setText(
"Save Changes");
321 if (!
m_Controls->m_Probes->currentText().isEmpty())
323 std::string probename =
m_Controls->m_Probes->currentText().toStdString();
325 QString depths =
m_Controls->m_AddDepths->text();
326 QStringList singleDepths = depths.split(
',');
327 for (
int i = 0; i < singleDepths.size(); i++)
329 currentProbe->SetDepth(singleDepths.at(i).toInt());
338 if (!
m_Controls->m_Probes->currentText().isEmpty() && !
m_Controls->m_Depths->currentText().isEmpty())
340 std::string probename =
m_Controls->m_Probes->currentText().toStdString();
341 int indexOfDepthToRemove =
m_Controls->m_Depths->currentIndex();
343 currentProbe->RemoveDepth(
m_Controls->m_Depths->currentText().toInt());
344 m_Controls->m_Depths->removeItem(indexOfDepthToRemove);
350 if (!
m_Controls->m_Probes->currentText().isEmpty())
352 std::string probename =
m_Controls->m_Probes->currentText().toStdString();
353 int indexOfProbeToRemove =
m_Controls->m_Probes->currentIndex();
355 m_Controls->m_Probes->removeItem(indexOfProbeToRemove);
361 if (!probename.isEmpty())
363 std::string name = probename.toStdString();
365 std::map<int, mitk::Vector3D> depths = probe->GetDepthsAndSpacing();
367 for (std::map<int, mitk::Vector3D>::iterator it = depths.begin(); it != depths.end(); it++)
369 m_Controls->m_Depths->addItem(QString::number(it->first));
391 QString probesInformation =
m_Controls->m_ProbesInformation->text();
392 QStringList probes = probesInformation.split(
';');
393 for (
int i = 0; i < probes.size(); i++)
395 QStringList depths = probes.at(i).split(
',');
397 probe->SetName(depths.at(0).toStdString());
398 for (
int i = 1; i < depths.size(); i++)
400 probe->SetDepth(depths.at(i).toInt());
402 device->AddNewProbe(probe);
itk::SmartPointer< Self > Pointer
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. ...
A mitk::USVideoDevice is the common class for video only devices. They capture video input either fro...