MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkUSPointMarkInteractor.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14#include "mitkDataNode.h"
15#include "mitkInteractionPositionEvent.h"
16
17//#include "mitkPlanarCircle.h"
18#include "mitkSurface.h"
19//#include "vtkSphere.h"
20//#include "vtkSphereSource.h"
21
25
29
31{
32 CONNECT_FUNCTION("addPoint", AddPoint);
33}
34
36{
37 mitk::DataNode::Pointer dataNode = this->GetDataNode();
38 if (dataNode.IsNotNull() && dataNode->GetData() == nullptr)
39 {
40 dataNode->SetData(mitk::Surface::New());
41 }
42}
43
44void mitk::USPointMarkInteractor::AddPoint(mitk::StateMachineAction*, mitk::InteractionEvent* interactionEvent)
45{
46 // cast InteractionEvent to a position event in order to read out the mouse position
47 mitk::InteractionPositionEvent* positionEvent = dynamic_cast<mitk::InteractionPositionEvent*>(interactionEvent);
48 // set origin of the data node to the mouse click position
49 this->GetDataNode()->GetData()->GetGeometry()->SetOrigin(positionEvent->GetPositionInWorld());
50
51 CoordinatesChangedEvent.Send(this->GetDataNode());
52
53 //return true;
54}
void AddPoint(StateMachineAction *, InteractionEvent *)
Set current position as origin to the data node.
void DataNodeChanged() override
Sets empty surface as data for the new data node. This is necessary as data nodes without data do not...
void ConnectActionsAndFunctions() override
Connects the functions from the state machine to methods of this class.