Mercurial > hg > octave-nkf
annotate scripts/plot/__fltk_print__.m @ 10954:ee9d74048827
Consolidate gs code into print.m.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 08 Sep 2010 18:15:28 -0400 |
parents | dd6b90f44ae5 |
children | 064aaf82222f |
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 |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
24 function opts = __fltk_print__ (opts) |
10834
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 if (! isempty (opts.fig2dev_binary)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
30 fig2dev_devices = {"pstex", "mf", "emf"}; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
31 else |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
32 ## 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
|
33 fig2dev_devices = {"pstex", "mf"}; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
34 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
35 |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
36 switch lower (opts.devopt) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
37 case {"eps", "eps2", "epsc", "epsc2"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
38 drawnow ("eps", opts.name); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
39 if (opts.tight_flag) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
40 __tight_eps_bbox__ (opts, opts.name); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
41 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
42 case {"epslatex", "pslatex", "pdflatex", "epslatexstandalone", ... |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
43 "pslatexstandalone", "pdflatexstandalone"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
44 ## format GL2PS_TEX |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
45 n = find (opts.devopt == "l", 1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
46 suffix = opts.devopt(1:n-1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
47 dot = find (opts.name == ".", 1, "last"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
48 if ((! isempty (dot)) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
49 && any (strcmpi (opts.name(dot:end), ... |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
50 {".eps", ".ps", ".pdf", ".tex", "."}))) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
51 name = opts.name(1:dot-1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
52 if (dot < numel (opts.name) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
53 && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"}))) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
54 ## If user provides eps/ps/pdf suffix, use it. |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
55 suffix = opts.name(dot+1:end); |
10861 | 56 endif |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
57 elseif (dot == numel (opts.name)) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
58 name = opts.name; |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
59 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
60 drawnow (strcat (lower (suffix), "notxt"), strcat (name, ".", suffix)); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
61 drawnow ("tex", strcat (name, ".tex")); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
62 if (opts.tight_flag && strcmp (suffix, "eps")) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
63 __tight_eps_bbox__ (opts, strcat (name, ".", suffix)); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
64 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
65 if (! isempty (strfind (opts.devopt, "standalone"))) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
66 __latex_standalone__ (strcat (name, ".tex")); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
67 endif |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
68 case {"tikz"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
69 ## format GL2PS_PGF |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
70 drawnow ("pgf", opts.name); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
71 case {"svg"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
72 ## format GL2PS_SVG |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
73 drawnow ("svg", opts.name); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
74 case fig2dev_devices |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
75 tmp_figfile = strcat (tmpnam (), ".fig"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
76 opts.unlink{end+1} = tmp_figfile; |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
77 status = __pstoedit__ (opts, "fig", tmp_figfile); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
78 if (status == 0) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
79 status = __fig2dev__ (opts, tmp_figfile); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
80 if (strcmp (opts.devopt, "pstex") && status == 0) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
81 if (strfind (opts.name, ".ps") == numel(opts.name) - 2) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
82 devfile = strcat (opts.name(1:end-2), "tex"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
83 else |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
84 devfile = strcat (opts.name, ".tex"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
85 endif |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
86 status = __fig2dev__ (opts, tmp_figfile, "pstex_t", devfile); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
87 endif |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
88 endif |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
89 case {"aifm"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
90 status = __pstoedit__ (opts, "ps2ai"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
91 case {"dxf", "emf", "fig", "hpgl"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
92 status = __pstoedit__ (opts); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
93 case {"corel", "gif"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
94 error ("print:unsupporteddevice", |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
95 "print.m: %s output is not available for the FLTK backend.", |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
96 upper (opts.devopt)) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
97 case opts.ghostscript.device |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
98 drawnow ("eps", opts.ghostscript.source); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
99 endswitch |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
100 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
101 endfunction |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
102 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
103 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
|
104 persistent warn_on_absence = true |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
105 if (nargin < 4) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
106 devfile = opts.name; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
107 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
108 if (nargin < 3) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
109 devopt = opts.devopt; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
110 endif |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
111 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
|
112 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
|
113 figfile, devfile); |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
114 [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
|
115 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
|
116 fprintf ("fig2dev command: %s", cmd) |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
117 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
|
118 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
|
119 disp (output) |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
120 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
|
121 endif |
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
122 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
|
123 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
|
124 warn_on_absence = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
125 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
126 endfunction |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
127 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
128 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
|
129 persistent warn_on_absence = true |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
130 if (nargin < 3) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
131 name = opts.name; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
132 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
133 if (nargin < 2) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
134 devopt = opts.devopt; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
135 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
|
136 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
|
137 tmp_epsfile = strcat (tmpnam (), ".eps"); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
138 unwind_protect |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
139 drawnow ("eps", tmp_epsfile) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
140 if (opts.tight_flag) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
141 __tight_eps_bbox__ (opts, tmp_epsfile); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
142 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
143 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
|
144 tmp_epsfile, name); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
145 [status, output] = system (cmd); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
146 if (opts.debug || status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
147 fprintf ("pstoedit command: %s", cmd) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
148 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
149 if (status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
150 disp (output) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
151 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
|
152 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
153 unwind_protect_cleanup |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
154 [status, output] = unlink (tmp_epsfile); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
155 if (status != 0) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
156 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
|
157 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
158 end_unwind_protect |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
159 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
|
160 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
|
161 warn_on_absence = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
162 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
163 endfunction |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
164 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
165 function __latex_standalone__ (latexfile) |
10861 | 166 prepend = {"\\documentclass{minimal}"; |
167 "\\usepackage{epsfig,color}"; | |
168 "\\begin{document}"; | |
169 "\\centering"}; | |
170 postpend = {"\\end{document}"}; | |
171 fid = fopen (latexfile, "r"); | |
172 if (fid >= 0) | |
173 latex = fscanf (fid, "%c", Inf); | |
174 status = fclose (fid); | |
175 if (status != 0) | |
176 error ("print:errorclosingfile", | |
177 "print.m: error closing file '%s'", latexfile) | |
178 endif | |
179 else | |
180 error ("print:erroropeningfile", | |
181 "print.m: error opening file '%s'", latexfile) | |
182 endif | |
183 fid = fopen (latexfile, "w"); | |
184 if (fid >= 0) | |
185 fprintf (fid, "%s\n", prepend{:}); | |
186 fprintf (fid, "%s", latex); | |
187 fprintf (fid, "%s\n", postpend{:}); | |
188 status = fclose (fid); | |
189 if (status != 0) | |
190 error ("print:errorclosingfile", | |
191 "print.m: error closing file '%s'", latexfile) | |
192 endif | |
193 else | |
194 error ("print:erroropeningfile", | |
195 "print.m: error opening file '%s'", latexfile) | |
196 endif | |
197 endfunction | |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
198 |
10861 | 199 |