| 191 | } |
| 192 | |
| 193 | void 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 | |
| 242 | void mitk::PointSetDataInteractor::IsClosedContour(StateMachineAction *, InteractionEvent *interactionEvent) |
| 243 | { |
no test coverage detected