Mercurial > hg > octave-nkf
changeset 12449:2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
author | Konstantinos Poulios <logari81@gmail.com> |
---|---|
date | Tue, 15 Feb 2011 18:49:13 +0100 |
parents | f2c080bbd8a5 |
children | 47612d3e7077 |
files | scripts/ChangeLog scripts/plot/__fltk_print__.m src/ChangeLog src/DLD-FUNCTIONS/__init_fltk__.cc src/graphics.cc |
diffstat | 5 files changed, 60 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2011-02-15 Konstantinos Poulios <logari81@gmail.com> + + * plot/__fltk_print__.m: Forward pipeline to drawnow instead of + invoking a process here. + 2010-02-14 Rik <octave@nomad.inbox5.com> * plot/semilogxerr.m, plot/semilogyerr.m, special-matrix/pascal.m,
--- a/scripts/plot/__fltk_print__.m +++ b/scripts/plot/__fltk_print__.m @@ -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")))
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2011-02-15 Konstantinos Poulios <logari81@googlemail.com> + + * __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 <dbateman@free.fr> * gl-render.cc (void opengl_renderer::draw_patch (
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc @@ -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
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -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; + } } }