GNU Octave  4.0.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-2015 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 #include "graphics.h"
27 
28 #ifdef HAVE_GL2PS_H
29 
30 #include "gl-render.h"
31 #include <gl2ps.h>
32 
33 class
35 glps_renderer : public opengl_renderer
36 {
37 public:
38  glps_renderer (FILE *_fp, const std::string& _term)
39  : opengl_renderer () , fp (_fp), term (_term), fontsize (), fontname () { }
40 
41  ~glps_renderer (void) { }
42 
43  void draw (const graphics_object& go, const std::string& print_cmd);
44 
45 protected:
46 
47  Matrix render_text (const std::string& txt,
48  double x, double y, double z,
49  int halign, int valign, double rotation = 0.0);
50 
51  void set_font (const base_properties& props);
52 
53  void draw_text (const text::properties& props);
54  void draw_pixels (GLsizei w, GLsizei h, GLenum format,
55  GLenum type, const GLvoid *data);
56 
57  void set_linestyle (const std::string& s, bool use_stipple = false)
58  {
59  opengl_renderer::set_linestyle (s, use_stipple);
60 
61  if (s == "-" && ! use_stipple)
62  gl2psDisable (GL2PS_LINE_STIPPLE);
63  else
64  gl2psEnable (GL2PS_LINE_STIPPLE);
65  }
66 
67  void set_polygon_offset (bool on, float offset = 0.0f)
68  {
69  if (on)
70  {
71  opengl_renderer::set_polygon_offset (on, offset);
72  gl2psEnable (GL2PS_POLYGON_OFFSET_FILL);
73  }
74  else
75  {
76  gl2psDisable (GL2PS_POLYGON_OFFSET_FILL);
77  opengl_renderer::set_polygon_offset (on, offset);
78  }
79  }
80 
81  void set_linewidth (float w)
82  {
83  gl2psLineWidth (w);
84  }
85 
86 private:
87  int alignment_to_mode (int ha, int va) const;
88  FILE *fp;
89  caseless_str term;
90  double fontsize;
91  std::string fontname;
92 };
93 
94 #endif // HAVE_GL2PS_H
95 
96 extern OCTINTERP_API void
97 gl2ps_print (const graphics_object& fig, const std::string& cmd,
98  const std::string& term);
99 
100 #endif
F77_RET_T const double const double * f
#define OCTINTERP_API
Definition: mexproto.h:66
std::complex< double > w(std::complex< double > z, double relerr=0)
Definition: dMatrix.h:35
OCTINTERP_API void gl2ps_print(const graphics_object &fig, const std::string &cmd, const std::string &term)
F77_RET_T const double * x