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

Method PickFrom2D

Modules/Gizmo/src/mitkGizmoInteractor.cpp:357–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357mitk::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
397mitk::Gizmo::HandleType mitk::GizmoInteractor::PickFrom3D(const InteractionPositionEvent *positionEvent)
398{

Callers

nothing calls this directly

Calls 8

GetSenderMethod · 0.80
GetMapperMethod · 0.80
NewFunction · 0.50
GetVtkPropMethod · 0.45
GetVtkRendererMethod · 0.45
GetVtkPolyDataMethod · 0.45

Tested by

no test coverage detected