# HG changeset patch # User Konstantinos Poulios # Date 1297792153 -3600 # Node ID 2f0d1e12806d581b4a24e0707513cb74ff253426 # Parent f2c080bbd8a5f7040a61d3c3a6b4e71aab3761c8 invoke/terminate printing process synchronously with rendering (#32319) diff -r f2c080bbd8a5 -r 2f0d1e12806d scripts/ChangeLog --- a/scripts/ChangeLog Mon Feb 14 17:23:04 2011 -0800 +++ b/scripts/ChangeLog Tue Feb 15 18:49:13 2011 +0100 @@ -1,3 +1,8 @@ +2011-02-15 Konstantinos Poulios + + * plot/__fltk_print__.m: Forward pipeline to drawnow instead of + invoking a process here. + 2010-02-14 Rik * plot/semilogxerr.m, plot/semilogyerr.m, special-matrix/pascal.m, diff -r f2c080bbd8a5 -r 2f0d1e12806d scripts/plot/__fltk_print__.m --- a/scripts/plot/__fltk_print__.m Mon Feb 14 17:23:04 2011 -0800 +++ b/scripts/plot/__fltk_print__.m Tue Feb 15 18:49:13 2011 +0100 @@ -150,16 +150,7 @@ if (opts.debug) fprintf ("fltk-pipeline: '%s'\n", pipeline{n}); endif - pid = popen (pipeline{n}, "w"); - if (pid < 0) - error ("print:popenfailed", "print.m: failed to open pipe"); - endif - unwind_protect - drawnow (gl2ps_device{n} , sprintf ("%d" , pid)); - waitpid (pid); - unwind_protect_cleanup - pclose (pid); - end_unwind_protect + drawnow (gl2ps_device{n}, strcat('|',pipeline{n})); endfor if (! isempty (strfind (opts.devopt, "standalone"))) diff -r f2c080bbd8a5 -r 2f0d1e12806d src/ChangeLog --- a/src/ChangeLog Mon Feb 14 17:23:04 2011 -0800 +++ b/src/ChangeLog Tue Feb 15 18:49:13 2011 +0100 @@ -1,3 +1,18 @@ +2011-02-15 Konstantinos Poulios + + * __init_fltk__.cc: Include sysdep.h. + (class OpenGL_fltk): Replace integer print_fid member with + boolean print_mode. New class member print_cmd of type string. + (OpenGL_fltk::print): Accept command string argument instead of + file id. + (OpenGL_fltk::draw): Invoke and terminate an octave process for + the printing job. + (plot_window::print, figure_manager::print, + figure_manager::do_print): Replace file id with command string. + (fltk_graphics_toolkit::print_figure): Remove parsing of file id. + * graphics.cc (drawnow): Recognize strings beginning with "|" as + pipelines instead of filenames. + 2011-02-14 David Bateman * gl-render.cc (void opengl_renderer::draw_patch ( diff -r f2c080bbd8a5 -r 2f0d1e12806d src/DLD-FUNCTIONS/__init_fltk__.cc --- a/src/DLD-FUNCTIONS/__init_fltk__.cc Mon Feb 14 17:23:04 2011 -0800 +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc Tue Feb 15 18:49:13 2011 +0100 @@ -70,6 +70,7 @@ #include "gl2ps-renderer.h" #include "graphics.h" #include "parse.h" +#include "sysdep.h" #include "toplev.h" #include "variables.h" @@ -97,7 +98,7 @@ public: OpenGL_fltk (int xx, int yy, int ww, int hh, double num) : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), renderer (), - in_zoom (false), zoom_box (), print_fid (-1) + in_zoom (false), zoom_box (), print_mode (false) { // Ask for double buffering and a depth buffer. mode (FL_DEPTH | FL_DOUBLE); @@ -115,9 +116,10 @@ bool zoom (void) { return in_zoom; } void set_zoom_box (const Matrix& zb) { zoom_box = zb; } - void print (const int fid, const std::string& term) + void print (const std::string& cmd, const std::string& term) { - print_fid = fid; + print_mode = true; + print_cmd = cmd; print_term = term; } @@ -135,7 +137,8 @@ // (x1,y1,x2,y2) Matrix zoom_box; - int print_fid; + bool print_mode; + std::string print_cmd; std::string print_term; void setup_viewport (int ww, int hh) @@ -153,13 +156,15 @@ setup_viewport (w (), h ()); } - if (print_fid > 0) + if (print_mode) { - glps_renderer rend (print_fid, print_term); + FILE *fp = octave_popen (print_cmd.c_str (), "w"); + glps_renderer rend (fileno (fp), print_term); rend.draw (gh_manager::get_object (number)); - print_fid = -1; + octave_pclose (fp); + print_mode = false; } else { @@ -759,9 +764,9 @@ // FIXME -- this could change. double number (void) { return fp.get___myhandle__ ().value (); } - void print (const int fid, const std::string& term) + void print (const std::string& cmd, const std::string& term) { - canvas->print (fid, term); + canvas->print (cmd, term); // Print immediately so the output file will exist when the drawnow // command is done. @@ -1495,10 +1500,10 @@ return get_size (hnd2idx (gh)); } - static void print (const graphics_handle& gh , const int fid, const std::string& term) + static void print (const graphics_handle& gh , const std::string& cmd, const std::string& term) { if (instance_ok ()) - instance->do_print (hnd2idx(gh), fid, term); + instance->do_print (hnd2idx(gh), cmd, term); } static void uimenu_update (const graphics_handle& figh, const graphics_handle& uimenuh, const int id) @@ -1634,12 +1639,12 @@ return sz; } - void do_print (int idx, const int fid, const std::string& term) + void do_print (int idx, const std::string& cmd, const std::string& term) { wm_iterator win; if ((win = windows.find (idx)) != windows.end ()) { - win->second->print (fid, term); + win->second->print (cmd, term); } } @@ -1858,18 +1863,11 @@ void print_figure (const graphics_object& go, const std::string& term, - const std::string& file, bool /*mono*/, + const std::string& file_cmd, bool /*mono*/, const std::string& /*debug_file*/) const { - int fid; - std::istringstream istr (file); - if (istr >> fid) - { - figure_manager::print (go.get_handle (), fid, term); - redraw_figure (go); - } - else - error ("fltk_graphics_toolkit: filename should be fid"); + figure_manager::print (go.get_handle (), file_cmd, term); + redraw_figure (go); } Matrix get_canvas_size (const graphics_handle& fh) const diff -r f2c080bbd8a5 -r 2f0d1e12806d src/graphics.cc --- a/src/graphics.cc Mon Feb 14 17:23:04 2011 -0800 +++ b/src/graphics.cc Tue Feb 15 18:49:13 2011 +0100 @@ -7620,20 +7620,26 @@ if (! error_state) { - size_t pos = file.find_last_of (file_ops::dir_sep_chars ()); - - if (pos != std::string::npos) + size_t pos = file.find_first_not_of ("|"); + if (pos > 0) + file = file.substr (pos); + else { - std::string dirname = file.substr (0, pos+1); - - file_stat fs (dirname); - - if (! (fs && fs.is_dir ())) + pos = file.find_last_of (file_ops::dir_sep_chars ()); + + if (pos != std::string::npos) { - error ("drawnow: nonexistent directory `%s'", - dirname.c_str ()); - - return retval; + std::string dirname = file.substr (0, pos+1); + + file_stat fs (dirname); + + if (! (fs && fs.is_dir ())) + { + error ("drawnow: nonexistent directory `%s'", + dirname.c_str ()); + + return retval; + } } }