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

Method PickObject

Modules/Core/src/Rendering/mitkVtkPropRenderer.cpp:404–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404mitk::DataNode *mitk::VtkPropRenderer::PickObject(const Point2D &displayPosition, Point3D &worldPosition) const
405{
406 m_CellPicker->InitializePickList();
407
408 // Iterate over all DataStorage objects to determine all vtkProps intended
409 // for picking
410 DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll();
411 for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it)
412 {
413 const DataNode *node = it->Value();
414 if (node == nullptr)
415 continue;
416
417 bool pickable = false;
418 node->GetBoolProperty("pickable", pickable);
419 if (!pickable)
420 continue;
421
422 auto *mapper = dynamic_cast<VtkMapper *>(node->GetMapper(m_MapperID));
423 if (mapper == nullptr)
424 continue;
425
426 vtkProp *prop = mapper->GetVtkProp((mitk::BaseRenderer *)this);
427 if (prop == nullptr)
428 continue;
429
430 m_CellPicker->AddPickList(prop);
431 }
432
433 // Do the picking and retrieve the picked vtkProp (if any)
434 m_CellPicker->PickFromListOn();
435 m_CellPicker->Pick(displayPosition[0], displayPosition[1], 0.0, m_VtkRenderer);
436 m_CellPicker->PickFromListOff();
437
438 mitk::FillArray(worldPosition, m_CellPicker->GetPickPosition());
439 vtkProp *prop = m_CellPicker->GetViewProp();
440
441 if (prop == nullptr)
442 {
443 return nullptr;
444 }
445
446 // Iterate over all DataStorage objects to determine if the retrieved
447 // vtkProp is owned by any associated mapper.
448 for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it)
449 {
450 DataNode::Pointer node = it->Value();
451 if (node.IsNull())
452 continue;
453
454 mitk::Mapper *mapper = node->GetMapper(m_MapperID);
455 if (mapper == nullptr)
456 continue;
457
458 auto *vtkmapper = dynamic_cast<VtkMapper *>(mapper);
459
460 if (vtkmapper)
461 {

Callers 4

CheckOverObjectMethod · 0.80
InitDeformationMethod · 0.80
CheckOverObjectMethod · 0.80
CheckOverObjectMethod · 0.80

Calls 10

FillArrayFunction · 0.85
GetAllMethod · 0.80
ValueMethod · 0.80
GetMapperMethod · 0.80
HasVtkPropMethod · 0.80
BeginMethod · 0.45
EndMethod · 0.45
GetBoolPropertyMethod · 0.45
GetVtkPropMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected