annotate libinterp/corefcn/gl2ps-renderer.cc @ 19673:61cc00ebac60

move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc * gl2ps-renderer.h, gl2ps-renderer.cc (gl2ps_print): New function. * __init_fltk__.cc (OpenGL_fltk::print): Use it.
author John W. Eaton <jwe@octave.org>
date Thu, 29 Jan 2015 17:07:09 -0500
parents 0e1f5a750d00
children 16f21db320b5
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
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 16892
diff changeset
3 Copyright (C) 2009-2013 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
17797
06a850f83dd4 build: Remove embedded gl2ps. Require gl2ps as external dependency.
Rik <rik@octave.org>
parents: 17787
diff changeset
27 #ifdef HAVE_GL2PS_H
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
28
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
29 #include <cstdio>
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
30
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
31 #include "lo-mappers.h"
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
32 #include "oct-locbuf.h"
19673
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
33 #include "unwind-prot.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
34
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
35 #include "gl2ps-renderer.h"
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
36 #include "gl2ps.h"
19673
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
37 #include "sysdep.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
38
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
39 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
40 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
41 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
42 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
43 static std::string old_print_cmd;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
44
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
45 if (!in_draw)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
46 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
47 in_draw = true;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
48
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
49 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
50 GLint state = GL2PS_OVERFLOW;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
51 GLint viewport[4];
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
52
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
53 glGetIntegerv (GL_VIEWPORT, viewport);
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
54
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
55 GLint gl2ps_term;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
56 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
57 else if (term.find ("pdf") != std::string::npos) gl2ps_term = GL2PS_PDF;
18700
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18099
diff changeset
58 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
59 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
60 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
61 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
62 else
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
63 {
18992
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
64 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
65 return;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
66 }
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
67
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
68 GLint gl2ps_text = 0;
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
69 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
70
14389
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
71 // 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
72 GLint gl2ps_sort = GL2PS_BSP_SORT;
18700
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18099
diff changeset
73 // 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: 18099
diff changeset
74 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: 18099
diff changeset
75 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
76
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
77 while (state == GL2PS_OVERFLOW)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
78 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
79 // 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
80 // 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
81 // 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
82 // 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
83 // 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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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
92 {
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
93 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
94 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
95 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
96 }
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
97 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
98 include_graph = "foobar-inc";
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
99 buffsize += 1024*1024;
18992
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
100 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
101 GLint ret = gl2psBeginPage ("glps_renderer figure", "Octave", viewport,
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
102 gl2ps_term, gl2ps_sort,
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
103 ( GL2PS_NO_BLENDING
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
104 | GL2PS_OCCLUSION_CULL
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
105 | GL2PS_BEST_ROOT
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
106 | gl2ps_text
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
107 | GL2PS_NO_PS3_SHADING),
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
108 GL_RGBA, 0, NULL, 0, 0, 0,
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
109 buffsize, fp, include_graph.c_str ());
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
110 if (ret == GL2PS_ERROR)
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
111 error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
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
112 old_print_cmd = print_cmd;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
113 opengl_renderer::draw (go);
18992
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
114
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
115 // Force execution of GL commands in finite time.
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
116 // Without glFlush () there may primitives be missing in the gl2ps output.
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
117 glFlush ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18770
diff changeset
118
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
119 state = gl2psEndPage ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
120 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
121
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
122 in_draw = 0;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
123 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
124 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
125 opengl_renderer::draw (go);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
126 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
127
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
128 int
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
129 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
130 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
131 int gl2psa=GL2PS_TEXT_BL;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
132 if (ha == 0)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
133 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
134 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
135 gl2psa=GL2PS_TEXT_BL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
136 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
137 gl2psa=GL2PS_TEXT_TL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
138 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
139 gl2psa=GL2PS_TEXT_CL;
9798
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 if (ha == 2)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
142 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
143 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
144 gl2psa=GL2PS_TEXT_BR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
145 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
146 gl2psa=GL2PS_TEXT_TR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
147 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
148 gl2psa=GL2PS_TEXT_CR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
149 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
150 else if (ha == 1)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
151 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
152 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
153 gl2psa=GL2PS_TEXT_B;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
154 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
155 gl2psa=GL2PS_TEXT_T;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
156 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
157 gl2psa=GL2PS_TEXT_C;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
158 }
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
159 return gl2psa;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
160 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
161
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
162 Matrix
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
163 glps_renderer::render_text (const std::string& txt,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
164 double x, double y, double z,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
165 int ha, int va, double rotation)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
166 {
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
167 if (txt.empty ())
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
168 return Matrix (1, 4, 0.0);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
169
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
170 glRasterPos3d (x, y, z);
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
171 gl2psTextOpt (txt.c_str (), fontname.c_str (), fontsize,
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
172 alignment_to_mode (ha, va), rotation);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
173
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17797
diff changeset
174 // FIXME?
18770
333901476119 maint: Use "FreeType" rather than "freetype" in messages and comments.
Rik <rik@octave.org>
parents: 18733
diff changeset
175 // 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
176 Matrix bbox;
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
177 uint8NDArray pixels;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
178 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
179 return bbox;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
180 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
181
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
182 void
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
183 glps_renderer::set_font (const base_properties& props)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
184 {
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
185 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
186
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18992
diff changeset
187 fontsize = props.get ("fontsize_points").double_value ();
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
188
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
189 caseless_str fn = props.get ("fontname").string_value ();
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
190 fontname = "";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
191 if (fn == "times" || fn == "times-roman")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
192 fontname = "Times-Roman";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
193 else if (fn == "courier")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
194 fontname = "Courier";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
195 else if (fn == "symbol")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
196 fontname = "Symbol";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
197 else if (fn == "zapfdingbats")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
198 fontname = "ZapfDingbats";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
199 else
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
200 fontname = "Helvetica";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
201
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
202 // FIXME: add support for bold and italic
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
203 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
204
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
205 template <typename T>
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
206 static void
18693
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
207 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
208 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
209 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
210
18693
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
211 // Convert to GL_FLOAT as it is the only type gl2ps accepts.
18714
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18705
diff changeset
212 for (int i = 0; i < 3*w*h; i++)
18693
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
213 a[i] = data[i] / maxval;
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18693
diff changeset
214
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
215 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
216 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
217
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
218 void
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
219 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
220 GLenum type, const GLvoid *data)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
221 {
18693
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
222 // 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
223 // 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
224 if (type == GL_UNSIGNED_BYTE)
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
225 ::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
226 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
227 ::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
228 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
229 gl2psDrawPixels (w, h, 0, 0, format, type, data);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
230 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
231
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
232 void
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
233 glps_renderer::draw_text (const text::properties& props)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
234 {
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
235 if (props.get_string ().is_empty ())
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
236 return;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
237
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
238 set_font (props);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
239 set_color (props.get_color_rgb ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
240
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
241 const Matrix pos = get_transform ().scale (props.get_data_position ());
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
242 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
243 int valign = 0;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
244
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
245 if (props.horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
246 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
247 else if (props.horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
248 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
249
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
250 if (props.verticalalignment_is ("top"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
251 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
252 else if (props.verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
253 valign = 3;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
254 else if (props.verticalalignment_is ("middle"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
255 valign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
256
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
257 // FIXME: handle margin and surrounding box
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
258
14468
d16638f73691 Modify gl2ps_renderer.cc to properly specificy 2D/3D text object positions.
Konstantinos Poulios <logari81@googlemail.com>
parents: 14418
diff changeset
259 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
260
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
261 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
262
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
263 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
264
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12322
diff changeset
265 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
266
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12965
diff changeset
267 gl2psTextOpt (s.c_str (), fontname.c_str (), fontsize,
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
268 alignment_to_mode (halign, valign), props.get_rotation ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
269 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
270
19673
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
271 static void
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
272 safe_pclose (FILE *f)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
273 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
274 if (f)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
275 octave_pclose (f);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
276 }
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
277
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
278 #endif
19673
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
279
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
280 void
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
281 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: 19630
diff changeset
282 const std::string& term)
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
283 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
284 #ifdef HAVE_GL2PS_H
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
285
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
286 unwind_protect frame;
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
287
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
288 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: 19630
diff changeset
289
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
290 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: 19630
diff changeset
291
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
292 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: 19630
diff changeset
293
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
294 rend.draw (fig, cmd);
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
295
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
296 #else
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
297
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
298 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: 19630
diff changeset
299
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
300 #endif
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
301 }