diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/files.cmake b/Plugins/org.mitk.gui.qt.igt.app.echotrack/files.cmake
index c52dc3511e..54901bd4e4 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/files.cmake
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/files.cmake
@@ -1,137 +1,137 @@
set(SRC_CPP_FILES
)
set(INTERNAL_CPP_FILES
org_mbi_gui_qt_usnavigation_Activator.cpp
#USNavigation.cpp //not functional anymore. Delete code?
QmitkUltrasoundCalibration.cpp
- USNavigationMarkerPlacement.cpp
+ QmitkUSNavigationMarkerPlacement.cpp
QmitkUSNavigationPerspective.cpp
mitkUSTargetPlacementQualityCalculator.cpp
QmitkUSZonesDataModel.cpp
QmitkUSNavigationCalibrationsDataModel.cpp
QmitkUSZoneManagementColorDialogDelegate.cpp
QmitkUSNavigationCalibrationRemoveDelegate.cpp
QmitkUSNavigationCalibrationUpdateDepthDelegate.cpp
Interactors/mitkUSZonesInteractor.cpp
Interactors/mitkUSPointMarkInteractor.cpp
Widgets/QmitkUSCombinedModalityCreationWidget.cpp
Widgets/QmitkUSCombinedModalityEditWidget.cpp
Widgets/QmitkUSNavigationFreezeButton.cpp
Widgets/QmitkUSNavigationProcessWidget.cpp
Widgets/QmitkUSNavigationZoneDistancesWidget.cpp
Widgets/QmitkUSZoneManagementWidget.cpp
Widgets/QmitkZoneProgressBar.cpp
NavigationStepWidgets/QmitkUSAbstractNavigationStep.cpp
NavigationStepWidgets/QmitkUSNavigationStepCombinedModality.cpp
NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.cpp
NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.cpp
NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.cpp
NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.cpp
NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.cpp
SettingsWidgets/QmitkUSNavigationCombinedSettingsWidget.cpp
SettingsWidgets/QmitkUSNavigationAbstractSettingsWidget.cpp
Filter/mitkUSNavigationTargetOcclusionFilter.cpp
Filter/mitkUSNavigationTargetUpdateFilter.cpp
Filter/mitkUSNavigationTargetIntersectionFilter.cpp
IO/mitkUSNavigationCombinedModalityPersistence.cpp
IO/mitkUSNavigationLoggingBackend.cpp
IO/mitkUSNavigationExperimentLogging.cpp
IO/mitkUSNavigationStepTimer.cpp
)
set(UI_FILES
#src/internal/USNavigationControls.ui //not functional anymore. Delete code?
src/internal/QmitkUltrasoundCalibrationControls.ui
- src/internal/USNavigationMarkerPlacement.ui
+ src/internal/QmitkUSNavigationMarkerPlacement.ui
src/internal/Widgets/QmitkUSCombinedModalityCreationWidget.ui
src/internal/Widgets/QmitkUSCombinedModalityEditWidget.ui
src/internal/Widgets/QmitkUSNavigationProcessWidget.ui
src/internal/Widgets/QmitkUSZoneManagementWidget.ui
src/internal/NavigationStepWidgets/QmitkUSAbstractNavigationStep.ui
src/internal/NavigationStepWidgets/QmitkUSNavigationStepCombinedModality.ui
src/internal/NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.ui
src/internal/NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.ui
src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.ui
src/internal/NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.ui
src/internal/NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.ui
src/internal/SettingsWidgets/QmitkUSNavigationCombinedSettingsWidget.ui
)
set(MOC_H_FILES
src/internal/org_mbi_gui_qt_usnavigation_Activator.h
#src/internal/USNavigation.h //not functional anymore. Delete code?
src/internal/QmitkUltrasoundCalibration.h
- src/internal/USNavigationMarkerPlacement.h
+ src/internal/QmitkUSNavigationMarkerPlacement.h
src/internal/QmitkUSZonesDataModel.h
src/internal/QmitkUSNavigationCalibrationsDataModel.h
src/internal/QmitkUSZoneManagementColorDialogDelegate.h
src/internal/QmitkUSNavigationCalibrationRemoveDelegate.h
src/internal/QmitkUSNavigationCalibrationUpdateDepthDelegate.h
src/internal/QmitkUSNavigationPerspective.h
src/internal/Widgets/QmitkUSCombinedModalityCreationWidget.h
src/internal/Widgets/QmitkUSCombinedModalityEditWidget.h
src/internal/Widgets/QmitkUSNavigationFreezeButton.h
src/internal/Widgets/QmitkUSNavigationProcessWidget.h
src/internal/Widgets/QmitkUSNavigationZoneDistancesWidget.h
src/internal/Widgets/QmitkUSZoneManagementWidget.h
src/internal/Widgets/QmitkZoneProgressBar.h
src/internal/NavigationStepWidgets/QmitkUSAbstractNavigationStep.h
src/internal/NavigationStepWidgets/QmitkUSNavigationStepCombinedModality.h
src/internal/NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.h
src/internal/NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.h
src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.h
src/internal/NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.h
src/internal/NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.h
src/internal/SettingsWidgets/QmitkUSNavigationCombinedSettingsWidget.h
src/internal/SettingsWidgets/QmitkUSNavigationAbstractSettingsWidget.h
)
# list of resource files which can be used by the plug-in
# system without loading the plug-ins shared library,
# for example the icon used in the menu and tabs for the
# plug-in views in the workbench
set(CACHED_RESOURCE_FILES
# resources/icon.xpm //not functional anymore. Delete code?
resources/icon2.xpm
resources/icon_US_calibration.svg
plugin.xml
)
# list of Qt .qrc files which contain additional resources
# specific to this plugin
set(QRC_FILES
resources/USNavigation.qrc
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
set(RESOURCE_FILES
Interactions/USPointMarkInteractions.xml
Interactions/USZoneInteractions.xml
Interactions/USZoneInteractionsHold.xml
)
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/plugin.xml b/Plugins/org.mitk.gui.qt.igt.app.echotrack/plugin.xml
index e5ff5432a2..3e385bffbd 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/plugin.xml
@@ -1,26 +1,26 @@
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.cpp
index 61c7b2e42d..3c6f6514df 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.cpp
@@ -1,1017 +1,1017 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkUSNavigationStepMarkerIntervention.h"
#include "ui_QmitkUSNavigationStepMarkerIntervention.h"
#include "mitkBaseRenderer.h"
#include "mitkContourModel.h"
#include "mitkNeedleProjectionFilter.h"
#include "mitkNodeDisplacementFilter.h"
#include "mitkSurface.h"
#include "mitkTextAnnotation2D.h"
#include
#include
#include "../Filter/mitkUSNavigationTargetIntersectionFilter.h"
#include "../Filter/mitkUSNavigationTargetOcclusionFilter.h"
#include "../Filter/mitkUSNavigationTargetUpdateFilter.h"
-#include "../USNavigationMarkerPlacement.h"
+#include "../QmitkUSNavigationMarkerPlacement.h"
#include "../Widgets/QmitkZoneProgressBar.h"
#include "../mitkUSTargetPlacementQualityCalculator.h"
#include "../Interactors/mitkUSPointMarkInteractor.h"
#include "usModuleRegistry.h"
#include "mitkLookupTable.h"
#include "mitkLookupTableProperty.h"
#include "mitkSurface.h"
// VTK
#include "vtkCellLocator.h"
#include "vtkDataSet.h"
#include "vtkDoubleArray.h"
#include "vtkFloatArray.h"
#include "vtkIdList.h"
#include "vtkLinearTransform.h"
#include "vtkLookupTable.h"
#include "vtkMath.h"
#include "vtkOBBTree.h"
#include "vtkPointData.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkSelectEnclosedPoints.h"
#include "vtkSmartPointer.h"
#include "vtkSphereSource.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkWarpScalar.h"
QmitkUSNavigationStepMarkerIntervention::QmitkUSNavigationStepMarkerIntervention(QWidget *parent)
: QmitkUSAbstractNavigationStep(parent),
m_NumberOfTargets(0),
m_PlannedTargetsNodes(),
m_ReachedTargetsNodes(),
m_TargetProgressBar(new QmitkZoneProgressBar(QString::fromStdString("Target: %1 mm"), 200, 0, this)),
m_PlannedTargetProgressBar(nullptr),
m_CurrentTargetIndex(0),
m_CurrentTargetReached(false),
m_ShowPlanningColors(false),
m_PointMarkInteractor(mitk::USPointMarkInteractor::New()),
m_TargetNode(nullptr),
m_TargetColorLookupTableProperty(nullptr),
m_TargetSurface(nullptr),
m_NeedleProjectionFilter(mitk::NeedleProjectionFilter::New()),
m_NodeDisplacementFilter(mitk::NodeDisplacementFilter::New()),
m_TargetUpdateFilter(mitk::USNavigationTargetUpdateFilter::New()),
m_TargetOcclusionFilter(mitk::USNavigationTargetOcclusionFilter::New()),
m_TargetIntersectionFilter(mitk::USNavigationTargetIntersectionFilter::New()),
m_PlacementQualityCalculator(mitk::USTargetPlacementQualityCalculator::New()),
m_TargetStructureWarnOverlay(mitk::TextAnnotation2D::New()),
m_ReferenceSensorName(),
m_NeedleSensorName(),
m_ReferenceSensorIndex(1),
m_NeedleSensorIndex(0),
m_ListenerTargetCoordinatesChanged(this, &QmitkUSNavigationStepMarkerIntervention::UpdateTargetCoordinates),
ui(new Ui::QmitkUSNavigationStepMarkerIntervention)
{
m_ActiveTargetColor[0] = 1;
m_ActiveTargetColor[1] = 1;
m_ActiveTargetColor[2] = 0;
m_InactiveTargetColor[0] = 1;
m_InactiveTargetColor[1] = 1;
m_InactiveTargetColor[2] = 0.5;
m_ReachedTargetColor[0] = 0.6;
m_ReachedTargetColor[1] = 1;
m_ReachedTargetColor[2] = 0.6;
ui->setupUi(this);
connect(ui->freezeImageButton, SIGNAL(SignalFreezed(bool)), this, SLOT(OnFreeze(bool)));
connect(ui->backToLastTargetButton, SIGNAL(clicked()), this, SLOT(OnBackToLastTargetClicked()));
connect(ui->targetReachedButton, SIGNAL(clicked()), this, SLOT(OnTargetLeft()));
connect(this, SIGNAL(TargetReached(int)), this, SLOT(OnTargetReached()));
connect(this, SIGNAL(TargetLeft(int)), this, SLOT(OnTargetLeft()));
connect(ui->riskStructuresRangeWidget,
SIGNAL(SignalZoneViolated(const mitk::DataNode *, mitk::Point3D)),
this,
SLOT(OnRiskZoneViolated(const mitk::DataNode *, mitk::Point3D)));
m_PointMarkInteractor->CoordinatesChangedEvent.AddListener(m_ListenerTargetCoordinatesChanged);
this->GenerateTargetColorLookupTable();
m_TargetProgressBar->SetTextFormatInvalid("Target is not on Needle Path");
ui->targetStructuresRangeLayout->addWidget(m_TargetProgressBar);
m_TargetUpdateFilter->SetScalarArrayIdentifier("USNavigation::ReachedTargetScores");
}
QmitkUSNavigationStepMarkerIntervention::~QmitkUSNavigationStepMarkerIntervention()
{
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage(false);
if (dataStorage.IsNotNull())
{
// remove the node for the needle path
mitk::DataNode::Pointer node =
this->GetNamedDerivedNode("Needle Path", QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
if (node.IsNotNull())
{
dataStorage->Remove(node);
}
}
delete ui;
m_PointMarkInteractor->CoordinatesChangedEvent.RemoveListener(m_ListenerTargetCoordinatesChanged);
}
bool QmitkUSNavigationStepMarkerIntervention::OnStartStep()
{
m_NeedleProjectionFilter->SelectInput(m_NeedleSensorIndex);
// create node for Needle Projection
mitk::DataNode::Pointer node =
this->GetNamedDerivedNodeAndCreate("Needle Path", QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
node->SetData(m_NeedleProjectionFilter->GetProjection());
node->SetBoolProperty("show contour", true);
// initialize warning overlay (and do not display it, yet)
m_TargetStructureWarnOverlay->SetText("Warning: Needle is Inside the Target Structure.");
m_TargetStructureWarnOverlay->SetVisibility(false);
// set position and font size for the text overlay
mitk::Point2D overlayPosition;
overlayPosition.SetElement(0, 10.0f);
overlayPosition.SetElement(1, 10.0f);
m_TargetStructureWarnOverlay->SetPosition2D(overlayPosition);
m_TargetStructureWarnOverlay->SetFontSize(18);
// overlay should be red
mitk::Color color;
color[0] = 1;
color[1] = 0;
color[2] = 0;
m_TargetStructureWarnOverlay->SetColor(color);
mitk::ManualPlacementAnnotationRenderer::AddAnnotation(m_TargetStructureWarnOverlay.GetPointer(), "stdmulti.widget4");
return true;
}
bool QmitkUSNavigationStepMarkerIntervention::OnStopStep()
{
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage();
// remove all reached nodes from the data storage
for (QVector>::iterator it = m_ReachedTargetsNodes.begin();
it != m_ReachedTargetsNodes.end();
++it)
{
dataStorage->Remove(*it);
}
m_ReachedTargetsNodes.clear();
m_CurrentTargetIndex = 0;
// reset button states
ui->freezeImageButton->setEnabled(false);
ui->backToLastTargetButton->setEnabled(false);
ui->targetReachedButton->setEnabled(true);
// make sure that it is unfreezed after stopping the step
ui->freezeImageButton->Unfreeze();
// remove base node for reached targets from the data storage
mitk::DataNode::Pointer reachedTargetsNode = this->GetNamedDerivedNode(
- QmitkUSAbstractNavigationStep::DATANAME_BASENODE, USNavigationMarkerPlacement::DATANAME_REACHED_TARGETS);
+ QmitkUSAbstractNavigationStep::DATANAME_BASENODE, QmitkUSNavigationMarkerPlacement::DATANAME_REACHED_TARGETS);
if (reachedTargetsNode.IsNotNull())
{
dataStorage->Remove(reachedTargetsNode);
}
return true;
}
bool QmitkUSNavigationStepMarkerIntervention::OnFinishStep()
{
return true;
}
bool QmitkUSNavigationStepMarkerIntervention::OnActivateStep()
{
this->ClearZones(); // clear risk zones before adding new ones
// get target node from data storage and make sure that it contains data
- m_TargetNode = this->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_TARGETSURFACE,
- USNavigationMarkerPlacement::DATANAME_TUMOUR);
+ m_TargetNode = this->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_TARGETSURFACE,
+ QmitkUSNavigationMarkerPlacement::DATANAME_TUMOUR);
if (m_TargetNode.IsNull() || m_TargetNode->GetData() == 0)
{
- mitkThrow() << "Target node (" << USNavigationMarkerPlacement::DATANAME_TARGETSURFACE << ") must not be null.";
+ mitkThrow() << "Target node (" << QmitkUSNavigationMarkerPlacement::DATANAME_TARGETSURFACE << ") must not be null.";
}
// get target data and make sure that it is a surface
m_TargetSurface = dynamic_cast(m_TargetNode->GetData());
if (m_TargetSurface.IsNull())
{
- mitkThrow() << "Target node (" << USNavigationMarkerPlacement::DATANAME_TARGETSURFACE
+ mitkThrow() << "Target node (" << QmitkUSNavigationMarkerPlacement::DATANAME_TARGETSURFACE
<< ") data must be of type mitk::Surface";
}
// delete progress bars for reinitializing them again afterwards
if (m_PlannedTargetProgressBar)
{
ui->targetStructuresRangeLayout->removeWidget(m_PlannedTargetProgressBar);
delete m_PlannedTargetProgressBar;
m_PlannedTargetProgressBar = 0;
}
m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
this->UpdateTargetProgressDisplay();
- mitk::DataNode::Pointer tumourNode = this->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_TUMOUR,
+ mitk::DataNode::Pointer tumourNode = this->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_TUMOUR,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
if (tumourNode.IsNotNull())
{
// do not show tumour node during intervention (target surface is shown)
tumourNode->SetBoolProperty("visible", false);
// add tumour as a risk structure
ui->riskStructuresRangeWidget->AddZone(tumourNode);
}
// set target structure for target update filter
m_TargetUpdateFilter->SetTargetStructure(m_TargetNode);
m_TargetOcclusionFilter->SetTargetStructure(m_TargetNode);
// set lookup table of tumour node
m_TargetNode->SetProperty("LookupTable", m_TargetColorLookupTableProperty);
//
- mitk::DataNode::Pointer targetsBaseNode = this->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_TARGETS,
+ mitk::DataNode::Pointer targetsBaseNode = this->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
mitk::DataStorage::SetOfObjects::ConstPointer plannedTargetNodes;
if (targetsBaseNode.IsNotNull())
{
plannedTargetNodes = this->GetDataStorage()->GetDerivations(targetsBaseNode);
}
if (plannedTargetNodes.IsNotNull() && plannedTargetNodes->Size() > 0)
{
for (mitk::DataStorage::SetOfObjects::ConstIterator it = plannedTargetNodes->Begin();
it != plannedTargetNodes->End();
++it)
{
m_PlannedTargetsNodes.push_back(it->Value());
}
m_PlannedTargetProgressBar = new QmitkZoneProgressBar(QString::fromStdString("Planned Target"), 200, 0);
ui->targetStructuresRangeLayout->addWidget(m_PlannedTargetProgressBar);
}
// add progress bars for risk zone nodes
- mitk::DataNode::Pointer zonesBaseNode = this->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_ZONES,
+ mitk::DataNode::Pointer zonesBaseNode = this->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_ZONES,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
// only add progress bars if the base node for zones was created
if (zonesBaseNode.IsNotNull())
{
mitk::DataStorage::SetOfObjects::ConstPointer zoneNodes = this->GetDataStorage()->GetDerivations(zonesBaseNode);
for (mitk::DataStorage::SetOfObjects::ConstIterator it = zoneNodes->Begin(); it != zoneNodes->End(); ++it)
{
ui->riskStructuresRangeWidget->AddZone(it->Value());
}
m_TargetOcclusionFilter->SelectStartPositionInput(m_NeedleSensorIndex);
m_TargetOcclusionFilter->SetObstacleStructures(zoneNodes);
}
return true;
}
bool QmitkUSNavigationStepMarkerIntervention::OnDeactivateStep()
{
ui->freezeImageButton->Unfreeze();
return true;
}
void QmitkUSNavigationStepMarkerIntervention::OnUpdate()
{
// get navigation data source and make sure that it is not null
mitk::NavigationDataSource::Pointer navigationDataSource = this->GetCombinedModality()->GetNavigationDataSource();
if (navigationDataSource.IsNull())
{
MITK_ERROR("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepMarkerIntervention") << "Navigation Data Source of Combined Modality must not be null.";
mitkThrow() << "Navigation Data Source of Combined Modality must not be null.";
}
ui->riskStructuresRangeWidget->UpdateDistancesToNeedlePosition(navigationDataSource->GetOutput(m_NeedleSensorIndex));
this->UpdateBodyMarkerStatus(navigationDataSource->GetOutput(m_ReferenceSensorIndex));
this->UpdateTargetColors();
this->UpdateTargetScore();
this->UpdateTargetViolationStatus();
}
void QmitkUSNavigationStepMarkerIntervention::OnSettingsChanged(const itk::SmartPointer settingsNode)
{
if (settingsNode.IsNull())
{
return;
}
int numberOfTargets;
if (settingsNode->GetIntProperty("settings.number-of-targets", numberOfTargets))
{
m_NumberOfTargets = numberOfTargets;
m_TargetUpdateFilter->SetNumberOfTargets(numberOfTargets);
m_PlacementQualityCalculator->SetOptimalAngle(m_TargetUpdateFilter->GetOptimalAngle());
}
std::string referenceSensorName;
if (settingsNode->GetStringProperty("settings.reference-name-selected", referenceSensorName))
{
m_ReferenceSensorName = referenceSensorName;
}
std::string needleSensorName;
if (settingsNode->GetStringProperty("settings.needle-name-selected", needleSensorName))
{
m_NeedleSensorName = needleSensorName;
}
this->UpdateSensorsNames();
}
QString QmitkUSNavigationStepMarkerIntervention::GetTitle()
{
return "Computer-assisted Intervention";
}
bool QmitkUSNavigationStepMarkerIntervention::GetIsRestartable()
{
return true;
}
QmitkUSAbstractNavigationStep::FilterVector QmitkUSNavigationStepMarkerIntervention::GetFilter()
{
FilterVector filter;
filter.push_back(m_NeedleProjectionFilter.GetPointer());
filter.push_back(m_NodeDisplacementFilter.GetPointer());
filter.push_back(m_TargetOcclusionFilter.GetPointer());
return filter;
}
void QmitkUSNavigationStepMarkerIntervention::OnSetCombinedModality()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if (combinedModality.IsNotNull())
{
mitk::AffineTransform3D::Pointer calibration = combinedModality->GetCalibration();
if (calibration.IsNotNull())
{
m_NeedleProjectionFilter->SetTargetPlane(calibration);
}
}
ui->freezeImageButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex);
this->UpdateSensorsNames();
}
void QmitkUSNavigationStepMarkerIntervention::OnTargetReached()
{
m_CurrentTargetReached = true;
}
void QmitkUSNavigationStepMarkerIntervention::OnTargetLeft()
{
m_CurrentTargetReached = false;
m_CurrentTargetIndex++;
if (m_CurrentTargetIndex >= 0 && static_cast(m_CurrentTargetIndex) >= m_NumberOfTargets)
{
ui->targetReachedButton->setDisabled(true);
}
ui->backToLastTargetButton->setEnabled(true);
ui->freezeImageButton->setEnabled(true);
this->UpdateTargetProgressDisplay();
if (m_ReachedTargetsNodes.size() < m_CurrentTargetIndex)
{
mitk::DataNode::Pointer node = mitk::DataNode::New();
node->SetName(
(QString("Target ") + QString("%1").arg(m_CurrentTargetIndex, 2, 10, QLatin1Char('0'))).toStdString());
this->GetDataStorage()->Add(
node,
- this->GetNamedDerivedNodeAndCreate(USNavigationMarkerPlacement::DATANAME_REACHED_TARGETS,
+ this->GetNamedDerivedNodeAndCreate(QmitkUSNavigationMarkerPlacement::DATANAME_REACHED_TARGETS,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE));
m_ReachedTargetsNodes.push_back(node);
}
mitk::DataNode::Pointer node = m_ReachedTargetsNodes.at(m_CurrentTargetIndex - 1);
mitk::Surface::Pointer zone = mitk::Surface::New();
// create a vtk sphere with given radius
vtkSphereSource *vtkData = vtkSphereSource::New();
vtkData->SetRadius(5);
vtkData->SetCenter(0, 0, 0);
vtkData->Update();
zone->SetVtkPolyData(vtkData->GetOutput());
vtkData->Delete();
// set vtk sphere and origin to data node
node->SetData(zone);
node->GetData()->GetGeometry()->SetOrigin(
this->GetCombinedModality()->GetNavigationDataSource()->GetOutput(m_NeedleSensorIndex)->GetPosition());
node->SetColor(0.2, 0.9, 0.2);
this->UpdateTargetCoordinates(node);
}
void QmitkUSNavigationStepMarkerIntervention::OnBackToLastTargetClicked()
{
if (m_CurrentTargetIndex < 1)
{
MITK_WARN << "Cannot go back to last target as there is no last target.";
return;
}
m_CurrentTargetIndex--;
if (m_ReachedTargetsNodes.size() > m_CurrentTargetIndex)
{
this->GetDataStorage()->Remove(m_ReachedTargetsNodes.last());
MITK_INFO("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepMarkerIntervention") << "Removed Target " << m_ReachedTargetsNodes.size();
m_ReachedTargetsNodes.pop_back();
}
if (m_CurrentTargetIndex == 0)
{
ui->backToLastTargetButton->setDisabled(true);
}
if (m_CurrentTargetIndex >= 0 && static_cast(m_CurrentTargetIndex) < m_NumberOfTargets)
{
ui->targetReachedButton->setEnabled(true);
}
ui->freezeImageButton->setEnabled(false);
ui->freezeImageButton->Unfreeze();
this->UpdateTargetProgressDisplay();
m_TargetUpdateFilter->RemovePositionOfTarget(m_CurrentTargetIndex);
}
void QmitkUSNavigationStepMarkerIntervention::OnFreeze(bool freezed)
{
if (freezed)
{
this->GetCombinedModality()->SetIsFreezed(true);
// load state machine and event config for data interactor
m_PointMarkInteractor->LoadStateMachine("USPointMarkInteractions.xml", us::ModuleRegistry::GetModule("MitkUS"));
m_PointMarkInteractor->SetEventConfig("globalConfig.xml");
if (m_CurrentTargetIndex < 1)
{
mitkThrow() << "Current target index has to be greater zero when freeze button is clicked.";
}
if (m_ReachedTargetsNodes.size() < m_CurrentTargetIndex)
{
mitk::DataNode::Pointer node = mitk::DataNode::New();
node->SetName(
(QString("Target ") + QString("%1").arg(m_CurrentTargetIndex, 2, 10, QLatin1Char('0'))).toStdString());
this->GetDataStorage()->Add(
node,
- this->GetNamedDerivedNodeAndCreate(USNavigationMarkerPlacement::DATANAME_REACHED_TARGETS,
+ this->GetNamedDerivedNodeAndCreate(QmitkUSNavigationMarkerPlacement::DATANAME_REACHED_TARGETS,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE));
m_ReachedTargetsNodes.push_back(node);
}
m_PointMarkInteractor->SetDataNode(m_ReachedTargetsNodes.last());
}
else
{
m_PointMarkInteractor->SetDataNode(0);
this->GetCombinedModality()->SetIsFreezed(false);
}
}
void QmitkUSNavigationStepMarkerIntervention::OnShowPlanningView(bool show)
{
m_ShowPlanningColors = show;
}
void QmitkUSNavigationStepMarkerIntervention::OnRiskZoneViolated(const mitk::DataNode *node, mitk::Point3D position)
{
MITK_INFO << "Risk zone (" << node->GetName() << ") violated at position " << position << ".";
}
void QmitkUSNavigationStepMarkerIntervention::ClearZones()
{
ui->riskStructuresRangeWidget->ClearZones();
// remove all reached target nodes from the data storage and clear the list
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage();
for (QVector::iterator it = m_ReachedTargetsNodes.begin(); it != m_ReachedTargetsNodes.end();
++it)
{
if (it->IsNotNull())
{
dataStorage->Remove(*it);
}
}
m_ReachedTargetsNodes.clear();
}
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetCoordinates(mitk::DataNode *dataNode)
{
m_NodeDisplacementFilter->ResetNodes();
for (QVector>::iterator it = m_ReachedTargetsNodes.begin();
it != m_ReachedTargetsNodes.end();
++it)
{
if (it->IsNotNull() && (*it)->GetData() != 0)
{
m_NodeDisplacementFilter->AddNode(*it);
}
}
mitk::BaseData *baseData = dataNode->GetData();
if (!baseData)
{
mitkThrow() << "Data of the data node must not be null.";
}
mitk::BaseGeometry::Pointer geometry = baseData->GetGeometry();
if (geometry.IsNull())
{
mitkThrow() << "Geometry of the data node must not be null.";
}
m_TargetUpdateFilter->SetControlNode(m_CurrentTargetIndex - 1, dataNode);
if (m_PlannedTargetsNodes.size() > m_CurrentTargetIndex - 1)
{
m_PlannedTargetsNodes.at(m_CurrentTargetIndex - 1)->SetVisibility(false);
}
MITK_INFO("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepMarkerIntervention") << "Target " << m_CurrentTargetIndex << " reached at position "
<< geometry->GetOrigin();
this->CalculateTargetPlacementQuality();
}
void QmitkUSNavigationStepMarkerIntervention::UpdateBodyMarkerStatus(mitk::NavigationData::Pointer bodyMarker)
{
if (bodyMarker.IsNull())
{
MITK_ERROR("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepMarkerIntervention")
<< "Current Navigation Data for body marker of Combined Modality must not be null.";
mitkThrow() << "Current Navigation Data for body marker of Combined Modality must not be null.";
}
bool valid = bodyMarker->IsDataValid();
// update body marker status label
if (valid)
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #8bff8b; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is inside the tracking volume.");
}
else
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #ff7878; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is not inside the tracking volume.");
}
ui->targetStructuresRangeGroupBox->setEnabled(valid);
ui->riskStructuresRangeGroupBox->setEnabled(valid);
}
void QmitkUSNavigationStepMarkerIntervention::GenerateTargetColorLookupTable()
{
vtkSmartPointer lookupTable = vtkSmartPointer::New();
lookupTable->SetHueRange(0.0, 0.33);
lookupTable->SetSaturationRange(1.0, 1.0);
lookupTable->SetValueRange(1.0, 1.0);
lookupTable->SetTableRange(0.0, 1.0);
lookupTable->Build();
mitk::LookupTable::Pointer lut = mitk::LookupTable::New();
lut->SetVtkLookupTable(lookupTable);
m_TargetColorLookupTableProperty = mitk::LookupTableProperty::New(lut);
}
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetColors()
{
if (m_TargetNode.IsNull())
{
return;
}
m_TargetNode->SetColor(1, 1, 1);
mitk::BaseData *targetNodeData = m_TargetNode->GetData();
if (targetNodeData == 0)
{
return;
}
mitk::Surface::Pointer targetNodeSurface = dynamic_cast(targetNodeData);
vtkSmartPointer targetNodeSurfaceVtk = targetNodeSurface->GetVtkPolyData();
vtkPointData *targetPointData = targetNodeSurface->GetVtkPolyData()->GetPointData();
vtkFloatArray *scalars = dynamic_cast(targetPointData->GetScalars("USNavigation::Occlusion"));
vtkFloatArray *targetScoreScalars;
if (m_ShowPlanningColors)
{
targetScoreScalars = dynamic_cast(targetPointData->GetScalars("USNavigation::PlanningScalars"));
}
else
{
targetScoreScalars =
dynamic_cast(targetPointData->GetScalars("USNavigation::ReachedTargetScores"));
}
if (!scalars || !targetScoreScalars)
{
return;
}
unsigned int numberOfTupels = scalars->GetNumberOfTuples();
vtkSmartPointer colors = vtkSmartPointer::New();
colors->SetNumberOfComponents(1);
colors->SetNumberOfTuples(numberOfTupels);
colors->SetName("Colors");
double color, intersection, markerScore;
for (unsigned int n = 0; n < numberOfTupels; n++)
{
scalars->GetTuple(n, &intersection);
targetScoreScalars->GetTuple(n, &markerScore);
if (intersection > 0)
{
color = 0;
}
else
{
color = markerScore;
}
colors->SetTuple(n, &color);
}
if (numberOfTupels > 0)
{
targetNodeSurfaceVtk->GetPointData()->SetScalars(colors);
targetNodeSurfaceVtk->GetPointData()->Update();
}
}
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetScore()
{
if (m_NeedleProjectionFilter->GetProjection()->GetSize() != 2)
{
return;
}
vtkSmartPointer targetSurfaceVtk = m_TargetSurface->GetVtkPolyData();
m_TargetIntersectionFilter->SetTargetSurface(m_TargetSurface);
m_TargetIntersectionFilter->SetLine(m_NeedleProjectionFilter->GetProjection());
m_TargetIntersectionFilter->CalculateIntersection();
if (m_TargetIntersectionFilter->GetIsIntersecting())
{
vtkFloatArray *scalars =
dynamic_cast(targetSurfaceVtk->GetPointData()->GetScalars("USNavigation::ReachedTargetScores"));
double score;
scalars->GetTuple(m_TargetIntersectionFilter->GetIntersectionNearestSurfacePointId(), &score);
double color[3];
m_TargetColorLookupTableProperty->GetLookupTable()->GetVtkLookupTable()->GetColor(score, color);
float colorF[3];
colorF[0] = color[0];
colorF[1] = color[1];
colorF[2] = color[2];
m_TargetProgressBar->SetColor(colorF);
m_TargetProgressBar->SetBorderColor(colorF);
m_TargetProgressBar->setValue(m_TargetIntersectionFilter->GetDistanceToIntersection());
if (m_PlannedTargetProgressBar)
{
vtkFloatArray *scalars =
dynamic_cast(targetSurfaceVtk->GetPointData()->GetScalars("USNavigation::PlanningScalars"));
if (scalars)
{
double score;
scalars->GetTuple(m_TargetIntersectionFilter->GetIntersectionNearestSurfacePointId(), &score);
double color[3];
m_TargetColorLookupTableProperty->GetLookupTable()->GetVtkLookupTable()->GetColor(score, color);
float colorF[3];
colorF[0] = color[0];
colorF[1] = color[1];
colorF[2] = color[2];
m_PlannedTargetProgressBar->SetColor(colorF);
m_PlannedTargetProgressBar->SetBorderColor(colorF);
m_PlannedTargetProgressBar->SetTextFormatValid("Planned Target: %1 mm");
mitk::Point3D intersectionPoint = m_TargetIntersectionFilter->GetIntersectionPoint();
mitk::ScalarType minDistance = -1;
for (QVector>::iterator it = m_PlannedTargetsNodes.begin();
it != m_PlannedTargetsNodes.end();
++it)
{
mitk::ScalarType distance =
intersectionPoint.EuclideanDistanceTo((*it)->GetData()->GetGeometry()->GetOrigin());
if (minDistance < 0 || distance < minDistance)
{
minDistance = distance;
}
}
m_PlannedTargetProgressBar->setValue(minDistance);
}
}
}
else
{
m_TargetProgressBar->setValueInvalid();
}
}
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetProgressDisplay()
{
QString description;
if (m_CurrentTargetIndex >= static_cast(m_NumberOfTargets))
{
description = "All Targets Reached";
if (m_TargetProgressBar)
{
m_TargetProgressBar->hide();
}
}
else
{
description = QString("Distance to Target ") + QString::number(m_CurrentTargetIndex + 1) + QString(" of ") +
QString::number(m_NumberOfTargets);
if (m_TargetProgressBar)
{
m_TargetProgressBar->show();
}
}
ui->targetStructuresRangeGroupBox->setTitle(description);
}
void QmitkUSNavigationStepMarkerIntervention::UpdatePlannedTargetProgressDisplay()
{
// make sure that the needle projection consists of two points
if (m_NeedleProjectionFilter->GetProjection()->GetSize() != 2)
{
return;
}
vtkSmartPointer targetSurfaceVtk = m_TargetSurface->GetVtkPolyData();
m_TargetIntersectionFilter->SetTargetSurface(m_TargetSurface);
m_TargetIntersectionFilter->SetLine(m_NeedleProjectionFilter->GetProjection());
m_TargetIntersectionFilter->CalculateIntersection();
// update target progress bar according to the color of the intersection
// point on the target surface and the distance to the intersection
if (m_TargetIntersectionFilter->GetIsIntersecting())
{
vtkFloatArray *scalars = dynamic_cast(targetSurfaceVtk->GetPointData()->GetScalars("Colors"));
double score;
scalars->GetTuple(m_TargetIntersectionFilter->GetIntersectionNearestSurfacePointId(), &score);
double color[3];
m_TargetColorLookupTableProperty->GetLookupTable()->GetVtkLookupTable()->GetColor(score, color);
float colorF[3];
colorF[0] = color[0];
colorF[1] = color[1];
colorF[2] = color[2];
m_TargetProgressBar->SetColor(colorF);
m_TargetProgressBar->SetBorderColor(colorF);
m_TargetProgressBar->setValue(m_TargetIntersectionFilter->GetDistanceToIntersection());
}
else
{
float red[3] = {0.6f, 0.0f, 0.0f};
m_TargetProgressBar->SetBorderColor(red);
m_TargetProgressBar->setValueInvalid();
}
}
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetViolationStatus()
{
// transform vtk polydata according to mitk geometry
vtkSmartPointer transformFilter = vtkSmartPointer::New();
transformFilter->SetInputData(0, m_TargetSurface->GetVtkPolyData());
transformFilter->SetTransform(m_TargetSurface->GetGeometry()->GetVtkTransform());
transformFilter->Update();
vtkSmartPointer enclosedPoints = vtkSmartPointer::New();
enclosedPoints->Initialize(transformFilter->GetOutput());
mitk::Point3D needleTip = m_NeedleProjectionFilter->GetProjection()->GetPoint(0);
// show warning if the needle tip is inside the target surface
if (enclosedPoints->IsInsideSurface(needleTip[0], needleTip[1], needleTip[2]))
{
if (!m_TargetStructureWarnOverlay->IsVisible(NULL))
{
m_TargetStructureWarnOverlay->SetVisibility(true);
mitk::DataNode::Pointer targetViolationResult = mitk::DataNode::New();
targetViolationResult->SetName("TargetViolation");
targetViolationResult->SetProperty("USNavigation::TargetViolationPoint", mitk::Point3dProperty::New(needleTip));
emit SignalIntermediateResult(targetViolationResult);
}
MITK_INFO("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepMarkerIntervention") << "Target surface violated at " << needleTip << ".";
}
else
{
m_TargetStructureWarnOverlay->SetVisibility(false);
}
}
void QmitkUSNavigationStepMarkerIntervention::CalculateTargetPlacementQuality()
{
// clear quality display if there aren't all targets reached
if (m_ReachedTargetsNodes.size() != static_cast(m_NumberOfTargets))
{
ui->placementQualityGroupBox->setEnabled(false);
ui->angleDifferenceValue->setText("");
ui->centersOfMassValue->setText("");
return;
}
ui->placementQualityGroupBox->setEnabled(true);
mitk::Surface::Pointer targetSurface = dynamic_cast(m_TargetNode->GetData());
if (targetSurface.IsNull())
{
mitkThrow() << "Target surface must not be null.";
}
m_PlacementQualityCalculator->SetTargetSurface(targetSurface);
mitk::PointSet::Pointer targetPointSet = mitk::PointSet::New();
// copy the origins of all reached target nodes into a point set
// for the quality calculator
mitk::PointSet::PointIdentifier n = 0;
for (QVector>::iterator it = m_ReachedTargetsNodes.begin();
it != m_ReachedTargetsNodes.end();
++it)
{
targetPointSet->InsertPoint(n++, (*it)->GetData()->GetGeometry()->GetOrigin());
}
m_PlacementQualityCalculator->SetTargetPoints(targetPointSet);
m_PlacementQualityCalculator->Update();
double centersOfMassDistance = m_PlacementQualityCalculator->GetCentersOfMassDistance();
ui->centersOfMassValue->setText(QString::number(centersOfMassDistance, 103, 2) + " mm");
double meanAnglesDifference = m_PlacementQualityCalculator->GetMeanAngleDifference();
ui->angleDifferenceValue->setText(QString::number(meanAnglesDifference, 103, 2) + QString::fromLatin1(" °"));
// create an intermediate result of the placement quality
mitk::DataNode::Pointer placementQualityResult = mitk::DataNode::New();
placementQualityResult->SetName("PlacementQuality");
placementQualityResult->SetFloatProperty("USNavigation::CentersOfMassDistance", centersOfMassDistance);
placementQualityResult->SetFloatProperty("USNavigation::MeanAngleDifference", meanAnglesDifference);
placementQualityResult->SetProperty(
"USNavigation::AngleDifferences",
mitk::GenericProperty::New(m_PlacementQualityCalculator->GetAngleDifferences()));
if (m_PlannedTargetsNodes.size() == static_cast(m_NumberOfTargets))
{
mitk::VnlVector reachedPlannedDifferences;
double reachedPlannedDifferencesSum = 0;
double reachedPlannedDifferencesMax = 0;
reachedPlannedDifferences.set_size(m_NumberOfTargets);
// get sum and maximum of the planning / reality differences
for (unsigned int n = 0; n < m_NumberOfTargets; ++n)
{
mitk::ScalarType distance =
m_PlannedTargetsNodes.at(n)->GetData()->GetGeometry()->GetOrigin().EuclideanDistanceTo(
m_ReachedTargetsNodes.at(n)->GetData()->GetGeometry()->GetOrigin());
reachedPlannedDifferences.put(n, distance);
reachedPlannedDifferencesSum += distance;
if (distance > reachedPlannedDifferencesMax)
{
reachedPlannedDifferencesMax = distance;
}
}
// add distances between planning and reality to the quality intermediate result
placementQualityResult->SetProperty("USNavigation::PlanningRealityDistances",
mitk::GenericProperty::New(reachedPlannedDifferences));
placementQualityResult->SetProperty(
"USNavigation::MeanPlanningRealityDistance",
mitk::DoubleProperty::New(reachedPlannedDifferencesSum / static_cast(m_NumberOfTargets)));
placementQualityResult->SetProperty("USNavigation::MaximumPlanningRealityDistance",
mitk::DoubleProperty::New(reachedPlannedDifferencesMax));
}
emit SignalIntermediateResult(placementQualityResult);
}
void QmitkUSNavigationStepMarkerIntervention::UpdateSensorsNames()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if (combinedModality.IsNull())
{
return;
}
mitk::NavigationDataSource::Pointer navigationDataSource = combinedModality->GetNavigationDataSource();
if (navigationDataSource.IsNull())
{
return;
}
if (!m_NeedleSensorName.empty())
{
try
{
m_NeedleSensorIndex = navigationDataSource->GetOutputIndex(m_NeedleSensorName);
}
catch (const std::exception &e)
{
MITK_WARN("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Cannot get index for needle sensor name: " << e.what();
}
}
if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active)
{
m_NeedleProjectionFilter->SelectInput(m_NeedleSensorIndex);
}
if (!m_ReferenceSensorName.empty())
{
try
{
m_ReferenceSensorIndex = navigationDataSource->GetOutputIndex(m_ReferenceSensorName);
}
catch (const std::exception &e)
{
MITK_WARN("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Cannot get index for reference sensor name: " << e.what();
}
}
if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active)
{
m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
}
ui->freezeImageButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex);
}
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.cpp
index ed25fa6f63..4554922d1d 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.cpp
@@ -1,817 +1,817 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkUSNavigationStepPlacementPlanning.h"
#include "ui_QmitkUSNavigationStepPlacementPlanning.h"
#include "../Interactors/mitkUSPointMarkInteractor.h"
#include "../mitkUSTargetPlacementQualityCalculator.h"
#include "mitkNeedleProjectionFilter.h"
#include "mitkNodeDisplacementFilter.h"
#include "usModuleRegistry.h"
#include "../Filter/mitkUSNavigationTargetIntersectionFilter.h"
#include "../Filter/mitkUSNavigationTargetUpdateFilter.h"
-#include "../USNavigationMarkerPlacement.h"
+#include "../QmitkUSNavigationMarkerPlacement.h"
#include "mitkLookupTableProperty.h"
#include "mitkSurface.h"
#include
#include "mitkLayoutAnnotationRenderer.h"
#include "mitkTextAnnotation3D.h"
#include "vtkFloatArray.h"
#include "vtkLookupTable.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkSmartPointer.h"
#include "vtkLineSource.h"
#include "vtkSphereSource.h"
#include "vtkCenterOfMass.h"
#include "vtkLinearTransform.h"
#include "vtkPoints.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkUnstructuredGrid.h"
#include "vtkMath.h"
QmitkUSNavigationStepPlacementPlanning::QmitkUSNavigationStepPlacementPlanning(QWidget *parent)
: QmitkUSAbstractNavigationStep(parent),
m_NumberOfTargets(0),
m_CurrentTargetIndex(0),
m_BodyMarkerValid(false),
m_PointMarkInteractor(mitk::USPointMarkInteractor::New()),
m_TargetUpdateFilter(mitk::USNavigationTargetUpdateFilter::New()),
m_NodeDisplacementFilter(mitk::NodeDisplacementFilter::New()),
m_NeedleProjectionFilter(mitk::NeedleProjectionFilter::New()),
m_TargetIntersectionFilter(mitk::USNavigationTargetIntersectionFilter::New()),
m_PlacementQualityCalculator(mitk::USTargetPlacementQualityCalculator::New()),
m_ReferenceSensorIndex(1),
m_NeedleSensorIndex(0),
m_ListenerTargetCoordinatesChanged(this, &QmitkUSNavigationStepPlacementPlanning::UpdateTargetCoordinates),
ui(new Ui::QmitkUSNavigationStepPlacementPlanning)
{
ui->setupUi(this);
connect(ui->freezeImageButton, SIGNAL(SignalFreezed(bool)), this, SLOT(OnFreeze(bool)));
m_TargetUpdateFilter->SetScalarArrayIdentifier("USNavigation::PlanningPlacement");
this->GenerateTargetColorLookupTable();
}
QmitkUSNavigationStepPlacementPlanning::~QmitkUSNavigationStepPlacementPlanning()
{
delete ui;
}
bool QmitkUSNavigationStepPlacementPlanning::OnStartStep()
{
// create node for needle projection
mitk::DataNode::Pointer node =
this->GetNamedDerivedNodeAndCreate("Needle Path", QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
node->SetData(m_NeedleProjectionFilter->GetProjection());
node->SetBoolProperty("show contour", true);
// make sure that the targets node exist in the data storage
- this->GetNamedDerivedNodeAndCreate(USNavigationMarkerPlacement::DATANAME_TARGETS,
+ this->GetNamedDerivedNodeAndCreate(QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
- this->GetNamedDerivedNodeAndCreate(USNavigationMarkerPlacement::DATANAME_TARGETS_PATHS,
+ this->GetNamedDerivedNodeAndCreate(QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS_PATHS,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
// listen to event of point mark interactor
m_PointMarkInteractor->CoordinatesChangedEvent.AddListener(m_ListenerTargetCoordinatesChanged);
return true;
}
bool QmitkUSNavigationStepPlacementPlanning::OnStopStep()
{
// remove listener to event of point mark interactor
m_PointMarkInteractor->CoordinatesChangedEvent.RemoveListener(m_ListenerTargetCoordinatesChanged);
m_CurrentTargetIndex = 0;
m_TargetUpdateFilter->Reset();
m_NodeDisplacementFilter->ResetNodes();
// remove the planned target nodes from the data storage
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage();
for (QVector>::iterator it = m_PlannedTargetNodes.begin();
it != m_PlannedTargetNodes.end();
++it)
{
dataStorage->Remove(*it);
}
m_PlannedTargetNodes.clear();
// remove the planned target path nodes from the data storage
for (QVector>::iterator it = m_PlannedNeedlePaths.begin();
it != m_PlannedNeedlePaths.end();
++it)
{
dataStorage->Remove(*it);
}
m_PlannedNeedlePaths.clear();
// remove the targets node from the data storage
- mitk::DataNode::Pointer targetsNode = this->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_TARGETS,
+ mitk::DataNode::Pointer targetsNode = this->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
if (targetsNode.IsNotNull())
{
dataStorage->Remove(targetsNode);
}
// remove the target paths node from the data storage
mitk::DataNode::Pointer targetPathsNode = this->GetNamedDerivedNode(
- USNavigationMarkerPlacement::DATANAME_TARGETS_PATHS, QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
+ QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS_PATHS, QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
if (targetPathsNode.IsNotNull())
{
dataStorage->Remove(targetPathsNode);
}
// make sure that the image is no longer freezed after stopping
ui->freezeImageButton->Unfreeze();
return true;
}
bool QmitkUSNavigationStepPlacementPlanning::OnRestartStep()
{
this->OnStopStep();
this->OnStartStep();
return true;
}
bool QmitkUSNavigationStepPlacementPlanning::OnFinishStep()
{
// create scalars showing the planned positions on the target surface
if (!m_PlannedTargetNodes.isEmpty())
{
mitk::USNavigationTargetUpdateFilter::Pointer planningSurfaceFilter = mitk::USNavigationTargetUpdateFilter::New();
planningSurfaceFilter->SetOptimalAngle(0);
planningSurfaceFilter->SetScalarArrayIdentifier("USNavigation::PlanningScalars");
planningSurfaceFilter->SetUseMaximumScore(true);
planningSurfaceFilter->SetTargetStructure(m_TargetNode);
unsigned int n = 0;
for (QVector>::iterator it = m_PlannedTargetNodes.begin();
it != m_PlannedTargetNodes.end();
++it)
{
bool isSurfaceEmpty;
if (((*it)->GetBoolProperty("surface_empty", isSurfaceEmpty)) && isSurfaceEmpty)
{
// remove node from data storage if it is not fully planned
this->GetDataStorage()->Remove(*it);
}
else
{
// set origin to filter for coloring target surface (good
// positions are positions near to the origin)
planningSurfaceFilter->SetControlNode(n, *it);
}
n++;
}
}
// make sure that the image is no longer freezed after finishing
ui->freezeImageButton->Unfreeze();
return true;
}
bool QmitkUSNavigationStepPlacementPlanning::OnActivateStep()
{
emit SignalReadyForNextStep();
m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
m_NeedleProjectionFilter->SelectInput(m_NeedleSensorIndex);
if (m_PlannedTargetNodes.empty())
{
m_CurrentTargetIndex = 0;
}
else
{
m_CurrentTargetIndex = m_PlannedTargetNodes.size() - 1;
}
- m_TargetNode = this->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_TARGETSURFACE,
- USNavigationMarkerPlacement::DATANAME_TUMOUR);
+ m_TargetNode = this->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_TARGETSURFACE,
+ QmitkUSNavigationMarkerPlacement::DATANAME_TUMOUR);
m_TargetNode->SetBoolProperty("visible", true);
// set lookup table of tumour node
m_TargetNode->SetProperty("LookupTable", m_TargetColorLookupTableProperty);
m_TargetUpdateFilter->SetTargetStructure(m_TargetNode);
for (QVector>::iterator it = m_PlannedTargetNodes.begin();
it != m_PlannedTargetNodes.end();
++it)
{
(*it)->SetBoolProperty("visible", true);
}
this->UpdateTargetDescriptions();
// m_TargetUpdateFilter->UpdateTargetScores();
return true;
}
bool QmitkUSNavigationStepPlacementPlanning::OnDeactivateStep()
{
ui->freezeImageButton->Unfreeze();
return true;
}
void QmitkUSNavigationStepPlacementPlanning::OnUpdate()
{
this->UpdateTargetColors();
// get navigation data source and make sure that it is not null
mitk::NavigationDataSource::Pointer navigationDataSource = this->GetCombinedModality()->GetNavigationDataSource();
if (navigationDataSource.IsNull())
{
MITK_ERROR("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPunctuationIntervention") << "Navigation Data Source of Combined Modality must not be null.";
mitkThrow() << "Navigation Data Source of Combined Modality must not be null.";
}
navigationDataSource->Update();
this->UpdateBodyMarkerStatus(navigationDataSource->GetOutput(m_ReferenceSensorIndex));
ui->freezeImageButton->setEnabled(m_BodyMarkerValid);
mitk::PointSet::Pointer needleProjectionPointSet = m_NeedleProjectionFilter->GetProjection();
if (needleProjectionPointSet->GetSize() == 2)
{
m_TargetIntersectionFilter->SetTargetSurface(dynamic_cast(m_TargetNode->GetData()));
m_TargetIntersectionFilter->SetLine(needleProjectionPointSet);
m_TargetIntersectionFilter->CalculateIntersection();
if (m_TargetIntersectionFilter->GetIsIntersecting())
{
// only enable button if body marker is in the tracking volume, too
ui->placeTargetButton->setEnabled(m_BodyMarkerValid);
ui->placeTargetButton->setToolTip("");
if (m_PlannedTargetNodes.size() == m_NumberOfTargets - 1)
{
mitk::PointSet::Pointer targetPointSet = mitk::PointSet::New();
mitk::PointSet::PointIdentifier n = 0;
for (QVector>::iterator it = m_PlannedTargetNodes.begin();
it != m_PlannedTargetNodes.end();
++it)
{
targetPointSet->InsertPoint(n++, (*it)->GetData()->GetGeometry()->GetOrigin());
}
targetPointSet->InsertPoint(n, m_TargetIntersectionFilter->GetIntersectionPoint());
this->CalculatePlanningQuality(dynamic_cast(m_TargetNode->GetData()), targetPointSet);
}
}
else
{
ui->placeTargetButton->setEnabled(false);
ui->placeTargetButton->setToolTip(
"Target cannot be placed as the needle path is not intersecting the target surface.");
// no not show planning quality if not all nodes are planned for now
// and there is no needle path intersection
if (m_PlannedTargetNodes.size() < m_NumberOfTargets)
{
ui->angleDifferenceValue->setText("");
ui->centersOfMassValue->setText("");
}
}
}
}
void QmitkUSNavigationStepPlacementPlanning::OnSettingsChanged(const itk::SmartPointer settingsNode)
{
int numberOfTargets;
if (settingsNode->GetIntProperty("settings.number-of-targets", numberOfTargets))
{
m_NumberOfTargets = numberOfTargets;
m_TargetUpdateFilter->SetNumberOfTargets(numberOfTargets);
m_PlacementQualityCalculator->SetOptimalAngle(m_TargetUpdateFilter->GetOptimalAngle());
}
std::string referenceSensorName;
if (settingsNode->GetStringProperty("settings.reference-name-selected", referenceSensorName))
{
m_ReferenceSensorName = referenceSensorName;
}
std::string needleSensorName;
if (settingsNode->GetStringProperty("settings.needle-name-selected", needleSensorName))
{
m_NeedleSensorName = needleSensorName;
}
this->UpdateSensorsNames();
}
QString QmitkUSNavigationStepPlacementPlanning::GetTitle()
{
return "Placement Planning";
}
QmitkUSAbstractNavigationStep::FilterVector QmitkUSNavigationStepPlacementPlanning::GetFilter()
{
FilterVector filterVector;
filterVector.push_back(m_NodeDisplacementFilter.GetPointer());
filterVector.push_back(m_NeedleProjectionFilter.GetPointer());
return filterVector;
}
void QmitkUSNavigationStepPlacementPlanning::OnSetCombinedModality()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if (combinedModality.IsNotNull())
{
mitk::AffineTransform3D::Pointer calibration = combinedModality->GetCalibration();
if (calibration.IsNotNull())
{
m_NeedleProjectionFilter->SetTargetPlane(calibration);
}
}
ui->freezeImageButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex);
this->UpdateSensorsNames();
}
void QmitkUSNavigationStepPlacementPlanning::OnFreeze(bool freeze)
{
if (freeze)
this->GetCombinedModality()->SetIsFreezed(true);
if (freeze)
{
// load state machine and event config for data interactor
m_PointMarkInteractor->LoadStateMachine("USPointMarkInteractions.xml", us::ModuleRegistry::GetModule("MitkUS"));
m_PointMarkInteractor->SetEventConfig("globalConfig.xml");
this->CreateTargetNodesIfNecessary();
m_PointMarkInteractor->SetDataNode(m_PlannedTargetNodes.at(m_CurrentTargetIndex));
}
else
{
m_PointMarkInteractor->SetDataNode(0);
}
if (!freeze)
this->GetCombinedModality()->SetIsFreezed(false);
}
void QmitkUSNavigationStepPlacementPlanning::OnPlaceTargetButtonClicked()
{
this->CreateTargetNodesIfNecessary();
mitk::DataNode::Pointer currentNode = m_PlannedTargetNodes.at(m_CurrentTargetIndex);
currentNode->SetData(this->CreateSphere(5));
currentNode->SetBoolProperty("surface_empty", false);
mitk::PointSet::Pointer needleProjection = m_NeedleProjectionFilter->GetProjection();
m_TargetIntersectionFilter->SetTargetSurface(dynamic_cast(m_TargetNode->GetData()));
m_TargetIntersectionFilter->SetLine(m_NeedleProjectionFilter->GetProjection());
m_TargetIntersectionFilter->CalculateIntersection();
mitk::Point3D intersectionPoint = m_TargetIntersectionFilter->GetIntersectionPoint();
currentNode->GetData()->GetGeometry()->SetOrigin(intersectionPoint);
m_TargetUpdateFilter->SetControlNode(m_CurrentTargetIndex, currentNode);
mitk::PointSet::Pointer plannedPath = mitk::PointSet::New();
m_PlannedNeedlePaths.at(m_CurrentTargetIndex)->SetData(plannedPath);
plannedPath->SetPoint(0, needleProjection->GetPoint(0));
plannedPath->SetPoint(1, intersectionPoint);
if (m_CurrentTargetIndex < m_NumberOfTargets - 1)
{
this->OnGoToNextTarget();
}
else
{
this->UpdateTargetDescriptions();
}
this->ReinitNodeDisplacementFilter();
MITK_INFO("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Target " << m_CurrentTargetIndex + 1 << " planned at position "
<< intersectionPoint << ".";
}
void QmitkUSNavigationStepPlacementPlanning::OnGoToPreviousTarget()
{
if (m_CurrentTargetIndex < 1)
{
mitkThrow() << "Cannot go to previous target as current target is first target.";
}
m_CurrentTargetIndex--;
this->UpdateTargetDescriptions();
}
void QmitkUSNavigationStepPlacementPlanning::OnGoToNextTarget()
{
m_CurrentTargetIndex++;
this->UpdateTargetDescriptions();
}
void QmitkUSNavigationStepPlacementPlanning::OnRemoveCurrentTargetClicked()
{
if (m_CurrentTargetIndex >= m_PlannedTargetNodes.size())
{
MITK_WARN << "Cannot remove current target as there aren't as much planned target nodes.";
return;
}
this->GetDataStorage()->Remove(m_PlannedTargetNodes.at(m_CurrentTargetIndex));
m_PlannedTargetNodes.remove(m_CurrentTargetIndex);
this->GetDataStorage()->Remove(m_PlannedNeedlePaths.at(m_CurrentTargetIndex));
m_PlannedNeedlePaths.remove(m_CurrentTargetIndex);
this->ReinitNodeDisplacementFilter();
for (int n = 0; n < m_PlannedTargetNodes.size(); ++n)
{
// set name of the target node according to its new index
m_PlannedTargetNodes.at(n)->SetName(
QString("Target %1").arg(n + 1, m_NumberOfTargets / 10 + 1, 10, QLatin1Char('0')).toStdString());
m_PlannedNeedlePaths.at(n)->SetName(
QString("Target Path %1").arg(n + 1, m_NumberOfTargets / 10 + 1, 10, QLatin1Char('0')).toStdString());
}
m_TargetUpdateFilter->RemovePositionOfTarget(m_CurrentTargetIndex);
m_CurrentTargetIndex = m_PlannedTargetNodes.size();
this->UpdateTargetDescriptions();
MITK_INFO("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Planned target " << m_CurrentTargetIndex + 1 << " removed.";
}
void QmitkUSNavigationStepPlacementPlanning::CreateTargetNodesIfNecessary()
{
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage();
while (m_PlannedTargetNodes.size() <= m_CurrentTargetIndex)
{
QString targetNumber =
QString("%1").arg(m_PlannedTargetNodes.size() + 1, m_NumberOfTargets / 10 + 1, 10, QLatin1Char('0'));
mitk::DataNode::Pointer targetNode = this->GetNamedDerivedNodeAndCreate(
- (QString("Target ") + targetNumber).toStdString().c_str(), USNavigationMarkerPlacement::DATANAME_TARGETS);
+ (QString("Target ") + targetNumber).toStdString().c_str(), QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS);
targetNode->SetOpacity(0.5);
targetNode->SetBoolProperty("surface_empty", true);
targetNode->SetData(mitk::Surface::New());
m_PlannedTargetNodes.push_back(targetNode);
mitk::DataNode::Pointer targetPathNode =
this->GetNamedDerivedNodeAndCreate((QString("Target Path ") + targetNumber).toStdString().c_str(),
- USNavigationMarkerPlacement::DATANAME_TARGETS_PATHS);
+ QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS_PATHS);
targetPathNode->SetOpacity(0.5);
targetPathNode->SetColor(1, 1, 1);
targetPathNode->SetColor(1, 1, 1, nullptr, "contourcolor");
targetPathNode->SetBoolProperty("show contour", true);
m_PlannedNeedlePaths.push_back(targetPathNode);
mitk::Surface::Pointer pathSurface = mitk::Surface::New();
targetPathNode->SetData(pathSurface);
}
}
void QmitkUSNavigationStepPlacementPlanning::UpdateTargetCoordinates(mitk::DataNode *dataNode)
{
bool surfaceEmpty;
if (dataNode->GetBoolProperty("surface_empty", surfaceEmpty) && surfaceEmpty)
{
mitk::Point3D origin = dataNode->GetData()->GetGeometry()->GetOrigin();
dataNode->SetData(this->CreateSphere(5));
dataNode->SetBoolProperty("surface_empty", false);
dataNode->GetData()->GetGeometry()->SetOrigin(origin);
}
this->ReinitNodeDisplacementFilter();
mitk::BaseData *baseData = dataNode->GetData();
if (!baseData)
{
mitkThrow() << "Data of the data node must not be null.";
}
mitk::BaseGeometry::Pointer geometry = baseData->GetGeometry();
if (geometry.IsNull())
{
mitkThrow() << "Geometry of the data node must not be null.";
}
m_TargetUpdateFilter->SetControlNode(m_CurrentTargetIndex, dataNode);
MITK_INFO("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Target " << m_CurrentTargetIndex + 1 << " planned at position "
<< geometry->GetOrigin() << ".";
if (ui->freezeImageButton->isChecked())
{
ui->freezeImageButton->Unfreeze();
if (m_CurrentTargetIndex < m_NumberOfTargets - 1)
{
this->OnGoToNextTarget();
}
}
this->UpdateTargetDescriptions();
}
void QmitkUSNavigationStepPlacementPlanning::UpdateTargetColors()
{
if (m_TargetNode.IsNull())
{
return;
}
m_TargetNode->SetColor(1, 1, 1);
mitk::BaseData *targetNodeData = m_TargetNode->GetData();
if (targetNodeData == 0)
{
return;
}
mitk::Surface::Pointer targetNodeSurface = dynamic_cast(targetNodeData);
vtkSmartPointer targetNodeSurfaceVtk = targetNodeSurface->GetVtkPolyData();
vtkFloatArray *targetScoreScalars = dynamic_cast(
targetNodeSurface->GetVtkPolyData()->GetPointData()->GetScalars("USNavigation::PlanningPlacement"));
if (!targetScoreScalars)
{
return;
}
unsigned int numberOfTupels = targetScoreScalars->GetNumberOfTuples();
vtkSmartPointer colors = vtkSmartPointer::New();
colors->SetNumberOfComponents(1);
colors->SetNumberOfTuples(numberOfTupels);
colors->SetName("Colors");
double markerScore;
for (unsigned int n = 0; n < numberOfTupels; n++)
{
targetScoreScalars->GetTuple(n, &markerScore);
colors->SetTuple(n, &markerScore);
}
if (numberOfTupels > 0)
{
targetNodeSurfaceVtk->GetPointData()->SetScalars(colors);
targetNodeSurfaceVtk->GetPointData()->Update();
}
}
void QmitkUSNavigationStepPlacementPlanning::UpdateTargetDescriptions()
{
ui->previousButton->setEnabled(m_CurrentTargetIndex > 0);
ui->nextButton->setEnabled(m_CurrentTargetIndex + 1 < m_PlannedTargetNodes.size());
ui->removeButton->setEnabled(m_PlannedTargetNodes.size() > 0);
ui->currentTargetLabel->setText(
QString("Planning Target %1 of %2").arg(m_CurrentTargetIndex + 1).arg(m_NumberOfTargets));
ui->removeButton->setEnabled(m_CurrentTargetIndex < m_PlannedTargetNodes.size());
this->CalculatePlanningQuality();
}
void QmitkUSNavigationStepPlacementPlanning::GenerateTargetColorLookupTable()
{
vtkSmartPointer lookupTable = vtkSmartPointer::New();
lookupTable->SetHueRange(0.0, 0.27);
lookupTable->SetSaturationRange(1.0, 1.0);
lookupTable->SetValueRange(1.0, 1.0);
lookupTable->SetTableRange(0.0, 1.0);
lookupTable->Build();
mitk::LookupTable::Pointer lut = mitk::LookupTable::New();
lut->SetVtkLookupTable(lookupTable);
m_TargetColorLookupTableProperty = mitk::LookupTableProperty::New(lut);
}
void QmitkUSNavigationStepPlacementPlanning::ReinitNodeDisplacementFilter()
{
m_NodeDisplacementFilter->ResetNodes();
for (QVector>::iterator it = m_PlannedTargetNodes.begin();
it != m_PlannedTargetNodes.end();
++it)
{
if (it->IsNotNull() && (*it)->GetData() != 0)
{
m_NodeDisplacementFilter->AddNode(*it);
}
}
for (QVector>::iterator it = m_PlannedNeedlePaths.begin();
it != m_PlannedNeedlePaths.end();
++it)
{
if (it->IsNotNull() && (*it)->GetData() != 0)
{
m_NodeDisplacementFilter->AddNode(*it);
}
}
}
void QmitkUSNavigationStepPlacementPlanning::CalculatePlanningQuality()
{
if (m_PlannedTargetNodes.size() != m_NumberOfTargets)
{
ui->angleDifferenceLabel->setEnabled(false);
ui->centersOfMassLabel->setEnabled(false);
ui->allTargetsPlannedLabel->setEnabled(false);
ui->angleDifferenceValue->setText("");
ui->centersOfMassValue->setText("");
return;
}
ui->angleDifferenceLabel->setEnabled(true);
ui->centersOfMassLabel->setEnabled(true);
ui->allTargetsPlannedLabel->setEnabled(true);
mitk::PointSet::Pointer targetPointSet = mitk::PointSet::New();
mitk::PointSet::PointIdentifier n = 0;
for (QVector>::iterator it = m_PlannedTargetNodes.begin();
it != m_PlannedTargetNodes.end();
++it)
{
targetPointSet->InsertPoint(n++, (*it)->GetData()->GetGeometry()->GetOrigin());
}
mitk::DataNode::Pointer planningQualityResult =
this->CalculatePlanningQuality(dynamic_cast(m_TargetNode->GetData()), targetPointSet);
emit SignalIntermediateResult(planningQualityResult);
}
mitk::DataNode::Pointer QmitkUSNavigationStepPlacementPlanning::CalculatePlanningQuality(
mitk::Surface::Pointer targetSurface, mitk::PointSet::Pointer targetPoints)
{
if (targetSurface.IsNull())
{
mitkThrow() << "Target surface must not be null.";
}
m_PlacementQualityCalculator->SetTargetSurface(targetSurface);
m_PlacementQualityCalculator->SetTargetPoints(targetPoints);
m_PlacementQualityCalculator->Update();
mitk::DataNode::Pointer planningQualityResult = mitk::DataNode::New();
planningQualityResult->SetName("PlanningQuality");
double centersOfMassDistance = m_PlacementQualityCalculator->GetCentersOfMassDistance();
ui->centersOfMassValue->setText(QString::number(centersOfMassDistance, 103, 2) + " mm");
planningQualityResult->SetFloatProperty("USNavigation::CentersOfMassDistance", centersOfMassDistance);
if (m_PlannedTargetNodes.size() > 1)
{
double meanAnglesDifference = m_PlacementQualityCalculator->GetMeanAngleDifference();
ui->angleDifferenceValue->setText(QString::number(meanAnglesDifference, 103, 2) + QString::fromLatin1(" °"));
planningQualityResult->SetFloatProperty("USNavigation::MeanAngleDifference", meanAnglesDifference);
planningQualityResult->SetProperty(
"USNavigation::AngleDifferences",
mitk::GenericProperty::New(m_PlacementQualityCalculator->GetAngleDifferences()));
}
else
{
ui->angleDifferenceValue->setText("not valid for one point");
}
return planningQualityResult;
}
itk::SmartPointer QmitkUSNavigationStepPlacementPlanning::CreateSphere(float)
{
mitk::Surface::Pointer surface = mitk::Surface::New();
// create a vtk sphere with fixed radius
vtkSphereSource *vtkData = vtkSphereSource::New();
vtkData->SetRadius(5);
vtkData->SetCenter(0, 0, 0);
vtkData->Update();
surface->SetVtkPolyData(vtkData->GetOutput());
vtkData->Delete();
return surface;
}
void QmitkUSNavigationStepPlacementPlanning::UpdateBodyMarkerStatus(mitk::NavigationData::Pointer bodyMarker)
{
if (bodyMarker.IsNull())
{
MITK_ERROR("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPunctuationIntervention")
<< "Current Navigation Data for body marker of Combined Modality must not be null.";
mitkThrow() << "Current Navigation Data for body marker of Combined Modality must not be null.";
}
m_BodyMarkerValid = bodyMarker->IsDataValid();
// update body marker status label
if (m_BodyMarkerValid)
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #8bff8b; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is inside the tracking volume.");
}
else
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #ff7878; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is not inside the tracking volume.");
}
}
void QmitkUSNavigationStepPlacementPlanning::UpdateSensorsNames()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if (combinedModality.IsNull())
{
return;
}
mitk::NavigationDataSource::Pointer navigationDataSource = combinedModality->GetNavigationDataSource();
if (navigationDataSource.IsNull())
{
return;
}
if (!m_NeedleSensorName.empty())
{
try
{
m_NeedleSensorIndex = navigationDataSource->GetOutputIndex(m_NeedleSensorName);
}
catch (const std::exception &e)
{
MITK_WARN("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Cannot get index for needle sensor name: " << e.what();
}
}
if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active)
{
m_NeedleProjectionFilter->SelectInput(m_NeedleSensorIndex);
}
if (!m_ReferenceSensorName.empty())
{
try
{
m_ReferenceSensorIndex = navigationDataSource->GetOutputIndex(m_ReferenceSensorName);
}
catch (const std::exception &e)
{
MITK_WARN("QmitkUSAbstractNavigationStep")
("QmitkUSNavigationStepPlacementPlanning") << "Cannot get index for reference sensor name: " << e.what();
}
}
if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active)
{
m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
}
ui->freezeImageButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex);
}
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.cpp
index 1e0fcbba77..1fdbbb5ded 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.cpp
@@ -1,283 +1,283 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkUSNavigationStepPunctuationIntervention.h"
#include "ui_QmitkUSNavigationStepPunctuationIntervention.h"
#include "mitkNeedleProjectionFilter.h"
#include "../Widgets/QmitkZoneProgressBar.h"
-#include "../USNavigationMarkerPlacement.h"
+#include "../QmitkUSNavigationMarkerPlacement.h"
#include "usModuleRegistry.h"
#include
QmitkUSNavigationStepPunctuationIntervention::QmitkUSNavigationStepPunctuationIntervention(QWidget *parent) :
QmitkUSAbstractNavigationStep(parent),
m_Ui(new Ui::QmitkUSNavigationStepPunctuationIntervention),
m_ZoneNodes(nullptr),
m_NeedleProjectionFilter(mitk::NeedleProjectionFilter::New()),
m_NeedleNavigationTool(mitk::NavigationTool::New()),
m_OldColors(),
m_SphereSource(vtkSmartPointer::New()),
m_OBBTree(vtkSmartPointer::New()),
m_IntersectPoints(vtkSmartPointer::New())
{
m_Ui->setupUi(this);
connect(m_Ui->m_AddNewAblationZone, SIGNAL(clicked()), this, SLOT(OnAddAblationZoneClicked()));
connect(m_Ui->m_ShowToolAxisN, SIGNAL(stateChanged(int)), this, SLOT(OnShowToolAxisEnabled(int)));
connect(m_Ui->m_EnableAblationMarking, SIGNAL(clicked()), this, SLOT(OnEnableAblationZoneMarkingClicked()));
connect(m_Ui->m_AblationZoneSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(OnAblationZoneSizeSliderChanged(int)));
m_Ui->m_AblationZonesBox->setVisible(false);
}
void QmitkUSNavigationStepPunctuationIntervention::SetNeedleMetaData(mitk::NavigationTool::Pointer needleNavigationTool)
{
this->m_NeedleNavigationTool = needleNavigationTool;
}
void QmitkUSNavigationStepPunctuationIntervention::OnEnableAblationZoneMarkingClicked()
{
if(m_Ui->m_EnableAblationMarking->isChecked())
m_Ui->m_AblationZonesBox->setVisible(true);
else
m_Ui->m_AblationZonesBox->setVisible(false);
}
void QmitkUSNavigationStepPunctuationIntervention::OnAblationZoneSizeSliderChanged(int size)
{
int id = m_Ui->m_AblationZonesList->currentRow();
if (id!=-1) {emit AblationZoneChanged(id,size);}
}//
void QmitkUSNavigationStepPunctuationIntervention::OnAddAblationZoneClicked()
{
QListWidgetItem* newItem = new QListWidgetItem("Ablation Zone (initial size: " + QString::number(m_Ui->m_AblationZoneSizeSlider->value()) + " mm)", m_Ui->m_AblationZonesList);
newItem->setSelected(true);
emit AddAblationZoneClicked(m_Ui->m_AblationZoneSizeSlider->value());
}
QmitkUSNavigationStepPunctuationIntervention::~QmitkUSNavigationStepPunctuationIntervention()
{
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage(false);
if ( dataStorage.IsNotNull() )
{
// remove needle path from data storage if it is there
mitk::DataNode::Pointer node = this->GetNamedDerivedNode
("Needle Path", QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
if ( node.IsNotNull() ) { dataStorage->Remove(node); }
}
delete m_Ui;
}
bool QmitkUSNavigationStepPunctuationIntervention::OnStartStep()
{
// create node for Needle Projection
mitk::DataNode::Pointer node = this->GetNamedDerivedNodeAndCreate
("Needle Path", QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
node->SetData(m_NeedleProjectionFilter->GetProjection());
node->SetBoolProperty("show contour", true);
m_NeedleProjectionFilter->SetToolAxisForFilter(m_NeedleNavigationTool->GetToolAxis());
return true;
}
bool QmitkUSNavigationStepPunctuationIntervention::OnRestartStep()
{
return this->OnActivateStep();
}
bool QmitkUSNavigationStepPunctuationIntervention::OnFinishStep()
{
mitk::DataNode::Pointer finishPunctionResult = mitk::DataNode::New();
finishPunctionResult->SetName("PunctionResult");
mitk::Point3D needlePos = m_NeedleProjectionFilter->GetOutput(0)->GetPosition();
mitk::Quaternion needleRot = m_NeedleProjectionFilter->GetOutput(0)->GetOrientation();
finishPunctionResult->SetProperty("USNavigation::TipPositionEnd", mitk::Point3dProperty::New(needlePos));
MITK_INFO("USNavigationLogging") << "Instrument tip at end: " <ClearZones();
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage();
// add progress bars for risk zone nodes
- m_ZoneNodes = dataStorage->GetDerivations(dataStorage->GetNamedNode(USNavigationMarkerPlacement::DATANAME_ZONES));
+ m_ZoneNodes = dataStorage->GetDerivations(dataStorage->GetNamedNode(QmitkUSNavigationMarkerPlacement::DATANAME_ZONES));
// add zones to the widgets for risk structures
for (mitk::DataStorage::SetOfObjects::ConstIterator it = m_ZoneNodes->Begin();
it != m_ZoneNodes->End(); ++it)
{
m_Ui->riskStructuresRangeWidget->AddZone(it->Value());
float rgb[3];
it->Value()->GetColor(rgb);
mitk::Color color;
color.SetRed(rgb[0]);
color.SetGreen(rgb[1]);
color.SetBlue(rgb[2]);
m_OldColors[it->Value()] = color;
}
m_NeedleProjectionFilter->SelectInput(0);
return true;
}
void QmitkUSNavigationStepPunctuationIntervention::OnShowToolAxisEnabled(int enabled)
{
if (enabled == 0) { m_NeedleProjectionFilter->ShowToolAxis(false); }
else { m_NeedleProjectionFilter->ShowToolAxis(true); }
}
void QmitkUSNavigationStepPunctuationIntervention::OnUpdate()
{
// get navigation data source and make sure that it is not null
mitk::NavigationDataSource::Pointer navigationDataSource =
this->GetCombinedModality()->GetNavigationDataSource();
if ( navigationDataSource.IsNull() )
{
MITK_ERROR("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepPunctuationIntervention")
<< "Navigation Data Source of Combined Modality must not be null.";
mitkThrow() << "Navigation Data Source of Combined Modality must not be null.";
}
// update body marker
this->UpdateBodyMarkerStatus(navigationDataSource->GetOutput(1));
// update critical structures
this->UpdateCriticalStructures(navigationDataSource->GetOutput(0),m_NeedleProjectionFilter->GetProjection());
//Update Distance to US image
mitk::Point3D point1 = m_NeedleProjectionFilter->GetProjection()->GetPoint(0);
mitk::Point3D point2 = m_NeedleProjectionFilter->GetProjection()->GetPoint(1);
double distance = point1.EuclideanDistanceTo(point2);
m_Ui->m_DistanceToUSPlane->setText(QString::number(distance) + " mm");
}
void QmitkUSNavigationStepPunctuationIntervention::OnSettingsChanged(const itk::SmartPointer settingsNode)
{
if ( settingsNode.IsNull() ) { return; }
}
QString QmitkUSNavigationStepPunctuationIntervention::GetTitle()
{
return "Computer-assisted Intervention";
}
bool QmitkUSNavigationStepPunctuationIntervention::GetIsRestartable()
{
return false;
}
QmitkUSNavigationStepPunctuationIntervention::FilterVector QmitkUSNavigationStepPunctuationIntervention::GetFilter()
{
return FilterVector(1, m_NeedleProjectionFilter.GetPointer());
}
void QmitkUSNavigationStepPunctuationIntervention::OnSetCombinedModality()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if ( combinedModality.IsNotNull() )
{
// set calibration of the combined modality to the needle projection filter
mitk::AffineTransform3D::Pointer calibration = combinedModality->GetCalibration();
if ( calibration.IsNotNull() )
{
m_NeedleProjectionFilter->SetTargetPlane(calibration);
}
}
}
void QmitkUSNavigationStepPunctuationIntervention::ClearZones()
{
m_Ui->riskStructuresRangeWidget->ClearZones();
}
void QmitkUSNavigationStepPunctuationIntervention::UpdateBodyMarkerStatus(mitk::NavigationData::Pointer bodyMarker)
{
if ( bodyMarker.IsNull() )
{
MITK_ERROR("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepPunctuationIntervention")
<< "Current Navigation Data for body marker of Combined Modality must not be null.";
mitkThrow() << "Current Navigation Data for body marker of Combined Modality must not be null.";
}
bool valid = bodyMarker->IsDataValid();
// update body marker status label
if (valid)
{
m_Ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #8bff8b; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
m_Ui->bodyMarkerTrackingStatusLabel->setText("Body marker is inside the tracking volume.");
}
else
{
m_Ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #ff7878; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
m_Ui->bodyMarkerTrackingStatusLabel->setText("Body marker is not inside the tracking volume.");
}
m_Ui->riskStructuresRangeGroupBox->setEnabled(valid);
}
void QmitkUSNavigationStepPunctuationIntervention::UpdateCriticalStructures(mitk::NavigationData::Pointer needle, mitk::PointSet::Pointer path)
{
// update the distances for the risk structures widget
m_Ui->riskStructuresRangeWidget->UpdateDistancesToNeedlePosition(needle);
//iterate through all zones
for (mitk::DataStorage::SetOfObjects::ConstIterator it = m_ZoneNodes->Begin();
it != m_ZoneNodes->End(); ++it)
{
mitk::DataNode::Pointer currentNode = it->Value();
//get center point and radius
float radius = -1;
mitk::Point3D center;
currentNode->GetFloatProperty("zone.size", radius);
center = currentNode->GetData()->GetGeometry()->GetIndexToWorldTransform()->GetTranslation();
mitk::Point3D point0 = path->GetPoint(0);
mitk::Point3D point1 = path->GetPoint(1);
if (CheckSphereLineIntersection(center,radius,point0,point1))
{currentNode->SetColor(mitk::IGTColor_WARNING);}
else
{currentNode->SetColor(m_OldColors[currentNode]);}
}
}
bool QmitkUSNavigationStepPunctuationIntervention::CheckSphereLineIntersection(mitk::Point3D& sphereOrigin, float& sphereRadius, mitk::Point3D& lineStart, mitk::Point3D& lineEnd)
{
double center[3] = {sphereOrigin[0],sphereOrigin[1],sphereOrigin[2]};
m_SphereSource->SetCenter(center);
m_SphereSource->SetRadius(sphereRadius);
m_SphereSource->Update();
m_OBBTree->SetDataSet(m_SphereSource->GetOutput());
m_OBBTree->BuildLocator();
double lineP0[3] = {lineStart[0], lineStart[1], lineStart[2]};
double lineP1[3] = {lineEnd[0], lineEnd[1], lineEnd[2]};
m_OBBTree->IntersectWithLine(lineP0, lineP1, m_IntersectPoints, nullptr);
if (m_IntersectPoints->GetNumberOfPoints() > 0) {return true;}
else {return false;}
}
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.cpp
index 26fc7f79a9..bd6d29d4c9 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.cpp
@@ -1,428 +1,428 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkUSNavigationStepTumourSelection.h"
#include "ui_QmitkUSNavigationStepTumourSelection.h"
#include "usModuleRegistry.h"
#include "mitkDataNode.h"
#include "mitkSurface.h"
#include "mitkUSCombinedModality.h"
#include "../Interactors/mitkUSZonesInteractor.h"
#include "mitkNodeDisplacementFilter.h"
#include "QmitkUSNavigationStepCombinedModality.h"
-#include "../USNavigationMarkerPlacement.h"
+#include "../QmitkUSNavigationMarkerPlacement.h"
#include "mitkIOUtil.h"
#include "vtkSmartPointer.h"
#include "vtkDoubleArray.h"
#include "vtkPolyData.h"
#include "vtkPointData.h"
#include "vtkWarpScalar.h"
QmitkUSNavigationStepTumourSelection::QmitkUSNavigationStepTumourSelection(QWidget* parent) :
QmitkUSAbstractNavigationStep(parent),
m_targetSelectionOptional(false),
m_SecurityDistance(0),
m_Interactor(mitk::USZonesInteractor::New()),
m_NodeDisplacementFilter(mitk::NodeDisplacementFilter::New()),
m_StateMachineFilename("USZoneInteractions.xml"),
m_ReferenceSensorIndex(1),
m_ListenerChangeNode(this, &QmitkUSNavigationStepTumourSelection::TumourNodeChanged),
ui(new Ui::QmitkUSNavigationStepTumourSelection)
{
ui->setupUi(this);
connect(ui->freezeImageButton, SIGNAL(SignalFreezed(bool)), this, SLOT(OnFreeze(bool)));
connect(ui->tumourSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(OnTumourSizeChanged(int)));
connect(ui->deleteTumourButton, SIGNAL(clicked()), this, SLOT(OnDeleteButtonClicked()));
m_SphereColor = mitk::Color();
//default color: green
m_SphereColor[0] = 0;
m_SphereColor[1] = 255;
m_SphereColor[2] = 0;
}
void QmitkUSNavigationStepTumourSelection::SetTumorColor(mitk::Color c)
{
m_SphereColor = c;
}
void QmitkUSNavigationStepTumourSelection::SetTargetSelectionOptional(bool t)
{
m_targetSelectionOptional = t;
}
QmitkUSNavigationStepTumourSelection::~QmitkUSNavigationStepTumourSelection()
{
delete ui;
}
bool QmitkUSNavigationStepTumourSelection::OnStartStep()
{
m_TumourNode = this->GetNamedDerivedNodeAndCreate(
- USNavigationMarkerPlacement::DATANAME_TUMOUR,
+ QmitkUSNavigationMarkerPlacement::DATANAME_TUMOUR,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
m_TumourNode->SetColor(m_SphereColor[0], m_SphereColor[1], m_SphereColor[2]);
// load state machine and event config for data interactor
m_Interactor->LoadStateMachine(m_StateMachineFilename, us::ModuleRegistry::GetModule("MitkUS"));
m_Interactor->SetEventConfig("globalConfig.xml");
this->GetDataStorage()->ChangedNodeEvent.AddListener(m_ListenerChangeNode);
m_TargetSurfaceNode = this->GetNamedDerivedNodeAndCreate(
- USNavigationMarkerPlacement::DATANAME_TARGETSURFACE,
- USNavigationMarkerPlacement::DATANAME_TUMOUR);
+ QmitkUSNavigationMarkerPlacement::DATANAME_TARGETSURFACE,
+ QmitkUSNavigationMarkerPlacement::DATANAME_TUMOUR);
// do not show the surface until this is requested
m_TargetSurfaceNode->SetBoolProperty("visible", false);
// make sure that scalars will be renderer on the surface
m_TargetSurfaceNode->SetBoolProperty("scalar visibility", true);
m_TargetSurfaceNode->SetBoolProperty("color mode", true);
m_TargetSurfaceNode->SetBoolProperty("Backface Culling", true);
return true;
}
bool QmitkUSNavigationStepTumourSelection::OnStopStep()
{
// make sure that imaging isn't freezed anymore
ui->freezeImageButton->Unfreeze();
m_NodeDisplacementFilter->ResetNodes();
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage(false);
if (dataStorage.IsNotNull())
{
// remove target surface node from data storage, if available there
if (m_TargetSurfaceNode.IsNotNull()) { dataStorage->Remove(m_TargetSurfaceNode); }
dataStorage->ChangedNodeEvent.RemoveListener(m_ListenerChangeNode);
dataStorage->Remove(m_TumourNode);
m_TumourNode = 0;
}
MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
<< "Removing tumour.";
return true;
}
bool QmitkUSNavigationStepTumourSelection::OnRestartStep()
{
ui->tumourSizeExplanationLabel->setEnabled(false);
ui->tumourSizeLabel->setEnabled(false);
ui->tumourSizeSlider->setEnabled(false);
ui->deleteTumourButton->setEnabled(false);
ui->tumourSizeSlider->blockSignals(true);
ui->tumourSizeSlider->setValue(0);
ui->tumourSizeSlider->blockSignals(false);
emit SignalNoLongerReadyForNextStep();
return QmitkUSAbstractNavigationStep::OnRestartStep();
}
bool QmitkUSNavigationStepTumourSelection::OnFinishStep()
{
// make sure that the surface has the right extent (in case the
// tumor size was changed since the initial surface creation)
m_TargetSurfaceNode->SetData(this->CreateTargetSurface());
return true;
}
bool QmitkUSNavigationStepTumourSelection::OnActivateStep()
{
m_Interactor = mitk::USZonesInteractor::New();
m_Interactor->LoadStateMachine(m_StateMachineFilename, us::ModuleRegistry::GetModule("MitkUS"));
m_Interactor->SetEventConfig("globalConfig.xml");
m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
//target selection is optional
if (m_targetSelectionOptional) { emit SignalReadyForNextStep(); }
return true;
}
bool QmitkUSNavigationStepTumourSelection::OnDeactivateStep()
{
m_Interactor->SetDataNode(0);
bool value;
if (m_TumourNode.IsNotNull() && !(m_TumourNode->GetBoolProperty("zone.created", value) && value))
{
m_TumourNode->SetData(0);
}
// make sure that imaging isn't freezed anymore
ui->freezeImageButton->Unfreeze();
return true;
}
void QmitkUSNavigationStepTumourSelection::OnUpdate()
{
if (m_NavigationDataSource.IsNull()) { return; }
m_NavigationDataSource->Update();
bool valid = m_NavigationDataSource->GetOutput(m_ReferenceSensorIndex)->IsDataValid();
if (valid)
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #8bff8b; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is inside the tracking volume.");
}
else
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #ff7878; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is not inside the tracking volume.");
}
ui->freezeImageButton->setEnabled(valid);
bool created;
if (m_TumourNode.IsNull() || !m_TumourNode->GetBoolProperty("zone.created", created) || !created)
{
ui->tumourSearchExplanationLabel->setEnabled(valid);
}
}
void QmitkUSNavigationStepTumourSelection::OnSettingsChanged(const itk::SmartPointer settingsNode)
{
if (settingsNode.IsNull()) { return; }
float securityDistance;
if (settingsNode->GetFloatProperty("settings.security-distance", securityDistance))
{
m_SecurityDistance = securityDistance;
}
std::string stateMachineFilename;
if (settingsNode->GetStringProperty("settings.interaction-concept", stateMachineFilename) && stateMachineFilename != m_StateMachineFilename)
{
m_StateMachineFilename = stateMachineFilename;
m_Interactor->LoadStateMachine(stateMachineFilename, us::ModuleRegistry::GetModule("MitkUS"));
}
std::string referenceSensorName;
if (settingsNode->GetStringProperty("settings.reference-name-selected", referenceSensorName))
{
m_ReferenceSensorName = referenceSensorName;
}
this->UpdateReferenceSensorName();
}
QString QmitkUSNavigationStepTumourSelection::GetTitle()
{
return "Localisation of Tumour Position";
}
QmitkUSAbstractNavigationStep::FilterVector QmitkUSNavigationStepTumourSelection::GetFilter()
{
return FilterVector(1, m_NodeDisplacementFilter.GetPointer());
}
void QmitkUSNavigationStepTumourSelection::OnFreeze(bool freezed)
{
if (freezed) this->GetCombinedModality()->SetIsFreezed(true);
ui->tumourSelectionExplanation1Label->setEnabled(freezed);
ui->tumourSelectionExplanation2Label->setEnabled(freezed);
if (freezed)
{
if (!m_TumourNode->GetData())
{
// load state machine and event config for data interactor
m_Interactor->LoadStateMachine(m_StateMachineFilename, us::ModuleRegistry::GetModule("MitkUS"));
m_Interactor->SetEventConfig("globalConfig.xml");
m_Interactor->SetDataNode(m_TumourNode);
// feed reference pose to node displacement filter
m_NodeDisplacementFilter->SetInitialReferencePose(this->GetCombinedModality()->GetNavigationDataSource()->GetOutput(m_ReferenceSensorIndex)->Clone());
}
}
else
{
bool value;
if (m_TumourNode->GetBoolProperty("zone.created", value) && value)
{
ui->freezeImageButton->setEnabled(false);
ui->tumourSearchExplanationLabel->setEnabled(false);
}
}
if (!freezed) this->GetCombinedModality()->SetIsFreezed(false);
}
void QmitkUSNavigationStepTumourSelection::OnSetCombinedModality()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if (combinedModality.IsNotNull())
{
m_NavigationDataSource = combinedModality->GetNavigationDataSource();
}
else
{
m_NavigationDataSource = 0;
}
ui->freezeImageButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex);
this->UpdateReferenceSensorName();
}
void QmitkUSNavigationStepTumourSelection::OnTumourSizeChanged(int size)
{
m_TumourNode->SetFloatProperty("zone.size", static_cast(size));
mitk::USZonesInteractor::UpdateSurface(m_TumourNode);
MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
<< "Changing tumour radius to " << size << ".";
}
void QmitkUSNavigationStepTumourSelection::OnDeleteButtonClicked()
{
this->OnRestartStep();
}
void QmitkUSNavigationStepTumourSelection::TumourNodeChanged(const mitk::DataNode* dataNode)
{
// only changes of tumour node are of interest
if (dataNode != m_TumourNode) { return; }
float size;
dataNode->GetFloatProperty("zone.size", size);
ui->tumourSizeSlider->setValue(static_cast(size));
bool created;
if (dataNode->GetBoolProperty("zone.created", created) && created)
{
if (ui->freezeImageButton->isChecked())
{
m_NodeDisplacementFilter->AddNode(const_cast(dataNode));
m_TargetSurfaceNode->SetData(this->CreateTargetSurface());
m_NodeDisplacementFilter->AddNode(m_TargetSurfaceNode);
MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
<< "Tumour created with center " << dataNode->GetData()->GetGeometry()->GetOrigin()
<< " and radius " << size << ".";
mitk::DataNode::Pointer tumourResultNode = mitk::DataNode::New();
tumourResultNode->SetName("TumourResult");
tumourResultNode->SetProperty("USNavigation::TumourCenter",
mitk::Point3dProperty::New(dataNode->GetData()->GetGeometry()->GetOrigin()));
tumourResultNode->SetProperty("USNavigation::TumourRadius", mitk::DoubleProperty::New(size));
emit SignalIntermediateResult(tumourResultNode);
ui->freezeImageButton->Unfreeze();
}
ui->tumourSearchExplanationLabel->setEnabled(false);
ui->tumourSizeExplanationLabel->setEnabled(true);
ui->tumourSizeLabel->setEnabled(true);
ui->tumourSizeSlider->setEnabled(true);
ui->deleteTumourButton->setEnabled(true);
emit SignalReadyForNextStep();
}
}
mitk::Surface::Pointer QmitkUSNavigationStepTumourSelection::CreateTargetSurface()
{
mitk::Surface::Pointer tumourSurface = dynamic_cast(m_TumourNode->GetData());
if (tumourSurface.IsNull())
{
MITK_WARN << "No target selected, cannot create surface!";
return mitk::Surface::New(); //return a empty surface in this case...
}
// make a deep copy of the tumour surface polydata
vtkSmartPointer tumourSurfaceVtk = vtkSmartPointer::New();
tumourSurfaceVtk->DeepCopy(tumourSurface->GetVtkPolyData());
// create scalars for moving every point the same size onto its normal vector
vtkSmartPointer scalars = vtkSmartPointer::New();
int numberOfPoints = tumourSurfaceVtk->GetNumberOfPoints();
scalars->SetNumberOfTuples(numberOfPoints);
// set scalars for warp filter
for (vtkIdType i = 0; i < numberOfPoints; ++i) { scalars->SetTuple1(i, m_SecurityDistance * 10); }
tumourSurfaceVtk->GetPointData()->SetScalars(scalars);
vtkSmartPointer warpScalar = vtkSmartPointer::New();
warpScalar->SetInputData(tumourSurfaceVtk);
warpScalar->SetScaleFactor(1); // use the scalars themselves
warpScalar->Update();
vtkSmartPointer targetSurfaceVtk = warpScalar->GetPolyDataOutput();
// set the moved points to the deep copied tumour surface; this is
// necessary as setting the targetSurfaceVtk as polydata for the
// targetSurface would result in flat shading for the surface (seems
// to be a bug in MITK or VTK)
tumourSurfaceVtk->SetPoints(targetSurfaceVtk->GetPoints());
mitk::Surface::Pointer targetSurface = mitk::Surface::New();
targetSurface->SetVtkPolyData(tumourSurfaceVtk);
targetSurface->GetGeometry()->SetOrigin(tumourSurface->GetGeometry()->GetOrigin());
return targetSurface;
}
itk::SmartPointer QmitkUSNavigationStepTumourSelection::GetTumourNodeDisplacementFilter()
{
return m_NodeDisplacementFilter;
}
void QmitkUSNavigationStepTumourSelection::UpdateReferenceSensorName()
{
if (m_NavigationDataSource.IsNull()) { return; }
if (!m_ReferenceSensorName.empty())
{
try
{
m_ReferenceSensorIndex = m_NavigationDataSource->GetOutputIndex(m_ReferenceSensorName);
}
catch (const std::exception &e)
{
MITK_WARN("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
<< "Cannot get index for reference sensor name: " << e.what();
}
}
if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active)
{
m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
}
ui->freezeImageButton->SetCombinedModality(this->GetCombinedModality(false), m_ReferenceSensorIndex);
}
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.cpp
index b1380808ff..ffe7a26b38 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.cpp
@@ -1,269 +1,269 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkUSNavigationStepZoneMarking.h"
#include "ui_QmitkUSNavigationStepZoneMarking.h"
#include "mitkNodeDisplacementFilter.h"
-#include "../USNavigationMarkerPlacement.h"
+#include "../QmitkUSNavigationMarkerPlacement.h"
QmitkUSNavigationStepZoneMarking::QmitkUSNavigationStepZoneMarking(QWidget *parent) :
QmitkUSAbstractNavigationStep(parent),
m_ZoneDisplacementFilter(mitk::NodeDisplacementFilter::New()),
m_ReferenceSensorIndex(1),
m_CurrentlyAddingZone(false),
ui(new Ui::QmitkUSNavigationStepZoneMarking)
{
ui->setupUi(this);
connect( ui->freezeButton, SIGNAL(SignalFreezed(bool)), this, SLOT(OnFreeze(bool)) );
connect( ui->zonesWidget, SIGNAL(ZoneAdded()), this, SLOT(OnZoneAdded()) );
connect( ui->zonesWidget, SIGNAL(ZoneRemoved()), this, SLOT(OnZoneRemoved()) );
connect(ui->showStructureList, SIGNAL(stateChanged(int)), this, SLOT(OnShowListClicked(int)));
ui->zonesLabel->setVisible(false);
ui->zonesWidget->setVisible(false);
}
void QmitkUSNavigationStepZoneMarking::OnShowListClicked(int state)
{
ui->zonesLabel->setVisible(state);
ui->zonesWidget->setVisible(state);
}
QmitkUSNavigationStepZoneMarking::~QmitkUSNavigationStepZoneMarking()
{
delete ui;
}
bool QmitkUSNavigationStepZoneMarking::OnStartStep()
{
- this->GetNamedDerivedNodeAndCreate(USNavigationMarkerPlacement::DATANAME_ZONES,
+ this->GetNamedDerivedNodeAndCreate(QmitkUSNavigationMarkerPlacement::DATANAME_ZONES,
QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
- ui->zonesWidget->SetDataStorage(this->GetDataStorage(), USNavigationMarkerPlacement::DATANAME_ZONES);
+ ui->zonesWidget->SetDataStorage(this->GetDataStorage(), QmitkUSNavigationMarkerPlacement::DATANAME_ZONES);
return true;
}
bool QmitkUSNavigationStepZoneMarking::OnStopStep()
{
m_ZoneDisplacementFilter->ResetNodes();
ui->zonesWidget->OnResetZones();
m_ZoneNodes.clear();
// remove zone nodes from the data storage
mitk::DataStorage::Pointer dataStorage = this->GetDataStorage(false);
if ( dataStorage.IsNotNull() )
{
mitk::DataNode::Pointer baseNode = dataStorage->GetNamedNode(QmitkUSAbstractNavigationStep::DATANAME_BASENODE);
if ( baseNode.IsNotNull() )
{
- dataStorage->Remove(dataStorage->GetNamedDerivedNode(USNavigationMarkerPlacement::DATANAME_ZONES, baseNode));
+ dataStorage->Remove(dataStorage->GetNamedDerivedNode(QmitkUSNavigationMarkerPlacement::DATANAME_ZONES, baseNode));
}
}
return true;
}
bool QmitkUSNavigationStepZoneMarking::OnFinishStep()
{
return true;
}
bool QmitkUSNavigationStepZoneMarking::OnActivateStep()
{
m_ZoneDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
emit SignalReadyForNextStep();
return true;
}
bool QmitkUSNavigationStepZoneMarking::OnDeactivateStep()
{
ui->freezeButton->Unfreeze();
return true;
}
void QmitkUSNavigationStepZoneMarking::OnUpdate()
{
if (m_NavigationDataSource.IsNull()) { return; }
m_NavigationDataSource->Update();
bool valid = m_NavigationDataSource->GetOutput(m_ReferenceSensorIndex)->IsDataValid();
if (valid)
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #8bff8b; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is inside the tracking volume.");
}
else
{
ui->bodyMarkerTrackingStatusLabel->setStyleSheet(
"background-color: #ff7878; margin-right: 1em; margin-left: 1em; border: 1px solid grey");
ui->bodyMarkerTrackingStatusLabel->setText("Body marker is not inside the tracking volume.");
}
ui->freezeButton->setEnabled(valid);
}
void QmitkUSNavigationStepZoneMarking::OnSettingsChanged(const itk::SmartPointer settingsNode)
{
if ( settingsNode.IsNull() ) { return; }
std::string stateMachineFilename;
if ( settingsNode->GetStringProperty("settings.interaction-concept", stateMachineFilename) && stateMachineFilename != m_StateMachineFilename )
{
m_StateMachineFilename = stateMachineFilename;
ui->zonesWidget->SetStateMachineFilename(stateMachineFilename);
}
std::string referenceSensorName;
if ( settingsNode->GetStringProperty("settings.reference-name-selected", referenceSensorName) )
{
m_ReferenceSensorName = referenceSensorName;
}
this->UpdateReferenceSensorName();
}
QString QmitkUSNavigationStepZoneMarking::GetTitle()
{
return "Critical Structures";
}
QmitkUSAbstractNavigationStep::FilterVector QmitkUSNavigationStepZoneMarking::GetFilter()
{
return FilterVector(1, m_ZoneDisplacementFilter.GetPointer());
}
void QmitkUSNavigationStepZoneMarking::OnFreeze(bool freezed)
{
if (freezed) this->GetCombinedModality()->SetIsFreezed(true);
ui->zoneAddingExplanationLabel->setEnabled(freezed);
if ( freezed )
{
m_CurrentlyAddingZone = true;
ui->zonesWidget->OnStartAddingZone();
// feed reference pose to node displacement filter
m_ZoneDisplacementFilter->SetInitialReferencePose(this->GetCombinedModality()->GetNavigationDataSource()->GetOutput(m_ReferenceSensorIndex)->Clone());
}
else if ( m_CurrentlyAddingZone )
{
m_CurrentlyAddingZone = false;
ui->zonesWidget->OnAbortAddingZone();
}
if (!freezed) this->GetCombinedModality()->SetIsFreezed(false);
}
void QmitkUSNavigationStepZoneMarking::OnZoneAdded()
{
m_CurrentlyAddingZone = false;
ui->freezeButton->Unfreeze();
ui->zoneAddingExplanationLabel->setEnabled(ui->freezeButton->isChecked());
mitk::DataStorage::SetOfObjects::ConstPointer zoneNodesSet = ui->zonesWidget->GetZoneNodes();
for (mitk::DataStorage::SetOfObjects::ConstIterator it = zoneNodesSet->Begin();
it != zoneNodesSet->End(); ++it)
{
// add all zones to zone filter which aren't added until now
if ( std::find(m_ZoneNodes.begin(), m_ZoneNodes.end(), it->Value()) == m_ZoneNodes.end() )
{
// logging center point and radius
float radius = -1;
it->Value()->GetFloatProperty("zone.size", radius);
MITK_INFO("QmitkUSNavigationStepZoneMarking")("QmitkUSAbstractNavigationStep")
<< "Risk zone (" << it->Value()->GetName() << ") added with center "
<< it->Value()->GetData()->GetGeometry()->GetOrigin() << " and radius " << radius << ".";
m_ZoneNodes.push_back(it->Value());
m_ZoneDisplacementFilter->AddNode(it->Value());
}
}
}
void QmitkUSNavigationStepZoneMarking::OnZoneRemoved()
{
mitk::DataStorage::SetOfObjects::ConstPointer zoneNodesSet = ui->zonesWidget->GetZoneNodes();
for ( int n = m_ZoneNodes.size() - 1; n >= 0; --n )
{
bool found = false;
// test if the node can be found in the set of zone nodes
for (mitk::DataStorage::SetOfObjects::ConstIterator itSet = zoneNodesSet->Begin();
itSet != zoneNodesSet->End(); ++itSet)
{
if ( m_ZoneNodes.at(n) == itSet->Value() ) { found = true; break; }
}
if ( ! found )
{
MITK_INFO("QmitkUSNavigationStepZoneMarking")("QmitkUSAbstractNavigationStep")
<< "Risk zone (" << m_ZoneNodes.at(n)->GetName() << ") removed.";
m_ZoneNodes.erase(m_ZoneNodes.begin()+n);
m_ZoneDisplacementFilter->RemoveNode(n);
}
}
}
void QmitkUSNavigationStepZoneMarking::OnSetCombinedModality()
{
mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false);
if (combinedModality.IsNotNull())
{
m_NavigationDataSource = combinedModality->GetNavigationDataSource();
}
ui->freezeButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex);
this->UpdateReferenceSensorName();
}
void QmitkUSNavigationStepZoneMarking::UpdateReferenceSensorName()
{
if ( m_NavigationDataSource.IsNull() ) { return; }
if ( ! m_ReferenceSensorName.empty() )
{
try
{
m_ReferenceSensorIndex = m_NavigationDataSource->GetOutputIndex(m_ReferenceSensorName);
}
catch ( const std::exception &e )
{
MITK_WARN("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepZoneMarking")
<< "Cannot get index for reference sensor name: " << e.what();
}
}
if ( this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active )
{
m_ZoneDisplacementFilter->SelectInput(m_ReferenceSensorIndex);
}
ui->freezeButton->SetCombinedModality(this->GetCombinedModality(false), m_ReferenceSensorIndex);
}
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.cpp
similarity index 92%
rename from Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.cpp
rename to Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.cpp
index 61500be8af..843a7144dd 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.cpp
@@ -1,875 +1,875 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
-#include "USNavigationMarkerPlacement.h"
-#include "ui_USNavigationMarkerPlacement.h"
+#include "QmitkUSNavigationMarkerPlacement.h"
+#include "ui_QmitkUSNavigationMarkerPlacement.h"
#include "NavigationStepWidgets/QmitkUSNavigationStepCombinedModality.h"
#include "NavigationStepWidgets/QmitkUSNavigationStepMarkerIntervention.h"
#include "NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.h"
#include "NavigationStepWidgets/QmitkUSNavigationStepPunctuationIntervention.h"
#include "NavigationStepWidgets/QmitkUSNavigationStepTumourSelection.h"
#include "NavigationStepWidgets/QmitkUSNavigationStepZoneMarking.h"
#include "SettingsWidgets/QmitkUSNavigationCombinedSettingsWidget.h"
#include "mitkIRenderingManager.h"
#include "mitkNodeDisplacementFilter.h"
#include "mitkUSCombinedModality.h"
#include
#include "IO/mitkUSNavigationExperimentLogging.h"
#include "IO/mitkUSNavigationStepTimer.h"
#include
#include
#include
#include
#include
#include
#include "QmitkRenderWindow.h"
#include "QmitkStdMultiWidget.h"
#include "QmitkStdMultiWidgetEditor.h"
#include "mitkLayoutAnnotationRenderer.h"
#include "mitkCameraController.h"
// scene serialization
#include
#include
#include
#include
#include
-const std::string USNavigationMarkerPlacement::VIEW_ID = "org.mitk.views.usmarkerplacement";
+const std::string QmitkUSNavigationMarkerPlacement::VIEW_ID = "org.mitk.views.usmarkerplacement";
-const char *USNavigationMarkerPlacement::DATANAME_TUMOUR = "Tumour";
-const char *USNavigationMarkerPlacement::DATANAME_TARGETSURFACE = "Target Surface";
-const char *USNavigationMarkerPlacement::DATANAME_ZONES = "Zones";
-const char *USNavigationMarkerPlacement::DATANAME_TARGETS = "Targets";
-const char *USNavigationMarkerPlacement::DATANAME_TARGETS_PATHS = "Target Paths";
-const char *USNavigationMarkerPlacement::DATANAME_REACHED_TARGETS = "Reached Targets";
+const char *QmitkUSNavigationMarkerPlacement::DATANAME_TUMOUR = "Tumour";
+const char *QmitkUSNavigationMarkerPlacement::DATANAME_TARGETSURFACE = "Target Surface";
+const char *QmitkUSNavigationMarkerPlacement::DATANAME_ZONES = "Zones";
+const char *QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS = "Targets";
+const char *QmitkUSNavigationMarkerPlacement::DATANAME_TARGETS_PATHS = "Target Paths";
+const char *QmitkUSNavigationMarkerPlacement::DATANAME_REACHED_TARGETS = "Reached Targets";
-USNavigationMarkerPlacement::USNavigationMarkerPlacement()
+QmitkUSNavigationMarkerPlacement::QmitkUSNavigationMarkerPlacement()
: m_Parent(nullptr),
m_NavigationSteps(),
m_UpdateTimer(new QTimer(this)),
m_ImageAndNavigationDataLoggingTimer(new QTimer(this)),
m_StdMultiWidget(nullptr),
m_CombinedModality(nullptr),
m_ReinitAlreadyDone(false),
m_IsExperimentRunning(false),
m_CurrentApplicationName(),
m_NavigationStepTimer(mitk::USNavigationStepTimer::New()),
m_ExperimentLogging(mitk::USNavigationExperimentLogging::New()),
m_IconRunning(QPixmap(":/USNavigation/record.png")),
m_IconNotRunning(QPixmap(":/USNavigation/record-gray.png")),
m_ResultsDirectory(),
m_ExperimentName(),
m_ExperimentResultsSubDirectory(),
m_NavigationStepNames(),
m_LoggingBackend(),
m_USImageLoggingFilter(mitk::USImageLoggingFilter::New()),
m_NavigationDataRecorder(mitk::NavigationDataRecorder::New()),
m_TargetNodeDisplacementFilter(nullptr),
m_AblationZonesDisplacementFilter(mitk::NodeDisplacementFilter::New()),
m_AblationZonesVector(),
m_NeedleIndex(0),
m_MarkerIndex(1),
m_SceneNumber(1),
m_WarnOverlay(mitk::TextAnnotation2D::New()),
m_NavigationDataSource(nullptr),
m_CurrentStorage(nullptr),
- m_ListenerDeviceChanged(this, &USNavigationMarkerPlacement::OnCombinedModalityPropertyChanged),
- ui(new Ui::USNavigationMarkerPlacement)
+ m_ListenerDeviceChanged(this, &QmitkUSNavigationMarkerPlacement::OnCombinedModalityPropertyChanged),
+ ui(new Ui::QmitkUSNavigationMarkerPlacement )
{
connect(m_UpdateTimer, SIGNAL(timeout()), this, SLOT(OnTimeout()));
connect(
m_ImageAndNavigationDataLoggingTimer, SIGNAL(timeout()), this, SLOT(OnImageAndNavigationDataLoggingTimeout()));
// scale running (and not running) icon the specific height
m_IconRunning = m_IconRunning.scaledToHeight(20, Qt::SmoothTransformation);
m_IconNotRunning = m_IconNotRunning.scaledToHeight(20, Qt::SmoothTransformation);
// set prefix for experiment logging (only keys with this prefix are taken
// into consideration
m_ExperimentLogging->SetKeyPrefix("USNavigation::");
m_UpdateTimer->start(33); // every 33 Milliseconds = 30 Frames/Second
}
-USNavigationMarkerPlacement::~USNavigationMarkerPlacement()
+QmitkUSNavigationMarkerPlacement::~QmitkUSNavigationMarkerPlacement()
{
// remove listener for ultrasound device changes
if (m_CombinedModality.IsNotNull() && m_CombinedModality->GetUltrasoundDevice().IsNotNull())
{
m_CombinedModality->GetUltrasoundDevice()->RemovePropertyChangedListener(m_ListenerDeviceChanged);
}
// remove listener for ultrasound device changes
if (m_CombinedModality.IsNotNull() && m_CombinedModality->GetUltrasoundDevice().IsNotNull())
{
m_CombinedModality->GetUltrasoundDevice()->RemovePropertyChangedListener(m_ListenerDeviceChanged);
}
delete ui;
}
-void USNavigationMarkerPlacement::OnChangeAblationZone(int id, int newSize)
+void QmitkUSNavigationMarkerPlacement::OnChangeAblationZone(int id, int newSize)
{
if ((static_cast(m_AblationZonesVector.size()) < id) || (id < 0))
{
return;
}
MITK_INFO << "Ablation Zone " << id << " changed, new size: " << newSize;
// create a vtk sphere with given radius
vtkSphereSource *vtkData = vtkSphereSource::New();
vtkData->SetRadius(newSize / 2);
vtkData->SetCenter(0, 0, 0);
vtkData->SetPhiResolution(20);
vtkData->SetThetaResolution(20);
vtkData->Update();
mitk::Surface::Pointer zoneSurface = dynamic_cast(m_AblationZonesVector.at(id)->GetData());
zoneSurface->SetVtkPolyData(vtkData->GetOutput());
vtkData->Delete();
}
-void USNavigationMarkerPlacement::OnAddAblationZone(int size)
+void QmitkUSNavigationMarkerPlacement::OnAddAblationZone(int size)
{
m_AblationZonesDisplacementFilter->SetInitialReferencePose(
m_CombinedModality->GetNavigationDataSource()->GetOutput(m_MarkerIndex));
mitk::DataNode::Pointer NewAblationZone = mitk::DataNode::New();
mitk::Point3D origin = m_CombinedModality->GetNavigationDataSource()->GetOutput(m_NeedleIndex)->GetPosition();
MITK_INFO("USNavigationLogging") << "Ablation Zone Added, initial size: " << size << ", origin: " << origin;
mitk::Surface::Pointer zone = mitk::Surface::New();
// create a vtk sphere with given radius
vtkSphereSource *vtkData = vtkSphereSource::New();
vtkData->SetRadius(size / 2);
vtkData->SetCenter(0, 0, 0);
vtkData->SetPhiResolution(20);
vtkData->SetThetaResolution(20);
vtkData->Update();
zone->SetVtkPolyData(vtkData->GetOutput());
vtkData->Delete();
// set vtk sphere and origin to data node (origin must be set
// again, because of the new sphere set as data)
NewAblationZone->SetData(zone);
NewAblationZone->GetData()->GetGeometry()->SetOrigin(origin);
mitk::Color SphereColor = mitk::Color();
// default color
SphereColor[0] = 102;
SphereColor[1] = 0;
SphereColor[2] = 204;
NewAblationZone->SetColor(SphereColor);
NewAblationZone->SetOpacity(0.3);
// set name of zone
std::stringstream name;
name << "Ablation Zone" << m_AblationZonesVector.size();
NewAblationZone->SetName(name.str());
// add zone to filter
m_AblationZonesDisplacementFilter->AddNode(NewAblationZone);
m_AblationZonesVector.push_back(NewAblationZone);
this->GetDataStorage()->Add(NewAblationZone);
}
-void USNavigationMarkerPlacement::CreateQtPartControl(QWidget *parent)
+void QmitkUSNavigationMarkerPlacement::CreateQtPartControl(QWidget *parent)
{
m_Parent = parent;
ui->setupUi(parent);
connect(ui->navigationProcessWidget,
SIGNAL(SignalCombinedModalityChanged(itk::SmartPointer)),
this,
SLOT(OnCombinedModalityChanged(itk::SmartPointer)));
connect(ui->navigationProcessWidget,
SIGNAL(SignalSettingsChanged(itk::SmartPointer)),
this,
SLOT(OnSettingsChanged(itk::SmartPointer)));
connect(ui->navigationProcessWidget,
SIGNAL(SignalActiveNavigationStepChanged(int)),
this,
SLOT(OnActiveNavigationStepChanged(int)));
connect(ui->navigationProcessWidget,
SIGNAL(SignalActiveNavigationStepChangeRequested(int)),
this,
SLOT(OnNextNavigationStepInitialization(int)));
connect(ui->startExperimentButton, SIGNAL(clicked()), this, SLOT(OnStartExperiment()));
connect(ui->finishExperimentButton, SIGNAL(clicked()), this, SLOT(OnFinishExperiment()));
connect(ui->m_enableNavigationLayout, SIGNAL(clicked()), this, SLOT(OnChangeLayoutClicked()));
connect(ui->m_RenderWindowSelection, SIGNAL(valueChanged(int)), this, SLOT(OnRenderWindowSelection()));
connect(ui->m_RefreshView, SIGNAL(clicked()), this, SLOT(OnRefreshView()));
connect(ui->navigationProcessWidget,
SIGNAL(SignalIntermediateResult(const itk::SmartPointer)),
this,
SLOT(OnIntermediateResultProduced(const itk::SmartPointer)));
ui->navigationProcessWidget->SetDataStorage(this->GetDataStorage());
// indicate that no experiment is running at start
ui->runningLabel->setPixmap(m_IconNotRunning);
ui->navigationProcessWidget->SetSettingsWidget(new QmitkUSNavigationCombinedSettingsWidget(m_Parent));
}
-void USNavigationMarkerPlacement::OnCombinedModalityPropertyChanged(const std::string &key, const std::string &)
+void QmitkUSNavigationMarkerPlacement::OnCombinedModalityPropertyChanged(const std::string &key, const std::string &)
{
if (key == mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DEPTH)
{
m_ReinitAlreadyDone = false;
this->ReinitOnImage();
if (m_CombinedModality.IsNotNull() && !m_CombinedModality->GetIsCalibratedForCurrentStatus())
{
mitk::LayoutAnnotationRenderer::AddAnnotation(
m_WarnOverlay.GetPointer(), "stdmulti.widget1", mitk::LayoutAnnotationRenderer::TopLeft);
MITK_WARN << "No calibration available for the selected ultrasound image depth.";
}
}
}
-void USNavigationMarkerPlacement::SetFocus()
+void QmitkUSNavigationMarkerPlacement::SetFocus()
{
this->ReinitOnImage();
}
-void USNavigationMarkerPlacement::OnTimeout()
+void QmitkUSNavigationMarkerPlacement::OnTimeout()
{
if (!m_StdMultiWidget)
{
// try to get the standard multi widget if it couldn't be got before
mitk::IRenderWindowPart *renderWindow = this->GetRenderWindowPart();
QmitkStdMultiWidgetEditor *multiWidgetEditor = dynamic_cast(renderWindow);
// if there is a standard multi widget now, disable the level window and
// change the layout to 2D up and 3d down
if (multiWidgetEditor)
{
m_StdMultiWidget = multiWidgetEditor->GetStdMultiWidget();
SetTwoWindowView();
}
this->CreateOverlays();
}
if (m_CombinedModality.IsNotNull() &&
!this->m_CombinedModality->GetIsFreezed()) // if the combined modality is freezed: do nothing
{
ui->navigationProcessWidget->UpdateNavigationProgress();
m_AblationZonesDisplacementFilter->Update();
// update the 3D window only every fourth time to speed up the rendering (at least in 2D)
this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS);
// make sure that a reinit was performed on the image
this->ReinitOnImage();
}
}
-void USNavigationMarkerPlacement::OnEnableNavigationLayout()
+void QmitkUSNavigationMarkerPlacement::OnEnableNavigationLayout()
{
MITK_INFO << "Navigation Layout";
// try to get the standard multi widget if it couldn't be got before
mitk::IRenderWindowPart *renderWindow = this->GetRenderWindowPart();
QmitkStdMultiWidgetEditor *multiWidgetEditor = dynamic_cast(renderWindow);
// if there is a standard multi widget now, disable the level window and
// change the layout to 2D up and 3d down
if (multiWidgetEditor)
{
m_StdMultiWidget = multiWidgetEditor->GetStdMultiWidget();
SetTwoWindowView();
}
}
-void USNavigationMarkerPlacement::OnRenderWindowSelection()
+void QmitkUSNavigationMarkerPlacement::OnRenderWindowSelection()
{
SetTwoWindowView();
}
-void USNavigationMarkerPlacement::OnRefreshView()
+void QmitkUSNavigationMarkerPlacement::OnRefreshView()
{
if (!ui->m_enableNavigationLayout->isChecked())
OnResetStandardLayout();
else
{
//Reinit the US Image Stream (this might be broken if there was a global reinit somewhere...)
try
{
mitk::RenderingManager::GetInstance()->InitializeViews(//Reinit
this->GetDataStorage()//GetDataStorage
->GetNamedNode("US Support Viewing Stream")->GetData()->GetTimeGeometry());//GetNode
}
catch (...)
{
MITK_DEBUG << "No reinit possible";
}
SetTwoWindowView();
}
}
-void USNavigationMarkerPlacement::SetTwoWindowView()
+void QmitkUSNavigationMarkerPlacement::SetTwoWindowView()
{
if (m_StdMultiWidget)
{
m_StdMultiWidget->DisableStandardLevelWindow();
int i, j, k;
switch (this->ui->m_RenderWindowSelection->value())
{
case 1:
mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4"))->GetCameraController()->SetViewToCaudal();
i = 2; j = 3; //other windows
k = 1;
break;
case 2:
mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4"))->GetCameraController()->SetViewToSinister();
i = 1; j = 3;
k = 2;
break;
case 3:
mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4"))->GetCameraController()->SetViewToAnterior();
i = 2; j = 1;
k = 3;
break;
default:
return;
}
m_StdMultiWidget->changeLayoutTo2DUpAnd3DDown(k);
////Crosshair invisible in 3D view
this->GetDataStorage()->GetNamedNode("stdmulti.widget" + std::to_string(i) + ".plane")->
SetBoolProperty("visible", false, mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4")));
this->GetDataStorage()->GetNamedNode("stdmulti.widget" + std::to_string(j) + ".plane")->
SetBoolProperty("visible", false, mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4")));
this->GetDataStorage()->GetNamedNode("stdmulti.widget" + std::to_string(k) + ".plane")->
SetBoolProperty("visible", true, mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4")));
this->GetDataStorage()->GetNamedNode("stdmulti.widget" + std::to_string(i) + ".plane")->
SetIntProperty("Crosshair.Gap Size", 0);
this->GetDataStorage()->GetNamedNode("stdmulti.widget" + std::to_string(j) + ".plane")->
SetIntProperty("Crosshair.Gap Size", 0);
}
}
-void USNavigationMarkerPlacement::OnResetStandardLayout()
+void QmitkUSNavigationMarkerPlacement::OnResetStandardLayout()
{
//reset render windows
mitk::DataNode::Pointer widget1 = this->GetDataStorage()->GetNamedNode("stdmulti.widget1.plane");
if (widget1.IsNotNull()) { widget1->SetVisibility(true); }
mitk::DataNode::Pointer widget2 = this->GetDataStorage()->GetNamedNode("stdmulti.widget2.plane");
if (widget2.IsNotNull()) { widget2->SetVisibility(true); }
mitk::DataNode::Pointer widget3 = this->GetDataStorage()->GetNamedNode("stdmulti.widget3.plane");
if (widget3.IsNotNull()) { widget3->SetVisibility(true); }
m_StdMultiWidget->changeLayoutToDefault();
}
-void USNavigationMarkerPlacement::OnChangeLayoutClicked()
+void QmitkUSNavigationMarkerPlacement::OnChangeLayoutClicked()
{
if (ui->m_enableNavigationLayout->isChecked()) OnEnableNavigationLayout();
else OnResetStandardLayout();
}
-void USNavigationMarkerPlacement::OnImageAndNavigationDataLoggingTimeout()
+void QmitkUSNavigationMarkerPlacement::OnImageAndNavigationDataLoggingTimeout()
{
// update filter for logging navigation data and ultrasound images
if (m_CombinedModality.IsNotNull())
{
m_NavigationDataRecorder->Update();
// get last messages for logging filer and store them
std::vector messages = m_LoggingBackend.GetNavigationMessages();
std::string composedMessage = "";
for (std::size_t i = 0; i < messages.size(); i++)
{
composedMessage += messages.at(i);
}
m_USImageLoggingFilter->AddMessageToCurrentImage(composedMessage);
m_LoggingBackend.ClearNavigationMessages();
// update logging filter
m_USImageLoggingFilter->Update();
}
}
-void USNavigationMarkerPlacement::OnStartExperiment()
+void QmitkUSNavigationMarkerPlacement::OnStartExperiment()
{
// get name for the experiment by a QInputDialog
bool ok;
if (m_ExperimentName.isEmpty())
{ // default: current date
m_ExperimentName = QString::number(QDateTime::currentDateTime().date().year()) + "_" +
QString::number(QDateTime::currentDateTime().date().month()) + "_" +
QString::number(QDateTime::currentDateTime().date().day()) + "_experiment_" +
QString::number(QDateTime::currentDateTime().time().hour()) + "." +
QString::number(QDateTime::currentDateTime().time().minute());
}
m_ExperimentName = QInputDialog::getText(
m_Parent, QString("Experiment Name"), QString("Name of the Experiment"), QLineEdit::Normal, m_ExperimentName, &ok);
MITK_INFO("USNavigationLogging") << "Experiment started: " << m_ExperimentName.toStdString();
if (ok && !m_ExperimentName.isEmpty())
{
// display error message and call the function recursivly if a directory
// with the given name already exists
QDir experimentResultsDir(m_ResultsDirectory + QDir::separator() + m_ExperimentName);
if (experimentResultsDir.exists())
{
QMessageBox::critical(
m_Parent, "Results Directory Exists", "The result directory already exists.\nPlease choose an other name.");
this->OnStartExperiment();
}
else
{
QDir(m_ResultsDirectory).mkdir(m_ExperimentName);
m_ExperimentResultsSubDirectory = m_ResultsDirectory + QDir::separator() + m_ExperimentName;
// experiment is running now
ui->runningLabel->setPixmap(m_IconRunning);
ui->navigationProcessWidget->EnableInteraction(true);
// (re)start timer for navigation step durations
m_NavigationStepTimer->Reset();
m_NavigationStepTimer->SetOutputFileName(
QString(m_ExperimentResultsSubDirectory + QDir::separator() + QString("durations.cvs")).toStdString());
m_NavigationStepTimer->SetActiveIndex(0, m_NavigationSteps.at(0)->GetTitle().toStdString());
ui->finishExperimentButton->setEnabled(true);
ui->startExperimentButton->setDisabled(true);
// initialize and register logging backend
QString loggingFilename = m_ExperimentResultsSubDirectory + QDir::separator() + "logging.txt";
m_LoggingBackend.SetOutputFileName(loggingFilename.toStdString());
mbilog::RegisterBackend(&m_LoggingBackend);
// initialize and start navigation data recorder form xml recording
m_NavigationDataRecorder->StartRecording();
m_IsExperimentRunning = true;
m_ImageAndNavigationDataLoggingTimer->start(1000);
// (re)start experiment logging and set output file name
m_ExperimentLogging->Reset();
m_ExperimentLogging->SetFileName(
QString(m_ExperimentResultsSubDirectory + QDir::separator() + "experiment-logging.xml").toStdString());
}
}
}
-void USNavigationMarkerPlacement::OnFinishExperiment()
+void QmitkUSNavigationMarkerPlacement::OnFinishExperiment()
{
this->WaitCursorOn();
MITK_INFO("USNavigationLogging") << "Experiment finished!";
MITK_INFO("USNavigationLogging")
<< "Position/Orientation of needle tip: "
<< (dynamic_cast(m_CombinedModality->GetTrackingDevice()->GetOutput(0)))->GetPosition();
MITK_INFO("USNavigationLogging")
<< "Position of target: " << m_TargetNodeDisplacementFilter->GetRawDisplacementNavigationData(0)->GetPosition();
MITK_INFO("USNavigationLogging") << "Total duration: " << m_NavigationStepTimer->GetTotalDuration();
ui->navigationProcessWidget->FinishCurrentNavigationStep();
m_ImageAndNavigationDataLoggingTimer->stop();
ui->runningLabel->setPixmap(m_IconNotRunning);
ui->navigationProcessWidget->EnableInteraction(false);
m_NavigationStepTimer->Stop();
// make sure that the navigation process will be start from beginning at the
// next experiment
ui->navigationProcessWidget->ResetNavigationProcess();
ui->finishExperimentButton->setDisabled(true);
ui->startExperimentButton->setEnabled(true);
MITK_INFO("USNavigationLogging") << "Writing logging data to " << m_ExperimentResultsSubDirectory.toStdString();
// save ultrasound images to the file system
QDir(m_ExperimentResultsSubDirectory).mkdir("ImageStream");
m_USImageLoggingFilter->Update();
m_USImageLoggingFilter->SetImageFilesExtension(".jpg");
m_USImageLoggingFilter->SaveImages(
QString(m_ExperimentResultsSubDirectory + QDir::separator() + "ImageStream" + QDir::separator()).toStdString());
m_USImageLoggingFilter = mitk::USImageLoggingFilter::New();
m_NavigationDataRecorder->StopRecording();
// Write data to csv and xml file
mitk::IOUtil::Save(
m_NavigationDataRecorder->GetNavigationDataSet(),
(QString(m_ExperimentResultsSubDirectory + QDir::separator() + "navigation-data.xml").toStdString().c_str()));
mitk::IOUtil::Save(
m_NavigationDataRecorder->GetNavigationDataSet(),
(QString(m_ExperimentResultsSubDirectory + QDir::separator() + "navigation-data.csv").toStdString().c_str()));
// write logged navigation data messages to separate file
std::stringstream csvNavigationMessagesFilename;
csvNavigationMessagesFilename << m_ExperimentResultsSubDirectory.toStdString() << QDir::separator().toLatin1()
<< "CSVNavigationMessagesLogFile.csv";
MITK_INFO("USNavigationLogging") << "Writing logged navigation messages to separate csv file: "
<< csvNavigationMessagesFilename.str();
m_LoggingBackend.WriteCSVFileWithNavigationMessages(csvNavigationMessagesFilename.str());
mbilog::UnregisterBackend(&m_LoggingBackend);
m_IsExperimentRunning = false;
m_ImageAndNavigationDataLoggingTimer->stop();
m_CombinedModality = nullptr;
// reset scene number for next experiment
m_SceneNumber = 1;
this->WaitCursorOff();
MITK_INFO("USNavigationLogging") << "Finished!";
}
-void USNavigationMarkerPlacement::OnCombinedModalityChanged(
+void QmitkUSNavigationMarkerPlacement::OnCombinedModalityChanged(
itk::SmartPointer combinedModality)
{
// remove old listener for ultrasound device changes
if (m_CombinedModality.IsNotNull() && m_CombinedModality->GetUltrasoundDevice().IsNotNull())
{
m_CombinedModality->GetUltrasoundDevice()->RemovePropertyChangedListener(m_ListenerDeviceChanged);
}
m_CombinedModality = combinedModality;
m_ReinitAlreadyDone = false;
// add a listener for ultrasound device changes
if (m_CombinedModality.IsNotNull() && m_CombinedModality->GetUltrasoundDevice().IsNotNull())
{
m_CombinedModality->GetUltrasoundDevice()->AddPropertyChangedListener(m_ListenerDeviceChanged);
}
// update navigation data recorder for using the new combined modality
mitk::NavigationDataSource::Pointer navigationDataSource = combinedModality->GetNavigationDataSource();
m_NavigationDataRecorder->ConnectTo(navigationDataSource);
m_NavigationDataRecorder->ResetRecording();
// update ultrasound image logging filter for using the new combined modality
mitk::USDevice::Pointer ultrasoundImageSource = combinedModality->GetUltrasoundDevice();
for (unsigned int n = 0; n < ultrasoundImageSource->GetNumberOfIndexedOutputs(); ++n)
{
m_USImageLoggingFilter->SetInput(n, ultrasoundImageSource->GetOutput(n));
}
// update ablation zone filter for using the new combined modality
for (unsigned int n = 0; n < navigationDataSource->GetNumberOfIndexedOutputs(); ++n)
{
m_AblationZonesDisplacementFilter->SetInput(n, navigationDataSource->GetOutput(n));
}
m_AblationZonesDisplacementFilter->SelectInput(m_MarkerIndex);
// make sure that a reinit is done for the new images
this->ReinitOnImage();
}
-void USNavigationMarkerPlacement::OnSettingsChanged(itk::SmartPointer settings)
+void QmitkUSNavigationMarkerPlacement::OnSettingsChanged(itk::SmartPointer settings)
{
std::string applicationName;
if (!settings->GetStringProperty("settings.application", applicationName))
{
// set default application if the string property is not available
applicationName = "Marker Placement";
}
// create navigation step widgets according to the selected application
if (applicationName != m_CurrentApplicationName)
{
m_CurrentApplicationName = applicationName;
QmitkUSNavigationProcessWidget::NavigationStepVector navigationSteps;
if (applicationName == "Puncture")
{
QmitkUSNavigationStepCombinedModality* stepCombinedModality =
new QmitkUSNavigationStepCombinedModality(m_Parent);
QmitkUSNavigationStepTumourSelection* stepTumourSelection =
new QmitkUSNavigationStepTumourSelection(m_Parent);
stepTumourSelection->SetTargetSelectionOptional(true);
m_TargetNodeDisplacementFilter = stepTumourSelection->GetTumourNodeDisplacementFilter();
QmitkUSNavigationStepZoneMarking* stepZoneMarking =
new QmitkUSNavigationStepZoneMarking(m_Parent);
QmitkUSNavigationStepPunctuationIntervention* stepIntervention =
new QmitkUSNavigationStepPunctuationIntervention(m_Parent);
connect(stepIntervention, SIGNAL(AddAblationZoneClicked(int)), this, SLOT(OnAddAblationZone(int)));
connect(stepIntervention, SIGNAL(AblationZoneChanged(int, int)), this, SLOT(OnChangeAblationZone(int, int)));
m_NavigationStepNames = std::vector();
navigationSteps.push_back(stepCombinedModality);
m_NavigationStepNames.push_back("Combined Modality Initialization");
navigationSteps.push_back(stepTumourSelection);
m_NavigationStepNames.push_back("Target Selection");
navigationSteps.push_back(stepZoneMarking);
m_NavigationStepNames.push_back("Critical Structure Marking");
navigationSteps.push_back(stepIntervention);
m_NavigationStepNames.push_back("Intervention");
}
else if (applicationName == "Marker Placement")
{
QmitkUSNavigationStepCombinedModality *stepCombinedModality = new QmitkUSNavigationStepCombinedModality(m_Parent);
QmitkUSNavigationStepTumourSelection *stepTumourSelection = new QmitkUSNavigationStepTumourSelection(m_Parent);
m_TargetNodeDisplacementFilter = stepTumourSelection->GetTumourNodeDisplacementFilter();
QmitkUSNavigationStepZoneMarking *stepZoneMarking = new QmitkUSNavigationStepZoneMarking(m_Parent);
QmitkUSNavigationStepPlacementPlanning *stepPlacementPlanning =
new QmitkUSNavigationStepPlacementPlanning(m_Parent);
QmitkUSNavigationStepMarkerIntervention *stepMarkerIntervention =
new QmitkUSNavigationStepMarkerIntervention(m_Parent);
m_NavigationStepNames = std::vector();
navigationSteps.push_back(stepCombinedModality);
m_NavigationStepNames.push_back("Combined Modality Initialization");
navigationSteps.push_back(stepTumourSelection);
m_NavigationStepNames.push_back("Target Selection");
navigationSteps.push_back(stepZoneMarking);
m_NavigationStepNames.push_back("Critical Structure Marking");
navigationSteps.push_back(stepPlacementPlanning);
m_NavigationStepNames.push_back("Placement Planning");
navigationSteps.push_back(stepMarkerIntervention);
m_NavigationStepNames.push_back("Marker Intervention");
}
// set navigation step widgets to the process widget
ui->navigationProcessWidget->SetNavigationSteps(navigationSteps);
for (QmitkUSNavigationProcessWidget::NavigationStepIterator it = m_NavigationSteps.begin();
it != m_NavigationSteps.end();
++it)
{
delete *it;
}
m_NavigationSteps.clear();
m_NavigationSteps = navigationSteps;
}
// initialize gui according to the experiment mode setting
bool experimentMode = false;
settings->GetBoolProperty("settings.experiment-mode", experimentMode);
ui->startExperimentButton->setVisible(experimentMode);
ui->finishExperimentButton->setVisible(experimentMode);
ui->runningLabel->setVisible(experimentMode);
if (experimentMode && !m_IsExperimentRunning)
{
ui->navigationProcessWidget->ResetNavigationProcess();
ui->navigationProcessWidget->EnableInteraction(false);
ui->runningLabel->setPixmap(m_IconNotRunning);
}
else if (!experimentMode)
{
if (m_IsExperimentRunning)
{
this->OnFinishExperiment();
}
ui->navigationProcessWidget->EnableInteraction(true);
}
// get the results directory from the settings and use home directory if
// there is no results directory configured
std::string resultsDirectory;
if (settings->GetStringProperty("settings.experiment-results-directory", resultsDirectory))
{
m_ResultsDirectory = QString::fromStdString(resultsDirectory);
}
else
{
m_ResultsDirectory = QDir::homePath();
}
// make sure that the results directory exists
QDir resultsDirectoryQDir = QDir(m_ResultsDirectory);
if (!resultsDirectoryQDir.exists())
{
resultsDirectoryQDir.mkpath(m_ResultsDirectory);
}
MITK_INFO("USNavigation") << "Results Directory: " << m_ResultsDirectory.toStdString();
}
-void USNavigationMarkerPlacement::OnActiveNavigationStepChanged(int index)
+void QmitkUSNavigationMarkerPlacement::OnActiveNavigationStepChanged(int index)
{
// update navigation step timer each time the active navigation step changes
m_NavigationStepTimer->SetActiveIndex(index, m_NavigationSteps.at(index)->GetTitle().toStdString());
if (static_cast(m_NavigationStepNames.size()) <= index)
{
MITK_INFO("USNavigationLogging") << "Someting went wrong: unknown navigation step!";
}
else
{
MITK_INFO("USNavigationLogging") << "Navigation step finished/changed, next step: "
<< this->m_NavigationStepNames.at(index).toStdString()
<< "; duration until now: " << m_NavigationStepTimer->GetTotalDuration();
}
}
-void USNavigationMarkerPlacement::OnNextNavigationStepInitialization(int index)
+void QmitkUSNavigationMarkerPlacement::OnNextNavigationStepInitialization(int index)
{
MITK_DEBUG << "Next Step: " << m_NavigationSteps.at(index)->GetTitle().toStdString();
if (m_NavigationSteps.at(index)->GetTitle().toStdString() == "Computer-assisted Intervention")
{
QmitkUSNavigationStepPunctuationIntervention* navigationStepPunctuationIntervention = static_cast(m_NavigationSteps.at(index));
if (navigationStepPunctuationIntervention != nullptr)
{
if (m_CurrentStorage.IsNull()) { this->UpdateToolStorage(); }
if (m_CurrentStorage.IsNull() || (m_CurrentStorage->GetTool(m_NeedleIndex).IsNull()))
{
MITK_WARN << "Found null pointer when setting the tool axis, aborting";
}
else
{
navigationStepPunctuationIntervention->SetNeedleMetaData(m_CurrentStorage->GetTool(m_NeedleIndex));
MITK_DEBUG << "Needle axis vector: " << m_CurrentStorage->GetTool(m_NeedleIndex)->GetToolAxis();
}
}
}
}
-void USNavigationMarkerPlacement::OnIntermediateResultProduced(const itk::SmartPointer resultsNode)
+void QmitkUSNavigationMarkerPlacement::OnIntermediateResultProduced(const itk::SmartPointer resultsNode)
{
// intermediate results only matter during an experiment
if (!m_IsExperimentRunning)
{
return;
}
this->WaitCursorOn();
// set results node to the experiment logging (for saving contents to the
// file system)
m_ExperimentLogging->SetResult(resultsNode);
std::string resultsName;
if (!resultsNode->GetName(resultsName))
{
MITK_WARN << "Could not get name of current results node.";
return;
}
// save the mitk scene
std::string scenefile = QString(m_ExperimentResultsSubDirectory + QDir::separator() +
QString("Scene %1 - ").arg(m_SceneNumber++, 2, 10, QChar('0')) +
QString::fromStdString(resultsName).replace(":", "_") + ".mitk")
.toStdString();
MITK_INFO << "Saving Scene File: " << scenefile;
mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New();
mitk::NodePredicateNot::Pointer isNotHelperObject =
mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true)));
mitk::DataStorage::SetOfObjects::ConstPointer nodesToBeSaved = this->GetDataStorage()->GetSubset(isNotHelperObject);
this->Convert2DImagesTo3D(nodesToBeSaved);
sceneIO->SaveScene(nodesToBeSaved, this->GetDataStorage(), scenefile);
this->WaitCursorOff();
}
-void USNavigationMarkerPlacement::ReinitOnImage()
+void QmitkUSNavigationMarkerPlacement::ReinitOnImage()
{
if (!m_ReinitAlreadyDone && m_CombinedModality.IsNotNull())
{
// make sure that the output is already calibrated correctly
// (if the zoom level was changed recently)
m_CombinedModality->Modified();
m_CombinedModality->Update();
mitk::Image::Pointer image = m_CombinedModality->GetOutput();
if (image.IsNotNull() && image->IsInitialized())
{
// make a reinit on the ultrasound image
mitk::IRenderWindowPart *renderWindow = this->GetRenderWindowPart();
if (renderWindow != NULL && image->GetTimeGeometry()->IsValid())
{
renderWindow->GetRenderingManager()->InitializeViews(
image->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true);
renderWindow->GetRenderingManager()->RequestUpdateAll();
}
this->RequestRenderWindowUpdate();
m_ReinitAlreadyDone = true;
}
}
}
-void USNavigationMarkerPlacement::Convert2DImagesTo3D(mitk::DataStorage::SetOfObjects::ConstPointer nodes)
+void QmitkUSNavigationMarkerPlacement::Convert2DImagesTo3D(mitk::DataStorage::SetOfObjects::ConstPointer nodes)
{
for (mitk::DataStorage::SetOfObjects::ConstIterator it = nodes->Begin(); it != nodes->End(); ++it)
{
if (it->Value()->GetData() && strcmp(it->Value()->GetData()->GetNameOfClass(), "Image") == 0)
{
// convert image to 3d image if it is 2d at the moment
mitk::Image::Pointer image = dynamic_cast(it->Value()->GetData());
if (image.IsNotNull() && image->GetDimension() == 2 && !image->GetGeometry()->Is2DConvertable())
{
mitk::Convert2Dto3DImageFilter::Pointer convert2DTo3DImageFilter = mitk::Convert2Dto3DImageFilter::New();
convert2DTo3DImageFilter->SetInput(image);
convert2DTo3DImageFilter->Update();
it->Value()->SetData(convert2DTo3DImageFilter->GetOutput());
}
}
}
}
-void USNavigationMarkerPlacement::CreateOverlays()
+void QmitkUSNavigationMarkerPlacement::CreateOverlays()
{
// initialize warning overlay (and do not display it, yet)
m_WarnOverlay->SetText("Warning: No calibration available for current depth.");
// set position and font size for the text overlay
// (nonesense postition as a layouter is used, but it ignored
// the overlay without setting a position here)
mitk::Point2D overlayPosition;
overlayPosition.SetElement(0, -50.0f);
overlayPosition.SetElement(1, -50.0f);
m_WarnOverlay->SetPosition2D(overlayPosition);
m_WarnOverlay->SetFontSize(22);
m_WarnOverlay->SetColor(1, 0, 0); // overlay should be red
}
-void USNavigationMarkerPlacement::UpdateToolStorage()
+void QmitkUSNavigationMarkerPlacement::UpdateToolStorage()
{
if (m_NavigationDataSource.IsNull()) { m_NavigationDataSource = m_CombinedModality->GetNavigationDataSource(); }
if (m_NavigationDataSource.IsNull()) { MITK_WARN << "Found an invalid navigation data source object!"; }
us::ModuleContext* context = us::GetModuleContext();
std::string id = m_NavigationDataSource->US_PROPKEY_ID;
std::string filter = "(" + mitk::NavigationToolStorage::US_PROPKEY_SOURCE_ID + "=" + id + ")";
// Get Storage
std::vector > refs = context->GetServiceReferences();
m_CurrentStorage = context->GetService(refs.front());
if (m_CurrentStorage.IsNull())
{
MITK_WARN << "Found an invalid storage object!";
}
else if (m_CurrentStorage->GetToolCount() != m_NavigationDataSource->GetNumberOfOutputs()) //there is something wrong with the storage
{
MITK_WARN << "Found a tool storage, but it has not the same number of tools like the NavigationDataSource. This storage won't be used because it isn't the right one.";
m_CurrentStorage = NULL;
}
}
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.h b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.h
similarity index 92%
rename from Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.h
rename to Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.h
index 6dd2b585ea..e4e4634543 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.h
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.h
@@ -1,216 +1,216 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
-#ifndef USNAVIGATIONMARKERPLACEMENT_H
-#define USNAVIGATIONMARKERPLACEMENT_H
+#ifndef QmitkUSNAVIGATIONMARKERPLACEMENT_H
+#define QmitkUSNAVIGATIONMARKERPLACEMENT_H
#include
#include "IO/mitkUSNavigationLoggingBackend.h"
#include "Widgets/QmitkUSNavigationProcessWidget.h"
#include "mitkNavigationDataRecorder.h"
#include "mitkNodeDisplacementFilter.h"
#include "mitkUSImageLoggingFilter.h"
#include
#include
#include
#include
namespace itk
{
template
class SmartPointer;
}
namespace mitk
{
class USNavigationStepTimer;
class USNavigationExperimentLogging;
}
namespace Ui
{
- class USNavigationMarkerPlacement;
+ class QmitkUSNavigationMarkerPlacement;
}
class QmitkUSAbstractNavigationStep;
class QmitkUSNavigationStepPunctuationIntervention;
class QmitkStdMultiWidget;
class QTimer;
class QSignalMapper;
/**
* \brief View for navigated marker placement using the combined modality.
* This view utilizes the QmitkUSNavigationProcessWidget to do the navigation
* process. It can be switched between widgets for marker placement and widgets
* for punctuation.
*
* An experiment mode allows for logging results, durations and the ultrasound
* images.
*/
-class USNavigationMarkerPlacement : public QmitkAbstractView
+class QmitkUSNavigationMarkerPlacement : public QmitkAbstractView
{
Q_OBJECT
protected slots:
/**
* \brief Called periodically to update the rendering.
* The standard multi widget is changed to fit the navigation process once it
* is available and a reinit on the ultrasound image is done for a new image
* node.
*/
void OnTimeout();
/**
* \brief Called periodically during an experiment for logging the ultrasound images.
*/
void OnImageAndNavigationDataLoggingTimeout();
/**
* \brief Initializes anything neccessary for an experiment.
* The user is asked for a directory for storing the results and the logging
* is started.
*/
void OnStartExperiment();
/**
* \brief Stops logging and saves everything to the file system.
*/
void OnFinishExperiment();
void OnCombinedModalityChanged(itk::SmartPointer);
/**
* \brief Switches the navigation step widgets if the navigation application was changed.
*/
void OnSettingsChanged(itk::SmartPointer);
/**
* \brief Updates the timer for the navigation steps durations every time the active navigation step changes.
*/
void OnActiveNavigationStepChanged(int);
/** Initializes the next navigation step */
void OnNextNavigationStepInitialization(int);
/**
* \brief The data node is given to the experiment logging and scene is saved to the file system.
*/
void OnIntermediateResultProduced(const itk::SmartPointer);
void OnAddAblationZone(int size);
void OnEnableNavigationLayout();
void OnResetStandardLayout();
void OnChangeLayoutClicked();
void OnChangeAblationZone(int id, int newSize);
void OnRenderWindowSelection();
void OnRefreshView();
public:
static const char *DATANAME_TUMOUR;
static const char *DATANAME_TARGETSURFACE;
static const char *DATANAME_ZONES;
static const char *DATANAME_TARGETS;
static const char *DATANAME_TARGETS_PATHS;
static const char *DATANAME_REACHED_TARGETS;
- explicit USNavigationMarkerPlacement();
- ~USNavigationMarkerPlacement();
+ explicit QmitkUSNavigationMarkerPlacement();
+ ~QmitkUSNavigationMarkerPlacement();
virtual void CreateQtPartControl(QWidget *parent);
static const std::string VIEW_ID;
void OnCombinedModalityPropertyChanged(const std::string &, const std::string &);
protected:
/**
* \brief A reinit on the ultrasound image is performed every time the view gets the focus.
*/
virtual void SetFocus();
/**
* \brief Helper function which performs a reinit on the ultrasound image.
*/
void ReinitOnImage();
/**
* \brief Sets the multiwidget to two windows, axial on top and 3D render window on the bottom.
*/
virtual void SetTwoWindowView();
/**
* \brief Helper function for being able to serialize the 2d ultrasound image.
*/
void Convert2DImagesTo3D(mitk::DataStorage::SetOfObjects::ConstPointer nodes);
void UpdateToolStorage();
void CreateOverlays();
QWidget *m_Parent;
QmitkUSNavigationProcessWidget::NavigationStepVector m_NavigationSteps;
QTimer *m_UpdateTimer;
QTimer *m_ImageAndNavigationDataLoggingTimer;
QmitkStdMultiWidget *m_StdMultiWidget;
itk::SmartPointer m_CombinedModality;
bool m_ReinitAlreadyDone;
bool m_IsExperimentRunning;
std::string m_CurrentApplicationName;
itk::SmartPointer m_NavigationStepTimer;
itk::SmartPointer m_ExperimentLogging;
QPixmap m_IconRunning;
QPixmap m_IconNotRunning;
QString m_ResultsDirectory;
QString m_ExperimentName;
QString m_ExperimentResultsSubDirectory;
std::vector
m_NavigationStepNames; // stores the names of the navigation steps which are currently used (for logging purposes)
mitk::USNavigationLoggingBackend m_LoggingBackend;
mitk::USImageLoggingFilter::Pointer m_USImageLoggingFilter;
mitk::NavigationDataRecorder::Pointer m_NavigationDataRecorder; // records navigation data files
mitk::NodeDisplacementFilter::Pointer m_TargetNodeDisplacementFilter;
mitk::NodeDisplacementFilter::Pointer m_AblationZonesDisplacementFilter;
std::vector m_AblationZonesVector;
int m_NeedleIndex;
int m_MarkerIndex;
int m_SceneNumber;
itk::SmartPointer m_WarnOverlay;
//To get tool storage
mitk::NavigationDataSource::Pointer m_NavigationDataSource;
mitk::NavigationToolStorage::Pointer m_CurrentStorage;
private:
- mitk::MessageDelegate2 m_ListenerDeviceChanged;
+ mitk::MessageDelegate2 m_ListenerDeviceChanged;
- Ui::USNavigationMarkerPlacement *ui;
+ Ui::QmitkUSNavigationMarkerPlacement *ui;
};
#endif // USNAVIGATIONMARKERPLACEMENT_H
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.ui
similarity index 95%
copy from Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui
copy to Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.ui
index a181fe0767..ceb1ffc701 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/QmitkUSNavigationMarkerPlacement.ui
@@ -1,123 +1,123 @@
- USNavigationMarkerPlacement
-
+ QmitkUSNavigationMarkerPlacement
+
0
0
- 400
+ 443
146
Form
0
0
0
0
0
-
-
Qt::Horizontal
-
-
Enable Navigation Render Window Layout with RenderWindow
true
-
1
3
-
Refresh view
-
-
Start New Experiment
-
false
Finish Experiment
-
20
20
QmitkUSNavigationProcessWidget
QWidget
src/internal/Widgets/QmitkUSNavigationProcessWidget.h
1
OnStartExperiment()
OnFinishExperiment()
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui
index a181fe0767..4d3ceb49c3 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/USNavigationMarkerPlacement.ui
@@ -1,123 +1,123 @@
- USNavigationMarkerPlacement
+ QmitkUSNavigationMarkerPlacement
0
0
400
146
Form
0
0
0
0
0
-
-
Qt::Horizontal
-
-
Enable Navigation Render Window Layout with RenderWindow
true
-
1
3
-
Refresh view
-
-
Start New Experiment
-
false
Finish Experiment
-
20
20
QmitkUSNavigationProcessWidget
QWidget
src/internal/Widgets/QmitkUSNavigationProcessWidget.h
1
OnStartExperiment()
OnFinishExperiment()
diff --git a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/org_mbi_gui_qt_usnavigation_Activator.cpp b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/org_mbi_gui_qt_usnavigation_Activator.cpp
index fb1eaf8361..d02b7fb363 100644
--- a/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/org_mbi_gui_qt_usnavigation_Activator.cpp
+++ b/Plugins/org.mitk.gui.qt.igt.app.echotrack/src/internal/org_mbi_gui_qt_usnavigation_Activator.cpp
@@ -1,67 +1,67 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "org_mbi_gui_qt_usnavigation_Activator.h"
#include
#include
//#include "USNavigation.h"
-#include "UltrasoundCalibration.h"
-#include "USNavigationMarkerPlacement.h"
+#include "QmitkUltrasoundCalibration.h"
+#include "QmitkUSNavigationMarkerPlacement.h"
#include "QmitkUSNavigationPerspective.h"
#include "mitkVirtualTrackingDevice.h"
namespace mitk {
ctkPluginContext* org_mbi_gui_qt_usnavigation_Activator::m_Context = 0;
void org_mbi_gui_qt_usnavigation_Activator::start(ctkPluginContext* context)
{
m_Context = context;
//BERRY_REGISTER_EXTENSION_CLASS(USNavigation, context)
- BERRY_REGISTER_EXTENSION_CLASS(UltrasoundCalibration, context)
- BERRY_REGISTER_EXTENSION_CLASS(USNavigationMarkerPlacement, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkUltrasoundCalibration, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkUSNavigationMarkerPlacement, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkUSNavigationPerspective, context)
// create a combined modality persistence object for loading and storing
// combined modality objects persistently
m_USCombinedModalityPersistence = mitk::USNavigationCombinedModalityPersistence::New();
}
void org_mbi_gui_qt_usnavigation_Activator::stop(ctkPluginContext* context)
{
m_USCombinedModalityPersistence = 0;
m_Context = 0;
Q_UNUSED(context)
}
ctkPluginContext *org_mbi_gui_qt_usnavigation_Activator::GetContext()
{
return m_Context;
}
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(org_mitk_gui_qt_igt_app_echotrack, mitk::org_mbi_gui_qt_usnavigation_Activator)
#endif
// necessary for us::GetModuleContext() in USNavigationCombinedModalityPersistence
// (see: https://www.mail-archive.com/mitk-users@lists.sourceforge.net/msg04421.html)
US_INITIALIZE_MODULE