14#include "ui_QmitkUSNavigationStepPunctuationIntervention.h"
21#include "usModuleRegistry.h"
29 m_NeedleProjectionFilter(
mitk::NeedleProjectionFilter::New()),
30 m_NeedleNavigationTool(
mitk::NavigationTool::New()),
41 m_Ui->m_AblationZonesBox->setVisible(
false);
47 this->m_NeedleNavigationTool = needleNavigationTool;
52 if(m_Ui->m_EnableAblationMarking->isChecked())
53 m_Ui->m_AblationZonesBox->setVisible(
true);
55 m_Ui->m_AblationZonesBox->setVisible(
false);
60int id = m_Ui->m_AblationZonesList->currentRow();
66 QListWidgetItem* newItem =
new QListWidgetItem(
"Ablation Zone (initial size: " + QString::number(m_Ui->m_AblationZoneSizeSlider->value()) +
" mm)", m_Ui->m_AblationZonesList);
67 newItem->setSelected(
true);
73 mitk::DataStorage::Pointer dataStorage = this->
GetDataStorage(
false);
74 if ( dataStorage.IsNotNull() )
79 if ( node.IsNotNull() ) { dataStorage->Remove(node); }
90 node->SetData(m_NeedleProjectionFilter->GetProjection());
91 node->SetBoolProperty(
"show contour",
true);
103 mitk::DataNode::Pointer finishPunctionResult = mitk::DataNode::New();
104 finishPunctionResult->SetName(
"PunctionResult");
105 mitk::Point3D needlePos = m_NeedleProjectionFilter->GetOutput(0)->GetPosition();
106 mitk::Quaternion needleRot = m_NeedleProjectionFilter->GetOutput(0)->GetOrientation();
107 finishPunctionResult->SetProperty(
"USNavigation::TipPositionEnd", mitk::Point3dProperty::New(needlePos));
108 MITK_INFO(
"USNavigationLogging") <<
"Instrument tip at end: " <<needlePos<<
" / " << needleRot;
124 for (mitk::DataStorage::SetOfObjects::ConstIterator it = m_ZoneNodes->Begin();
125 it != m_ZoneNodes->End(); ++it)
127 m_Ui->riskStructuresRangeWidget->AddZone(it->Value());
129 it->Value()->GetColor(rgb);
131 color.SetRed(rgb[0]);
132 color.SetGreen(rgb[1]);
133 color.SetBlue(rgb[2]);
134 m_OldColors[it->Value()] = color;
137 m_NeedleProjectionFilter->SelectInput(0);
144 if (enabled == 0) { m_NeedleProjectionFilter->ShowToolAxis(
false); }
145 else { m_NeedleProjectionFilter->ShowToolAxis(
true); }
152 mitk::NavigationDataSource::Pointer navigationDataSource =
155 if ( navigationDataSource.IsNull() )
158 MITK_ERROR(
"QmitkUSAbstractNavigationStep")(
"QmitkUSNavigationStepPunctuationIntervention")
159 <<
"Navigation Data Source of Combined Modality must not be null.";
160 mitkThrow() <<
"Navigation Data Source of Combined Modality must not be null.";
167 m_NeedleProjectionFilter->Update();
170 mitk::Point3D point1 = m_NeedleProjectionFilter->GetProjection()->GetPoint(0);
171 mitk::Point3D point2 = m_NeedleProjectionFilter->GetProjection()->GetPoint(1);
172 double distance = point1.EuclideanDistanceTo(point2);
173 m_Ui->m_DistanceToUSPlane->setText(QString::number(distance) +
" mm");
178 if ( settingsNode.IsNull() ) {
return; }
183 return "Computer-assisted Intervention";
193 return FilterVector(1, m_NeedleProjectionFilter.GetPointer());
198 mitk::AbstractUltrasoundTrackerDevice::Pointer combinedModality = this->
GetCombinedModality(
false);
199 if ( combinedModality.IsNotNull() )
201 m_NeedleProjectionFilter->ConnectTo(combinedModality->GetNavigationDataSource());
204 mitk::AffineTransform3D::Pointer usPlaneTransform = combinedModality->GetUSPlaneTransform();
205 if (usPlaneTransform.IsNotNull())
207 m_NeedleProjectionFilter->SetTargetPlane(usPlaneTransform);
212 MITK_WARN <<
"CombinedModality is null!";
218 m_Ui->riskStructuresRangeWidget->ClearZones();
223 if ( bodyMarker.IsNull() )
225 MITK_ERROR(
"QmitkUSAbstractNavigationStep")(
"QmitkUSNavigationStepPunctuationIntervention")
226 <<
"Current Navigation Data for body marker of Combined Modality must not be null.";
227 mitkThrow() <<
"Current Navigation Data for body marker of Combined Modality must not be null.";
230 bool valid = bodyMarker->IsDataValid();
235 m_Ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
236 "background-color: #8bff8b; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
237 m_Ui->bodyMarkerTrackingStatusLabel->setText(
"Body marker is inside the tracking volume.");
241 m_Ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
242 "background-color: #ff7878; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
243 m_Ui->bodyMarkerTrackingStatusLabel->setText(
"Body marker is not inside the tracking volume.");
246 m_Ui->riskStructuresRangeGroupBox->setEnabled(valid);
252 m_Ui->riskStructuresRangeWidget->UpdateDistancesToNeedlePosition(needle);
255 for (mitk::DataStorage::SetOfObjects::ConstIterator it = m_ZoneNodes->Begin();
256 it != m_ZoneNodes->End(); ++it)
258 mitk::DataNode::Pointer currentNode = it->Value();
261 mitk::Point3D center;
262 currentNode->GetFloatProperty(
"zone.size", radius);
263 center = mitk::Point3D(currentNode->GetData()->GetGeometry()->GetIndexToWorldTransform()->GetTranslation());
264 mitk::Point3D point0 = path->GetPoint(0);
265 mitk::Point3D point1 = path->GetPoint(1);
267 {currentNode->SetColor(mitk::IGTColor_WARNING);}
269 {currentNode->SetColor(m_OldColors[currentNode]);}
275 double center[3] = {sphereOrigin[0],sphereOrigin[1],sphereOrigin[2]};
276 m_SphereSource->SetCenter(center);
277 m_SphereSource->SetRadius(sphereRadius);
278 m_SphereSource->Update();
280 m_OBBTree->SetDataSet(m_SphereSource->GetOutput());
281 m_OBBTree->BuildLocator();
283 double lineP0[3] = {lineStart[0], lineStart[1], lineStart[2]};
284 double lineP1[3] = {lineEnd[0], lineEnd[1], lineEnd[2]};
286 m_OBBTree->IntersectWithLine(lineP0, lineP1, m_IntersectPoints,
nullptr);
288 if (m_IntersectPoints->GetNumberOfPoints() > 0) {
return true;}
Abstract base class for navigation step widgets.
itk::SmartPointer< mitk::DataStorage > GetDataStorage(bool throwNull=true)
Returns the data storage set for the navigation step.
static const char * DATANAME_BASENODE
itk::SmartPointer< mitk::DataNode > GetNamedDerivedNodeAndCreate(const char *name, const char *sourceName)
Returns node with the given name and the given source node (parent) from the data storage....
itk::SmartPointer< mitk::AbstractUltrasoundTrackerDevice > GetCombinedModality(bool throwNull=true)
Returns the combined modality set for the navigation step.
std::vector< itk::SmartPointer< mitk::NavigationDataToNavigationDataFilter > > FilterVector
void SignalIntermediateResult(const itk::SmartPointer< mitk::DataNode >)
Signals that an intermediate result was produced. The properties of the given data node must contain ...
itk::SmartPointer< mitk::DataNode > GetNamedDerivedNode(const char *name, const char *sourceName)
Returns node with the given name and the given source node (parent) from the data storage.
static const char * DATANAME_ZONES
Navigations step for the actual punctuation intervention. The needle path is projected onto the image...
void OnShowToolAxisEnabled(int enabled)
bool CheckSphereLineIntersection(mitk::Point3D &sphereOrigin, float &sphereRadius, mitk::Point3D &lineStart, mitk::Point3D &lineEnd)
void OnAblationZoneSizeSliderChanged(int size)
void OnEnableAblationZoneMarkingClicked()
bool OnActivateStep() override
Called when the navigation step gets activated. This method has to be implemented by a concrete subcl...
bool GetIsRestartable() override
Indicates if it makes sense to be able to restart the step. This method must be implemented by concre...
void OnUpdate() override
Called periodically while a navigation step is active. This method has to be implemented by a concret...
void UpdateBodyMarkerStatus(mitk::NavigationData::Pointer bodyMarker)
bool OnRestartStep() override
Called when restarting a navigation step. This method may be implemented by a concrete subclass to ha...
QString GetTitle() override
Getter for the title of the navigation step. This title should be human readable and can be used to d...
bool OnStartStep() override
Called when the navigation step gets started. This method has to be implemented by a concrete subclas...
void UpdateCriticalStructures(mitk::NavigationData::Pointer needle, mitk::PointSet::Pointer path)
FilterVector GetFilter() override
Getter for navigation data filters of the navigation step. This method may be implemented by a concre...
~QmitkUSNavigationStepPunctuationIntervention() override
void AblationZoneChanged(int, int)
void AddAblationZoneClicked(int)
bool OnFinishStep() override
Called when all necessary actions for the step where done. This method has to be implemented by a con...
void OnSettingsChanged(const itk::SmartPointer< mitk::DataNode >) override
Called every time the settings for the navigation process where changed. This method may be implement...
void OnSetCombinedModality() override
Called every time SetCombinedModality() was called. This method may be implemented by a concrete subc...
void OnAddAblationZoneClicked()
QmitkUSNavigationStepPunctuationIntervention(QWidget *parent=nullptr)
void SetNeedleMetaData(mitk::NavigationTool::Pointer needleNavigationTool)