| 355 | } |
| 356 | |
| 357 | mitk::Gizmo::HandleType mitk::GizmoInteractor::PickFrom2D(const InteractionPositionEvent *positionEvent) |
| 358 | { |
| 359 | BaseRenderer *renderer = positionEvent->GetSender(); |
| 360 | |
| 361 | auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard2D); |
| 362 | auto gizmo_mapper = dynamic_cast<GizmoMapper2D *>(mapper); |
| 363 | auto &picker = m_Picker[renderer]; |
| 364 | |
| 365 | if (picker == nullptr) |
| 366 | { |
| 367 | picker = vtkSmartPointer<vtkCellPicker>::New(); |
| 368 | picker->SetTolerance(0.005); |
| 369 | |
| 370 | if (gizmo_mapper) |
| 371 | { // doing this each time is bizarre |
| 372 | picker->AddPickList(gizmo_mapper->GetVtkProp(renderer)); |
| 373 | picker->PickFromListOn(); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | auto displayPosition = positionEvent->GetPointerPositionOnScreen(); |
| 378 | picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); |
| 379 | |
| 380 | vtkIdType pickedPointID = picker->GetPointId(); |
| 381 | if (pickedPointID == -1) |
| 382 | { |
| 383 | return Gizmo::NoHandle; |
| 384 | } |
| 385 | |
| 386 | vtkPolyData *polydata = gizmo_mapper->GetVtkPolyData(renderer); |
| 387 | |
| 388 | if (polydata && polydata->GetPointData() && polydata->GetPointData()->GetScalars()) |
| 389 | { |
| 390 | double dataValue = polydata->GetPointData()->GetScalars()->GetTuple1(pickedPointID); |
| 391 | return m_Gizmo->GetHandleFromPointDataValue(dataValue); |
| 392 | } |
| 393 | |
| 394 | return Gizmo::NoHandle; |
| 395 | } |
| 396 | |
| 397 | mitk::Gizmo::HandleType mitk::GizmoInteractor::PickFrom3D(const InteractionPositionEvent *positionEvent) |
| 398 | { |
nothing calls this directly
no test coverage detected