changeset 26720:9a678e0de658

Measure LineWidth in points, not pixels, for Matlab compatibility (bug #53056). * gl-render.cc (opengl_renderer::set_linewidth): New const static variable pts2pix which is screen pixels_per_inch / 72 points_per_inch. Multiply input LineWidth by conversion factor pts2pix to translate linewidth to pixels for glLineWidth call. * gl-render.cc (opengl_renderer::set_linestyle): New const static variable pts2pix which is screen pixels_per_inch / 72 points_per_inch. Multiply input LineWidth by conversion factor pts2pix to translate linewidth to pixels. * gl-render.cc (opengl_renderer::make_marker_list): New const static variable pts2pix which is screen pixels_per_inch / 72 points_per_inch. Multiply input LineWidth by conversion factor pts2pix to translate linewidth to pixels. Remove old conversion factor based on toolkit.get_screen_resolution() which is incorrect.
author Rik <rik@octave.org>
date Mon, 11 Feb 2019 14:22:54 -0800
parents 91b152968ec1
children 72b9040ab196
files libinterp/corefcn/gl-render.cc
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Mon Feb 11 20:56:27 2019 +0000
+++ b/libinterp/corefcn/gl-render.cc	Mon Feb 11 14:22:54 2019 -0800
@@ -4273,8 +4273,15 @@
   opengl_renderer::set_linewidth (float w)
   {
 #if defined (HAVE_OPENGL)
-
-    m_glfcns.glLineWidth (w * m_devpixratio);
+    // FIXME: See bug #53056 (measure LineWidth in points).
+    //        pts2pix and m_devpixratio should eventually be combined in to a
+    //        a single conversion factor so that only one multiplication per
+    //        function call is required.
+    const static double pts2pix =
+      gh_manager::get_object (0).get ("screenpixelsperinch").double_value ()
+      / 72.0;
+
+    m_glfcns.glLineWidth (w * pts2pix * m_devpixratio);
 
 #else
 
@@ -4294,7 +4301,11 @@
   {
 #if defined (HAVE_OPENGL)
 
-    int factor = math::round (linewidth * m_devpixratio);
+    // FIXME: See bug #53056 (measure LineWidth in points).
+    const static double pts2pix =
+      gh_manager::get_object (0).get ("screenpixelsperinch").double_value ()
+      / 72.0;
+    int factor = math::round (linewidth * pts2pix * m_devpixratio);
     if (factor < 1)
       factor = 1;
 
@@ -4633,7 +4644,13 @@
       return 0;
 
     unsigned int ID = m_glfcns.glGenLists (1);
-    double sz = size * toolkit.get_screen_resolution () / 72.0;
+
+    // FIXME: See bug #53056 (measure LineWidth in points).
+    const static double pts2pix =
+      gh_manager::get_object (0).get ("screenpixelsperinch").double_value ()
+      / 72.0;
+
+    double sz = size * pts2pix;
 
     // constants for the * marker
     const double sqrt2d4 = 0.35355339059327;