Wrong label positions with vtkLabelPlacementMapper

Hello!

I am using VTK 9.1.0 and Qt 5.15.3 and encountered the following problem with vtkLabelPlacementMapper:

Without setting a render strategy the labels are corrected:

vtkLabelPlacementMapper added to vtkRenderer with viewport [0 0 1 1]:

vtkLabelPlacementMapper added to vtkRenderer with viewport [0.3 0 1 1]:

After setting an instance of “vtkQtLabelRenderStrategy” to vtkLabelPlacementMapper by
using the “SetRenderStrategy(…)” method, the result is as follows:

vtkLabelPlacementMapper added to vtkRenderer with viewport [0 0 1 1]:

vtkLabelPlacementMapper added to vtkRenderer with viewport [0.3 0 1 1]:

Unfortunately, the label positions are wrong if the viewport is different.

Any idea why this happens? I think there should be no difference.

Initially, GetRenderStrategy()->GetClassName() returns “vtkFreeTypeLabelRenderStrategy”, so
there might be a bug in vtkQtLabelRenderStrategy?

Thank you!

Adding the following code to vtkQtLabelRenderStrategy “RenderLabel(…)” fixes the issue:

void QtLabelRenderStrategy::RenderLabel(int x[2], vtkTextProperty* tprop, vtkUnicodeString label)
{
    double* vp = this->Renderer->GetViewport();
    int* rw_size = this->Renderer->GetRenderWindow()->GetSize();

    x[0] = x[0] - (1 - (vp[2] - vp[0])) * rw_size[0];

Is the actual implementation of vtkQtLabelRenderStrategy flawed or am I missing something?