MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateHoverText

Method UpdateHoverText

Views/Infovis/vtkRenderView.cxx:525–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525void 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
580void vtkRenderView::ApplyViewTheme(vtkViewTheme* theme)
581{

Callers 1

ProcessEventsMethod · 0.95

Calls 11

UpdatePickRenderMethod · 0.95
GetRepresentationMethod · 0.80
InvokeEventMethod · 0.80
GetInteractorMethod · 0.45
EndWidgetInteractionMethod · 0.45
GetPixelInformationMethod · 0.45
GetHoverStringMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected