Mercurial > hg > octave-lyh
annotate scripts/plot/__gnuplot_print__.m @ 11589:b0084095098e
missing semicolons in script files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 18:26:09 -0500 |
parents | d5bd2766c640 |
children |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1999-2011 Daniel Heiserer |
5361 | 2 ## Copyright (C) 2001 Laurent Mazet |
3 ## | |
5362 | 4 ## This file is part of Octave. |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
5362 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
5361 | 15 ## |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
5361 | 19 |
20 ## -*- texinfo -*- | |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
21 ## @deftypefn {Function File} {} __gnuplot_print__ (@var{@dots{}}) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
22 ## Undocumented internal function. |
5361 | 23 ## @end deftypefn |
24 | |
25 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | |
5362 | 26 ## Adapted-By: jwe |
5361 | 27 |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
28 function opts = __gnuplot_print__ (opts) |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
29 |
11009 | 30 dos_shell = (ispc () && ! isunix ()); |
31 | |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
32 if (isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
33 ## If no fontsize, determine the nominal axes fontsize. |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
34 defaultfontsize = get (0, "defaultaxesfontsize"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
35 axesfontsize = get (findobj (opts.figure, "type", "axes"), "fontsize"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
36 if (iscell (axesfontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
37 axesfontsize = round (median (cell2mat (axesfontsize))); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
38 endif |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
39 if (isempty (axesfontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
40 opts.fontsize = defaultfontsize; |
5361 | 41 else |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
42 opts.fontsize = axesfontsize; |
5361 | 43 endif |
11113
a8ac114ec9ab
Stylefixes, replace end by endif.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
11009
diff
changeset
|
44 endif |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
45 ## The axes-label and tick-label spacing is determined by |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
46 ## the font spec given in "set terminal ..." |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
47 gp_opts = font_spec (opts); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
48 |
11009 | 49 pipeline = ""; |
50 | |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
51 switch (lower (opts.devopt)) |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
52 case {"eps", "eps2", "epsc", "epsc2"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
53 if (any (strcmp (opts.devopt, {"eps", "epsc"}))) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
54 gp_opts = sprintf ("%s level1", gp_opts); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
55 endif |
11009 | 56 if (opts.tight_flag || ! isempty (opts.preview)) |
57 tmp_file = strcat (tmpnam (), ".eps"); | |
58 eps_drawnow (opts, tmp_file, gp_opts); | |
59 if (dos_shell) | |
11252
d048ce3f7cef
Replace "delete" with "del" in DOS shell commands.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11120
diff
changeset
|
60 cleanup = sprintf (" & del %s", strrep (tmp_file, '/', '\')); |
11009 | 61 else |
62 cleanup = sprintf (" ; rm %s", tmp_file); | |
63 endif | |
64 pipeline = {sprintf("%s %s", | |
65 opts.epstool_cmd (opts, tmp_file, opts.name), | |
66 cleanup)}; | |
67 else | |
68 eps_drawnow (opts, opts.name, gp_opts); | |
69 endif | |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
70 case {"epslatex", "pslatex", "pstex", "epslatexstandalone"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
71 dot = find (opts.name == ".", 1, "last"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
72 if ((! isempty (dot)) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
73 && any (strcmpi (opts.name(dot:end), |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
74 {".eps", ".ps", ".pdf", ".tex", "."}))) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
75 name = opts.name(1:dot-1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
76 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
77 if (strfind (opts.devopt, "standalone")) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
78 term = sprintf ("%s ", |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
79 strrep (opts.devopt, "standalone", " standalone")); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
80 else |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
81 term = sprintf ("%s ", opts.devopt); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
82 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
83 if (__gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
84 suffix = "tex"; |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
85 else |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
86 %% Gnuplot 4.0 wants a ".eps" suffix. |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
87 suffix = "eps"; |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
88 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
89 local_drawnow (sprintf ("%s %s", term, gp_opts), |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
90 strcat (name, ".", suffix), opts); |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
91 case "tikz" |
11009 | 92 if (__gnuplot_has_terminal__ ("tikz")) |
93 local_drawnow (sprintf ("lua tikz %s", gp_opts), opts.name, opts); | |
94 else | |
95 error (sprintf ("print:no%soutput", opts.devopt), | |
11588
d5bd2766c640
style fixes for warning and error messages in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
96 "print.m: '%s' output is not available for gnuplot-%s", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
97 upper (opts.devopt), __gnuplot_version__ ()); |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
98 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
99 case "svg" |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
100 local_drawnow (sprintf ("svg dynamic %s", gp_opts), opts.name, opts); |
11009 | 101 case {"aifm", "corel", "eepic", "emf", "fig"} |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
102 local_drawnow (sprintf ("%s %s", opts.devopt, gp_opts), opts.name, opts); |
11009 | 103 case {"pdfcairo", "pngcairo"} |
104 if (__gnuplot_has_terminal__ (opts.devopt)) | |
105 local_drawnow (sprintf ("%s %s", opts.devopt, gp_opts), opts.name, opts); | |
106 else | |
107 error (sprintf ("print:no%soutput", opts.devopt), | |
11588
d5bd2766c640
style fixes for warning and error messages in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
108 "print.m: '%s' output is not available for gnuplot-%s", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
109 upper (opts.devopt), __gnuplot_version__ ()); |
11009 | 110 endif |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
111 case {"canvas", "dxf", "hpgl", "mf", "gif", "pstricks", "texdraw"} |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
112 local_drawnow (sprintf ("%s %s", opts.devopt, gp_opts), opts.name, opts); |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
113 case opts.ghostscript.device |
11009 | 114 gp_opts = font_spec (opts, "devopt", "eps"); |
115 opts.ghostscript.output = opts.name; | |
116 opts.ghostscript.source = strcat (tmpnam (), ".eps"); | |
117 eps_drawnow (opts, opts.ghostscript.source, gp_opts); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
118 [cmd_gs, cmd_cleanup] = __ghostscript__ (opts.ghostscript); |
11009 | 119 if (opts.send_to_printer || isempty (opts.name)) |
120 cmd_lpr = opts.lpr_cmd (opts); | |
121 cmd = sprintf ("%s | %s", cmd_gs, cmd_lpr); | |
122 else | |
123 cmd = sprintf ("%s", cmd_gs); | |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
124 endif |
11009 | 125 if (dos_shell) |
11252
d048ce3f7cef
Replace "delete" with "del" in DOS shell commands.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11120
diff
changeset
|
126 cmd = sprintf ("%s & del %s", cmd, strrep (opts.ghostscript.source, '/', '\')); |
11009 | 127 else |
128 cmd = sprintf ("%s ; rm %s", cmd, opts.ghostscript.source); | |
129 endif | |
130 if (! isempty (cmd_cleanup)) | |
131 if (dos_shell) | |
132 pipeline = {sprintf("%s & %s", cmd, cmd_cleanup)}; | |
133 else | |
134 pipeline = {sprintf("%s ; %s", cmd, cmd_cleanup)}; | |
135 endif | |
136 else | |
137 pipeline = {cmd}; | |
138 endif | |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
139 otherwise |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
140 error (sprintf ("print:no%soutput", opts.devopt), |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
141 "print.m: %s output is not available for the Gnuplot graphics toolkit", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
142 upper (opts.devopt)); |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
143 endswitch |
5363 | 144 |
11009 | 145 |
146 opts.pipeline = pipeline; | |
147 | |
148 for n = 1:numel(pipeline) | |
149 if (opts.debug) | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
150 fprintf ("gnuplot-pipeline: '%s'\n", pipeline{n}); |
11009 | 151 endif |
152 [status, output] = system (pipeline{n}); | |
153 if (status) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
154 fprintf ("%s\n%s\n%s\n", |
11009 | 155 "---------- output begin ----------", |
156 output, | |
157 "----------- output end -----------"); | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
158 error ("gnuplot:failedpipe", "print: failed to print"); |
11009 | 159 endif |
160 endfor | |
161 | |
5361 | 162 endfunction |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
163 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
164 function eps_drawnow (opts, epsfile, gp_opts) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
165 [h, fontsize] = get_figure_text_objs (opts); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
166 unwind_protect |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
167 for n = 1:numel(h) |
10915
2a25f282e965
__gnuplot_print__.m: Properly restore fontsize after eps output.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
168 set (h(n), "fontsize", 2 * fontsize{n}); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
169 endfor |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
170 local_drawnow (sprintf ("postscript eps %s", gp_opts), epsfile, opts); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
171 unwind_protect_cleanup |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
172 for n = 1:numel(h) |
10915
2a25f282e965
__gnuplot_print__.m: Properly restore fontsize after eps output.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
173 set (h(n), "fontsize", fontsize{n}); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
174 endfor |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
175 end_unwind_protect |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
176 endfunction |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
177 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
178 function local_drawnow (term, file, opts) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
179 if (opts.use_color < 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
180 mono = true; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
181 else |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
182 mono = false; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
183 endif |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
184 figure (opts.figure); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
185 if (isempty (opts.debug_file) || ! opts.debug) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
186 drawnow (term, file, mono); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
187 else |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
188 drawnow (term, file, mono, opts.debug_file); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
189 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
190 endfunction |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
191 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
192 function f = font_spec (opts, varargin) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
193 for n = 1:2:numel(varargin) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
194 opts.(varargin{n}) = varargin{n+1}; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
195 endfor |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
196 f = ""; |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
197 switch (opts.devopt) |
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
198 case "cgm" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
199 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
200 f = sprintf ("font ""%s,%d""", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
201 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
202 f = sprintf ("font ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
203 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
204 f = sprintf ("%d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
205 endif |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10915
diff
changeset
|
206 case {"eps", "eps2", "epsc", "epsc2"} |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
207 ## Gnuplot renders fonts as half their specification, which |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
208 ## results in a tight spacing for the axes-labels and tick-labels. |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
209 ## Compensate for the half scale. This will produce the proper |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
210 ## spacing for the requested fontsize. |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
211 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
212 f = sprintf ("font ""%s,%d""", opts.font, 2 * opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
213 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
214 f = sprintf ("font ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
215 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
216 f = sprintf ("%d", 2 * opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
217 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
218 case "svg" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
219 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
220 fontsize = round (opts.fontsize * 0.75); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
221 f = sprintf ("fname ""%s"" fsize %d", opts.font, fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
222 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
223 f = sprintf ("fname ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
224 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
225 fontsize = round (opts.fontsize * 0.75); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
226 f = sprintf ("%s fsize %d", f, fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
227 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
228 case "pdf" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
229 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
230 f = sprintf ("font ""%s,%d""", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
231 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
232 f = sprintf ("font ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
233 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
234 f = sprintf ("fsize %d", f, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
235 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
236 case {"pdfcairo", "pngcairo"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
237 if (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
238 f = sprintf ("font ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
239 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
240 case {"epslatex", "epslatexstandalone"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
241 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
242 f = sprintf ("font ""%s,%d""", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
243 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
244 f = sprintf ("font ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
245 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
246 f = sprintf ("%d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
247 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
248 case "pslatex" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
249 if (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
250 f = sprintf ("%d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
251 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
252 case {"gif", "jpeg", "png"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
253 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
254 f = sprintf ("font ""%s ,%d""", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
255 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
256 f = sprintf ("font ""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
257 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
258 f = sprintf ("font ""%d""", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
259 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
260 case "emf" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
261 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
262 f = sprintf ("""%s"" %d", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
263 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
264 f = sprintf ("""%s""", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
265 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
266 f = sprintf ("%d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
267 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
268 case "canvas" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
269 if (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
270 f = sprintf ("fsize %d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
271 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
272 case {"aifm", "corel"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
273 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
274 f = sprintf ("%s %d", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
275 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
276 f = sprintf ("%s", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
277 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
278 f = sprintf ("%d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
279 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
280 case "fig" |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
281 if (! isempty (opts.font) && ! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
282 f = sprintf ("font %s fontsize %d", opts.font, opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
283 elseif (! isempty (opts.font)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
284 f = sprintf ("font %s", opts.font); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
285 elseif (! isempty (opts.fontsize)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
286 f = sprintf ("fontsize %d", opts.fontsize); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
287 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
288 endswitch |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
289 endfunction |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
290 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
291 function [h, fontsize] = get_figure_text_objs (opts) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
292 h = findall (opts.figure, "-property", "fontsize"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
293 fontsize = get (h, "fontsize"); |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11113
diff
changeset
|
294 switch (numel (fontsize)) |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
295 case 0 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
296 fontsize = {}; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
297 case 1 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
298 fontsize = {fontsize}; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
299 endswitch |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10854
diff
changeset
|
300 endfunction |