Mercurial > hg > octave-nkf
diff src/DLD-FUNCTIONS/fltk_backend.cc @ 9798:2d6a5af744b6
printing for fltk backend using gl2ps
author | Shai Ayal <shaiay@users.sourceforge.net> |
---|---|
date | Tue, 10 Nov 2009 19:48:02 -0500 |
parents | 09da0bd91412 |
children | 9b4a301d88ed |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/fltk_backend.cc +++ b/src/DLD-FUNCTIONS/fltk_backend.cc @@ -60,6 +60,7 @@ #include "defun-dld.h" #include "error.h" #include "gl-render.h" +#include "gl2ps-renderer.h" #include "graphics.h" #include "parse.h" #include "variables.h" @@ -83,7 +84,8 @@ { public: OpenGL_fltk (int xx, int yy, int ww, int hh, double num) - : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), in_zoom (false) + : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), in_zoom (false), + print_filename ("") { // ask for double buffering and a depth buffer mode (FL_DEPTH | FL_DOUBLE); @@ -92,18 +94,29 @@ ~OpenGL_fltk (void) { } void zoom (bool z) - {in_zoom = z; if (!in_zoom) hide_overlay ();} + { + in_zoom = z; + if (! in_zoom) + hide_overlay (); + } + bool zoom (void) { return in_zoom; } void set_zoom_box (const Matrix& zb) { zoom_box = zb; } + + void print (const std::string& filename) + { + print_filename = filename; + } private: double number; opengl_renderer renderer; bool in_zoom; - // (x1,y1,x2,y2) Matrix zoom_box; + std::string print_filename; + void setup_viewport (int _w, int _h) { glMatrixMode (GL_PROJECTION); @@ -113,16 +126,26 @@ void draw (void) { - if (!valid ()) + if (! valid ()) { valid (1); setup_viewport (w (), h ()); } - renderer.draw (gh_manager::lookup (number)); + if (! print_filename.empty ()) + { + opengl_renderer *rend = new glps_renderer (print_filename); + rend->draw (gh_manager::lookup (number)); + print_filename = ""; + delete rend; + } + else + { + renderer.draw (gh_manager::lookup (number)); + } } - void resize (int _x,int _y,int _w,int _h) + void resize (int _x, int _y, int _w, int _h) { Fl_Gl_Window::resize (_x, _y, _w, _h); setup_viewport (_w, _h); @@ -131,12 +154,12 @@ void draw_overlay (void) { - if (!in_zoom) + if (! in_zoom) return; - if (!valid()) + if (! valid ()) { - valid(1); + valid (1); setup_viewport (w (), h ()); } @@ -269,6 +292,11 @@ // FIXME -- this could change double number (void) { return fp.get___myhandle__ ().value (); } + void print (const std::string& fname) + { + canvas->print (fname); + } + void mark_modified (void) { damage (FL_DAMAGE_ALL); @@ -654,6 +682,12 @@ return get_size (hnd2idx (gh)); } + static void print (const graphics_handle& gh , const std::string& filename) + { + if (instance_ok ()) + instance->do_print (hnd2idx(gh), filename); + } + private: static figure_manager *instance; @@ -727,6 +761,15 @@ return sz; } + void do_print (int idx, const std::string& filename) + { + wm_iterator win; + if ((win = windows.find (idx)) != windows.end ()) + { + win->second->print (filename); + } + } + // FIXME -- default size should be configurable. void default_size (int& x, int& y, int& w, int& h) { @@ -873,10 +916,13 @@ __fltk_redraw__ (); } - void print_figure (const graphics_object& /*go*/, - const std::string& /*term*/, - const std::string& /*file*/, bool /*mono*/, - const std::string& /*debug_file*/) const { } + void print_figure (const graphics_object& go, + const std::string& term, + const std::string& file, bool mono, + const std::string& debug_file) const + { + figure_manager::print (go.get_handle (), file); + } Matrix get_canvas_size (const graphics_handle& fh) const {