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

Method RemovePoint

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

Source from the content-addressed store, hash-verified

191}
192
193void mitk::PointSetDataInteractor::RemovePoint(StateMachineAction *, InteractionEvent *interactionEvent)
194{
195 if (!m_IsRemovalEnabled)
196 return;
197
198 unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
199 ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
200
201 auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
202 if (positionEvent != nullptr)
203 {
204 mitk::Point3D itkPoint = positionEvent->GetPositionInWorld();
205
206 // search the point in the list
207 int position = m_PointSet->SearchPoint(itkPoint, m_SelectionAccuracy, timeStep);
208 if (position >= 0) // found a point
209 {
210 PointSet::PointType pt = m_PointSet->GetPoint(position, timeStep);
211 itkPoint[0] = pt[0];
212 itkPoint[1] = pt[1];
213 itkPoint[2] = pt[2];
214
215 auto *doOp = new mitk::PointOperation(OpREMOVE, timeInMs, itkPoint, position);
216 if (m_UndoEnabled) // write to UndoMechanism
217 {
218 auto *undoOp = new mitk::PointOperation(OpINSERT, timeInMs, itkPoint, position);
219 OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Remove point");
220 mitk::OperationEvent::IncCurrObjectEventId();
221 m_UndoController->SetOperationEvent(operationEvent);
222 }
223 // execute the Operation
224 m_PointSet->ExecuteOperation(doOp);
225
226 if (!m_UndoEnabled)
227 delete doOp;
228
229 /*now select the point "position-1",
230 and if it is the first in list,
231 then continue at the last in list*/
232 // only then a select of a point is possible!
233 if (m_PointSet->GetSize(timeStep) > 0)
234 {
235 this->SelectPoint(m_PointSet->Begin(timeStep)->Index(), timeStep, timeInMs);
236 }
237 }
238 RenderingManager::GetInstance()->RequestUpdateAll();
239 }
240}
241
242void mitk::PointSetDataInteractor::IsClosedContour(StateMachineAction *, InteractionEvent *interactionEvent)
243{

Callers 6

KeyDeleteMethod · 0.95
RemoveFunctionPointFunction · 0.80
RemoveFunctionPointFunction · 0.80
RemoveRGBPointMethod · 0.80

Calls 13

SelectPointMethod · 0.95
GetSenderMethod · 0.80
GetTimeMethod · 0.80
GetPositionInWorldMethod · 0.80
SearchPointMethod · 0.80
GetTimeStepMethod · 0.45
GetDataMethod · 0.45
GetPointMethod · 0.45
SetOperationEventMethod · 0.45
ExecuteOperationMethod · 0.45
GetSizeMethod · 0.45
BeginMethod · 0.45

Tested by

no test coverage detected