Mercurial > octave-nkf
annotate scripts/plot/__fltk_print__.m @ 10913:dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 27 Aug 2010 06:39:36 -0400 |
parents | d19d2abdd65f |
children | ee9d74048827 |
rev | line source |
---|---|
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
1 ## Copyright (C) 2010 Shai Ayal |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
2 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
4 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
8 ## your option) any later version. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
9 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
13 ## General Public License for more details. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
14 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
18 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10727
diff
changeset
|
20 ## @deftypefn {Function File} {} __fltk_print__ (@var{@dots{}}) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
21 ## Undocumented internal function. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
22 ## @end deftypefn |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
23 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
24 function __fltk_print__ (opts) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
25 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
26 figure (opts.figure) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
27 drawnow ("expose") |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
28 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
29 file2unlink = ""; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
30 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
31 if (! isempty (opts.fig2dev_binary)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
32 fig2dev_devices = {"pstex", "mf", "emf"}; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
33 else |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
34 ## If no fig2dev is present, support emf using pstoedit. |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
35 fig2dev_devices = {"pstex", "mf"}; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
36 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
37 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
38 unwind_protect |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
39 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
40 switch lower (opts.devopt) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
41 case {"eps", "eps2", "epsc", "epsc2"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
42 drawnow ("eps", opts.name); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
43 if (opts.tight_flag) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
44 __tight_eps_bbox__ (opts, opts.name); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
45 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
46 case {"epslatex", "pslatex", "pdflatex", "epslatexstandalone", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
47 "pslatexstandalone", "pdflatexstandalone"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
48 ## format GL2PS_TEX |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
49 n = find (opts.devopt == "l", 1); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
50 suffix = opts.devopt(1:n-1); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
51 dot = find (opts.name == ".", 1, "last"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
52 if ((! isempty (dot)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
53 && any (strcmpi (opts.name(dot:end), {".eps", ".ps", ".pdf", ".tex", "."}))) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
54 name = opts.name(1:dot-1); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
55 if (dot < numel (opts.name) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
56 && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"}))) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
57 ## If user provides eps/ps/pdf suffix, use it. |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
58 suffix = opts.name(dot+1:end); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
59 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
60 elseif (dot == numel (opts.name)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
61 name = opts.name; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
62 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
63 drawnow (strcat (lower (suffix), "notxt"), strcat (name, ".", suffix)); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
64 drawnow ("tex", strcat (name, ".", suffix, ".tex")); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
65 movefile (strcat (name, ".", suffix, ".tex"), strcat (name, ".tex")); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
66 if (opts.tight_flag && strncmpi (opts.devopt, "eps", 3)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
67 __tight_eps_bbox__ (opts, strcat (opts.name, ".eps")); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
68 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
69 if (! isempty (strfind (opts.devopt, "standalone"))) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
70 __latex_standalone__ (strcat (name, ".tex")); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
71 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
72 case {"tikz"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
73 ## format GL2PS_PGF |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
74 drawnow ("pgf", opts.name); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
75 case {"ps", "ps2", "psc", "psc2", "pdf"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
76 opts.ghostscript.source = strcat (tmpnam (), ".eps"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
77 file2unlink = opts.ghostscript.source; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
78 if (strcmp (opts.devopt, "pdf")) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
79 opts.ghostscript.device = "pdfwrite"; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
80 elseif (any (opts.devopt == '2')) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
81 opts.ghostscript.device = "ps2write"; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
82 else |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
83 opts.ghostscript.device = "pswrite"; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
84 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
85 opts.ghostscript.output = opts.name; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
86 drawnow ("eps", opts.ghostscript.source); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
87 if (opts.tight_flag) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
88 __tight_eps_bbox__ (opts, opts.ghostscript.source); |
10861 | 89 endif |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
90 case {"svg"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
91 ## format GL2PS_SVG |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
92 drawnow ("svg", opts.name); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
93 case gs_based_devices () |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
94 opts.ghostscript.antialiasing = true; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
95 switch opts.devopt |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
96 case "bmp" |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
97 opts.ghostscript.device = "bmp32b"; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
98 case "png" |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
99 opts.ghostscript.device = "png16m"; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
100 case {"tiff", "tiffn"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
101 opts.ghostscript.device = "tiff24nc"; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
102 otherwise |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
103 opts.ghostscript.device = opts.devopt; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
104 endswitch |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
105 opts.ghostscript.output = opts.name; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
106 opts.ghostscript.source = strcat (tmpnam (), ".eps"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
107 opts.ghostscript.epscrop = true; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
108 file2unlink = opts.ghostscript.source; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
109 drawnow ("eps", opts.ghostscript.source) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
110 if (opts.tight_flag) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
111 __tight_eps_bbox__ (opts, opts.ghostscript.source); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
112 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
113 case fig2dev_devices |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
114 tmp_figfile = strcat (tmpnam (), ".fig"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
115 file2unlink = tmp_figfile; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
116 status = __pstoedit__ (opts, "fig", tmp_figfile); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
117 if (status == 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
118 status = __fig2dev__ (opts, tmp_figfile); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
119 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
120 case {"aifm", "dxf", "emf", "fig", "hpgl"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
121 status = __pstoedit__ (opts); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
122 case {"corel", "gif"} |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
123 error ("print:unsupporteddevice", |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
124 "print.m: %s output is not available for the FLTK backend.", |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
125 upper (opts.devopt)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
126 otherwise |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
127 ## various ghostscript devices for printers |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
128 opts.ghostscript.device = opts.devopt; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
129 opts.ghostscript.output = opts.name; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
130 opts.ghostscript.epscrop = false; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
131 opts.ghostscript.source = strcat (tmpnam (), ".eps"); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
132 file2unlink = opts.ghostscript.source; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
133 ## Empirical observatin: "-dpxlcolor" requires a sign change. |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
134 opts.ghostscript.pageoffset = opts.ghostscript.pageoffset .* [1, -1]; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
135 drawnow ("eps", opts.ghostscript.source) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
136 if (opts.tight_flag) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
137 __tight_eps_bbox__ (opts, opts.ghostscript.source); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
138 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
139 endswitch |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
140 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
141 if (! isempty (opts.ghostscript.device)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
142 status = __ghostscript__ (opts.ghostscript); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
143 endif |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
144 |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
145 unwind_protect_cleanup |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
146 if (! isempty (file2unlink)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
147 [status, output] = unlink (file2unlink); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
148 if (status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
149 warning ("print.m: %s, '%s'.", output, file2unlink) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
150 endif |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
151 endif |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
152 end_unwind_protect |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
153 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
154 endfunction |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
155 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
156 function status = __fig2dev__ (opts, figfile, devopt, devfile) |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
157 persistent warn_on_absence = true |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
158 if (nargin < 4) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
159 devfile = opts.name; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
160 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
161 if (nargin < 3) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
162 devopt = opts.devopt; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
163 endif |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
164 if (! isempty (opts.fig2dev_binary)) |
10864
d19d2abdd65f
__fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
165 cmd = sprintf ("%s -L %s %s %s 2>&1", opts.fig2dev_binary, devopt, |
d19d2abdd65f
__fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
166 figfile, devfile); |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
167 [status, output] = system (cmd); |
10864
d19d2abdd65f
__fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
168 if (opts.debug || status != 0) |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
169 fprintf ("fig2dev command: %s", cmd) |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
170 endif |
10864
d19d2abdd65f
__fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
171 if (status != 0) |
d19d2abdd65f
__fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
172 disp (output) |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
173 warning ("print:fig2devfailed", "print.m: error running fig2dev.") |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
174 endif |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
175 elseif (isempty (opts.fig2dev_binary) && warn_on_absence) |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
176 warning ("print:nofig2dev", "print.m: 'fig2dev' not found in EXEC_PATH.") |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
177 warn_on_absence = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
178 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
179 endfunction |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
180 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
181 function status = __pstoedit__ (opts, devopt, name) |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
182 persistent warn_on_absence = true |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
183 if (nargin < 3) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
184 name = opts.name; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
185 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
186 if (nargin < 2) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
187 devopt = opts.devopt; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
188 endif |
10864
d19d2abdd65f
__fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
189 if (! isempty (opts.pstoedit_binary)) |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
190 tmp_epsfile = strcat (tmpnam (), ".eps"); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
191 unwind_protect |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
192 drawnow ("eps", tmp_epsfile) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
193 if (opts.tight_flag) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
194 __tight_eps_bbox__ (opts, tmp_epsfile); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
195 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
196 cmd = sprintf ("%s -f %s %s %s 2>&1", opts.pstoedit_binary, devopt, |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
197 tmp_epsfile, name); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
198 [status, output] = system (cmd); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
199 if (opts.debug || status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
200 fprintf ("pstoedit command: %s", cmd) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
201 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
202 if (status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
203 disp (output) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
204 warning ("print:pstoeditfailed", "print.m: error running pstoedit.") |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
205 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
206 unwind_protect_cleanup |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
207 [status, output] = unlink (tmp_epsfile); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
208 if (status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
209 warning ("print.m: %s, '%s'.", output, tmp_epsfile) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
210 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
211 end_unwind_protect |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
212 elseif (isempty (opts.pstoedit_binary) && warn_on_absence) |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
213 warning ("print:nopstoedit", "print.m: 'pstoedit' not found in EXEC_PATH.") |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
214 warn_on_absence = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
215 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
216 endfunction |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
217 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
218 function __latex_standalone__ (latexfile) |
10861 | 219 prepend = {"\\documentclass{minimal}"; |
220 "\\usepackage{epsfig,color}"; | |
221 "\\begin{document}"; | |
222 "\\centering"}; | |
223 postpend = {"\\end{document}"}; | |
224 fid = fopen (latexfile, "r"); | |
225 if (fid >= 0) | |
226 latex = fscanf (fid, "%c", Inf); | |
227 status = fclose (fid); | |
228 if (status != 0) | |
229 error ("print:errorclosingfile", | |
230 "print.m: error closing file '%s'", latexfile) | |
231 endif | |
232 else | |
233 error ("print:erroropeningfile", | |
234 "print.m: error opening file '%s'", latexfile) | |
235 endif | |
236 fid = fopen (latexfile, "w"); | |
237 if (fid >= 0) | |
238 fprintf (fid, "%s\n", prepend{:}); | |
239 fprintf (fid, "%s", latex); | |
240 fprintf (fid, "%s\n", postpend{:}); | |
241 status = fclose (fid); | |
242 if (status != 0) | |
243 error ("print:errorclosingfile", | |
244 "print.m: error closing file '%s'", latexfile) | |
245 endif | |
246 else | |
247 error ("print:erroropeningfile", | |
248 "print.m: error opening file '%s'", latexfile) | |
249 endif | |
250 endfunction | |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
251 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
252 function device_list = gs_based_devices (); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
253 device_list = {"bmp16", "bmp16m", "bmp256", "bmp32b", "bmpgray", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
254 "jpeg", "jpegcymk", "jpeggray", "pbm", "pbmraw", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
255 "pcx16", "pcx24b", "pcx256", "pcx2up", "pcxcmyk", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
256 "pcxgray", "pcxmono", "pdfwrite", "pgm", "pgmraw", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
257 "pgnm", "pgnmraw", "png16", "png16m", "png256", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
258 "png48", "pngalpha", "pnggray", "pngmono", "pnm", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
259 "pnmraw", "ppm", "ppmraw", "ps2write", "pswrite", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
260 "tiff12nc", "tiff24nc", "tiff32nc", "tiffcrle", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
261 "tiffg3", "tiffg32d", "tiffg4", "tiffgray", "tifflzw", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
262 "tiffpack", "tiffsep", "bmp", "png", "tiff", "tiffn", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
263 "pdf", "ps", "psc", "ps2", "psc2"}; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
264 endfunction |
10861 | 265 |