comparison libinterp/corefcn/gl2ps-renderer.cc @ 18958:c9f960441513

Overhaul FLTK plotting and printing * gl2ps-renderer.cc: Force execution of GL commands before gl2psEndPage to avoid missing primitives in output. Enable error output of gl2ps, check return value of gl2psBeginPage for error. * __init_fltk__.cc: Avoid redraw of the OpenGL and the plot window if not needed. Let FLTK do the resizing of the canvas, the menubar and the statusbar. This was done by creating a resize_dummy and set this as resizable for the plot_window group. Previously this was done inside draw(). Avoid timing issues with fltk_maxtime (removed) and other hacks with multiple Fl::check and redraw () calls. You can use flush and glFlush if you really need to force a immediate redraw. Remove print_mode in draw () and print directly without waiting that FLTK flushes its buffers. This fixes bug #42458 and #40215 Manually placement of the toolbar is only done once when hiding or showing the menubar. (update_toolbar_position) set(gcf, "position", [x, y, w, h]) is now handled by figure::properties::ID_POSITION which calls update_position * __add_default_menu__.m: Remove now unneeded hacks for the menubar.
author Andreas Weber <andy.weber.aw@gmail.com>
date Sat, 26 Jul 2014 10:09:48 +0200
parents 333901476119
children 1288a2f27769
comparison
equal deleted inserted replaced
18955:914c3ce73665 18958:c9f960441513
57 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG; 57 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG;
58 else if (term.find ("pgf") != std::string::npos) gl2ps_term = GL2PS_PGF; 58 else if (term.find ("pgf") != std::string::npos) gl2ps_term = GL2PS_PGF;
59 else if (term.find ("tex") != std::string::npos) gl2ps_term = GL2PS_TEX; 59 else if (term.find ("tex") != std::string::npos) gl2ps_term = GL2PS_TEX;
60 else 60 else
61 { 61 {
62 error ("gl2ps-renderer:: Unknown terminal"); 62 error ("gl2ps-renderer::draw: Unknown terminal %s", term.c_str ());
63 return; 63 return;
64 } 64 }
65 65
66 GLint gl2ps_text = 0; 66 GLint gl2ps_text = 0;
67 if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT; 67 if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT;
93 n_end - n_begin + 1); 93 n_end - n_begin + 1);
94 } 94 }
95 else 95 else
96 include_graph = "foobar-inc"; 96 include_graph = "foobar-inc";
97 buffsize += 1024*1024; 97 buffsize += 1024*1024;
98 gl2psBeginPage ("glps_renderer figure", "Octave", viewport, 98 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr
99 gl2ps_term, gl2ps_sort, 99 GLint ret = gl2psBeginPage ("glps_renderer figure", "Octave", viewport,
100 (GL2PS_SILENT 100 gl2ps_term, gl2ps_sort,
101 | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL 101 ( GL2PS_NO_BLENDING
102 | GL2PS_BEST_ROOT | gl2ps_text 102 | GL2PS_OCCLUSION_CULL
103 | GL2PS_NO_PS3_SHADING), 103 | GL2PS_BEST_ROOT
104 GL_RGBA, 0, NULL, 0, 0, 0, 104 | gl2ps_text
105 buffsize, fp, include_graph.c_str ()); 105 | GL2PS_NO_PS3_SHADING),
106 GL_RGBA, 0, NULL, 0, 0, 0,
107 buffsize, fp, include_graph.c_str ());
108 if (ret == GL2PS_ERROR)
109 error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
106 old_print_cmd = print_cmd; 110 old_print_cmd = print_cmd;
107 opengl_renderer::draw (go); 111 opengl_renderer::draw (go);
112
113 // Force execution of GL commands in finite time.
114 // Without glFlush () there may primitives be missing in the gl2ps output.
115 glFlush ();
116
108 state = gl2psEndPage (); 117 state = gl2psEndPage ();
109 } 118 }
110 119
111 in_draw = 0; 120 in_draw = 0;
112 } 121 }
198 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h); 207 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
199 208
200 // Convert to GL_FLOAT as it is the only type gl2ps accepts. 209 // Convert to GL_FLOAT as it is the only type gl2ps accepts.
201 for (int i = 0; i < 3*w*h; i++) 210 for (int i = 0; i < 3*w*h; i++)
202 a[i] = data[i] / maxval; 211 a[i] = data[i] / maxval;
203 212
204 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a); 213 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a);
205 } 214 }
206 215
207 void 216 void
208 glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format, 217 glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format,