comparison src/gl2ps-renderer.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents fd0a3ac60b0e
children 11427f71699b
comparison
equal deleted inserted replaced
11585:1473d0cf86d2 11586:12df7854fa7c
32 #include "oct-locbuf.h" 32 #include "oct-locbuf.h"
33 33
34 #include "gl2ps-renderer.h" 34 #include "gl2ps-renderer.h"
35 #include "gl2ps.h" 35 #include "gl2ps.h"
36 36
37 void 37 void
38 glps_renderer::draw (const graphics_object& go) 38 glps_renderer::draw (const graphics_object& go)
39 { 39 {
40 static bool in_draw = false; 40 static bool in_draw = false;
41 41
42 if (!in_draw) 42 if (!in_draw)
43 { 43 {
44 in_draw = true; 44 in_draw = true;
45 45
46 FILE *fp = fdopen (fid, "wb"); 46 FILE *fp = fdopen (fid, "wb");
47 GLint buffsize = 0, state = GL2PS_OVERFLOW; 47 GLint buffsize = 0, state = GL2PS_OVERFLOW;
54 else if (term.find ("pdf") != std::string::npos) gl2ps_term = GL2PS_PDF; 54 else if (term.find ("pdf") != std::string::npos) gl2ps_term = GL2PS_PDF;
55 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG; 55 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG;
56 else if (term.find ("ps") != std::string::npos) gl2ps_term = GL2PS_PS; 56 else if (term.find ("ps") != std::string::npos) gl2ps_term = GL2PS_PS;
57 else if (term.find ("pgf") != std::string::npos) gl2ps_term = GL2PS_PGF; 57 else if (term.find ("pgf") != std::string::npos) gl2ps_term = GL2PS_PGF;
58 else if (term.find ("tex") != std::string::npos) gl2ps_term = GL2PS_TEX; 58 else if (term.find ("tex") != std::string::npos) gl2ps_term = GL2PS_TEX;
59 else 59 else
60 { 60 {
61 error ("gl2ps-renderer:: Unknown terminal"); 61 error ("gl2ps-renderer:: Unknown terminal");
62 return; 62 return;
63 } 63 }
64 64
65 GLint gl2ps_text = 0; 65 GLint gl2ps_text = 0;
66 if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT; 66 if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT;
67 67
68 while (state == GL2PS_OVERFLOW) 68 while (state == GL2PS_OVERFLOW)
69 { 69 {
70 buffsize += 1024*1024; 70 buffsize += 1024*1024;
71 gl2psBeginPage ("glps_renderer figure", "Octave", viewport, 71 gl2psBeginPage ("glps_renderer figure", "Octave", viewport,
72 gl2ps_term, GL2PS_BSP_SORT, 72 gl2ps_term, GL2PS_BSP_SORT,
73 (GL2PS_SILENT | GL2PS_SIMPLE_LINE_OFFSET 73 (GL2PS_SILENT | GL2PS_SIMPLE_LINE_OFFSET
74 | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL 74 | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL
75 | GL2PS_BEST_ROOT | gl2ps_text), 75 | GL2PS_BEST_ROOT | gl2ps_text),
76 GL_RGBA, 0, NULL, 0, 0, 0, 76 GL_RGBA, 0, NULL, 0, 0, 0,
77 buffsize, fp, "" ); 77 buffsize, fp, "" );
78 78
79 opengl_renderer::draw (go); 79 opengl_renderer::draw (go);
80 state = gl2psEndPage (); 80 state = gl2psEndPage ();
83 gnulib::fclose (fp); 83 gnulib::fclose (fp);
84 84
85 in_draw = 0; 85 in_draw = 0;
86 } 86 }
87 else 87 else
88 opengl_renderer::draw (go); 88 opengl_renderer::draw (go);
89 } 89 }
90 90
91 int 91 int
92 glps_renderer::alignment_to_mode (int ha, int va) const 92 glps_renderer::alignment_to_mode (int ha, int va) const
93 { 93 {
120 gl2psa=GL2PS_TEXT_C; 120 gl2psa=GL2PS_TEXT_C;
121 } 121 }
122 return gl2psa; 122 return gl2psa;
123 } 123 }
124 124
125 Matrix 125 Matrix
126 glps_renderer::render_text (const std::string& txt, 126 glps_renderer::render_text (const std::string& txt,
127 double x, double y, double z, 127 double x, double y, double z,
128 int ha, int va, double rotation) 128 int ha, int va, double rotation)
129 { 129 {
130 if (txt.empty ()) 130 if (txt.empty ())
157 fontname = "Courier"; 157 fontname = "Courier";
158 else if (fn == "symbol") 158 else if (fn == "symbol")
159 fontname = "Symbol"; 159 fontname = "Symbol";
160 else if (fn == "zapfdingbats") 160 else if (fn == "zapfdingbats")
161 fontname = "ZapfDingbats"; 161 fontname = "ZapfDingbats";
162 else 162 else
163 fontname = "Helvetica"; 163 fontname = "Helvetica";
164 164
165 // FIXME -- add support for bold and italic 165 // FIXME -- add support for bold and italic
166 } 166 }
167 167
171 { 171 {
172 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h); 172 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
173 173
174 for (int i = 0; i < 3*w*h; i++) 174 for (int i = 0; i < 3*w*h; i++)
175 a[i] = data[i]; 175 a[i] = data[i];
176 176
177 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a); 177 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a);
178 } 178 }
179 179
180 void 180 void
181 glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format, 181 glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format,
182 GLenum type, const GLvoid *data) 182 GLenum type, const GLvoid *data)
183 { 183 {
184 if (type == GL_UNSIGNED_SHORT) 184 if (type == GL_UNSIGNED_SHORT)
185 ::draw_pixels (w, h, format, static_cast<const GLushort *> (data)); 185 ::draw_pixels (w, h, format, static_cast<const GLushort *> (data));
186 else if (type == GL_UNSIGNED_BYTE) 186 else if (type == GL_UNSIGNED_BYTE)
187 ::draw_pixels (w, h, format, static_cast<const GLubyte *> (data)); 187 ::draw_pixels (w, h, format, static_cast<const GLubyte *> (data));
188 else 188 else
189 gl2psDrawPixels (w, h, 0, 0, format, type, data); 189 gl2psDrawPixels (w, h, 0, 0, format, type, data);
190 } 190 }
191 191
203 203
204 if (props.horizontalalignment_is ("center")) 204 if (props.horizontalalignment_is ("center"))
205 halign = 1; 205 halign = 1;
206 else if (props.horizontalalignment_is ("right")) 206 else if (props.horizontalalignment_is ("right"))
207 halign = 2; 207 halign = 2;
208 208
209 if (props.verticalalignment_is ("top")) 209 if (props.verticalalignment_is ("top"))
210 valign = 2; 210 valign = 2;
211 else if (props.verticalalignment_is ("baseline")) 211 else if (props.verticalalignment_is ("baseline"))
212 valign = 3; 212 valign = 3;
213 else if (props.verticalalignment_is ("middle")) 213 else if (props.verticalalignment_is ("middle"))