annotate scripts/plot/__fltk_print__.m @ 10864:d19d2abdd65f

__fltk_print__.m: When running pstoedit, crop eps file after it is created.
author Ben Abbott <bpabbott@mac.com>
date Sat, 07 Aug 2010 13:47:52 -0400
parents 337db4e1342d
children dd6b90f44ae5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
26 file2unlink = "";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
27
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
28 if (! isempty (opts.fig2dev_binary))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
29 fig2dev_devices = {"pstex", "mf", "emf"};
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
30 else
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
31 ## 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
32 fig2dev_devices = {"pstex", "mf"};
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
33 endif
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
34
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
35 switch lower (opts.devopt)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
36 case {"eps", "eps2", "epsc", "epsc2"}
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
37 drawnow ("eps", opts.name);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
38 if (opts.tight_flag)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
39 __tight_eps_bbox__ (opts, opts.name);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
40 endif
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
41 case {"epslatex", "pslatex", "pdflatex", "epslatexstandalone", ...
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
42 "pslatexstandalone", "pdflatexstandalone"}
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
43 ## format GL2PS_TEX
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
44 ## FIXME - rotated text do not align properly.
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
45 n = find (opts.devopt == "l", 1);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
46 suffix = opts.devopt(1:n-1);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
47 dot = find (opts.name == ".", 1, "last");
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
48 if ((! isempty (dot))
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
49 && any (strcmpi (opts.name(dot:end), {".eps", ".ps", ".pdf", ".tex", "."})))
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
50 name = opts.name(1:dot-1);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
51 if (dot < numel (opts.name)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
52 && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"})))
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
53 ## If user provides eps/ps/pdf suffix, use it.
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
54 suffix = opts.name(dot+1:end);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
55 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
56 elseif (dot == numel (opts.name))
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
57 name = opts.name;
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
58 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
59 drawnow (strcat (lower (suffix), "notxt"), strcat (name, ".", suffix));
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
60 drawnow ("tex", strcat (name, ".", suffix, ".tex"));
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
61 movefile (strcat (name, ".", suffix, ".tex"), strcat (name, ".tex"));
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
62 if (opts.tight_flag && strncmpi (opts.devopt, "eps", 3))
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
63 __tight_eps_bbox__ (opts, strcat (opts.name, ".eps"));
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
64 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
65 if (! isempty (strfind (opts.devopt, "standalone")))
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
66 __standalone__ (strcat (name, ".tex"));
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
67 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
68 case {"tikz"}
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
69 ## format GL2PS_PGF
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
70 drawnow ("pgf", opts.name);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
71 case {"ps", "ps2", "psc", "psc2", "pdf"}
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
72 opts.ghostscript.source = strcat (tmpnam (), ".eps");
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
73 file2unlink = opts.ghostscript.source;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
74 if (strcmp (opts.devopt, "pdf"))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
75 opts.ghostscript.device = "pdfwrite";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
76 else
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
77 opts.ghostscript.device = "pswrite";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
78 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
79 opts.ghostscript.output = opts.name;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
80 drawnow ("eps", opts.ghostscript.source);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
81 if (opts.tight_flag)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
82 __tight_eps_bbox__ (opts, opts.ghostscript.source);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
83 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
84 case {"svg"}
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
85 ## format GL2PS_SVG
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
86 drawnow ("svg", opts.name);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
87 case {"jpeg", "pbm", "pbmraw", "pcx24b", "pcx256", "pcx16", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
88 "pgm", "pgmraw", "png", "ppm", "ppmraw", "pdfwrite", ...
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
89 "tiff", "tiffn"}
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
90 switch opts.devopt
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
91 case "png"
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
92 opts.ghostscript.device = "png16m";
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
93 case {"tiff", "tiffn"}
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
94 opts.ghostscript.device = "tiff24nc";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
95 otherwise
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
96 opts.ghostscript.device = opts.devopt;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
97 endswitch
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
98 opts.ghostscript.output = opts.name;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
99 opts.ghostscript.source = strcat (tmpnam (), ".eps");
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
100 opts.ghostscript.epscrop = true;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
101 file2unlink = opts.ghostscript.source;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
102 drawnow ("eps", opts.ghostscript.source)
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
103 if (opts.tight_flag)
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
104 __tight_eps_bbox__ (opts, opts.ghostscript.source);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
105 endif
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
106 case fig2dev_devices
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
107 tmp_figfile = strcat (tmpnam (), ".fig");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
108 file2unlink = tmp_figfile;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
109 status = __pstoedit__ (opts, "fig", tmp_figfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
110 if (status == 0)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
111 status = __fig2dev__ (opts, tmp_figfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
112 endif
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
113 case {"aifm", "dxf", "emf", "fig", "hpgl"};
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
114 status = __pstoedit__ (opts);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
115 otherwise
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
116 ## various ghostscript devices for printers
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
117 opts.ghostscript.device = opts.devopt;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
118 opts.ghostscript.output = opts.name;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
119 opts.ghostscript.epscrop = false;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
120 opts.ghostscript.source = strcat (tmpnam (), ".eps");
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
121 file2unlink = opts.ghostscript.source;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
122 drawnow ("eps", opts.ghostscript.source)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
123 if (opts.tight_flag)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
124 __tight_eps_bbox__ (opts, opts.ghostscript.source);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
125 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
126 endswitch
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
127
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
128 ## FIXME - warning: unrecognized escape sequence `\P' -- converting to `P'
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
129 if (! isempty (opts.ghostscript.device))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
130 status = __ghostscript__ (opts.ghostscript);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
131 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
132
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
133 if (! isempty (file2unlink))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
134 [status, output] = unlink (file2unlink);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
135 if (status != 0)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
136 disp (output)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
137 warning ("print.m: failed to delete temporay file, '%s'.", file2unlink)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
138 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
139 endif
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
140
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
141 endfunction
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
142
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
143 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
144 persistent warn_on_absence = true
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
145 if (nargin < 4)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
146 devfile = opts.name;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
147 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
148 if (nargin < 3)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
149 devopt = opts.devopt;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
150 endif
10862
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
151 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
152 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
153 figfile, devfile);
10862
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
154 [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
155 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
156 fprintf ("fig2dev command: %s", cmd)
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
157 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
158 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
159 disp (output)
10862
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
160 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
161 endif
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
162 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
163 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
164 warn_on_absence = false;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
165 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
166 endfunction
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
167
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
168 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
169 persistent warn_on_absence = true
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
170 if (nargin < 3)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
171 name = opts.name;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
172 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
173 if (nargin < 2)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
174 devopt = opts.devopt;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
175 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
176 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
177 tmp_epsfile = strcat (tmpnam (), ".eps");
10864
d19d2abdd65f __fltk_print__.m: When running pstoedit, crop eps file after it is created.
Ben Abbott <bpabbott@mac.com>
parents: 10862
diff changeset
178 drawnow ("eps", tmp_epsfile)
10862
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
179 if (opts.tight_flag)
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
180 __tight_eps_bbox__ (opts, tmp_epsfile);
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
181 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
182 cmd = sprintf ("%s -f %s %s %s 2>&1", opts.pstoedit_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
183 tmp_epsfile, name);
10862
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
184 [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
185 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
186 fprintf ("pstoedit command: %s", cmd)
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
187 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
188 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
189 disp (output)
10862
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
190 warning ("print:pstoeditfailed", "print.m: error running pstoedit.")
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
191 endif
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
192 [status, output] = unlink (tmp_epsfile);
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
193 if (status != 0)
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
194 disp (output)
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
195 warning ("print.m: failed to delete temporay file, '%s'.", tmp_epsfile)
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
196 endif
337db4e1342d Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents: 10861
diff changeset
197 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
198 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
199 warn_on_absence = false;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
200 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
201 endfunction
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
202
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
203 function __standalone__ (latexfile)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
204 prepend = {"\\documentclass{minimal}";
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
205 "\\usepackage{epsfig,color}";
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
206 "\\begin{document}";
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
207 "\\centering"};
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
208 postpend = {"\\end{document}"};
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
209 fid = fopen (latexfile, "r");
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
210 if (fid >= 0)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
211 latex = fscanf (fid, "%c", Inf);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
212 status = fclose (fid);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
213 if (status != 0)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
214 error ("print:errorclosingfile",
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
215 "print.m: error closing file '%s'", latexfile)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
216 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
217 else
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
218 error ("print:erroropeningfile",
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
219 "print.m: error opening file '%s'", latexfile)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
220 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
221 fid = fopen (latexfile, "w");
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
222 if (fid >= 0)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
223 fprintf (fid, "%s\n", prepend{:});
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
224 fprintf (fid, "%s", latex);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
225 fprintf (fid, "%s\n", postpend{:});
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
226 status = fclose (fid);
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
227 if (status != 0)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
228 error ("print:errorclosingfile",
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
229 "print.m: error closing file '%s'", latexfile)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
230 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
231 else
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
232 error ("print:erroropeningfile",
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
233 "print.m: error opening file '%s'", latexfile)
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
234 endif
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
235 endfunction
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
236
10861
2f70e7098cbe __print_parse_opts__.m: .
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
237