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

Method MovePoint

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

Source from the content-addressed store, hash-verified

257}
258
259void mitk::PointSetDataInteractor::MovePoint(StateMachineAction *stateMachineAction, InteractionEvent *interactionEvent)
260{
261 if (!m_IsMovementEnabled)
262 return;
263
264 unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
265 ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
266 auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
267 if (positionEvent != nullptr)
268 {
269 IsClosedContour(stateMachineAction, interactionEvent);
270
271 // search the elements in the list that are selected then calculate the
272 // vector, because only with the vector we can move several elements in
273 // the same direction
274 // newPoint - lastPoint = vector
275 // then move all selected and set the lastPoint = newPoint.
276 // then add all vectors to a summeryVector (to be able to calculate the
277 // startpoint for undoOperation)
278 auto newPoint = positionEvent->GetPositionInWorld();
279 mitk::Vector3D dirVector = newPoint - m_LastPoint;
280
281 // sum up all Movement for Undo in FinishMovement
282 m_SumVec = m_SumVec + dirVector;
283
284 mitk::PointSet::PointsIterator it, end;
285 it = m_PointSet->Begin(timeStep);
286 end = m_PointSet->End(timeStep);
287 while (it != end)
288 {
289 int position = it->Index();
290 if (m_PointSet->GetSelectInfo(position, timeStep)) // if selected
291 {
292 auto pt = m_PointSet->GetPoint(position, timeStep);
293 auto resultPoint = pt + dirVector;
294
295 if (m_Bounds.IsNotNull())
296 resultPoint = m_Bounds->ClampPoint(resultPoint);
297
298 auto *doOp = new mitk::PointOperation(OpMOVE, timeInMs, resultPoint, position);
299 // execute the Operation
300 // here no undo is stored, because the movement-steps aren't interesting.
301 // only the start and the end is interisting to store for undo.
302 m_PointSet->ExecuteOperation(doOp);
303 delete doOp;
304 }
305 ++it;
306 }
307 m_LastPoint = newPoint; // for calculation of the direction vector
308 // Update the display
309 RenderingManager::GetInstance()->RequestUpdateAll();
310 IsClosedContour(stateMachineAction, interactionEvent);
311 }
312}
313
314void mitk::PointSetDataInteractor::UnSelectPointAtPosition(StateMachineAction *, InteractionEvent *interactionEvent)
315{

Callers

nothing calls this directly

Calls 13

GetSenderMethod · 0.80
GetTimeMethod · 0.80
GetPositionInWorldMethod · 0.80
GetSelectInfoMethod · 0.80
IsNotNullMethod · 0.80
ClampPointMethod · 0.80
GetTimeStepMethod · 0.45
GetDataMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
GetPointMethod · 0.45
ExecuteOperationMethod · 0.45

Tested by

no test coverage detected