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

Method FinishMove

Modules/Core/src/Interactions/mitkPointSetDataInteractor.cpp:493–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493void mitk::PointSetDataInteractor::FinishMove(StateMachineAction *, InteractionEvent *interactionEvent)
494{
495 if (!m_IsMovementEnabled)
496 return;
497
498 unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
499 ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
500
501 auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
502
503 if (positionEvent != nullptr)
504 {
505 // finish the movement:
506 // the final point is m_LastPoint
507 // m_SumVec stores the movement in a vector
508 // the operation would not be necessary, but we need it for the undo Operation.
509 // m_LastPoint is for the Operation
510 // the point for undoOperation calculates from all selected
511 // elements (point) - m_SumVec
512
513 // search all selected elements and move them with undo-functionality.
514
515 mitk::PointSet::PointsIterator it, end;
516 it = m_PointSet->Begin(timeStep);
517 end = m_PointSet->End(timeStep);
518 while (it != end)
519 {
520 int position = it->Index();
521 if (m_PointSet->GetSelectInfo(position, timeStep)) // if selected
522 {
523 PointSet::PointType pt = m_PointSet->GetPoint(position, timeStep);
524 auto *doOp = new mitk::PointOperation(OpMOVE, timeInMs, pt, position);
525
526 if (m_UndoEnabled) //&& (posEvent->GetType() == mitk::Type_MouseButtonRelease)
527 {
528 // set the undo-operation, so the final position is undo-able
529 // calculate the old Position from the already moved position - m_SumVec
530 mitk::Point3D undoPoint = (pt - m_SumVec);
531 auto *undoOp = new mitk::PointOperation(OpMOVE, timeInMs, undoPoint, position);
532 OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Move point");
533 OperationEvent::IncCurrObjectEventId();
534 m_UndoController->SetOperationEvent(operationEvent);
535 }
536 // execute the Operation
537 m_PointSet->ExecuteOperation(doOp);
538
539 if (!m_UndoEnabled)
540 delete doOp;
541 }
542 ++it;
543 }
544
545 // Update the display
546 RenderingManager::GetInstance()->RequestUpdateAll();
547 }
548 else
549 {
550 return;

Callers

nothing calls this directly

Calls 12

GetSenderMethod · 0.80
GetTimeMethod · 0.80
GetSelectInfoMethod · 0.80
NotifyResultReadyMethod · 0.80
GetTimeStepMethod · 0.45
GetDataMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
GetPointMethod · 0.45
SetOperationEventMethod · 0.45
ExecuteOperationMethod · 0.45
RequestUpdateAllMethod · 0.45

Tested by

no test coverage detected