gl2ps-renderer.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2009-2012 Shai Ayal
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (gl2ps_renderer_h)
00024 #define gl2ps_renderer_h 1
00025 
00026 #include "gl-render.h"
00027 #include "gl2ps.h"
00028 
00029 class
00030 OCTINTERP_API
00031 glps_renderer : public opengl_renderer
00032 {
00033 public:
00034   glps_renderer (const int _fid, const std::string& _term)
00035     : opengl_renderer () , fid (_fid), term (_term),
00036     fontsize (), fontname () { }
00037 
00038   ~glps_renderer (void) { }
00039 
00040   void draw (const graphics_object& go);
00041 
00042 protected:
00043 
00044   Matrix render_text (const std::string& txt,
00045                       double x, double y, double z,
00046                       int halign, int valign, double rotation = 0.0);
00047 
00048 
00049   void set_font (const base_properties& props);
00050 
00051   void draw_text (const text::properties& props);
00052   void draw_pixels (GLsizei w, GLsizei h, GLenum format,
00053                     GLenum type, const GLvoid *data);
00054 
00055   void set_linestyle (const std::string& s, bool use_stipple)
00056   {
00057     opengl_renderer::set_linestyle (s, use_stipple);
00058     if (use_stipple)
00059       gl2psEnable (GL2PS_LINE_STIPPLE);
00060     else
00061       gl2psDisable (GL2PS_LINE_STIPPLE);
00062   }
00063 
00064   void set_polygon_offset (bool on, double offset = 0.0)
00065   {
00066     opengl_renderer::set_polygon_offset (on, offset);
00067     if (on)
00068       gl2psEnable (GL2PS_POLYGON_OFFSET_FILL);
00069     else
00070       gl2psDisable (GL2PS_POLYGON_OFFSET_FILL);
00071   }
00072 
00073   void set_linewidth (float w)
00074   {
00075     gl2psLineWidth (w);
00076   }
00077 
00078 private:
00079   int alignment_to_mode (int ha, int va) const;
00080   int fid;
00081   caseless_str term;
00082   double fontsize;
00083   std::string fontname;
00084 };
00085 
00086 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines