High-DPI scaling issues

Hi there,

I am trialling out a new 4k display. Moving over from 1920x1080 to 3840x2040 of course results in tiny fonts etc, so I am using my system’s desktop scaling mechanism to so that everything is scaled by a factor of 2.

Most of the things in VTK I am working with work quite well with this, but I have some small issues where objects don’t apply the scaling correctly. The ones which I have identified so far are:

  • vtkCubeAxesActor uses incorrect font scaling
  • vtkAxis creates the wrong number of ticks/labels
  • vtkPlotLine uses wrong marker sizes and line widths

I’ll try to attach two screenshots below showing the effects of vtkAxis and vtkPlotLine.

I’m happy to have a go at fixing these issues, but need some pointers. How does VTK detect scaling factors, and are there some examples on how they are applied to classes?

Normal HD, no scaling:

High DPI, with system-wide scaling set:

So is there a way that I can determine the display scaling factor from within a Paint() method?

There’s no method to get the display scaling factor, but you can get the DPI:

int dpi = renderWindow->GetDPI();

The DPI is generally equal to 72 times the display scaling factor.