annotate scripts/plot/__fltk_print__.m @ 10854:d5a7db05d591

Add PS and PDF output for the fltk backend.
author Ben Abbott <bpabbott@mac.com>
date Wed, 04 Aug 2010 20:32:49 -0400
parents 05ba991794d4
children 2f70e7098cbe
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
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
41 case {"epslatex", "epslatexstandalone", "pslatex"}
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
42 # FIXME - format GL2PS_TEX is not implemented
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
43 drawnow ("epslatex", opts.name);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
44 if (opts.tight_flag)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
45 __tight_eps_bbox__ (opts, opts.name);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
46 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
47 case {"tikz"}
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
48 ## FIXME - format GL2PS_PGF if not implemented
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
49 drawnow ("pgf", opts.name);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
50 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
51 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
52 file2unlink = opts.ghostscript.source;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
53 if (strcmp (opts.devopt, "pdf"))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
54 opts.ghostscript.device = "pdfwrite";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
55 else
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
56 opts.ghostscript.device = "pswrite";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
57 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
58 opts.ghostscript.output = opts.name;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
59 drawnow ("eps", opts.ghostscript.source);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
60 if (opts.tight_flag)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
61 __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
62 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
63 case {"svg"}
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
64 ## FIXME - format GL2PS_SVG if not implemented
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
65 drawnow ("svg", opts.name);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
66 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
67 "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
68 "tiff", "tiffn"}
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
69 switch opts.devopt
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
70 case "png"
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
71 opts.ghostscript.device = "png256";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
72 case {"tiff", "tiffn"}
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
73 opts.ghostscript.device = "tiff24nc";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
74 otherwise
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
75 opts.ghostscript.device = opts.devopt;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
76 endswitch
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
77 opts.ghostscript.output = opts.name;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
78 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
79 opts.ghostscript.epscrop = true;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
80 file2unlink = opts.ghostscript.source;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
81 drawnow ("eps", opts.ghostscript.source)
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
82 if (opts.tight_flag)
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
83 __tight_eps_bbox__ (opts, opts.ghostscript.source);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
84 endif
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
85 case fig2dev_devices
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
86 tmp_figfile = strcat (tmpnam (), ".fig");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
87 file2unlink = tmp_figfile;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
88 status = __pstoedit__ (opts, "fig", tmp_figfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
89 if (status == 0)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
90 status = __fig2dev__ (opts, tmp_figfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
91 endif
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
92 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
93 status = __pstoedit__ (opts);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
94 otherwise
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
95 ## various ghostscript devices for printers
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 opts.ghostscript.output = opts.name;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
98 opts.ghostscript.epscrop = false;
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 file2unlink = opts.ghostscript.source;
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
101 drawnow ("eps", opts.ghostscript.source)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
102 if (opts.tight_flag)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
103 __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
104 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
105 endswitch
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
106
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
107 ## 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
108 if (! isempty (opts.ghostscript.device))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
109 status = __ghostscript__ (opts.ghostscript);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
110 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
111
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
112 if (! isempty (file2unlink))
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
113 [status, output] = unlink (file2unlink);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
114 if (status != 0)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
115 disp (output)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
116 warning ("print.m: failed to delete temporay file, '%s'.", file2unlink)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
117 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
118 endif
10727
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
119
570f30a48732 split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
120 endfunction
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
121
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
122 function status = __fig2dev__ (opts, figfile, devopt, devfile)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
123 if (nargin < 4)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
124 devfile = opts.name;
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 if (nargin < 3)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
127 devopt = opts.devopt;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
128 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
129 cmd = sprintf ("%s -L %s %s %s 2>&1", opts.fig2dev_binary, devopt, figfile, devfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
130 [status, output] = system (cmd);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
131 if (opts.debug)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
132 fprintf ("fig2dev command: %s", cmd)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
133 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
134 if (status)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
135 warning ("print:fig2devfailed", "print.m: error running fig2dev.")
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
136 disp (cmd)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
137 disp (output)
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 endfunction
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
140
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
141 function status = __pstoedit__ (opts, devopt, name)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
142 if (nargin < 3)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
143 name = opts.name;
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
144 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
145 if (nargin < 2)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
146 devopt = opts.devopt;
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 tmp_epsfile = strcat (tmpnam (), ".eps");
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
149 if (opts.tight_flag)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
150 __tight_eps_bbox__ (opts, tmp_epsfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
151 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
152 drawnow ("eps", tmp_epsfile)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
153 cmd = sprintf ("%s -f %s %s %s 2>&1", opts.pstoedit_binary, devopt, tmp_epsfile, name);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
154 [status, output] = system (cmd);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
155 if (opts.debug)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
156 fprintf ("pstoedit command: %s", cmd)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
157 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
158 if (status)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
159 warning ("print:pstoeditfailed", "print.m: error running pstoedit.")
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
160 disp (cmd)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
161 disp (output)
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 [status, output] = unlink (tmp_epsfile);
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
164 if (status != 0)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
165 disp (output)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
166 warning ("print.m: failed to delete temporay file, '%s'.", tmp_epsfile)
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
167 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
168 endfunction
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
169
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
170