MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUSNavigationZoneDistancesWidget.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
15
16#include "mitkDataNode.h"
17#include "mitkNavigationData.h"
18
19#include <QVBoxLayout>
20
22 QWidget(parent),
23 m_SizePropertyKey("zone.size")
24{
25 this->setLayout(new QVBoxLayout(this));
26}
27
31
32void QmitkUSNavigationZoneDistancesWidget::SetSizePropertyKey(const std::string& sizePropertyKey)
33{
34 m_SizePropertyKey = sizePropertyKey;
35}
36
41
43{
44 m_ZoneNodes.append(zoneNode);
45 QmitkZoneProgressBar* progressBar =
46 new QmitkZoneProgressBar(QString::fromStdString(zoneNode->GetName())+QString(": %1 mm"), 60, 25, this);
47
48 float color[3] = {1, 0, 0};
49 progressBar->SetWarnColor(color);
50
51 zoneNode->GetColor(color);
52 progressBar->SetColor(color);
53
54 m_ZoneProgressBars.append(progressBar);
55 this->layout()->addWidget(progressBar);
56}
57
59{
60 // clear risk zones
61 for (QVector<QmitkZoneProgressBar*>::Iterator it = m_ZoneProgressBars.begin();
62 it != m_ZoneProgressBars.end(); ++it)
63 {
64 this->layout()->removeWidget(*it);
65 delete *it;
66 }
67
68 m_ZoneProgressBars.clear();
69 m_ZoneNodes.clear();
70}
71
73{
74 if ( needle.IsNull() )
75 {
76 MITK_ERROR("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepMarkerIntervention")
77 << "Current Navigation Data for needle must not be null.";
78 mitkThrow() << "Current Navigation Data for needle must not be null.";
79 }
80
81 // get needle position
82 if (needle->IsDataValid())
83 {
84 mitk::Point3D needlePosition = needle->GetPosition();
85
86 for (int n = 0; n < m_ZoneNodes.size(); ++n)
87 {
88 mitk::Point3D zoneOrigin = m_ZoneNodes.at(n)->GetData()->GetGeometry()->GetOrigin();
89
90 // calculate absolute distance
91 mitk::ScalarType distance = sqrt( pow(zoneOrigin[0] - needlePosition[0], 2) + pow(zoneOrigin[1] - needlePosition[1], 2) + pow(zoneOrigin[2] - needlePosition[2], 2) );
92
93 // subtract zone size
94 float zoneSize;
95 m_ZoneNodes.at(n)->GetFloatProperty(m_SizePropertyKey.c_str(), zoneSize);
96 distance = distance - zoneSize;
97
98 m_ZoneProgressBars.at(n)->setValue(distance);
99
100 if ( distance < 0 ) { SignalZoneViolated(m_ZoneNodes.at(n), needlePosition); }
101 }
102 }
103}
void AddZone(itk::SmartPointer< mitk::DataNode > zoneNode)
Adds a zone to the widget.
void UpdateDistancesToNeedlePosition(itk::SmartPointer< mitk::NavigationData > needle)
Updates color and label of each zone distance bar according to the given needle position.
void SetSizePropertyKey(const std::string &sizePropertyKey)
Set the key for the data node float property holding the radius of a zone. The default value of this ...
QVector< itk::SmartPointer< mitk::DataNode > > m_ZoneNodes
void SignalZoneViolated(const mitk::DataNode *, mitk::Point3D)
Emitted whenever a the distance to a zone falls below zero.
const std::string & GetSizePropertyKey() const
Get the key for the data node float property holding the radius of a zone.
void ClearZones()
Removes all zones from the widget.
QProgressBar for displaying distances to zones. Colors are changed according to the distance to the z...
void SetColor(float color[3])
void SetWarnColor(float color[3])