| 34 | } |
| 35 | |
| 36 | void mitk::SinglePointDataInteractor::AddPoint(StateMachineAction * /*stateMachineAction*/, |
| 37 | InteractionEvent *interactionEvent) |
| 38 | { |
| 39 | unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData()); |
| 40 | ScalarType timeInMs = interactionEvent->GetSender()->GetTime(); |
| 41 | |
| 42 | // To add a point the minimal information is the position, this method accepts all InteractionsPositionEvents |
| 43 | auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent); |
| 44 | if (positionEvent != nullptr) |
| 45 | { |
| 46 | PointOperation *doOp; |
| 47 | PointOperation *undoOp; |
| 48 | |
| 49 | if (m_PointSet->IndexExists(0, timeStep)) |
| 50 | { |
| 51 | PointSet::PointType pt = m_PointSet->GetPoint(0, timeStep); |
| 52 | Point3D itkPoint; |
| 53 | itkPoint[0] = pt[0]; |
| 54 | itkPoint[1] = pt[1]; |
| 55 | itkPoint[2] = pt[2]; |
| 56 | |
| 57 | doOp = new mitk::PointOperation(OpMOVE, timeInMs, positionEvent->GetPositionInWorld(), 0); |
| 58 | undoOp = new mitk::PointOperation(OpMOVE, timeInMs, itkPoint, 0); |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | doOp = new mitk::PointOperation(OpINSERT, timeInMs, positionEvent->GetPositionInWorld(), 0); |
| 63 | undoOp = new mitk::PointOperation(OpREMOVE, timeInMs, positionEvent->GetPositionInWorld(), 0); |
| 64 | } |
| 65 | |
| 66 | if (m_UndoEnabled) |
| 67 | { |
| 68 | OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Move point"); |
| 69 | OperationEvent::IncCurrObjectEventId(); |
| 70 | |
| 71 | m_UndoController->SetOperationEvent(operationEvent); |
| 72 | } |
| 73 | // execute the Operation |
| 74 | m_PointSet->ExecuteOperation(doOp); |
| 75 | |
| 76 | if (!m_UndoEnabled) |
| 77 | delete doOp; |
| 78 | |
| 79 | RenderingManager::GetInstance()->RequestUpdateAll(); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Check whether the DataNode contains a pointset, if not create one and add it. |
nothing calls this directly
no test coverage detected