MCPcopy Create free account
hub / github.com/MITK/MITK / AddPoint

Method AddPoint

Examples/Tutorial/Step10/Step10.cpp:49–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49bool mitk::ExampleInteractor::AddPoint(StateMachineAction *, InteractionEvent *interactionEvent)
50{
51 // cast InteractionEvent to a position event in order to read out the mouse position
52 // we stay here as general as possible so that a different state machine pattern
53 // can reuse this code with MouseRelease or MouseMoveEvents.
54 InteractionPositionEvent *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
55 if (positionEvent != nullptr)
56 {
57 // query the position of the mouse in the world geometry
58 mitk::Point3D point = positionEvent->GetPositionInWorld();
59 m_PointSet->InsertPoint(m_NumberOfPoints, point, 0);
60 m_NumberOfPoints++;
61 GetDataNode()->SetData(m_PointSet);
62 GetDataNode()->Modified();
63
64 if (m_NumberOfPoints != 0 && m_NumberOfPoints >= m_MaximalNumberOfPoints)
65 {
66 // create internal event that signal that the maximal number of points is reached
67 InternalEvent::Pointer event = InternalEvent::New(nullptr, this, "enoughPointsAdded");
68 // add the internal event to the event queue of the Dispatcher
69 positionEvent->GetSender()->GetDispatcher()->QueueEvent(event.GetPointer());
70 }
71 // update the RenderWindow to show new points
72 mitk::RenderingManager::GetInstance()->RequestUpdateAll();
73 return true;
74 }
75 else
76 {
77 return false;
78 }
79}
80
81bool mitk::ExampleInteractor::EnoughPoints(StateMachineAction *, InteractionEvent *)
82{

Callers 1

mainFunction · 0.45

Calls 10

GetPositionInWorldMethod · 0.80
InsertPointMethod · 0.80
QueueEventMethod · 0.80
GetSenderMethod · 0.80
GetPointerMethod · 0.80
NewFunction · 0.50
SetDataMethod · 0.45
ModifiedMethod · 0.45
GetDispatcherMethod · 0.45
RequestUpdateAllMethod · 0.45

Tested by

no test coverage detected