vtkCaptionActor2D and the size of Leader glyph

I am using vtkCaptionActor2D to create an annotation on a volume dataset; I liked the idea of the “leader glyph”, and played around with it a bit, but could not get the automatic sizing working for my case: when setting the camera rather close to the attachment point, the leader glyph is extremely small, and therefore not visible:

only when zooming out a lot, I see the glyph:

My code (sorry that it’s not a full MWE at the moment, I did not yet have time to prepare one):

	vtkNew<vtkCaptionActor2D> capAct;
	capAct->SetCaption("Annotation 0");
	vtkNew<vtkArrowSource> leaderGlyphSource;
	leaderGlyphSource->SetShaftRadius(0.2);
	leaderGlyphSource->SetTipRadius(0.5);
	leaderGlyphSource->SetTipLength(0.6);
	leaderGlyphSource->Update();
	
	capAct->SetLeaderGlyphConnection(leaderGlyphSource->GetOutputPort());
	capAct->SetLeaderGlyphSize(1);
	capAct->SetMaximumLeaderGlyphSize(30.0);
	...

Am I doing something weird here?

When looking at the size adaptation code, I found it peculiar that the code just takes the middle display point and computes the distance of 1 pixel in world coordinates.
On a hunch, I took the attachment point instead, converted that to display coordinates, add +1 in x and y direction and converted it back, and used that distance for scale factor creation:

    auto p1 = this->AttachmentPointCoordinate->GetComputedWorldValue(viewport);
    // get world coordinates of point 1 pixel away from attach point:
    viewport->SetWorldPoint(p1[0], p1[1], p1[2], 1.0);
    viewport->WorldToDisplay();
    double dispPt[4];
    viewport->GetDisplayPoint(dispPt);
    dispPt[0] = dispPt[0] + 1;
    dispPt[1] = dispPt[1] + 1;
    viewport->SetDisplayPoint(dispPt);
    viewport->DisplayToWorld();
    double p2[4];
    viewport->GetWorldPoint(p2);
    if (p2[3] != 0.0)
    {
        p2[0] /= p2[3];
        p2[1] /= p2[3];
        p2[2] /= p2[3];
    }

Now it looks as expected - the leader glyph stays roughly the same when resized:

Also regarding the “arbitrary” factor of 1.5 factor - I think a “more correct” value there would be the square root of 2 as the diagonal length of a unit cube?

Another minor nitpick: I find the name LeaderGlyphSize confusing - since, as specified in the doc, it is not a size, but a factor to the size of the glyph itself.

Anybody working with vtk’s text annotations who could chime in?

The behavior I describe is actually visible in the vtkCaptionWidget example as well - zoom in there, and you will see the leader glyph (the arrow) get so small that it basically disappears (since vtkCaptionWidget internally uses vtkCaptionActor2D, vtkCaptionWidget is directly affected by this behavior).

I have prepared a pull request with the changes proposed above, to fix the leader glyph size computation.