I am trying to use the vtkCaptionWidget and would like to be able to show or hide the anchor representation point at will. Any time I use the vtkPointHandleRepresentation3D::SetVisibility function accessed from the vtkCaptionWidget’s vtkCaptionRepresentation object to hide the anchor point, it will initially hide it and then show it again as soon as I interact with the render window again.
I had a similar issue with the vtkCaptionWidget not respecting the font size on the caption itself which turned out to be a bug so I am wondering if this is a bug or if I just need to do something differently. I’ve included my setup for the widget and it’s representation here for context:
vtkNew<vtkCaptionWidget> m_CaptionWidget;
vtkNew<vtkCaptionRepresentation> m_CaptionRepresentation;
m_CaptionWidget->SetInteractor(m_ViewWidget->getVisualizationWidget()->renderWindow()->GetInteractor());
m_CaptionWidget->SetEnabled(true);
m_CaptionWidget->SetSelectable(false);
m_CaptionWidget->SetResizable(true);
m_CaptionWidget->SetRepresentation(m_CaptionRepresentation);
m_CaptionRepresentation->GetCaptionActor2D()->BorderOff();
m_CaptionRepresentation->GetCaptionActor2D()->GetTextActor()->SetTextScaleModeToNone();
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 4, 0)
m_CaptionRepresentation->SetFitToBorder();
m_CaptionRepresentation->SetFitToText();
#endif
m_CaptionRepresentation->GetCaptionActor2D()->SetCaption(m_Text.toLatin1());
m_CaptionRepresentation->GetCaptionActor2D()->GetTextActor()->GetTextProperty()->SetFontSize(m_FontSize);
m_CaptionRepresentation->GetCaptionActor2D()->GetTextActor()->GetTextProperty()->SetJustificationToCentered();
m_CaptionRepresentation->SetAnchorPosition(m_AnchorPos.data());
m_CaptionRepresentation->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay();
m_CaptionRepresentation->GetPositionCoordinate()->SetValue(0.75, 0.9);
m_CaptionRepresentation->EnforceNormalizedViewportBoundsOn();
m_CaptionRepresentation->GetAnchorRepresentation()->UseBoundsOff(); // Don't include the anchor point in the global grid axes bounds calculations
m_CaptionRepresentation->GetAnchorRepresentation()->SetVisibility(m_ShowAnchorPt && m_Visible);
m_CaptionRepresentation->GetAnchorRepresentation()->SetActiveRepresentation(false);