# HG changeset patch # User Shai Ayal # Date 1284031778 -10800 # Node ID 2786e3b7072eacb0aff918722f9880c47b9b2cfb # Parent ee9d74048827c969ab21000b1bbe261305d8ba28 gl2ps print to fid instead of filename diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-09-09 Shai Ayal + + * gl2ps-renderer.cc: Renders to a previously opened fid. + * gl2ps-renderer.h: Ditto. + * DLD-FUNCTIONS/fltk_backend.cc: print now accepts fid instead + of filename to use with above change + 2010-09-07 Jaroslav Hajek * DLD-FUNCTIONS/__magick_read__.cc (maybe_initialize_magick): New diff --git a/src/DLD-FUNCTIONS/fltk_backend.cc b/src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc +++ b/src/DLD-FUNCTIONS/fltk_backend.cc @@ -87,7 +87,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_filename () + in_zoom (false), zoom_box (), print_fid (-1) { // Ask for double buffering and a depth buffer. mode (FL_DEPTH | FL_DOUBLE); @@ -105,9 +105,9 @@ bool zoom (void) { return in_zoom; } void set_zoom_box (const Matrix& zb) { zoom_box = zb; } - void print (const std::string& filename, const std::string& term) + void print (const int fid, const std::string& term) { - print_filename = filename; + print_fid = fid; print_term = term; } @@ -118,7 +118,7 @@ // (x1,y1,x2,y2) Matrix zoom_box; - std::string print_filename; + int print_fid; std::string print_term; void setup_viewport (int ww, int hh) @@ -136,11 +136,11 @@ setup_viewport (w (), h ()); } - if (! print_filename.empty ()) + if ( print_fid > 0 ) { - opengl_renderer *rend = new glps_renderer (print_filename, print_term); + opengl_renderer *rend = new glps_renderer (print_fid, print_term); rend->draw (gh_manager::lookup (number)); - print_filename = ""; + print_fid = -1; delete rend; } else @@ -338,9 +338,9 @@ // FIXME -- this could change. double number (void) { return fp.get___myhandle__ ().value (); } - void print (const std::string& fname, const std::string& term) + void print (const int fid, const std::string& term) { - canvas->print (fname, term); + canvas->print (fid, term); // Print immediately so the output file will exist when the drawnow // command is done. @@ -958,10 +958,10 @@ return get_size (hnd2idx (gh)); } - static void print (const graphics_handle& gh , const std::string& filename, const std::string& term) + static void print (const graphics_handle& gh , const int fid, const std::string& term) { if (instance_ok ()) - instance->do_print (hnd2idx(gh), filename, term); + instance->do_print (hnd2idx(gh), fid, term); } private: @@ -1060,12 +1060,12 @@ return sz; } - void do_print (int idx, const std::string& filename, const std::string& term) + void do_print (int idx, const int fid, const std::string& term) { wm_iterator win; if ((win = windows.find (idx)) != windows.end ()) { - win->second->print (filename, term); + win->second->print (fid, term); } } @@ -1228,8 +1228,15 @@ const std::string& file, bool /*mono*/, const std::string& /*debug_file*/) const { - figure_manager::print (go.get_handle (), file, term); - redraw_figure (go); + int fid; + std::istringstream istr (file); + if (istr >> fid) + { + figure_manager::print (go.get_handle (), fid, term); + redraw_figure (go); + } + else + error ("fltk_backend: filename should be fid"); } Matrix get_canvas_size (const graphics_handle& fh) const diff --git a/src/gl2ps-renderer.cc b/src/gl2ps-renderer.cc --- a/src/gl2ps-renderer.cc +++ b/src/gl2ps-renderer.cc @@ -43,7 +43,7 @@ { in_draw = true; - FILE *fp = fopen (filename.c_str (), "wb"); + FILE *fp = fdopen (fid, "wb"); GLint buffsize = 0, state = GL2PS_OVERFLOW; GLint viewport[4]; @@ -74,7 +74,7 @@ | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT | gl2ps_text), GL_RGBA, 0, NULL, 0, 0, 0, - buffsize, fp, filename.c_str () ); + buffsize, fp, "" ); opengl_renderer::draw (go); state = gl2psEndPage (); diff --git a/src/gl2ps-renderer.h b/src/gl2ps-renderer.h --- a/src/gl2ps-renderer.h +++ b/src/gl2ps-renderer.h @@ -31,8 +31,8 @@ glps_renderer : public opengl_renderer { public: - glps_renderer (const std::string& _filename, const std::string& _term) - : opengl_renderer () , filename (_filename), term (_term) { } + glps_renderer (const int _fid, const std::string& _term) + : opengl_renderer () , fid (_fid), term (_term) { } ~glps_renderer (void) { } @@ -74,7 +74,7 @@ } private: - std::string filename; + int fid; caseless_str term; double fontsize; std::string fontname;