14#include "mitkDataStorage.h"
15#include "mitkDataNode.h"
16#include "mitkSurface.h"
17#include "mitkInteractionPositionEvent.h"
19#include <vtkSphereSource.h>
26 if (!dataNode->GetData())
28 MITK_WARN(
"USZonesInteractor")(
"DataInteractor")
29 <<
"Cannot update surface for node as no data is set to the node.";
33 mitk::Point3D origin = dataNode->GetData()->GetGeometry()->GetOrigin();
38 MITK_WARN(
"USZonesInteractor")(
"DataInteractor")
39 <<
"Cannut update surface for node as no radius is specified in the node properties.";
43 mitk::Surface::Pointer zone = mitk::Surface::New();
47 vtkSphere->SetRadius(radius);
48 vtkSphere->SetCenter(0, 0, 0);
49 vtkSphere->SetPhiResolution(20);
50 vtkSphere->SetThetaResolution(20);
52 zone->SetVtkPolyData(vtkSphere->GetOutput());
56 dataNode->SetData(zone);
57 dataNode->GetData()->GetGeometry()->SetOrigin(origin);
60 mitk::RenderingManager::GetInstance()->RequestUpdateAll();
73 CONNECT_FUNCTION(
"addCenter", AddCenter);
74 CONNECT_FUNCTION(
"changeRadius", ChangeRadius);
75 CONNECT_FUNCTION(
"endCreation", EndCreation);
76 CONNECT_FUNCTION(
"abortCreation", AbortCreation);
81 mitk::DataNode::Pointer dataNode = this->GetDataNode();
82 if (dataNode.IsNotNull() && dataNode->GetData() ==
nullptr)
84 dataNode->SetData(mitk::Surface::New());
91 mitk::InteractionPositionEvent* positionEvent =
dynamic_cast<mitk::InteractionPositionEvent*
>(interactionEvent);
92 mitk::DataNode::Pointer dataNode = this->GetDataNode();
93 dataNode->SetBoolProperty(DATANODE_PROPERTY_CREATED,
false);
96 mitk::BaseData::Pointer dataNodeData = this->GetDataNode()->GetData();
97 if (dataNodeData.IsNull())
99 dataNodeData = mitk::Surface::New();
100 this->GetDataNode()->SetData(dataNodeData);
104 dataNodeData->GetGeometry()->SetOrigin(positionEvent->GetPositionInWorld());
105 MITK_INFO(
"USNavigationLogging") <<
"Critical Structure added on position " << positionEvent->GetPointerPositionOnScreen() <<
" (Image Coordinates); "
106 << positionEvent->GetPositionInWorld() <<
" (World Coordinates)";
108 dataNode->SetFloatProperty(
"opacity", 0.60f);
116 mitk::InteractionPositionEvent* positionEvent =
dynamic_cast<mitk::InteractionPositionEvent*
>(interactionEvent);
117 mitk::DataNode::Pointer curNode = this->GetDataNode();
118 mitk::Point3D mousePosition = positionEvent->GetPositionInWorld();
120 mitk::ScalarType radius = mousePosition.EuclideanDistanceTo(curNode->GetData()->GetGeometry()->GetOrigin());
121 curNode->SetFloatProperty(DATANODE_PROPERTY_SIZE, radius);
130 this->GetDataNode()->SetBoolProperty(DATANODE_PROPERTY_CREATED,
true);
136 this->GetDataNode()->SetData(mitk::Surface::New());
139 mitk::RenderingManager::GetInstance()->RequestUpdateAll();
static void UpdateSurface(itk::SmartPointer< mitk::DataNode >)
Creates Vtk Sphere according to current radius. The radius is gotten from the float property "zone....
void AddCenter(StateMachineAction *, InteractionEvent *)
Sets origin of the data node to the coordinates of the position event.
void ChangeRadius(StateMachineAction *, InteractionEvent *)
Updates radius attribute according to position event. Calculates distance between the data node origi...
static const char * DATANODE_PROPERTY_SIZE
void EndCreation(StateMachineAction *, InteractionEvent *)
Sets the property "zone.created" of the data node to true.
static const char * DATANODE_PROPERTY_CREATED
void ConnectActionsAndFunctions() override
Connects the functions from the state machine to methods of this class.
void DataNodeChanged() override
Sets empty surface as data for the new data node. This is necessary as data nodes without data do not...
void AbortCreation(StateMachineAction *, InteractionEvent *)
Removes Vtk Sphere from data node.
~USZonesInteractor() override