Mercurial > octave-nkf
comparison scripts/plot/util/private/__opengl_print__.m @ 19674:3b0b4d55002d
rename __fltk_print__.m to __opengl_print__.m
* __opengl_print__.m: Rename from __fltk_print__.m.
* scripts/plot/util/module.mk (plot_util_PRIVATE_FCN_FILES):
Update list.
* print.m: Call __opengl_print__.m instead of __fltk_print__.m.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Jan 2015 17:13:16 -0500 |
parents | scripts/plot/util/private/__fltk_print__.m@0e1f5a750d00 |
children | 4197fc428c7d |
comparison
equal
deleted
inserted
replaced
19673:61cc00ebac60 | 19674:3b0b4d55002d |
---|---|
1 ## Copyright (C) 2010-2013 Shai Ayal | |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} __opengl_print__ (@var{@dots{}}) | |
21 ## Undocumented internal function. | |
22 ## @end deftypefn | |
23 | |
24 function opts = __opengl_print__ (opts) | |
25 | |
26 dos_shell = (ispc () && ! isunix ()); | |
27 | |
28 set (0, "currentfigure", opts.figure); | |
29 drawnow ("expose"); | |
30 | |
31 if (! isempty (opts.fig2dev_binary)) | |
32 ## fig2dev is prefered for conversion to emf | |
33 fig2dev_devices = {"pstex", "mf", "emf"}; | |
34 else | |
35 fig2dev_devices = {"pstex", "mf"}; | |
36 endif | |
37 | |
38 gl2ps_device = {}; | |
39 pipeline = {}; | |
40 switch (lower (opts.devopt)) | |
41 case {"eps", "eps2", "epsc", "epsc2"} | |
42 ## format GL2PS_EPS | |
43 gl2ps_device = {"eps"}; | |
44 ## FIXME: use epstool to tighten bbox and provide preview. | |
45 pipeline = {opts.epstool_cmd(opts, "-", opts.name)}; | |
46 case {"epslatex", "pslatex", "pdflatex", "epslatexstandalone", ... | |
47 "pslatexstandalone", "pdflatexstandalone"} | |
48 ## format GL2PS_TEX | |
49 n = find (opts.devopt == "l", 1); | |
50 suffix = opts.devopt(1:n-1); | |
51 dot = find (opts.name == ".", 1, "last"); | |
52 if ((! isempty (dot)) | |
53 && any (strcmpi (opts.name(dot:end), ... | |
54 {strcat(".", suffix), ".tex", "."}))) | |
55 name = opts.name(1:dot-1); | |
56 if (dot < numel (opts.name) | |
57 && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"}))) | |
58 ## If user provides eps/ps/pdf suffix, use it. | |
59 suffix = opts.name(dot+1:end); | |
60 endif | |
61 else | |
62 error ("print:invalid-suffix", | |
63 "invalid suffix '%s' for device '%s'.", | |
64 opts.name(dot:end), lower (opts.devopt)); | |
65 endif | |
66 gl2ps_device = {sprintf("%snotxt", lower (suffix))}; | |
67 gl2ps_device{2} = "tex"; | |
68 if (dos_shell) | |
69 ## FIXME: this will only work on MinGW with the MSYS shell | |
70 pipeline = {sprintf("cat > %s-inc.%s", name, suffix)}; | |
71 pipeline{2} = sprintf ("cat > %s.tex", name); | |
72 else | |
73 pipeline = {sprintf("cat > %s-inc.%s", name, suffix)}; | |
74 pipeline{2} = sprintf ("cat > %s.tex", name); | |
75 endif | |
76 case "tikz" | |
77 ## format GL2PS_PGF | |
78 gl2ps_device = {"pgf"}; | |
79 pipeline = {sprintf("cat > %s", opts.name)}; | |
80 case "svg" | |
81 ## format GL2PS_SVG | |
82 gl2ps_device = {"svg"}; | |
83 pipeline = {sprintf("cat > %s", opts.name)}; | |
84 case fig2dev_devices | |
85 cmd_pstoedit = opts.pstoedit_cmd (opts, "fig"); | |
86 cmd_fig2dev = opts.fig2dev_cmd (opts, opts.devopt); | |
87 if (strcmp (opts.devopt, "pstex")) | |
88 [~, ~, ext] = fileparts (opts.name); | |
89 if (any (strcmpi (ext, {".ps", ".tex", "."}))) | |
90 opts.name = opts.name(1:end-numel(ext)); | |
91 endif | |
92 opts.name = strcat (opts.name, ".ps"); | |
93 cmd = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, opts.name); | |
94 gl2ps_device = {"eps"}; | |
95 pipeline = {cmd}; | |
96 cmd_fig2dev = opts.fig2dev_cmd (opts, "pstex_t"); | |
97 gl2ps_device{2} = "eps"; | |
98 pipeline{2} = sprintf ("%s | %s > %s", cmd_pstoedit, | |
99 cmd_fig2dev, strrep(opts.name, ".ps", ".tex")); | |
100 else | |
101 cmd = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, opts.name); | |
102 gl2ps_device = {"eps"}; | |
103 pipeline = {cmd}; | |
104 endif | |
105 case "aifm" | |
106 cmd = opts.pstoedit_cmd (opts, "ps2ai"); | |
107 gl2ps_device = {"eps"}; | |
108 pipeline = {sprintf("%s > %s", cmd, opts.name)}; | |
109 case {"dxf", "emf", "fig", "hpgl"} | |
110 cmd = opts.pstoedit_cmd (opts); | |
111 gl2ps_device = {"eps"}; | |
112 pipeline = {sprintf("%s > %s", cmd, opts.name)}; | |
113 case {"corel", "gif"} | |
114 error ("print:unsupporteddevice", | |
115 "print.m: %s output is not available for the FLTK graphics toolkit", | |
116 upper (opts.devopt)); | |
117 case opts.ghostscript.device | |
118 opts.ghostscript.source = "-"; | |
119 opts.ghostscript.output = opts.name; | |
120 if (opts.send_to_printer) | |
121 opts.unlink(strcmp (opts.unlink, opts.ghostscript.output)) = []; | |
122 opts.ghostscript.output = "-"; | |
123 endif | |
124 [cmd_gs, cmd_cleanup] = __ghostscript__ (opts.ghostscript); | |
125 if (opts.send_to_printer || isempty (opts.name)) | |
126 cmd_lpr = opts.lpr_cmd (opts); | |
127 cmd = sprintf ("%s | %s", cmd_gs, cmd_lpr); | |
128 else | |
129 cmd = sprintf ("%s", cmd_gs); | |
130 endif | |
131 if (! isempty (cmd_cleanup)) | |
132 gl2ps_device = {"eps"}; | |
133 if (dos_shell) | |
134 pipeline = {sprintf("%s & %s", cmd, cmd_cleanup)}; | |
135 else | |
136 pipeline = {sprintf("%s ; %s", cmd, cmd_cleanup)}; | |
137 endif | |
138 else | |
139 gl2ps_device = {"eps"}; | |
140 pipeline = {cmd}; | |
141 endif | |
142 otherwise | |
143 error (sprintf ("print:no%soutput", opts.devopt), | |
144 "print.m: %s output is not available for GL2PS output", | |
145 upper (opts.devopt)); | |
146 endswitch | |
147 | |
148 opts.pipeline = pipeline; | |
149 | |
150 ## Tell gl2ps to use different rendering options for 2D plots | |
151 haxes = findall (opts.figure, "type", "axes"); | |
152 vw = get (haxes, "view"); | |
153 if (iscell (vw)) | |
154 vw = vertcat (vw{:}); | |
155 endif | |
156 is2D = all (abs (vw(:,2)) == 90); | |
157 if (is2D) | |
158 gl2ps_device{end} = [gl2ps_device{end}, "is2D"]; | |
159 endif | |
160 | |
161 for n = 1:numel (pipeline) | |
162 if (opts.debug) | |
163 fprintf ("opengl-pipeline: '%s'\n", pipeline{n}); | |
164 endif | |
165 drawnow (gl2ps_device{n}, strcat ('|',pipeline{n})); | |
166 endfor | |
167 | |
168 if (! isempty (strfind (opts.devopt, "standalone"))) | |
169 opts.latex_standalone (opts); | |
170 endif | |
171 | |
172 endfunction | |
173 |