MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUltrasoundSupport.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13// Blueberry
14#include <berryISelectionService.h>
15#include <berryIWorkbenchWindow.h>
16
17//Mitk
18#include <mitkDataNode.h>
19#include <mitkNodePredicateNot.h>
20#include <mitkNodePredicateProperty.h>
21#include <mitkIRenderingManager.h>
22#include <mitkImageGenerator.h>
23
24// Qmitk
26
27// Qt
28#include <QMessageBox>
29#include <QSettings>
30#include <QTimer>
31
32// Ultrasound
33#include "mitkUSDevice.h"
35
36#include <usModuleContext.h>
37#include <usGetModuleContext.h>
38#include "usServiceReference.h"
40
41#include <ui_QmitkUltrasoundSupportControls.h>
42
43const std::string QmitkUltrasoundSupport::VIEW_ID = "org.mitk.views.ultrasoundsupport";
44
46 : m_Controls(nullptr), m_ControlCustomWidget(nullptr), m_ControlBModeWidget(nullptr),
47 m_ControlProbesWidget(nullptr), m_ImageAlreadySetToNode(false),
48 m_CurrentImageWidth(0), m_CurrentImageHeight(0)
49{
50 ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext();
51
52 if (pluginContext)
53 {
54 // to be notified about service event of an USDevice
55 pluginContext->connectServiceListener(this, "OnDeviceServiceEvent",
56 QString::fromStdString("(" + us::ServiceConstants::OBJECTCLASS() + "=" + us_service_interface_iid<mitk::USDevice>() + ")"));
57 }
58}
59
61{
62 try
63 {
65 StopTimers();
66
67 // Get all active devicesand deactivate them to prevent freeze
68 std::vector<mitk::USDevice*> devices = this->m_Controls->m_ActiveVideoDevices->GetAllServices<mitk::USDevice>();
69 for (size_t i = 0; i < devices.size(); i++)
70 {
71 mitk::USDevice::Pointer device = devices[i];
72 if (device.IsNotNull() && device->GetIsActive())
73 {
74 device->Deactivate();
75 device->Disconnect();
76 }
77 }
78 }
79 catch (std::exception &e)
80 {
81 MITK_ERROR << "Exception during call of destructor! Message: " << e.what();
82 }
83}
84
88
90{
91 //initialize timers
92 m_UpdateTimer = new QTimer(this);
93 m_RenderingTimer2d = new QTimer(this);
94 m_RenderingTimer3d = new QTimer(this);
95
96 // build up qt view, unless already done
97 if (!m_Controls)
98 {
99 // create GUI widgets from the Qt Designer's .ui file
100 m_Controls = new Ui::UltrasoundSupportControls;
101
102 // create GUI widgets from the Qt Designer's .ui file
103 m_Controls->setupUi(parent);
104
105 //load persistence data before connecting slots (so no slots are called in this phase...)
107
108 //connect signals and slots...
109 connect(m_Controls->m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this, SLOT(OnClickedAddNewDevice())); // Change Widget Visibilities
110 connect(m_Controls->m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this->m_Controls->m_NewVideoDeviceWidget, SLOT(CreateNewDevice())); // Init NewDeviceWidget
111 connect(m_Controls->m_ActiveVideoDevices, SIGNAL(ServiceSelectionChanged(us::ServiceReferenceU)), this, SLOT(OnChangedActiveDevice()));
112 connect(m_Controls->m_RunImageTimer, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice()));
113 connect(m_Controls->m_ShowImageStream, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice()));
114 connect(m_Controls->m_NewVideoDeviceWidget, SIGNAL(Finished()), this, SLOT(OnNewDeviceWidgetDone())); // After NewDeviceWidget finished editing
115 connect(m_Controls->m_FrameRatePipeline, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit()));
116 connect(m_Controls->m_FrameRate2d, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit()));
117 connect(m_Controls->m_FrameRate3d, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit()));
118 connect(m_Controls->m_FreezeButton, SIGNAL(clicked()), this, SLOT(OnClickedFreezeButton()));
119 connect(m_UpdateTimer, SIGNAL(timeout()), this, SLOT(UpdateImage()));
120 connect(m_RenderingTimer2d, SIGNAL(timeout()), this, SLOT(RenderImage2d()));
121 connect(m_RenderingTimer3d, SIGNAL(timeout()), this, SLOT(RenderImage3d()));
122 connect(m_Controls->m_Update2DView, SIGNAL(clicked()), this, SLOT(StartTimers()));
123 connect(m_Controls->m_Update3DView, SIGNAL(clicked()), this, SLOT(StartTimers()));
124 connect(m_Controls->m_DeviceManagerWidget, SIGNAL(EditDeviceButtonClicked(mitk::USDevice::Pointer)), this, SLOT(OnClickedEditDevice())); //Change Widget Visibilities
125 connect(m_Controls->m_DeviceManagerWidget, SIGNAL(EditDeviceButtonClicked(mitk::USDevice::Pointer)), this->m_Controls->m_NewVideoDeviceWidget, SLOT(EditDevice(mitk::USDevice::Pointer)));
126
127 connect(m_Controls->m_SetXPoint1, SIGNAL(clicked()), this, SLOT(SetXPoint1()));
128 connect(m_Controls->m_SetXPoint2, SIGNAL(clicked()), this, SLOT(SetXPoint2()));
129 connect(m_Controls->m_SetYPoint1, SIGNAL(clicked()), this, SLOT(SetYPoint1()));
130 connect(m_Controls->m_SetYPoint2, SIGNAL(clicked()), this, SLOT(SetYPoint2()));
131 connect(m_Controls->m_SaveSpacing, SIGNAL(clicked()), this, SLOT(WriteSpacingToDevice()));
132
133
134 // Initializations
135 m_Controls->m_NewVideoDeviceWidget->setVisible(false);
136 std::string filter = "(&(" + us::ServiceConstants::OBJECTCLASS() + "="
137 + "org.mitk.services.UltrasoundDevice)("
139 m_Controls->m_ActiveVideoDevices->Initialize<mitk::USDevice>(
141 m_Controls->m_ActiveVideoDevices->SetAutomaticallySelectFirstEntry(true);
145
146 m_Controls->tabWidget->setTabEnabled(1, false);
147 }
148}
149
151{
152 m_Controls->m_NewVideoDeviceWidget->setVisible(true);
153 m_Controls->m_DeviceManagerWidget->setVisible(false);
154 m_Controls->m_Headline->setText("Add New Video Device:");
155 m_Controls->m_WidgetActiveDevices->setVisible(false);
156}
157
159{
160 m_Controls->m_NewVideoDeviceWidget->setVisible(true);
161 m_Controls->m_DeviceManagerWidget->setVisible(false);
162 m_Controls->m_WidgetActiveDevices->setVisible(false);
163 m_Controls->m_Headline->setText("Edit Video Device:");
164}
165
167{
168 //Update device
169 m_Device->Modified();
170 m_Device->Update();
171
172
173 //Only update the view if the image is shown
174 if (m_Controls->m_ShowImageStream->isChecked())
175 {
176 //Update data nodes
177 for (size_t i = 0; i < m_AmountOfOutputs; i++)
178 {
179 mitk::Image::Pointer curOutput = m_Device->GetOutput(i);
180 if (curOutput->IsEmpty())
181 {
182 m_Node.at(i)->SetName("No Data received yet ...");
183 //create a noise image for correct initialization of level window, etc.
184 mitk::Image::Pointer randomImage = mitk::ImageGenerator::GenerateRandomImage<float>(32, 32, 1, 1, 1, 1, 1, 255, 0);
185 m_Node.at(i)->SetData(randomImage);
186 curOutput->SetGeometry(randomImage->GetGeometry());
187 }
188 else
189 {
190 std::stringstream nodeName;
191 nodeName << "US Viewing Stream - Image " << i;
192 m_Node.at(i)->SetName(nodeName.str());
193 m_Node.at(i)->SetData(curOutput);
194 m_Node.at(i)->Modified();
195 }
196 // if the geometry changed: reinitialize the ultrasound image
197 if ((i==0) && (m_OldGeometry.IsNotNull()) &&
198 (curOutput->GetGeometry() != nullptr) &&
199 (!mitk::Equal(*(m_OldGeometry.GetPointer()), *(curOutput->GetGeometry()), 0.0001, false))
200 )
201 {
202 mitk::IRenderWindowPart* renderWindow = this->GetRenderWindowPart();
203 if ((renderWindow != nullptr) && (curOutput->GetTimeGeometry()->IsValid()) && (m_Controls->m_ShowImageStream->isChecked()))
204 {
205 renderWindow->GetRenderingManager()->InitializeViews(curOutput->GetGeometry());
206 }
207 m_CurrentImageWidth = curOutput->GetDimension(0);
208 m_CurrentImageHeight = curOutput->GetDimension(1);
209 m_OldGeometry = dynamic_cast<mitk::SlicedGeometry3D*>(curOutput->GetGeometry());
210 }
211 }
212 }
213
214
215
216 //Update frame counter
219 {
220 //compute framerate of pipeline update
221 int nMilliseconds = m_Clock.restart();
222 int fps = 1000.0 / nMilliseconds;
223 m_FPSPipeline = fps;
225
226 //display lowest framerate in UI
227 int lowestFPS = m_FPSPipeline;
228 if (m_Controls->m_Update2DView->isChecked() && (m_FPS2d < lowestFPS)) { lowestFPS = m_FPS2d; }
229 if (m_Controls->m_Update3DView->isChecked() && (m_FPS3d < lowestFPS)) { lowestFPS = m_FPS3d; }
230 m_Controls->m_FramerateLabel->setText("Current Framerate: " + QString::number(lowestFPS) + " FPS");
231 }
232}
233
235{
236 if (!m_Controls->m_Update2DView->isChecked())
237 return;
238
239 this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS);
241 if (m_FrameCounter2d >0)
242 {
243 //compute framerate of 2d render window update
244 int nMilliseconds = m_Clock2d.restart();
245 int fps = 1000.0f / (nMilliseconds);
246 m_FPS2d = fps;
248 }
249}
250
252{
253 if (!m_Controls->m_Update3DView->isChecked())
254 return;
255
256 this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS);
258 if (m_FrameCounter3d >0)
259 {
260 //compute framerate of 2d render window update
261 int nMilliseconds = m_Clock3d.restart();
262 int fps = 1000.0f / (nMilliseconds);
263 m_FPS3d = fps;
265 }
266}
267
269{
270 StopTimers();
271 int intervalPipeline = (1000 / m_Controls->m_FrameRatePipeline->value());
272 int interval2D = (1000 / m_Controls->m_FrameRate2d->value());
273 int interval3D = (1000 / m_Controls->m_FrameRate3d->value());
274 SetTimerIntervals(intervalPipeline, interval2D, interval3D);
275 StartTimers();
276}
277
279{
280 if (m_Device.IsNull())
281 {
282 MITK_WARN("UltrasoundSupport") << "Freeze button clicked though no device is selected.";
283 return;
284 }
285 if (m_Device->GetIsFreezed())
286 {
287 m_Device->SetIsFreezed(false);
288 m_Controls->m_FreezeButton->setText("Freeze");
289 }
290 else
291 {
292 m_Device->SetIsFreezed(true);
293 m_Controls->m_FreezeButton->setText("Start Viewing Again");
294 }
295}
296
298{
299 //clean up and stop timer
300 StopTimers();
301 this->RemoveControlWidgets();
302 for (size_t j = 0; j < m_Node.size(); j++)
303 {
304 this->GetDataStorage()->Remove(m_Node.at(j));
305 m_Node.at(j)->ReleaseData();
306 }
307 m_Node.clear();
308 //get current device, abort if it is invalid
309 m_Device = m_Controls->m_ActiveVideoDevices->GetSelectedService<mitk::USDevice>();
310 if (m_Device.IsNull())
311 {
312 m_Controls->tabWidget->setTabEnabled(1, false);
313 return;
314 }
315 m_AmountOfOutputs = m_Device->GetNumberOfIndexedOutputs();
316 // clear data storage, create new nodes and add
317 for (size_t i = 0; i < m_AmountOfOutputs; i++)
318 {
319 mitk::DataNode::Pointer currentNode = mitk::DataNode::New();
320 std::stringstream nodeName;
321 nodeName << "US Viewing Stream - Image " << i;
322 currentNode->SetName(nodeName.str());
323 //create a dummy image (gray values 0..255) for correct initialization of level window, etc.
324 mitk::Image::Pointer dummyImage = mitk::ImageGenerator::GenerateRandomImage<float>(100, 100, 1, 1, 1, 1, 1, 255, 0);
325 currentNode->SetData(dummyImage);
326 m_OldGeometry = dynamic_cast<mitk::SlicedGeometry3D*>(dummyImage->GetGeometry());
327 m_Node.push_back(currentNode);
328 //show node if the option is enabled
329 if (m_Controls->m_ShowImageStream->isChecked())
330 {
331 this->GetDataStorage()->Add(m_Node.at(i));
332 }
333 }
334
335 //create the widgets for this device and enable the widget tab
336 this->CreateControlWidgets();
337 m_Controls->tabWidget->setTabEnabled(1, true);
338
339 //start timer
340 if (m_Controls->m_RunImageTimer->isChecked())
341 {
342 int intervalPipeline = (1000 / m_Controls->m_FrameRatePipeline->value());
343 int interval2D = (1000 / m_Controls->m_FrameRate2d->value());
344 int interval3D = (1000 / m_Controls->m_FrameRate3d->value());
345 SetTimerIntervals(intervalPipeline, interval2D, interval3D);
346 StartTimers();
347 m_Controls->m_TimerWidget->setEnabled(true);
348 }
349 else
350 {
351 m_Controls->m_TimerWidget->setEnabled(false);
352 }
353}
354
356{
357 m_Controls->m_NewVideoDeviceWidget->setVisible(false);
358 m_Controls->m_DeviceManagerWidget->setVisible(true);
359 m_Controls->m_Headline->setText("Ultrasound Devices:");
360 m_Controls->m_WidgetActiveDevices->setVisible(true);
361}
362
364{
365 m_ControlProbesWidget = new QmitkUSControlsProbesWidget(m_Device->GetControlInterfaceProbes(), m_Controls->m_ToolBoxControlWidgets);
366 m_Controls->probesWidgetContainer->addWidget(m_ControlProbesWidget);
367
368 // create b mode widget for current device
369 m_ControlBModeWidget = new QmitkUSControlsBModeWidget(m_Device->GetControlInterfaceBMode(), m_Controls->m_ToolBoxControlWidgets);
370 m_Controls->m_ToolBoxControlWidgets->addItem(m_ControlBModeWidget, "B Mode Controls");
371 if (!m_Device->GetControlInterfaceBMode())
372 {
373 m_Controls->m_ToolBoxControlWidgets->setItemEnabled(m_Controls->m_ToolBoxControlWidgets->count() - 1, false);
374 }
375
376 // create doppler widget for current device
377 m_ControlDopplerWidget = new QmitkUSControlsDopplerWidget(m_Device->GetControlInterfaceDoppler(), m_Controls->m_ToolBoxControlWidgets);
378 m_Controls->m_ToolBoxControlWidgets->addItem(m_ControlDopplerWidget, "Doppler Controls");
379 if (!m_Device->GetControlInterfaceDoppler())
380 {
381 m_Controls->m_ToolBoxControlWidgets->setItemEnabled(m_Controls->m_ToolBoxControlWidgets->count() - 1, false);
382 }
383
384 ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext();
385 if (pluginContext)
386 {
387 std::string filter = "(org.mitk.services.UltrasoundCustomWidget.deviceClass=" + m_Device->GetDeviceClass() + ")";
388 //Hint: The following three lines are a workaround. Till now the only US video device was an USVideoDevice.
389 // And everything worked fine. However, the ultrasound image source can be an USIGTLDevice (IGTL Client), as well.
390 // This second option wasn't considered yet. So, the custom control widget will work correctly only, if
391 // the filter declares the device class as org.mitk.modules.us.USVideoDevice. Another option, how to deal with
392 // the two possible ultrasound image devices would be to change the returned string of the method
393 // std::string QmitkUSControlsCustomVideoDeviceWidget::GetDeviceClass(), which always returns the string
394 // org.mitk.modules.us.USVideoDevice of the USVideoDevice class. If there is a possility to change the
395 // returned string dynamically between "IGTL Client" and "org.mitk.modules.us.USVideoDevice" the following
396 // three lines will not be needed.
397 if (m_Device->GetDeviceClass().compare("IGTL Client") == 0)
398 {
399 filter = "(org.mitk.services.UltrasoundCustomWidget.deviceClass=" + mitk::USVideoDevice::GetDeviceClassStatic() + ")";
400 }
401
402 QString interfaceName = QString::fromStdString(us_service_interface_iid<QmitkUSAbstractCustomWidget>());
403 m_CustomWidgetServiceReference = pluginContext->getServiceReferences(interfaceName, QString::fromStdString(filter));
404
405 if (m_CustomWidgetServiceReference.size() > 0)
406 {
407 m_ControlCustomWidget = pluginContext->getService<QmitkUSAbstractCustomWidget>
410 m_Controls->m_ToolBoxControlWidgets->addItem(m_ControlCustomWidget, "Custom Controls");
411 }
412 else
413 {
414 m_Controls->m_ToolBoxControlWidgets->addItem(new QWidget(m_Controls->m_ToolBoxControlWidgets), "Custom Controls");
415 m_Controls->m_ToolBoxControlWidgets->setItemEnabled(m_Controls->m_ToolBoxControlWidgets->count() - 1, false);
416 }
417 }
418
419 // select first enabled control widget
420 for (int n = 0; n < m_Controls->m_ToolBoxControlWidgets->count(); ++n)
421 {
422 if (m_Controls->m_ToolBoxControlWidgets->isItemEnabled(n))
423 {
424 m_Controls->m_ToolBoxControlWidgets->setCurrentIndex(n);
425 break;
426 }
427 }
428}
429
431{
432 if (!m_ControlProbesWidget) { return; } //widgets do not exist... nothing to do
433
434 // remove all control widgets from the tool box widget
435 while (m_Controls->m_ToolBoxControlWidgets->count() > 0)
436 {
437 m_Controls->m_ToolBoxControlWidgets->removeItem(0);
438 }
439
440 // remove probes widget (which is not part of the tool box widget)
441 m_Controls->probesWidgetContainer->removeWidget(m_ControlProbesWidget);
443 m_ControlProbesWidget = nullptr;
444
446 m_ControlBModeWidget = nullptr;
447
449 m_ControlDopplerWidget = nullptr;
450
451 // delete custom widget if it is present
453 {
454 ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext();
456 if (m_CustomWidgetServiceReference.size() > 0)
457 {
458 pluginContext->ungetService(m_CustomWidgetServiceReference.at(0));
459 }
460 }
461}
462
463void QmitkUltrasoundSupport::OnDeviceServiceEvent(const ctkServiceEvent event)
464{
465 if (m_Device.IsNull() || event.getType() != ctkServiceEvent::MODIFIED)
466 {
467 return;
468 }
469
470 ctkServiceReference service = event.getServiceReference();
471
472 if (m_Device->GetManufacturer() != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_MANUFACTURER)).toString().toStdString()
473 && m_Device->GetName() != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_NAME)).toString().toStdString())
474 {
475 return;
476 }
477
478 if (!m_Device->GetIsActive() && m_UpdateTimer->isActive())
479 {
480 StopTimers();
481 }
482
483 if (m_CurrentDynamicRange != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE)).toDouble())
484 {
485 m_CurrentDynamicRange = service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE)).toDouble();
486
487 // update level window for the current dynamic range
488 mitk::LevelWindow levelWindow;
489 m_Node.at(0)->GetLevelWindow(levelWindow);
490 levelWindow.SetAuto(m_curOutput.at(0), true, true);
491 m_Node.at(0)->SetLevelWindow(levelWindow);
492 }
493}
494
496{
497 QSettings settings;
498 settings.beginGroup(QString::fromStdString(VIEW_ID));
499 settings.setValue("DisplayImage", QVariant(m_Controls->m_ShowImageStream->isChecked()));
500 settings.setValue("RunImageTimer", QVariant(m_Controls->m_RunImageTimer->isChecked()));
501 settings.setValue("Update2DView", QVariant(m_Controls->m_Update2DView->isChecked()));
502 settings.setValue("Update3DView", QVariant(m_Controls->m_Update3DView->isChecked()));
503 settings.setValue("UpdateRatePipeline", QVariant(m_Controls->m_FrameRatePipeline->value()));
504 settings.setValue("UpdateRate2d", QVariant(m_Controls->m_FrameRate2d->value()));
505 settings.setValue("UpdateRate3d", QVariant(m_Controls->m_FrameRate3d->value()));
506 settings.endGroup();
507}
508
510{
511 QSettings settings;
512 settings.beginGroup(QString::fromStdString(VIEW_ID));
513 m_Controls->m_ShowImageStream->setChecked(settings.value("DisplayImage", true).toBool());
514 m_Controls->m_RunImageTimer->setChecked(settings.value("RunImageTimer", true).toBool());
515 m_Controls->m_Update2DView->setChecked(settings.value("Update2DView", true).toBool());
516 m_Controls->m_Update3DView->setChecked(settings.value("Update3DView", true).toBool());
517 m_Controls->m_FrameRatePipeline->setValue(settings.value("UpdateRatePipeline", 50).toInt());
518 m_Controls->m_FrameRate2d->setValue(settings.value("UpdateRate2d", 20).toInt());
519 m_Controls->m_FrameRate3d->setValue(settings.value("UpdateRate3d", 5).toInt());
520 settings.endGroup();
521}
522
524{
525 m_Clock.start();
526 m_UpdateTimer->start();
527 if (m_Controls->m_Update2DView->isChecked()) { m_RenderingTimer2d->start(); }
528 if (m_Controls->m_Update3DView->isChecked()) { m_RenderingTimer3d->start(); }
529}
530
532{
533 m_UpdateTimer->stop();
534 m_RenderingTimer2d->stop();
535 m_RenderingTimer3d->stop();
536}
537
538void QmitkUltrasoundSupport::SetTimerIntervals(int intervalPipeline, int interval2D, int interval3D)
539{
540 m_UpdateTimer->setInterval(intervalPipeline);
541 m_RenderingTimer2d->setInterval(interval2D);
542 m_RenderingTimer3d->setInterval(interval3D);
543}
544
545
546/* Spacing methods */
548{
549 m_Xpoint1 = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
550 m_XSpacing = ComputeSpacing(m_Xpoint1, m_Xpoint2, m_Controls->m_XDistance->value());
551 m_Controls->m_XSpacing->setText(QString("X Spacing: ") + QString::number(m_XSpacing) + " mm");
552}
554{
555 m_Xpoint2 = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
556 m_XSpacing = ComputeSpacing(m_Xpoint1, m_Xpoint2, m_Controls->m_XDistance->value());
557 m_Controls->m_XSpacing->setText(QString("X Spacing: ") + QString::number(m_XSpacing) + " mm");
558}
560{
561 m_Ypoint1 = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
562 m_YSpacing = ComputeSpacing(m_Ypoint1, m_Ypoint2, m_Controls->m_YDistance->value());
563 m_Controls->m_YSpacing->setText(QString("Y Spacing: ") + QString::number(m_YSpacing) + " mm");
564}
566{
567 m_Ypoint2 = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
568 m_YSpacing = ComputeSpacing(m_Ypoint1, m_Ypoint2, m_Controls->m_YDistance->value());
569 m_Controls->m_YSpacing->setText(QString("Y Spacing: ") + QString::number(m_YSpacing) + " mm");
570}
572{
573 this->m_Device->SetSpacing(m_XSpacing, m_YSpacing);
574 MITK_INFO << "Spacing saved to device object, please save device data to permanently store the spacing.";
575}
576double QmitkUltrasoundSupport::ComputeSpacing(mitk::Point3D p1, mitk::Point3D p2, double distance)
577{
578 double spacing = 0;
579 double pointDistance = p1.EuclideanDistanceTo(p2);
580 spacing = distance / pointDistance;
581 return spacing;
582}
583
Abstract superclass for all custom control widgets of mitk::USDevice classes.
void SetDevice(mitk::USDevice::Pointer device)
QmitkUSAbstractCustomWidget * CloneForQt(QWidget *parent=nullptr) const
Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with add...
Widget for b mode controls of ultrasound devices. This class handles the mitk::USControlInterfaceBMod...
Widget for b mode controls of ultrasound devices. This class handles the mitk::USControlInterfaceDopp...
Widget for probes controls of ultrasound devices. This class handles the mitk::USControlInterfaceProb...
QmitkUSAbstractCustomWidget * m_ControlCustomWidget
void CreateQtPartControl(QWidget *parent) override
mitk::USDevice::Pointer m_Device
QmitkUSControlsProbesWidget * m_ControlProbesWidget
std::vector< mitk::Image::Pointer > m_curOutput
QmitkUSControlsDopplerWidget * m_ControlDopplerWidget
QmitkUSControlsBModeWidget * m_ControlBModeWidget
static const std::string VIEW_ID
void OnDeviceServiceEvent(const ctkServiceEvent event)
std::vector< mitk::DataNode::Pointer > m_Node
Ui::UltrasoundSupportControls * m_Controls
QList< ctkServiceReference > m_CustomWidgetServiceReference
void SetTimerIntervals(int intervalPipeline, int interval2D, int interval3D)
mitk::SlicedGeometry3D::Pointer m_OldGeometry
double ComputeSpacing(mitk::Point3D p1, mitk::Point3D p2, double distance)
A device holds information about it's model, make and the connected probes. It is the common super cl...
static mitk::USDevice::PropertyKeys GetPropertyKeys()
static std::string GetDeviceClassStatic()
MITKIGTBASE_EXPORT bool Equal(const mitk::NavigationData &leftHandSide, const mitk::NavigationData &rightHandSide, ScalarType eps=mitk::eps, bool verbose=false)
Equal A function comparing two navigation data objects for beeing equal in meta- and imagedata.
const std::string US_PROPKEY_ISACTIVE
const std::string US_PROPKEY_MANUFACTURER
const std::string US_PROPKEY_NAME
const std::string US_PROPKEY_BMODE_DYNAMIC_RANGE
const std::string US_PROPKEY_LABEL