| 523 | } |
| 524 | |
| 525 | void vtkRenderView::UpdateHoverText() |
| 526 | { |
| 527 | this->UpdatePickRender(); |
| 528 | |
| 529 | int pos[2] = { 0, 0 }; |
| 530 | unsigned int upos[2] = { 0, 0 }; |
| 531 | double loc[2] = { 0.0, 0.0 }; |
| 532 | if (this->RenderWindow->GetInteractor()) |
| 533 | { |
| 534 | this->RenderWindow->GetInteractor()->GetEventPosition(pos); |
| 535 | loc[0] = pos[0]; |
| 536 | loc[1] = pos[1]; |
| 537 | upos[0] = static_cast<unsigned int>(pos[0]); |
| 538 | upos[1] = static_cast<unsigned int>(pos[1]); |
| 539 | } |
| 540 | this->Balloon->EndWidgetInteraction(loc); |
| 541 | |
| 542 | // The number of pixels away from the pointer to search for hovered objects. |
| 543 | int hoverTol = 3; |
| 544 | |
| 545 | // Retrieve the hovered cell from the saved buffer. |
| 546 | vtkHardwareSelector::PixelInformation info = this->Selector->GetPixelInformation(upos, hoverTol); |
| 547 | vtkIdType cell = info.AttributeID; |
| 548 | vtkProp* prop = info.Prop; |
| 549 | if (prop == nullptr || cell == -1) |
| 550 | { |
| 551 | this->Balloon->SetBalloonText(""); |
| 552 | return; |
| 553 | } |
| 554 | |
| 555 | // For debugging |
| 556 | // std::ostringstream oss; |
| 557 | // oss << "prop: " << prop << " cell: " << cell; |
| 558 | // this->Balloon->SetBalloonText(oss.str().c_str()); |
| 559 | // this->Balloon->StartWidgetInteraction(loc); |
| 560 | |
| 561 | std::string hoverText; |
| 562 | for (int i = 0; i < this->GetNumberOfRepresentations(); ++i) |
| 563 | { |
| 564 | vtkRenderedRepresentation* rep = |
| 565 | vtkRenderedRepresentation::SafeDownCast(this->GetRepresentation(i)); |
| 566 | if (rep && this->RenderWindow->GetInteractor()) |
| 567 | { |
| 568 | hoverText = rep->GetHoverString(this, prop, cell); |
| 569 | if (!hoverText.empty()) |
| 570 | { |
| 571 | break; |
| 572 | } |
| 573 | } |
| 574 | } |
| 575 | this->Balloon->SetBalloonText(hoverText.c_str()); |
| 576 | this->Balloon->StartWidgetInteraction(loc); |
| 577 | this->InvokeEvent(vtkCommand::HoverEvent, &hoverText); |
| 578 | } |
| 579 | |
| 580 | void vtkRenderView::ApplyViewTheme(vtkViewTheme* theme) |
| 581 | { |
no test coverage detected