Mercurial > octave
annotate libinterp/corefcn/gl2ps-print.cc @ 23740:38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
* gl2ps-print.cc (gl2ps_renderer:draw): Use unwind-protect to ensure
that temporary file is closed.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Jul 2017 16:25:38 -0400 |
parents | 08036a7f3660 |
children | 7a1097510439 |
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 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2009-2017 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 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
10 (at your option) any later version. |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22753
diff
changeset
|
15 GNU General Public License for more details. |
9798
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 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21539
diff
changeset
|
23 #if defined (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 |
21539
212bafe8413a
gl2ps-print.cc: Fix compiling whet --without-opengl used.
Rik <rik@octave.org>
parents:
21527
diff
changeset
|
27 // Both header files are required outside of HAVE_GLP2S_H |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
28 #include "errwarn.h" |
21539
212bafe8413a
gl2ps-print.cc: Fix compiling whet --without-opengl used.
Rik <rik@octave.org>
parents:
21527
diff
changeset
|
29 #include "gl2ps-print.h" |
19648
16f21db320b5
Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents:
19639
diff
changeset
|
30 |
22750
dc828d9a7f3a
Fix building gl2ps when --without-opengl is used (bug #47886).
Rik <rik@octave.org>
parents:
22704
diff
changeset
|
31 #if defined (HAVE_GL2PS_H) && defined (HAVE_OPENGL) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
32 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
33 #include <cstdio> |
21852
25493c55d976
don't include unistd.h unless it is needed
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
34 |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
35 #include <limits> |
21852
25493c55d976
don't include unistd.h unless it is needed
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
36 |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
37 #include <gl2ps.h> |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
38 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
39 #include "lo-mappers.h" |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
40 #include "oct-locbuf.h" |
21991
80659e58609f
provide wrapper for tmpfile (bug #48337)
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
41 #include "tmpfile-wrapper.h" |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21852
diff
changeset
|
42 #include "unistd-wrappers.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 "unwind-prot.h" |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
44 |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
45 #include "gl-render.h" |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
46 #include "oct-opengl.h" |
21527
ab8760b1245d
Raise an error if writes to pipe fail (bug #47381).
Rik <rik@octave.org>
parents:
21391
diff
changeset
|
47 #include "sighandlers.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
|
48 #include "sysdep.h" |
21209
67d2965af0b5
revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
21207
diff
changeset
|
49 #include "text-renderer.h" |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
50 |
23740
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
51 static void |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
52 safe_pclose (FILE *f) |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
53 { |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
54 if (f) |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
55 octave_pclose (f); |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
56 } |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
57 |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
58 static void |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
59 safe_fclose (FILE *f) |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
60 { |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
61 if (f) |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
62 std::fclose (f); |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
63 } |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
64 |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
65 namespace octave |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
66 { |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
67 class |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
68 OCTINTERP_API |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
69 gl2ps_renderer : public opengl_renderer |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
70 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
71 public: |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
72 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
73 gl2ps_renderer (FILE *_fp, const std::string& _term) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
74 : opengl_renderer () , fp (_fp), term (_term), fontsize (), |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22396
diff
changeset
|
75 fontname (), buffer_overflow (false) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22396
diff
changeset
|
76 { } |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
77 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
78 ~gl2ps_renderer (void) = default; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
79 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
80 // FIXME: should we import the functions from the base class and |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
81 // overload them here, or should we use a different name so we don't |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
82 // have to do this? Without the using declaration or a name change, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
83 // the base class functions will be hidden. That may be OK, but it |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
84 // can also cause some confusion. |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
85 using opengl_renderer::draw; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
86 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
87 void draw (const graphics_object& go, const std::string& print_cmd); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
88 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
89 protected: |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
90 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
91 Matrix render_text (const std::string& txt, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
92 double x, double y, double z, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
93 int halign, int valign, double rotation = 0.0); |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
94 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
95 void set_font (const base_properties& props); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
96 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
97 void draw_axes (const axes::properties& props) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
98 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
99 // Initialize a sorting tree (viewport) in gl2ps for each axes |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
100 GLint vp[4]; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
101 glGetIntegerv (GL_VIEWPORT, vp); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
102 gl2psBeginViewport (vp); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
103 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
104 // Draw and finish () or there may primitives missing in the gl2ps output. |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
105 opengl_renderer::draw_axes (props); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
106 finish (); |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
107 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
108 // Finalize viewport |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
109 GLint state = gl2psEndViewport (); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
110 if (state == GL2PS_NO_FEEDBACK) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
111 warning ("gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
112 else if (state == GL2PS_ERROR) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
113 error ("gl2ps_renderer::draw_axes: gl2psEndPage returned GL2PS_ERROR"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
114 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
115 buffer_overflow |= (state == GL2PS_OVERFLOW); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
116 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
117 // Don't draw background for subsequent viewports (legends, subplots, etc.) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
118 GLint opts; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
119 gl2psGetOptions (&opts); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
120 opts &= ~GL2PS_DRAW_BACKGROUND; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
121 gl2psSetOptions (opts); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
122 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
123 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
124 void draw_text (const text::properties& props); |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
125 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
126 void draw_pixels (int w, int h, const float *data); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
127 void draw_pixels (int w, int h, const uint8_t *data); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
128 void draw_pixels (int w, int h, const uint16_t *data); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
129 |
22396
52c205a0ad88
Make linestyles compatible at larger linewidths (bug #48884).
Rik <rik@octave.org>
parents:
22392
diff
changeset
|
130 void set_linestyle (const std::string& s, bool use_stipple = false, |
52c205a0ad88
Make linestyles compatible at larger linewidths (bug #48884).
Rik <rik@octave.org>
parents:
22392
diff
changeset
|
131 double linewidth = 0.5) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
132 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
133 opengl_renderer::set_linestyle (s, use_stipple, linewidth); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
134 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
135 if (s == "-" && ! use_stipple) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
136 gl2psDisable (GL2PS_LINE_STIPPLE); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
137 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
138 gl2psEnable (GL2PS_LINE_STIPPLE); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
139 } |
21333
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
140 |
22838
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
141 void set_linecap (const std::string& s) |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
142 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
143 opengl_renderer::set_linejoin (s); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
144 |
22838
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
145 #if defined (HAVE_GL2PSLINEJOIN) |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
146 if (s == "butt") |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
147 gl2psLineCap (GL2PS_LINE_CAP_BUTT); |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
148 else if (s == "square") |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
149 gl2psLineCap (GL2PS_LINE_CAP_SQUARE); |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
150 else if (s == "round") |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
151 gl2psLineCap (GL2PS_LINE_CAP_ROUND); |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
152 #endif |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
153 } |
1444a65085ca
Make axes corners join in printout (bug #39643)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22759
diff
changeset
|
154 |
22759
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
155 void set_linejoin (const std::string& s) |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
156 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
157 opengl_renderer::set_linejoin (s); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
158 |
22759
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
159 #if defined (HAVE_GL2PSLINEJOIN) |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
160 if (s == "round") |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
161 gl2psLineJoin (GL2PS_LINE_JOIN_ROUND); |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
162 else if (s == "miter") |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
163 gl2psLineJoin (GL2PS_LINE_JOIN_MITER); |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
164 else if (s == "chamfer") |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
165 gl2psLineJoin (GL2PS_LINE_JOIN_BEVEL); |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
166 #endif |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
167 } |
39f39eb4e476
Implement "linejoin" property (bug #48387)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22755
diff
changeset
|
168 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
169 void set_polygon_offset (bool on, float offset = 0.0f) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
170 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
171 if (on) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
172 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
173 opengl_renderer::set_polygon_offset (on, offset); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
174 gl2psEnable (GL2PS_POLYGON_OFFSET_FILL); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
175 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
176 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
177 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
178 gl2psDisable (GL2PS_POLYGON_OFFSET_FILL); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
179 opengl_renderer::set_polygon_offset (on, offset); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
180 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
181 } |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
182 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
183 void set_linewidth (float w) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
184 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
185 gl2psLineWidth (w); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
186 } |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
187 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
188 private: |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
189 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
190 // Use xform to compute the coordinates of the string list |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
191 // that have been parsed by freetype |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
192 void fix_strlist_position (double x, double y, double z, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
193 Matrix box, double rotation, |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
194 std::list<text_renderer::string>& lst); |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
195 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
196 int alignment_to_mode (int ha, int va) const; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
197 FILE *fp; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
198 caseless_str term; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
199 double fontsize; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
200 std::string fontname; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
201 bool buffer_overflow; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
202 }; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
203 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
204 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
205 gl2ps_renderer::draw (const graphics_object& go, const std::string& print_cmd) |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
206 { |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
207 static bool in_draw = false; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
208 static std::string old_print_cmd; |
22753
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
209 static GLint buffsize; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
210 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
211 if (! in_draw) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
212 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
213 unwind_protect frame; |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
214 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
215 frame.protect_var (in_draw); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
216 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
217 in_draw = true; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
218 |
22336
47629df12b79
Fix crash when choosing an inappropriate terminal in drawnow (bug #48782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22331
diff
changeset
|
219 GLint gl2ps_term = GL2PS_PS; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
220 if (term.find ("eps") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
221 gl2ps_term = GL2PS_EPS; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
222 else if (term.find ("pdf") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
223 gl2ps_term = GL2PS_PDF; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
224 else if (term.find ("ps") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
225 gl2ps_term = GL2PS_PS; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
226 else if (term.find ("svg") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
227 gl2ps_term = GL2PS_SVG; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
228 else if (term.find ("pgf") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
229 gl2ps_term = GL2PS_PGF; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
230 else if (term.find ("tex") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
231 gl2ps_term = GL2PS_TEX; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
232 else |
22336
47629df12b79
Fix crash when choosing an inappropriate terminal in drawnow (bug #48782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22331
diff
changeset
|
233 warning ("gl2ps_renderer::draw: Unknown terminal %s, using 'ps'", |
47629df12b79
Fix crash when choosing an inappropriate terminal in drawnow (bug #48782)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
22331
diff
changeset
|
234 term.c_str ()); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
235 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
236 GLint gl2ps_text = 0; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
237 if (term.find ("notxt") != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
238 gl2ps_text = GL2PS_NO_TEXT; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
239 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
240 // Default sort order optimizes for 3D plots |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
241 GLint gl2ps_sort = GL2PS_BSP_SORT; |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
242 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
243 // For 2D plots we can use a simpler Z-depth sorting algorithm |
23546
06805aabbdd1
Draw 2D axes primitives in the children stack order (bug #50750)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23457
diff
changeset
|
244 // FIXME: gl2ps does not provide a way to change the sorting algorythm |
06805aabbdd1
Draw 2D axes primitives in the children stack order (bug #50750)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23457
diff
changeset
|
245 // on a viewport basis, we thus disable sorting only if all axes are 2D |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
246 if (term.find ("is2D") != std::string::npos) |
23546
06805aabbdd1
Draw 2D axes primitives in the children stack order (bug #50750)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23457
diff
changeset
|
247 gl2ps_sort = GL2PS_NO_SORT; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
248 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
249 // Use a temporary file in case an overflow happens |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23305
diff
changeset
|
250 FILE *tmpf = octave_tmpfile_wrapper (); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
251 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
252 if (! tmpf) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
253 error ("gl2ps_renderer::draw: couldn't open temporary file for printing"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
254 |
23740
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
255 frame.add_fcn (safe_fclose, tmpf); |
38188d1aaf3f
ensure that temporary file used by gl2ps is closed (bug #50696)
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
256 |
22753
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
257 // Reset buffsize, unless this is 2nd pass of a texstandalone print. |
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
258 if (term.find ("tex") == std::string::npos) |
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
259 buffsize = 2*1024*1024; |
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
260 else |
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
261 buffsize /= 2; |
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
262 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
263 buffer_overflow = true; |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
264 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
265 while (buffer_overflow) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
266 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
267 buffer_overflow = false; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
268 buffsize *= 2; |
22753
50fa2d656326
Size gl2ps print buffer just once when printing tex formats (bug #49492).
Rik <rik@octave.org>
parents:
22750
diff
changeset
|
269 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
270 std::fseek (tmpf, 0, SEEK_SET); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
271 octave_ftruncate_wrapper (fileno (tmpf), 0); |
21391
13b6be3cb217
Correctly print figure background when multiple axes present (bug #47315).
Rik <rik@octave.org>
parents:
21353
diff
changeset
|
272 |
22704
b5407b1ab11a
Provide extra info message when gl2ps buffer overflows (bug #49482).
Rik <rik@octave.org>
parents:
22622
diff
changeset
|
273 // For LaTeX output the print process uses 2 drawnow() commands. |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
274 // The first one is for the pdf/ps/eps graph to be included. The |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
275 // print_cmd is saved as old_print_cmd. Then the second drawnow() |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
276 // outputs the tex-file and the graphic filename to be included is |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
277 // extracted from old_print_cmd. |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
278 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
279 std::string include_graph; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
280 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
281 size_t found_redirect = old_print_cmd.find (">"); |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
282 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
283 if (found_redirect != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
284 include_graph = old_print_cmd.substr (found_redirect + 1); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
285 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
286 include_graph = old_print_cmd; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
287 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
288 size_t n_begin = include_graph.find_first_not_of (" "); |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
289 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
290 if (n_begin != std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
291 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
292 size_t n_end = include_graph.find_last_not_of (" "); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
293 include_graph = include_graph.substr (n_begin, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
294 n_end - n_begin + 1); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
295 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
296 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
297 include_graph = "foobar-inc"; |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
298 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
299 // GL2PS_SILENT was removed to allow gl2ps to print errors on stderr |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
300 GLint ret = gl2psBeginPage ("gl2ps_renderer figure", "Octave", 0, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
301 gl2ps_term, gl2ps_sort, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
302 (GL2PS_NO_BLENDING |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
303 | GL2PS_OCCLUSION_CULL |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
304 | GL2PS_BEST_ROOT |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
305 | gl2ps_text |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
306 | GL2PS_DRAW_BACKGROUND |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
307 | GL2PS_NO_PS3_SHADING |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
308 | GL2PS_USE_CURRENT_VIEWPORT), |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
309 GL_RGBA, 0, 0, 0, 0, 0, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
310 buffsize, tmpf, include_graph.c_str ()); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
311 if (ret == GL2PS_ERROR) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
312 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
313 old_print_cmd.clear (); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
314 error ("gl2ps_renderer::draw: gl2psBeginPage returned GL2PS_ERROR"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
315 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
316 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
317 opengl_renderer::draw (go); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
318 |
22704
b5407b1ab11a
Provide extra info message when gl2ps buffer overflows (bug #49482).
Rik <rik@octave.org>
parents:
22622
diff
changeset
|
319 if (buffer_overflow) |
b5407b1ab11a
Provide extra info message when gl2ps buffer overflows (bug #49482).
Rik <rik@octave.org>
parents:
22622
diff
changeset
|
320 warning ("gl2ps_renderer::draw: retrying with buffer size: %.1E B\n", double (2*buffsize)); |
b5407b1ab11a
Provide extra info message when gl2ps buffer overflows (bug #49482).
Rik <rik@octave.org>
parents:
22622
diff
changeset
|
321 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
322 if (! buffer_overflow) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
323 old_print_cmd = print_cmd; |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
324 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
325 // Don't check return value of gl2psEndPage, it is not meaningful. |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
326 // Errors and warnings are checked after gl2psEndViewport in |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
327 // gl2ps_renderer::draw_axes instead. |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
328 gl2psEndPage (); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
329 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
330 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
331 // Copy temporary file to pipe |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
332 std::fseek (tmpf, 0, SEEK_SET); |
23305
34c75889ed50
Possibly improve performance of OpenGL printing.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
333 char str[8192]; // 8 kB is a common kernel buffersize |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
334 size_t nread, nwrite; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
335 nread = 1; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
336 while (! feof (tmpf) && nread) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
337 { |
23305
34c75889ed50
Possibly improve performance of OpenGL printing.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
338 nread = std::fread (str, 1, 8192, tmpf); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
339 if (nread) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
340 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
341 nwrite = std::fwrite (str, 1, nread, fp); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
342 if (nwrite != nread) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
343 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
344 signal_handler (); // Clear SIGPIPE signal |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
345 error ("gl2ps_renderer::draw: internal pipe error"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
346 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
347 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
348 } |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
349 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
350 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
351 opengl_renderer::draw (go); |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
352 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
353 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
354 int |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
355 gl2ps_renderer::alignment_to_mode (int ha, int va) const |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
356 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
357 int gl2psa = GL2PS_TEXT_BL; |
19890 | 358 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
359 if (ha == 0) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
360 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
361 if (va == 0 || va == 3) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
362 gl2psa=GL2PS_TEXT_BL; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
363 else if (va == 2) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
364 gl2psa=GL2PS_TEXT_TL; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
365 else if (va == 1) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
366 gl2psa=GL2PS_TEXT_CL; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
367 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
368 else if (ha == 2) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
369 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
370 if (va == 0 || va == 3) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
371 gl2psa=GL2PS_TEXT_BR; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
372 else if (va == 2) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
373 gl2psa=GL2PS_TEXT_TR; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
374 else if (va == 1) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
375 gl2psa=GL2PS_TEXT_CR; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
376 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
377 else if (ha == 1) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
378 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
379 if (va == 0 || va == 3) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
380 gl2psa=GL2PS_TEXT_B; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
381 else if (va == 2) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
382 gl2psa=GL2PS_TEXT_T; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
383 else if (va == 1) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
384 gl2psa=GL2PS_TEXT_C; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
385 } |
19890 | 386 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
387 return gl2psa; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
388 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
389 |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
390 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
391 gl2ps_renderer::fix_strlist_position (double x, double y, double z, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
392 Matrix box, double rotation, |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
393 std::list<text_renderer::string>& lst) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
394 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
395 for (auto& txtobj : lst) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
396 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
397 // Get pixel coordinates |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
398 ColumnVector coord_pix = get_transform ().transform (x, y, z, false); |
19890 | 399 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
400 // Translate and rotate |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
401 double rot = rotation * 4.0 * atan (1.0) / 180; |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
402 coord_pix(0) += (txtobj.get_x () + box(0))*cos (rot) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
403 - (txtobj.get_y () + box(1))*sin (rot); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
404 coord_pix(1) -= (txtobj.get_y () + box(1))*cos (rot) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
405 + (txtobj.get_x () + box(0))*sin (rot); |
19890 | 406 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
407 // Turn coordinates back into current gl coordinates |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
408 ColumnVector coord = get_transform ().untransform (coord_pix(0), |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
409 coord_pix(1), |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
410 coord_pix(2), |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
411 false); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
412 txtobj.set_x (coord(0)); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
413 txtobj.set_y (coord(1)); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
414 txtobj.set_z (coord(2)); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
415 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
416 } |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
417 } |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
418 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
419 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
|
420 code_to_symbol (uint32_t code) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
421 { |
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
|
422 std::string retval; |
9834
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
423 |
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
|
424 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
|
425 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
|
426 { |
4e47e10d5279
Add 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 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
|
428 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
|
429 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
|
430 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
431 |
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
|
432 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
|
433 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
|
434 { |
4e47e10d5279
Add 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 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
|
436 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
|
437 } |
4e47e10d5279
Add 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 == 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 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
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 else if (code == 8707) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
473 retval = std::string ("\x24"); |
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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 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
|
479 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
|
480 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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 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
|
487 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
|
488 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
|
489 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
|
490 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
|
491 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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 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
|
522 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
|
523 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
|
524 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
|
525 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 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
|
531 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 |
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 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
|
568 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
|
569 |
4e47e10d5279
Add 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 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
|
571 } |
4e47e10d5279
Add 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 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
573 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
|
574 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
|
575 { |
4e47e10d5279
Add 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 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
|
577 std::string fontname; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
578 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
|
579 { |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
580 if (isitalic && isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
581 fontname = "Times-BoldItalic"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
582 else if (isitalic) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
583 fontname = "Times-Italic"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
584 else if (isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
585 fontname = "Times-Bold"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
586 else |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
587 fontname = "Times-Roman"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
588 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
589 else if (fn == "courier") |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
590 { |
20020
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
591 if (isitalic && isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
592 fontname = "Courier-BoldOblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
593 else if (isitalic) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
594 fontname = "Courier-Oblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
595 else if (isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
596 fontname = "Courier-Bold"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
597 else |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
598 fontname = "Courier"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
599 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
600 else if (fn == "symbol") |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
601 fontname = "Symbol"; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
602 else if (fn == "zapfdingbats") |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
603 fontname = "ZapfDingbats"; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
604 else |
20020
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
605 { |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
606 if (isitalic && isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
607 fontname = "Helvetica-BoldOblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
608 else if (isitalic) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
609 fontname = "Helvetica-Oblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
610 else if (isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
611 fontname = "Helvetica-Bold"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
612 else |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
613 fontname = "Helvetica"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
614 } |
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
|
615 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
|
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 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
618 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
|
619 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
|
620 { |
4e47e10d5279
Add 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 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
|
622 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
|
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 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
|
625 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
|
626 } |
4e47e10d5279
Add 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 } |
4e47e10d5279
Add 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 |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
629 namespace octave |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
630 { |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
631 Matrix |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
632 gl2ps_renderer::render_text (const std::string& txt, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
633 double x, double y, double z, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
634 int ha, int va, double rotation) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
635 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
636 std::string saved_font = fontname; |
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
|
637 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
638 if (txt.empty ()) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
639 return Matrix (1, 4, 0.0); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
640 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
641 // We have no way to get a bounding box from gl2ps, so we parse the raw |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
642 // string using freetype |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
643 Matrix bbox; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
644 std::string str = txt; |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
645 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
|
646 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
647 text_to_strlist (str, lst, bbox, ha, va, rotation); |
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
|
648 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
649 // When using "tex" or when the string has only one line and no |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
650 // special characters, use gl2ps for alignment |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
651 if (lst.empty () || term.find ("tex") != std::string::npos |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
652 || (lst.size () == 1 && ! lst.front ().get_code ())) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
653 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
654 std::string name = fontname; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
655 int sz = fontsize; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
656 if (! lst.empty () && term.find ("tex") == std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
657 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
658 text_renderer::string s = lst.front (); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
659 name = select_font (s.get_name (), s.get_weight () == "bold", |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
660 s.get_angle () == "italic"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
661 set_color (s.get_color ()); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
662 str = s.get_string (); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
663 sz = s.get_size (); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
664 } |
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
|
665 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
666 glRasterPos3d (x, y, 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
|
667 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
668 // Escape parentheses until gl2ps does it (see bug #45301). |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
669 if (term.find ("svg") == std::string::npos |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
670 && term.find ("tex") == std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
671 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
672 escape_character ("(", str); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
673 escape_character (")", str); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
674 } |
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
|
675 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
676 gl2psTextOpt (str.c_str (), name.c_str (), sz, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
677 alignment_to_mode (ha, va), rotation); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
678 return bbox; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
679 } |
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
|
680 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
681 // Translate and rotate coordinates in order to use bottom-left alignment |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
682 fix_strlist_position (x, y, z, bbox, rotation, 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
|
683 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
684 for (const auto& txtobj : lst) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
685 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
686 fontname = select_font (txtobj.get_name (), |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
687 txtobj.get_weight () == "bold", |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
688 txtobj.get_angle () == "italic"); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
689 if (txtobj.get_code ()) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
690 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
691 // This is only one character represented by a uint32 (utf8) code. |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
692 // We replace it by the corresponding character in the |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
693 // "Symbol" font except for svg which has built-in utf8 support. |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
694 if (term.find ("svg") == std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
695 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
696 fontname = "Symbol"; |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
697 str = code_to_symbol (txtobj.get_code ()); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
698 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
699 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
700 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
701 std::stringstream ss; |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
702 ss << txtobj.get_code (); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
703 str = "&#" + ss.str () + ";"; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
704 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
705 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
706 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
707 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
708 str = txtobj.get_string (); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
709 // Escape parenthesis until gl2ps does it (see bug ##45301). |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
710 if (term.find ("svg") == std::string::npos) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
711 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
712 escape_character ("(", str); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
713 escape_character (")", str); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
714 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
715 } |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
716 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
717 set_color (txtobj.get_color ()); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
718 glRasterPos3d (txtobj.get_x (), txtobj.get_y (), txtobj.get_z ()); |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22838
diff
changeset
|
719 gl2psTextOpt (str.c_str (), fontname.c_str (), txtobj.get_size (), |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
720 GL2PS_TEXT_BL, rotation); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
721 } |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
722 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
723 fontname = saved_font; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
724 return bbox; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
725 } |
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
|
726 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
727 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
728 gl2ps_renderer::set_font (const base_properties& props) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
729 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
730 opengl_renderer::set_font (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
|
731 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
732 // Set the interpreter so that text_to_pixels can parse strings properly |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
733 if (props.has_property ("interpreter")) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
734 set_interpreter (props.get ("interpreter").string_value ()); |
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
|
735 |
22622
4191f8b5070c
Add '__' to start/end of hidden Octave-only graphics properties (bug #49205).
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
736 fontsize = props.get ("__fontsize_points__").double_value (); |
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
|
737 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
738 caseless_str fn = props.get ("fontname").xtolower ().string_value (); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
739 bool isbold = |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
740 (props.get ("fontweight").xtolower ().string_value () == "bold"); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
741 bool isitalic = |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
742 (props.get ("fontangle").xtolower ().string_value () == "italic"); |
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
|
743 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
744 fontname = select_font (fn, isbold, isitalic); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
745 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
746 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
747 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
748 gl2ps_renderer::draw_pixels (int w, int h, const float *data) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
749 { |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22396
diff
changeset
|
750 // Clip data between 0 and 1 for float values |
22392
4dfb28724863
Clip double RGB data before passing to gl2psDrawPixels (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22336
diff
changeset
|
751 OCTAVE_LOCAL_BUFFER (float, tmp_data, 3*w*h); |
4dfb28724863
Clip double RGB data before passing to gl2psDrawPixels (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22336
diff
changeset
|
752 |
4dfb28724863
Clip double RGB data before passing to gl2psDrawPixels (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22336
diff
changeset
|
753 for (int i = 0; i < 3*h*w; i++) |
4dfb28724863
Clip double RGB data before passing to gl2psDrawPixels (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22336
diff
changeset
|
754 tmp_data[i] = (data[i] < 0.0f ? 0.0f : (data[i] > 1.0f ? 1.0f : data[i])); |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22396
diff
changeset
|
755 |
22392
4dfb28724863
Clip double RGB data before passing to gl2psDrawPixels (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22336
diff
changeset
|
756 gl2psDrawPixels (w, h, 0, 0, GL_RGB, GL_FLOAT, tmp_data); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
757 } |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
758 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
759 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
760 gl2ps_renderer::draw_pixels (int w, int h, const uint8_t *data) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
761 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
762 // gl2psDrawPixels only supports the GL_FLOAT type. |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
763 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
764 OCTAVE_LOCAL_BUFFER (float, tmp_data, 3*w*h); |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
765 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
766 static const float maxval = std::numeric_limits<float>::max (); |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
767 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
768 for (int i = 0; i < 3*w*h; i++) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
769 tmp_data[i] = data[i] / maxval; |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
770 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
771 draw_pixels (w, h, tmp_data); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
772 } |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
773 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
774 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
775 gl2ps_renderer::draw_pixels (int w, int h, const uint16_t *data) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
776 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
777 // gl2psDrawPixels only supports the GL_FLOAT type. |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
778 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
779 OCTAVE_LOCAL_BUFFER (float, tmp_data, 3*w*h); |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
780 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
781 static const float maxval = std::numeric_limits<float>::max (); |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
782 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
783 for (int i = 0; i < 3*w*h; i++) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
784 tmp_data[i] = data[i] / maxval; |
21353
e4fc19d8c6c3
remove HAVE_OPENGL from public header file
John W. Eaton <jwe@octave.org>
parents:
21341
diff
changeset
|
785 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
786 draw_pixels (w, h, tmp_data); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
787 } |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
788 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
789 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
790 gl2ps_renderer::draw_text (const text::properties& props) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
791 { |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23546
diff
changeset
|
792 if (props.get_string ().isempty ()) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
793 return; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
794 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
795 // First set font properties: freetype will use them to compute |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
796 // coordinates and gl2ps will retrieve the color directly from the |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
797 // feedback buffer |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
798 set_font (props); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
799 set_color (props.get_color_rgb ()); |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
800 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
801 std::string saved_font = fontname; |
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
|
802 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
803 // Alignment |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
804 int halign = 0; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
805 int valign = 0; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
806 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
807 if (props.horizontalalignment_is ("center")) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
808 halign = 1; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
809 else if (props.horizontalalignment_is ("right")) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
810 halign = 2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
811 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
812 if (props.verticalalignment_is ("top")) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
813 valign = 2; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
814 else if (props.verticalalignment_is ("baseline")) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
815 valign = 3; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
816 else if (props.verticalalignment_is ("middle")) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
817 valign = 1; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
818 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
819 // FIXME: handle margin and surrounding box |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
820 // Matrix bbox; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
821 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
822 const Matrix pos = get_transform ().scale (props.get_data_position ()); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
823 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
|
824 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
825 render_text (str, pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
826 halign, valign, props.get_rotation ()); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
827 } |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
828 |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
829 } |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
830 |
21207
945695cafd2b
allow build to succeed with missing dependencies
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
831 #endif |
945695cafd2b
allow build to succeed with missing dependencies
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
832 |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
833 namespace octave |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
834 { |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
835 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
836 // If the name of the stream begins with '|', open a pipe to the command |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
837 // 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
|
838 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
839 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
840 gl2ps_print (const graphics_object& fig, const std::string& stream, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
841 const std::string& term) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
842 { |
22750
dc828d9a7f3a
Fix building gl2ps when --without-opengl is used (bug #47886).
Rik <rik@octave.org>
parents:
22704
diff
changeset
|
843 #if defined (HAVE_GL2PS_H) && defined (HAVE_OPENGL) |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
844 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
845 // FIXME: should we have a way to create a file that begins with the |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
846 // 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
|
847 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
848 bool have_cmd = stream.length () > 1 && stream[0] == '|'; |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
849 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
850 FILE *fp = nullptr; |
19709
5cfb3ccbf24a
style fixes for resource management
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
851 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
852 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
|
853 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
854 if (have_cmd) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
855 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
856 // Create process and pipe gl2ps output to it. |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
857 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
858 std::string cmd = stream.substr (1); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
859 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
860 fp = octave_popen (cmd.c_str (), "w"); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
861 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
862 if (! fp) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
863 error ("print: failed to open pipe \"%s\"", stream.c_str ()); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
864 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
865 frame.add_fcn (safe_pclose, fp); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
866 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
867 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
868 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
869 // Write gl2ps output directly to file. |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
870 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
871 fp = std::fopen (stream.c_str (), "w"); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
872 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
873 if (! fp) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
874 error ("gl2ps_print: failed to create file \"%s\"", stream.c_str ()); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
875 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
876 frame.add_fcn (safe_fclose, fp); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
877 } |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
878 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
879 gl2ps_renderer rend (fp, term); |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
880 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
881 rend.draw (fig, stream); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
882 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
883 // Make sure buffered commands are finished!!! |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
884 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
|
885 |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
886 #else |
22750
dc828d9a7f3a
Fix building gl2ps when --without-opengl is used (bug #47886).
Rik <rik@octave.org>
parents:
22704
diff
changeset
|
887 octave_unused_parameter (fig); |
dc828d9a7f3a
Fix building gl2ps when --without-opengl is used (bug #47886).
Rik <rik@octave.org>
parents:
22704
diff
changeset
|
888 octave_unused_parameter (stream); |
dc828d9a7f3a
Fix building gl2ps when --without-opengl is used (bug #47886).
Rik <rik@octave.org>
parents:
22704
diff
changeset
|
889 octave_unused_parameter (term); |
dc828d9a7f3a
Fix building gl2ps when --without-opengl is used (bug #47886).
Rik <rik@octave.org>
parents:
22704
diff
changeset
|
890 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
891 err_disabled_feature ("gl2ps_print", "gl2ps"); |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
892 #endif |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
893 } |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
894 } |