Mercurial > hg > octave-nkf
diff libinterp/corefcn/gl2ps-renderer.cc @ 19836:61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
* gl2ps-renderer.h, gl2ps-renderer.cc (gl2ps_print): New function.
* __init_fltk__.cc (OpenGL_fltk::print): Use it.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Jan 2015 17:07:09 -0500 |
parents | 0e1f5a750d00 |
children | 16f21db320b5 |
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-renderer.cc +++ b/libinterp/corefcn/gl2ps-renderer.cc @@ -30,9 +30,11 @@ #include "lo-mappers.h" #include "oct-locbuf.h" +#include "unwind-prot.h" #include "gl2ps-renderer.h" #include "gl2ps.h" +#include "sysdep.h" void glps_renderer::draw (const graphics_object& go, const std::string print_cmd) @@ -266,4 +268,34 @@ alignment_to_mode (halign, valign), props.get_rotation ()); } +static void +safe_pclose (FILE *f) +{ + if (f) + octave_pclose (f); +} + #endif + +void +gl2ps_print (const graphics_object& fig, const std::string& cmd, + const std::string& term) +{ +#ifdef HAVE_GL2PS_H + + unwind_protect frame; + + FILE *fp = octave_popen (cmd.c_str (), "w"); + + frame.add_fcn (safe_pclose, fp); + + glps_renderer rend (fp, term); + + rend.draw (fig, cmd); + +#else + + error ("print: printing not available without gl2ps library"); + +#endif +}