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

Method AddPoint

Modules/Core/src/Interactions/mitkSinglePointDataInteractor.cpp:36–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void 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.

Callers

nothing calls this directly

Calls 10

GetSenderMethod · 0.80
GetTimeMethod · 0.80
IndexExistsMethod · 0.80
GetPositionInWorldMethod · 0.80
GetTimeStepMethod · 0.45
GetDataMethod · 0.45
GetPointMethod · 0.45
SetOperationEventMethod · 0.45
ExecuteOperationMethod · 0.45
RequestUpdateAllMethod · 0.45

Tested by

no test coverage detected