| 47 | } |
| 48 | |
| 49 | bool 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 | |
| 81 | bool mitk::ExampleInteractor::EnoughPoints(StateMachineAction *, InteractionEvent *) |
| 82 | { |
no test coverage detected