Mercurial > hg > octave-nkf
changeset 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 | 3da4b083e0b8 |
children | 3b0b4d55002d |
files | libinterp/corefcn/gl2ps-renderer.cc libinterp/corefcn/gl2ps-renderer.h libinterp/dldfcn/__init_fltk__.cc |
diffstat | 3 files changed, 38 insertions(+), 11 deletions(-) [+] |
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 +}
--- a/libinterp/corefcn/gl2ps-renderer.h +++ b/libinterp/corefcn/gl2ps-renderer.h @@ -86,4 +86,8 @@ #endif // HAVE_GL2PS_H +extern OCTINTERP_API void +gl2ps_print (const graphics_object& fig, const std::string& cmd, + const std::string& term); + #endif
--- a/libinterp/dldfcn/__init_fltk__.cc +++ b/libinterp/dldfcn/__init_fltk__.cc @@ -83,11 +83,9 @@ #include "display.h" #include "file-ops.h" -#include "gl-render.h" #include "gl2ps-renderer.h" #include "graphics.h" #include "parse.h" -#include "sysdep.h" #include "toplev.h" #include "variables.h" @@ -133,15 +131,8 @@ void print (const std::string& cmd, const std::string& term) { //std::cout << "OpenGL_fltk::print(cmd=" << cmd << ", term=" << term << ") canvas size = " << w () << "x" << h () << std::endl; -#ifdef HAVE_GL2PS_H - FILE *fp; - fp = octave_popen (cmd.c_str (), "w"); - glps_renderer rend (fp, term); - rend.draw (gh_manager::get_object (number), cmd); - octave_pclose (fp); -#else - error ("fltk: printing not available without gl2ps library"); -#endif + + gl2ps_print (gh_manager::get_object (number), cmd, term); } void resize (int xx, int yy, int ww, int hh)