| 402 | } |
| 403 | |
| 404 | mitk::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 | { |
no test coverage detected