annotate libinterp/corefcn/gl2ps-renderer.cc @ 19697:4197fc428c7d

maint: Update copyright notices for 2015.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Feb 2015 14:19:08 -0500
parents 05b40890bbb2
children 5cfb3ccbf24a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
1 /*
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
3 Copyright (C) 2009-2015 Shai Ayal
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
4
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
5 This file is part of Octave.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
6
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
10 option) any later version.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
11
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
15 for more details.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
16
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
20
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
21 */
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
22
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
24 #include <config.h>
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
19648
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
27 #include "error.h"
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
28 #include "gl2ps-renderer.h"
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
29
17797
06a850f83dd4 build: Remove embedded gl2ps. Require gl2ps as external dependency.
Rik <rik@octave.org>
parents: 17787
diff changeset
30 #ifdef HAVE_GL2PS_H
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
31
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
32 #include <cstdio>
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
33
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
34 #include "lo-mappers.h"
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
35 #include "oct-locbuf.h"
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
36 #include "unwind-prot.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
37
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
38 #include "gl2ps.h"
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
39 #include "sysdep.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
40
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
41 void
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
42 glps_renderer::draw (const graphics_object& go, const std::string print_cmd)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
43 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
44 static bool in_draw = false;
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
45 static std::string old_print_cmd;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
46
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
47 if (!in_draw)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
48 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
49 in_draw = true;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
50
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
51 GLint buffsize = 0;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
52 GLint state = GL2PS_OVERFLOW;
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
53 GLint gl2ps_term;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
54 if (term.find ("eps") != std::string::npos) gl2ps_term = GL2PS_EPS;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
55 else if (term.find ("pdf") != std::string::npos) gl2ps_term = GL2PS_PDF;
18666
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
56 else if (term.find ("ps") != std::string::npos) gl2ps_term = GL2PS_PS;
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
57 else if (term.find ("svg") != std::string::npos) gl2ps_term = GL2PS_SVG;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
58 else if (term.find ("pgf") != std::string::npos) gl2ps_term = GL2PS_PGF;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
59 else if (term.find ("tex") != std::string::npos) gl2ps_term = GL2PS_TEX;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
60 else
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
61 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
62 error ("gl2ps-renderer::draw: Unknown terminal %s", term.c_str ());
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
63 return;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
64 }
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
65
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
66 GLint gl2ps_text = 0;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
67 if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
68
14389
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
69 // Default sort order optimizes for 3D plots
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
70 GLint gl2ps_sort = GL2PS_BSP_SORT;
18666
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
71 // For 2D plots we can use a simpler Z-depth sorting algorithm
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
72 if (term.find ("is2D") != std::string::npos)
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
73 gl2ps_sort = GL2PS_SIMPLE_SORT;
14389
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
74
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
75 while (state == GL2PS_OVERFLOW)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
76 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
77 // For LaTeX output the fltk print process uses 2 drawnow() commands.
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
78 // The first one is for the pdf/ps/eps graph to be included. The
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
79 // print_cmd is saved as old_print_cmd. Then the second drawnow()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
80 // outputs the tex-file and the graphic filename to be included is
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
81 // extracted from old_print_cmd.
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
82 std::string include_graph;
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
83 std::size_t found_redirect = old_print_cmd.find (">");
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
84 if (found_redirect != std::string::npos)
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
85 include_graph = old_print_cmd.substr (found_redirect + 1);
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
86 else
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
87 include_graph = old_print_cmd;
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
88 std::size_t n_begin = include_graph.find_first_not_of (" ");
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
89 if (n_begin != std::string::npos)
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
90 {
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
91 std::size_t n_end = include_graph.find_last_not_of (" ");
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
92 include_graph = include_graph.substr (n_begin,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
93 n_end - n_begin + 1);
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
94 }
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
95 else
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
96 include_graph = "foobar-inc";
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
97 buffsize += 1024*1024;
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
98 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
99 GLint ret = gl2psBeginPage ("glps_renderer figure", "Octave", NULL,
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
100 gl2ps_term, gl2ps_sort,
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
101 ( GL2PS_NO_BLENDING
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
102 | GL2PS_OCCLUSION_CULL
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
103 | GL2PS_BEST_ROOT
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
104 | gl2ps_text
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
105 | GL2PS_NO_PS3_SHADING
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
106 | GL2PS_USE_CURRENT_VIEWPORT),
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
107 GL_RGBA, 0, NULL, 0, 0, 0,
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
108 buffsize, fp, include_graph.c_str ());
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
109 if (ret == GL2PS_ERROR)
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
110 {
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
111 in_draw = 0;
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
112 old_print_cmd.clear ();
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
113 error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
114 return;
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
115 }
16732
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
116 old_print_cmd = print_cmd;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
117 opengl_renderer::draw (go);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
118
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
119 // Without glFinish () there may primitives be missing in the gl2ps output.
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
120 glFinish ();
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
121
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
122 state = gl2psEndPage ();
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
123
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
124 if (state == GL2PS_NO_FEEDBACK)
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
125 {
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
126 warning ("gl2ps-renderer::draw: empty feedback buffer and/or nothing else to print");
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
127 }
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
128 else if (state == GL2PS_ERROR)
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
129 {
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
130 in_draw = 0;
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
131 old_print_cmd.clear ();
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
132 error ("gl2ps-renderer::draw: gl2psEndPage returned GL2PS_ERROR");
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
133 return;
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
134 }
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
135 // Don't check state for GL2PS_UNINITIALIZED (should never happen)
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
136 // GL2PS_OVERFLOW (see while loop) or GL2PS_SUCCESS
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
137 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
138
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
139 in_draw = 0;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
140 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
141 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
142 opengl_renderer::draw (go);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
143 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
144
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
145 int
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
146 glps_renderer::alignment_to_mode (int ha, int va) const
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
147 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
148 int gl2psa=GL2PS_TEXT_BL;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
149 if (ha == 0)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
150 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
151 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
152 gl2psa=GL2PS_TEXT_BL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
153 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
154 gl2psa=GL2PS_TEXT_TL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
155 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
156 gl2psa=GL2PS_TEXT_CL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
157 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
158 else if (ha == 2)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
159 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
160 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
161 gl2psa=GL2PS_TEXT_BR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
162 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
163 gl2psa=GL2PS_TEXT_TR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
164 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
165 gl2psa=GL2PS_TEXT_CR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
166 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
167 else if (ha == 1)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
168 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
169 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
170 gl2psa=GL2PS_TEXT_B;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
171 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
172 gl2psa=GL2PS_TEXT_T;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
173 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
174 gl2psa=GL2PS_TEXT_C;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
175 }
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
176 return gl2psa;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
177 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
178
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
179 Matrix
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
180 glps_renderer::render_text (const std::string& txt,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
181 double x, double y, double z,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
182 int ha, int va, double rotation)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
183 {
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
184 if (txt.empty ())
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
185 return Matrix (1, 4, 0.0);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
186
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
187 glRasterPos3d (x, y, z);
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
188 gl2psTextOpt (txt.c_str (), fontname.c_str (), fontsize,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
189 alignment_to_mode (ha, va), rotation);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
190
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17797
diff changeset
191 // FIXME?
18736
333901476119 maint: Use "FreeType" rather than "freetype" in messages and comments.
Rik <rik@octave.org>
parents: 18703
diff changeset
192 // We have no way of getting a bounding box from gl2ps, so we use FreeType.
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
193 Matrix bbox;
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
194 uint8NDArray pixels;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
195 text_to_pixels (txt, pixels, bbox, 0, 0, rotation);
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
196 return bbox;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
197 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
198
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
199 void
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
200 glps_renderer::set_font (const base_properties& props)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
201 {
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
202 opengl_renderer::set_font (props);
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
203
19047
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18958
diff changeset
204 fontsize = props.get ("fontsize_points").double_value ();
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
205
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
206 caseless_str fn = props.get ("fontname").string_value ();
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
207 fontname = "";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
208 if (fn == "times" || fn == "times-roman")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
209 fontname = "Times-Roman";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
210 else if (fn == "courier")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
211 fontname = "Courier";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
212 else if (fn == "symbol")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
213 fontname = "Symbol";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
214 else if (fn == "zapfdingbats")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
215 fontname = "ZapfDingbats";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
216 else
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
217 fontname = "Helvetica";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
218
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
219 // FIXME: add support for bold and italic
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
220 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
221
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
222 template <typename T>
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
223 static void
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
224 draw_pixels (GLsizei w, GLsizei h, GLenum format, const T *data, float maxval)
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
225 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
226 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
227
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
228 // Convert to GL_FLOAT as it is the only type gl2ps accepts.
18680
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18671
diff changeset
229 for (int i = 0; i < 3*w*h; i++)
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
230 a[i] = data[i] / maxval;
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18659
diff changeset
231
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
232 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
233 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
234
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
235 void
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
236 glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format,
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
237 GLenum type, const GLvoid *data)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
238 {
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
239 // gl2psDrawPixels only supports the GL_FLOAT type.
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
240 // Other formats, such as uint8, must be converted first.
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
241 if (type == GL_UNSIGNED_BYTE)
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
242 ::draw_pixels (w, h, format, static_cast<const GLubyte *> (data), 255.0f);
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
243 else if (type == GL_UNSIGNED_SHORT)
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
244 ::draw_pixels (w, h, format, static_cast<const GLushort *> (data), 65535.0f);
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
245 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
246 gl2psDrawPixels (w, h, 0, 0, format, type, data);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
247 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
248
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
249 void
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
250 glps_renderer::draw_text (const text::properties& props)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
251 {
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
252 if (props.get_string ().is_empty ())
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
253 return;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
254
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
255 set_font (props);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
256 set_color (props.get_color_rgb ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
257
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
258 const Matrix pos = get_transform ().scale (props.get_data_position ());
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
259 int halign = 0;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
260 int valign = 0;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
261
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
262 if (props.horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
263 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
264 else if (props.horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
265 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
266
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
267 if (props.verticalalignment_is ("top"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
268 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
269 else if (props.verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
270 valign = 3;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
271 else if (props.verticalalignment_is ("middle"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
272 valign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
273
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
274 // FIXME: handle margin and surrounding box
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
275
14468
d16638f73691 Modify gl2ps_renderer.cc to properly specificy 2D/3D text object positions.
Konstantinos Poulios <logari81@googlemail.com>
parents: 14418
diff changeset
276 glRasterPos3d (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0);
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
277
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
278 octave_value string_prop = props.get_string ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
279
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
280 string_vector sv = string_prop.all_strings ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
281
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
282 std::string s = sv.join ("\n");
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
283
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12965
diff changeset
284 gl2psTextOpt (s.c_str (), fontname.c_str (), fontsize,
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
285 alignment_to_mode (halign, valign), props.get_rotation ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
286 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
287
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
288 static void
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
289 safe_pclose (FILE *f)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
290 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
291 if (f)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
292 octave_pclose (f);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
293 }
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
294
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
295 #endif
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
296
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
297 void
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
298 gl2ps_print (const graphics_object& fig, const std::string& cmd,
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
299 const std::string& term)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
300 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
301 #ifdef HAVE_GL2PS_H
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
302
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
303 unwind_protect frame;
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
304
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
305 FILE *fp = octave_popen (cmd.c_str (), "w");
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
306
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
307 frame.add_fcn (safe_pclose, fp);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
308
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
309 glps_renderer rend (fp, term);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
310
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
311 rend.draw (fig, cmd);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
312
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
313 #else
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
314
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
315 error ("print: printing not available without gl2ps library");
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
316
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
317 #endif
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
318 }