GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
gl2ps-renderer.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2009-2013 Shai Ayal
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_gl2ps_renderer_h)
24 #define octave_gl2ps_renderer_h 1
25 
26 #ifdef HAVE_GL2PS_H
27 
28 #include "gl-render.h"
29 #include <gl2ps.h>
30 
31 class
33 glps_renderer : public opengl_renderer
34 {
35 public:
36  glps_renderer (FILE *_fp, const std::string& _term)
37  : opengl_renderer () , fp (_fp), term (_term), fontsize (), fontname () { }
38 
39  ~glps_renderer (void) { }
40 
41  void draw (const graphics_object& go, const std::string print_cmd);
42 
43 protected:
44 
45  Matrix render_text (const std::string& txt,
46  double x, double y, double z,
47  int halign, int valign, double rotation = 0.0);
48 
49  void set_font (const base_properties& props);
50 
51  void draw_text (const text::properties& props);
52  void draw_pixels (GLsizei w, GLsizei h, GLenum format,
53  GLenum type, const GLvoid *data);
54 
55  void set_linestyle (const std::string& s, bool use_stipple = false)
56  {
57  opengl_renderer::set_linestyle (s, use_stipple);
58 
59  if (s == "-" && ! use_stipple)
60  gl2psDisable (GL2PS_LINE_STIPPLE);
61  else
62  gl2psEnable (GL2PS_LINE_STIPPLE);
63  }
64 
65  void set_polygon_offset (bool on, double offset = 0.0)
66  {
68  if (on)
69  gl2psEnable (GL2PS_POLYGON_OFFSET_FILL);
70  else
71  gl2psDisable (GL2PS_POLYGON_OFFSET_FILL);
72  }
73 
74  void set_linewidth (float w)
75  {
76  gl2psLineWidth (w);
77  }
78 
79 private:
80  int alignment_to_mode (int ha, int va) const;
81  FILE *fp;
82  caseless_str term;
83  double fontsize;
84  std::string fontname;
85 };
86 
87 #endif // HAVE_GL2PS_H
88 
89 #endif