changeset 28190:500937ff19d9

maint: merge stable to default.
author Rik <rik@octave.org>
date Mon, 06 Apr 2020 17:31:37 -0700
parents ad33d23d264f (current diff) 5624fd0c5efb (diff)
children 450fe5371acd
files
diffstat 4 files changed, 35 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Sun Apr 05 14:56:29 2020 -0700
+++ b/libinterp/corefcn/gl-render.cc	Mon Apr 06 17:31:37 2020 -0700
@@ -687,10 +687,10 @@
 
   opengl_renderer::opengl_renderer (opengl_functions& glfcns)
     : m_glfcns (glfcns), xmin (), xmax (), ymin (), ymax (), zmin (), zmax (),
-      m_devpixratio (1.), xform (), toolkit (), xZ1 (), xZ2 (), marker_id (),
+      m_devpixratio (1.0), xform (), toolkit (), xZ1 (), xZ2 (), marker_id (),
       filled_marker_id (), camera_pos (), camera_dir (), view_vector (),
       interpreter ("none"), txt_renderer (), m_current_light (0),
-      m_max_lights (0), selecting (false)
+      m_max_lights (0), selecting (false), m_printing (false)
   {
     // This constructor will fail if we don't have OpenGL or if the data
     // types we assumed in our public interface aren't compatible with the
@@ -776,6 +776,8 @@
   void
   opengl_renderer::draw_figure (const figure::properties& props)
   {
+    m_printing = props.is___printing__ ();
+
     // Initialize OpenGL context
     init_gl_context (props.is_graphicssmoothing (), props.get_color_rgb ());
 
@@ -4088,19 +4090,8 @@
   opengl_renderer::set_linewidth (float w)
   {
 #if defined (HAVE_OPENGL)
-    gh_manager& gh_mgr = __get_gh_manager__ ("opengl_renderer::set_linewidth");
-
-    // 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.
-    // FIXME: Should this be static?  What happens if window is moved to a second
-    //        monitor with a different screenpixelsperinch?
-    const static double pts2pix
-      = (gh_mgr.get_object (0).get ("screenpixelsperinch").double_value ()
-         / 72.0);
-
-    m_glfcns.glLineWidth (w * pts2pix * m_devpixratio);
+    // Measure LineWidth in points.  See bug #53056.
+    m_glfcns.glLineWidth (points_to_pixels (w) * m_devpixratio);
 
 #else
 
@@ -4119,13 +4110,8 @@
                                   double linewidth)
   {
 #if defined (HAVE_OPENGL)
-    gh_manager& gh_mgr = __get_gh_manager__ ("opengl_renderer::set_linestyle");
-
-    // FIXME: See bug #53056 (measure LineWidth in points).
-    const static double pts2pix
-      = (gh_mgr.get_object (0).get ("screenpixelsperinch").double_value ()
-         / 72.0);
-    int factor = math::round (linewidth * pts2pix * m_devpixratio);
+    // Measure LineWidth in points.  See bug #53056.
+    int factor = math::round (points_to_pixels (linewidth) * m_devpixratio);
     if (factor < 1)
       factor = 1;
 
@@ -4453,6 +4439,24 @@
 #endif
   }
 
+  double
+  opengl_renderer::points_to_pixels (const double val) const
+  {
+    gh_manager& gh_mgr = __get_gh_manager__ ("opengl_renderer::points_to_pixels");
+
+    // FIXME: Does making this static cause problems if figure is moved to a
+    //        2nd monitor with a different value for "screenpixelsperinch"?
+    static const double pix_per_pts =
+      gh_mgr.get_object (0).get ("screenpixelsperinch").double_value () / 72.0;
+
+    double retval = val;
+
+    if (! m_printing)
+      retval *= pix_per_pts;
+
+    return retval;
+  }
+
   unsigned int
   opengl_renderer::make_marker_list (const std::string& marker, double size,
                                      bool filled) const
@@ -4464,19 +4468,10 @@
     if (filled && (c == '+' || c == 'x' || c == '*' || c == '.'))
       return 0;
 
-    gh_manager& gh_mgr
-      = __get_gh_manager__ ("opengl_renderer::make_marker_list");
-
     unsigned int ID = m_glfcns.glGenLists (1);
 
     // FIXME: See bug #53056 (measure LineWidth in points).
-    // FIXME: Should this be static?  What happens if window is moved to a second
-    //        monitor with a different screenpixelsperinch?
-    const static double pts2pix
-      = (gh_mgr.get_object (0).get ("screenpixelsperinch").double_value ()
-         / 72.0);
-
-    double sz = size * pts2pix;
+    double sz = points_to_pixels (size);
 
     // constants for the * marker
     const double sqrt2d4 = 0.35355339059327;
--- a/libinterp/corefcn/gl-render.h	Sun Apr 05 14:56:29 2020 -0700
+++ b/libinterp/corefcn/gl-render.h	Mon Apr 06 17:31:37 2020 -0700
@@ -183,6 +183,8 @@
 
     void set_normal (int bfl_mode, const NDArray& n, int j, int i);
 
+    double points_to_pixels (const double val) const;
+
     unsigned int make_marker_list (const std::string& m, double size,
                                    bool filled) const;
 
@@ -240,6 +242,9 @@
     // Indicate we are drawing for selection purpose
     bool selecting;
 
+    // Indicate we are drawing for printing purpose
+    bool m_printing;
+
   private:
     class patch_tessellator;
   };
--- a/libinterp/corefcn/gl2ps-print.cc	Sun Apr 05 14:56:29 2020 -0700
+++ b/libinterp/corefcn/gl2ps-print.cc	Mon Apr 06 17:31:37 2020 -0700
@@ -189,15 +189,7 @@
 
     void init_marker (const std::string& m, double size, float width)
     {
-      // FIXME: Undo scaling that will take place in opengl_renderer::make_marker_list
-      gh_manager& gh_mgr
-        = __get_gh_manager__ ("gl2ps_renderer::init_marker");
-      // FIXME: Should this be static?  What happens if window is moved to a second
-      //        monitor with a different screenpixelsperinch?
-      const static double rescale
-        = 72.0 / gh_mgr.get_object (0).get ("screenpixelsperinch").double_value ();
-
-      opengl_renderer::init_marker (m, size * rescale, width);
+      opengl_renderer::init_marker (m, size, width);
 
       // FIXME: gl2ps can't handle closed contours so we set linecap/linejoin
       //        round to obtain a better looking result for some markers.
--- a/scripts/plot/util/print.m	Sun Apr 05 14:56:29 2020 -0700
+++ b/scripts/plot/util/print.m	Mon Apr 06 17:31:37 2020 -0700
@@ -777,7 +777,8 @@
     endif
 
     ## Avoid a redraw since the figure should not have changed
-    set (gcf, "__modified__", "off");
+    ## FIXME: Bug #57552, marker sizes, requires that redraw be done.
+    ##set (gcf, "__modified__", "off");
 
     ## Unlink temporary files
     for n = 1:numel (opts.unlink)