annotate libinterp/corefcn/gl2ps-print.cc @ 21333:c4690d9ff566

avoid warnings about overloading virtual functions from a base class * pt-id.h (tree_black_hole::dup): Fix decl. * pt.h (tree::set_breakpoint): Fix decl. * audiodevinfo.cc (audioplayer::print, audiorecorder::print): Fix decl. * gl2ps-print.cc, ov-base-mat.h, ov-base-sparse.h, pt-array-list.h: Import virtual functions from base class that are overloaded in the derived class.
author John W. Eaton <jwe@octave.org>
date Wed, 24 Feb 2016 11:08:45 -0500
parents 40de9f8f23a6
children ae384d86196e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
1 /*
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
3 Copyright (C) 2009-2015 Shai Ayal
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
4
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
5 This file is part of Octave.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
6
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
10 option) any later version.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
11
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
15 for more details.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
16
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
20
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
21 */
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
22
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21230
diff changeset
24 # include "config.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
25 #endif
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
26
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
27 #include "errwarn.h"
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
28 #include "gl2ps-print.h"
19648
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
29
17797
06a850f83dd4 build: Remove embedded gl2ps. Require gl2ps as external dependency.
Rik <rik@octave.org>
parents: 17787
diff changeset
30 #ifdef HAVE_GL2PS_H
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
31
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
32 #include <cstdio>
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
33 #include <unistd.h>
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
34
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
35 #include <gl2ps.h>
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
36
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
37 #include "lo-mappers.h"
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
38 #include "oct-locbuf.h"
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
39 #include "unwind-prot.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
40
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
41 #include "gl-render.h"
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
42 #include "oct-opengl.h"
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
43 #include "sysdep.h"
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
44 #include "text-renderer.h"
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
45
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
46 class
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
47 OCTINTERP_API
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
48 gl2ps_renderer : public opengl_renderer
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
49 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
50 public:
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
51
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
52 gl2ps_renderer (FILE *_fp, const std::string& _term)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
53 : opengl_renderer () , fp (_fp), term (_term), fontsize (),
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
54 fontname (), buffer_overflow (false)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
55 { }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
56
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
57 ~gl2ps_renderer (void) { }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
58
21333
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
59 // FIXME: should we import the functions from the base class and
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
60 // overload them here, or should we use a different name so we don't
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
61 // have to do this? Without the using declaration or a name change,
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
62 // the base class functions will be hidden. That may be OK, but it
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
63 // can also cause some confusion.
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
64 using opengl_renderer::draw;
c4690d9ff566 avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
65
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
66 void draw (const graphics_object& go, const std::string& print_cmd);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
67
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
68 protected:
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
69
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
70 Matrix render_text (const std::string& txt,
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
71 double x, double y, double z,
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
72 int halign, int valign, double rotation = 0.0);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
73
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
74 void set_font (const base_properties& props);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
75
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
76 void draw_axes (const axes::properties& props)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
77 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
78 // Initialize a sorting tree (viewport) in gl2ps for each axes
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
79 GLint vp[4];
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
80 glGetIntegerv (GL_VIEWPORT, vp);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
81 gl2psBeginViewport (vp);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
82
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
83 // Draw and finish () or there may primitives missing in the
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
84 // gl2ps output.
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
85 opengl_renderer::draw_axes (props);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
86 finish ();
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
87
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
88 // Finalize viewport
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
89 GLint state = gl2psEndViewport ();
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
90 if (state == GL2PS_NO_FEEDBACK)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
91 warning ("gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print");
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
92 else if (state == GL2PS_ERROR)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
93 error ("gl2ps_renderer::draw_axes: gl2psEndPage returned GL2PS_ERROR");
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
94
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
95 buffer_overflow |= (state == GL2PS_OVERFLOW);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
96 }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
97
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
98 void draw_text (const text::properties& props);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
99 void draw_pixels (GLsizei w, GLsizei h, GLenum format,
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
100 GLenum type, const GLvoid *data);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
101
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
102 void set_linestyle (const std::string& s, bool use_stipple = false)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
103 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
104 opengl_renderer::set_linestyle (s, use_stipple);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
105
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
106 if (s == "-" && ! use_stipple)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
107 gl2psDisable (GL2PS_LINE_STIPPLE);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
108 else
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
109 gl2psEnable (GL2PS_LINE_STIPPLE);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
110 }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
111
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
112 void set_polygon_offset (bool on, float offset = 0.0f)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
113 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
114 if (on)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
115 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
116 opengl_renderer::set_polygon_offset (on, offset);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
117 gl2psEnable (GL2PS_POLYGON_OFFSET_FILL);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
118 }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
119 else
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
120 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
121 gl2psDisable (GL2PS_POLYGON_OFFSET_FILL);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
122 opengl_renderer::set_polygon_offset (on, offset);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
123 }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
124 }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
125
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
126 void set_linewidth (float w)
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
127 {
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
128 gl2psLineWidth (w);
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
129 }
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
130
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
131 private:
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
132
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
133 // Use xform to compute the coordinates of the string list
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
134 // that have been parsed by freetype
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
135 void fix_strlist_position (double x, double y, double z,
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
136 Matrix box, double rotation,
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
137 std::list<text_renderer::string>& lst);
21199
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
138
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
139 int alignment_to_mode (int ha, int va) const;
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
140 FILE *fp;
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
141 caseless_str term;
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
142 double fontsize;
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
143 std::string fontname;
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
144 bool buffer_overflow;
dd6605e1eaea make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents: 21198
diff changeset
145 };
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
146
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
147 void
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
148 gl2ps_renderer::draw (const graphics_object& go, const std::string& print_cmd)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
149 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
150 static bool in_draw = false;
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
151 static std::string old_print_cmd;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
152
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20831
diff changeset
153 if (! in_draw)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
154 {
19889
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
155 unwind_protect frame;
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
156
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
157 frame.protect_var (in_draw);
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
158
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
159 in_draw = true;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
160
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
161 GLint gl2ps_term;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
162 if (term.find ("eps") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
163 gl2ps_term = GL2PS_EPS;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
164 else if (term.find ("pdf") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
165 gl2ps_term = GL2PS_PDF;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
166 else if (term.find ("ps") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
167 gl2ps_term = GL2PS_PS;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
168 else if (term.find ("svg") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
169 gl2ps_term = GL2PS_SVG;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
170 else if (term.find ("pgf") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
171 gl2ps_term = GL2PS_PGF;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
172 else if (term.find ("tex") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
173 gl2ps_term = GL2PS_TEX;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
174 else
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
175 error ("gl2ps_renderer::draw: Unknown terminal %s", term.c_str ());
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
176
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
177 GLint gl2ps_text = 0;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
178 if (term.find ("notxt") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
179 gl2ps_text = GL2PS_NO_TEXT;
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
180
14389
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
181 // Default sort order optimizes for 3D plots
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
182 GLint gl2ps_sort = GL2PS_BSP_SORT;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
183
18666
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
184 // For 2D plots we can use a simpler Z-depth sorting algorithm
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
185 if (term.find ("is2D") != std::string::npos)
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
186 gl2ps_sort = GL2PS_SIMPLE_SORT;
14389
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
187
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
188 // Use a temporary file in case an overflow happens
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
189 FILE* tmpf = gnulib::tmpfile ();
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
190
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
191 if (! tmpf)
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
192 error ("gl2ps_renderer::draw: couldn't open temporary file for printing");
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
193
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
194 GLint buffsize = 2*1024*1024;
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
195 buffer_overflow = true;
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
196
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
197 while (buffer_overflow)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
198 {
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
199 buffer_overflow = false;
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
200 buffsize *= 2;
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
201 gnulib::fseek (tmpf, 0, SEEK_SET);
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
202 gnulib::ftruncate (fileno (tmpf), 0);
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
203
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
204 // For LaTeX output the fltk print process uses 2 drawnow() commands.
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
205 // The first one is for the pdf/ps/eps graph to be included. The
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
206 // print_cmd is saved as old_print_cmd. Then the second drawnow()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
207 // outputs the tex-file and the graphic filename to be included is
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
208 // extracted from old_print_cmd.
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
209
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
210 std::string include_graph;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
211
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19709
diff changeset
212 size_t found_redirect = old_print_cmd.find (">");
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
213
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
214 if (found_redirect != std::string::npos)
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
215 include_graph = old_print_cmd.substr (found_redirect + 1);
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
216 else
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
217 include_graph = old_print_cmd;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
218
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19709
diff changeset
219 size_t n_begin = include_graph.find_first_not_of (" ");
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
220
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
221 if (n_begin != std::string::npos)
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
222 {
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19709
diff changeset
223 size_t n_end = include_graph.find_last_not_of (" ");
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
224 include_graph = include_graph.substr (n_begin,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
225 n_end - n_begin + 1);
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
226 }
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
227 else
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
228 include_graph = "foobar-inc";
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
229
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
230 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
231 GLint ret = gl2psBeginPage ("gl2ps_renderer figure", "Octave", 0,
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
232 gl2ps_term, gl2ps_sort,
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
233 (GL2PS_NO_BLENDING
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
234 | GL2PS_OCCLUSION_CULL
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
235 | GL2PS_BEST_ROOT
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
236 | gl2ps_text
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
237 | GL2PS_NO_PS3_SHADING
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
238 | GL2PS_USE_CURRENT_VIEWPORT),
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
239 GL_RGBA, 0, 0, 0, 0, 0,
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
240 buffsize, tmpf, include_graph.c_str ());
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
241 if (ret == GL2PS_ERROR)
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
242 {
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
243 old_print_cmd.clear ();
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
244 error ("gl2ps_renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
245 }
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
246
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
247 opengl_renderer::draw (go);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
248
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
249 if (! buffer_overflow)
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
250 old_print_cmd = print_cmd;
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
251
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
252 // Don't check return value of gl2psEndPage, it is not meaningful.
21174
a223cce1daa4 strip trailing space from source files we maintain
John W. Eaton <jwe@octave.org>
parents: 21121
diff changeset
253 // Errors and warnings are checked after gl2psEndViewport in
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
254 // gl2ps_renderer::draw_axes instead.
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
255 gl2psEndPage ();
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
256 }
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
257
21083
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
258 // Copy temporary file to pipe
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
259 gnulib::fseek (tmpf, 0, SEEK_SET);
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
260 char str[256];
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
261 int nread = 1;
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
262 while (! feof (tmpf) && nread)
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
263 {
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
264 nread = gnulib::fread (str, 1, 256, tmpf);
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
265 if (nread)
8c9755d29d2a Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20990
diff changeset
266 gnulib::fwrite (str, 1, nread, fp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
267 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
268 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
269 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
270 opengl_renderer::draw (go);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
271 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
272
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
273 int
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
274 gl2ps_renderer::alignment_to_mode (int ha, int va) const
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
275 {
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
276 int gl2psa = GL2PS_TEXT_BL;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
277
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
278 if (ha == 0)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
279 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
280 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
281 gl2psa=GL2PS_TEXT_BL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
282 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
283 gl2psa=GL2PS_TEXT_TL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
284 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
285 gl2psa=GL2PS_TEXT_CL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
286 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
287 else if (ha == 2)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
288 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
289 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
290 gl2psa=GL2PS_TEXT_BR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
291 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
292 gl2psa=GL2PS_TEXT_TR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
293 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
294 gl2psa=GL2PS_TEXT_CR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
295 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
296 else if (ha == 1)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
297 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
298 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
299 gl2psa=GL2PS_TEXT_B;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
300 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
301 gl2psa=GL2PS_TEXT_T;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
302 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
303 gl2psa=GL2PS_TEXT_C;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
304 }
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
305
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
306 return gl2psa;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
307 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
308
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
309 void
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
310 gl2ps_renderer::fix_strlist_position (double x, double y, double z,
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
311 Matrix box, double rotation,
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
312 std::list<text_renderer::string>& lst)
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
313 {
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
314 for (std::list<text_renderer::string>::iterator p = lst.begin ();
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
315 p != lst.end (); p++)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
316 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
317 // Get pixel coordinates
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
318 ColumnVector coord_pix = get_transform ().transform (x, y, z, false);
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
319
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
320 // Translate and rotate
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
321 double rot = rotation * 4.0 * atan (1.0) / 180;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
322 coord_pix(0) += ((*p).get_x () + box(0))*cos (rot)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
323 - ((*p).get_y () + box(1))*sin (rot);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
324 coord_pix(1) -= ((*p).get_y () + box(1))*cos (rot)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
325 + ((*p).get_x () + box(0))*sin (rot);;
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
326
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
327 // Turn coordinates back into current gl coordinates
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
328 ColumnVector coord =
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
329 get_transform ().untransform (coord_pix(0), coord_pix(1),
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
330 coord_pix(2), false);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
331 (*p).set_x (coord(0));
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
332 (*p).set_y (coord(1));
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
333 (*p).set_z (coord(2));
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
334 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
335 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
336
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
337 static std::string
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
338 code_to_symbol (uint32_t code)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
339 {
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
340 std::string retval;
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
341
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
342 uint32_t idx = code - 945;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
343 if (idx < 25)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
344 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
345 std::string characters("abgdezhqiklmnxoprVstufcyw");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
346 retval = characters[idx];
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
347 return retval;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
348 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
349
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
350 idx = code - 913;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
351 if (idx < 25)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
352 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
353 std::string characters("ABGDEZHQIKLMNXOPRVSTUFCYW");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
354 retval = characters[idx];
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
355 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
356 else if (code == 978)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
357 retval = std::string ("U");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
358 else if (code == 215)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
359 retval = std::string ("\xb4");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
360 else if (code == 177)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
361 retval = std::string ("\xb1");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
362 else if (code == 8501)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
363 retval = std::string ("\xc0");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
364 else if (code == 8465)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
365 retval = std::string ("\xc1");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
366 else if (code == 8242)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
367 retval = std::string ("\xa2");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
368 else if (code == 8736)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
369 retval = std::string ("\xd0");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
370 else if (code == 172)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
371 retval = std::string ("\xd8");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
372 else if (code == 9829)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
373 retval = std::string ("\xa9");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
374 else if (code == 8472)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
375 retval = std::string ("\xc3");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
376 else if (code == 8706)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
377 retval = std::string ("\xb6");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
378 else if (code == 8704)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
379 retval = std::string ("\x22");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
380 else if (code == 9827)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
381 retval = std::string ("\xa7");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
382 else if (code == 9824)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
383 retval = std::string ("\xaa");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
384 else if (code == 8476)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
385 retval = std::string ("\xc2");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
386 else if (code == 8734)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
387 retval = std::string ("\xa5");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
388 else if (code == 8730)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
389 retval = std::string ("\xd6");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
390 else if (code == 8707)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
391 retval = std::string ("\x24");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
392 else if (code == 9830)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
393 retval = std::string ("\xa8");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
394 else if (code == 8747)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
395 retval = std::string ("\xf2");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
396 else if (code == 8727)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
397 retval = std::string ("\x2a");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
398 else if (code == 8744)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
399 retval = std::string ("\xda");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
400 else if (code == 8855)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
401 retval = std::string ("\xc4");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
402 else if (code == 8901)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
403 retval = std::string ("\xd7");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
404 else if (code == 8728)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
405 retval = std::string ("\xb0");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
406 else if (code == 8745)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
407 retval = std::string ("\xc7");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
408 else if (code == 8743)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
409 retval = std::string ("\xd9");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
410 else if (code == 8856)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
411 retval = std::string ("\xc6");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
412 else if (code == 8729)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
413 retval = std::string ("\xb7");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
414 else if (code == 8746)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
415 retval = std::string ("\xc8");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
416 else if (code == 8853)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
417 retval = std::string ("\xc5");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
418 else if (code == 8804)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
419 retval = std::string ("\xa3");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
420 else if (code == 8712)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
421 retval = std::string ("\xce");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
422 else if (code == 8839)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
423 retval = std::string ("\xca");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
424 else if (code == 8801)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
425 retval = std::string ("\xba");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
426 else if (code == 8773)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
427 retval = std::string ("\x40");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
428 else if (code == 8834)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
429 retval = std::string ("\xcc");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
430 else if (code == 8805)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
431 retval = std::string ("\xb3");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
432 else if (code == 8715)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
433 retval = std::string ("\x27");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
434 else if (code == 8764)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
435 retval = std::string ("\x7e");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
436 else if (code == 8733)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
437 retval = std::string ("\xb5");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
438 else if (code == 8838)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
439 retval = std::string ("\xcd");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
440 else if (code == 8835)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
441 retval = std::string ("\xc9");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
442 else if (code == 8739)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
443 retval = std::string ("\xbd");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
444 else if (code == 8776)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
445 retval = std::string ("\xbb");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
446 else if (code == 8869)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
447 retval = std::string ("\x5e");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
448 else if (code == 8656)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
449 retval = std::string ("\xdc");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
450 else if (code == 8592)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
451 retval = std::string ("\xac");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
452 else if (code == 8658)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
453 retval = std::string ("\xde");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
454 else if (code == 8594)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
455 retval = std::string ("\xae");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
456 else if (code == 8596)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
457 retval = std::string ("\xab");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
458 else if (code == 8593)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
459 retval = std::string ("\xad");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
460 else if (code == 8595)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
461 retval = std::string ("\xaf");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
462 else if (code == 8970)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
463 retval = std::string ("\xeb");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
464 else if (code == 8971)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
465 retval = std::string ("\xfb");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
466 else if (code == 10216)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
467 retval = std::string ("\xe1");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
468 else if (code == 10217)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
469 retval = std::string ("\xf1");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
470 else if (code == 8968)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
471 retval = std::string ("\xe9");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
472 else if (code == 8969)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
473 retval = std::string ("\xf9");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
474 else if (code == 8800)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
475 retval = std::string ("\xb9");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
476 else if (code == 8230)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
477 retval = std::string ("\xbc");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
478 else if (code == 176)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
479 retval = std::string ("\xb0");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
480 else if (code == 8709)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
481 retval = std::string ("\xc6");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
482 else if (code == 169)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
483 retval = std::string ("\xd3");
20020
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
484
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
485 if (retval.empty ())
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
486 warning ("print: unhandled symbol %d", code);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
487
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
488 return retval;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
489 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
490
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
491
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
492 static std::string
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
493 select_font (caseless_str fn, bool isbold, bool isitalic)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
494 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
495 std::transform (fn.begin (), fn.end (), fn.begin (), ::tolower);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
496 std::string fontname;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
497 if (fn == "times" || fn == "times-roman")
20020
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
498 {
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
499 if (isitalic && isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
500 fontname = "Times-BoldItalic";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
501 else if (isitalic)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
502 fontname = "Times-Italic";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
503 else if (isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
504 fontname = "Times-Bold";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
505 else
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
506 fontname = "Times-Roman";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
507 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
508 else if (fn == "courier")
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
509 {
20020
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
510 if (isitalic && isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
511 fontname = "Courier-BoldOblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
512 else if (isitalic)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
513 fontname = "Courier-Oblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
514 else if (isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
515 fontname = "Courier-Bold";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
516 else
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
517 fontname = "Courier";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
518 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
519 else if (fn == "symbol")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
520 fontname = "Symbol";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
521 else if (fn == "zapfdingbats")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
522 fontname = "ZapfDingbats";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
523 else
20020
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
524 {
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
525 if (isitalic && isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
526 fontname = "Helvetica-BoldOblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
527 else if (isitalic)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
528 fontname = "Helvetica-Oblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
529 else if (isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
530 fontname = "Helvetica-Bold";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
531 else
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
532 fontname = "Helvetica";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
533 }
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
534 return fontname;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
535 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
536
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
537 static void
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
538 escape_character (const std::string chr, std::string& str)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
539 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
540 std::size_t idx = str.find (chr);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
541 while (idx != std::string::npos)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
542 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
543 str.insert (idx, "\\");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
544 idx = str.find (chr, idx + 2);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
545 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
546 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
547
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
548 Matrix
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
549 gl2ps_renderer::render_text (const std::string& txt,
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
550 double x, double y, double z,
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
551 int ha, int va, double rotation)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
552 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
553 std::string saved_font = fontname;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
554
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
555 if (txt.empty ())
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
556 return Matrix (1, 4, 0.0);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
557
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
558 // We have no way to get a bounding box from gl2ps, so we parse the raw
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
559 // string using freetype
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
560 Matrix bbox;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
561 std::string str = txt;
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
562 std::list<text_renderer::string> lst;
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
563
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
564 text_to_strlist (str, lst, bbox, ha, va, rotation);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
565
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
566 // When using "tex" or when the string has only one line and no
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
567 // special characters, use gl2ps for alignment
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
568 if (lst.empty () || term.find ("tex") != std::string::npos
20792
d0991cbd6141 maint: Remove extra spaces in if () conditionals.
Rik <rik@octave.org>
parents: 20715
diff changeset
569 || (lst.size () == 1 && ! lst.front ().get_code ()))
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
570 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
571 std::string name = fontname;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
572 int sz = fontsize;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
573 if (! lst.empty () && term.find ("tex") == std::string::npos)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
574 {
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
575 text_renderer::string s = lst.front ();
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
576 name = select_font (s.get_name (), s.get_weight () == "bold",
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
577 s.get_angle () == "italic");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
578 set_color (s.get_color ());
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
579 str = s.get_string ();
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
580 sz = s.get_size ();
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
581 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
582
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
583 glRasterPos3d (x, y, z);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
584
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
585 // Escape parenthesis until gl2ps does it (see bug ##45301).
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
586 if (term.find ("svg") == std::string::npos
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
587 && term.find ("tex") == std::string::npos)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
588 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
589 escape_character ("(", str);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
590 escape_character (")", str);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
591 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
592
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
593 gl2psTextOpt (str.c_str (), name.c_str (), sz,
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
594 alignment_to_mode (ha, va), rotation);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
595 return bbox;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
596 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
597
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
598 // Translate and rotate coordinates in order to use bottom-left alignment
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
599 fix_strlist_position (x, y, z, bbox, rotation, lst);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
600
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents: 21207
diff changeset
601 for (std::list<text_renderer::string>::iterator p = lst.begin ();
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
602 p != lst.end (); p++)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
603 {
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
604 fontname = select_font ((*p).get_name (),
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
605 (*p).get_weight () == "bold",
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
606 (*p).get_angle () == "italic");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
607 if ((*p).get_code ())
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
608 {
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
609 // This is only one character represented by a uint32 (utf8) code.
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
610 // We replace it by the corresponding character in the
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
611 // "Symbol" font except for svg which has built-in utf8 support.
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
612 if (term.find ("svg") == std::string::npos)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
613 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
614 fontname = "Symbol";
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
615 str = code_to_symbol ((*p).get_code ());
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
616 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
617 else
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
618 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
619 std::stringstream ss;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
620 ss << (*p).get_code ();
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
621 str = "&#" + ss.str () + ";";
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
622 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
623 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
624 else
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
625 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
626 str = (*p).get_string ();
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
627 // Escape parenthesis until gl2ps does it (see bug ##45301).
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
628 if (term.find ("svg") == std::string::npos)
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
629 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
630 escape_character ("(", str);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
631 escape_character (")", str);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
632 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
633 }
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
634
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
635 set_color ((*p).get_color ());
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
636 glRasterPos3d ((*p).get_x (), (*p).get_y (), (*p).get_z ());
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
637 gl2psTextOpt (str.c_str (), fontname.c_str (), (*p).get_size (),
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
638 GL2PS_TEXT_BL, rotation);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
639 }
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
640
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
641 fontname = saved_font;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
642 return bbox;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
643 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
644
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
645 void
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
646 gl2ps_renderer::set_font (const base_properties& props)
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
647 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
648 opengl_renderer::set_font (props);
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
649
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
650 // Set the interpreter so that text_to_pixels can parse strings properly
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
651 if (props.has_property ("interpreter"))
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
652 set_interpreter (props.get ("interpreter").string_value ());
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
653
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
654 fontsize = props.get ("fontsize_points").double_value ();
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
655
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
656 caseless_str fn = props.get ("fontname").xtolower ().string_value ();
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
657 bool isbold =
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
658 (props.get ("fontweight").xtolower ().string_value () == "bold");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
659 bool isitalic =
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
660 (props.get ("fontangle").xtolower ().string_value () == "italic");
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
661
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
662 fontname = select_font (fn, isbold, isitalic);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
663 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
664
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
665 template <typename T>
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
666 static void
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
667 draw_pixels (GLsizei w, GLsizei h, GLenum format, const T *data, float maxval)
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
668 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
669 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
670
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
671 // Convert to GL_FLOAT as it is the only type gl2ps accepts.
18680
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18671
diff changeset
672 for (int i = 0; i < 3*w*h; i++)
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
673 a[i] = data[i] / maxval;
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18659
diff changeset
674
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
675 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
676 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
677
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
678 void
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
679 gl2ps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format,
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
680 GLenum type, const GLvoid *data)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
681 {
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
682 // gl2psDrawPixels only supports the GL_FLOAT type.
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
683 // Other formats, such as uint8, must be converted first.
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
684 if (type == GL_UNSIGNED_BYTE)
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
685 ::draw_pixels (w, h, format, static_cast<const GLubyte *> (data), 255.0f);
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
686 else if (type == GL_UNSIGNED_SHORT)
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
687 ::draw_pixels (w, h, format, static_cast<const GLushort *> (data), 65535.0f);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
688 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
689 gl2psDrawPixels (w, h, 0, 0, format, type, data);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
690 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
691
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
692 void
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
693 gl2ps_renderer::draw_text (const text::properties& props)
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
694 {
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
695 if (props.get_string ().is_empty ())
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
696 return;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
697
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
698 // First set font properties: freetype will use them to compute
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
699 // coordinates and gl2ps will retrieve the color directly from the
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
700 // feedback buffer
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
701 set_font (props);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
702 set_color (props.get_color_rgb ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
703
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
704 std::string saved_font = fontname;
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
705
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
706 // Alignment
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
707 int halign = 0;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
708 int valign = 0;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
709
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
710 if (props.horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
711 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
712 else if (props.horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
713 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
714
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
715 if (props.verticalalignment_is ("top"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
716 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
717 else if (props.verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
718 valign = 3;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
719 else if (props.verticalalignment_is ("middle"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
720 valign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
721
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
722 // FIXME: handle margin and surrounding box
21121
f5b17eb2508b maint: Remove unused variables.
Rik <rik@octave.org>
parents: 21109
diff changeset
723 // Matrix bbox;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
724
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
725 const Matrix pos = get_transform ().scale (props.get_data_position ());
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20962
diff changeset
726 std::string str = props.get_string ().string_vector_value ().join ("\n");
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
727
20624
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
728 render_text (str, pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0,
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
729 halign, valign, props.get_rotation ());
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
730 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
731
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
732 static void
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
733 safe_pclose (FILE *f)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
734 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
735 if (f)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
736 octave_pclose (f);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
737 }
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
738
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
739 static void
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
740 safe_fclose (FILE *f)
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
741 {
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
742 if (f)
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
743 gnulib::fclose (f);
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
744 }
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
745
21207
945695cafd2b allow build to succeed with missing dependencies
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
746 #endif
945695cafd2b allow build to succeed with missing dependencies
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
747
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
748 // If the name of the stream begins with '|', open a pipe to the command
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
749 // named by the rest of the string. Otherwise, write to the named file.
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
750
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
751 void
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
752 gl2ps_print (const graphics_object& fig, const std::string& stream,
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
753 const std::string& term)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
754 {
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
755 #if defined (HAVE_GL2PS_H)
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
756
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
757 // FIXME: should we have a way to create a file that begins with the
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
758 // character '|'?
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
759
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
760 bool have_cmd = stream.length () > 1 && stream[0] == '|';
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
761
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
762 FILE *fp = 0;
19709
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
763
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20955
diff changeset
764 unwind_protect frame;
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
765
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
766 if (have_cmd)
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
767 {
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
768 // Create process and pipe gl2ps output to it.
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
769
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
770 std::string cmd = stream.substr (1);
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
771
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
772 fp = octave_popen (cmd.c_str (), "w");
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
773
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
774 if (! fp)
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
775 error ("print: failed to open pipe \"%s\"", stream.c_str ());
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
776
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
777 frame.add_fcn (safe_pclose, fp);
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
778 }
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
779 else
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
780 {
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
781 // Write gl2ps output directly to file.
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
782
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
783 fp = gnulib::fopen (stream.c_str (), "w");
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
784
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
785 if (! fp)
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
786 error ("gl2ps_print: failed to create file \"%s\"", stream.c_str ());
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
787
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
788 frame.add_fcn (safe_fclose, fp);
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
789 }
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
790
21084
83ce7b8fb91c maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents: 21083
diff changeset
791 gl2ps_renderer rend (fp, term);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20955
diff changeset
792
21230
721539013db4 make gl2ps printing work again (bug #47080)
John W. Eaton <jwe@octave.org>
parents: 21209
diff changeset
793 rend.draw (fig, stream);
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
794
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
795 // Make sure buffered commands are finished!!!
21198
1adcdc518d9e provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents: 21197
diff changeset
796 rend.finish ();
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
797
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
798 #else
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
799
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21084
diff changeset
800 err_disabled_feature ("gl2ps_print", "gl2ps");
21197
9a5bb6996b16 write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents: 21196
diff changeset
801
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
802 #endif
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
803 }