Mercurial > hg > octave-lyh
annotate scripts/plot/print.m @ 7555:df583cd2f21e
print.m: fix oops in applying last change
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 04 Mar 2008 22:29:00 -0500 |
parents | bffb1e2ab732 |
children | c69d4732d877 |
rev | line source |
---|---|
7341 | 1 ## Copyright (C) 1999, 2005, 2006, 2007, 2008 Daniel Heiserer |
5361 | 2 ## Copyright (C) 2001 Laurent Mazet |
3 ## | |
5362 | 4 ## This file is part of Octave. |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
5362 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
5361 | 15 ## |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
5361 | 19 |
20 ## -*- texinfo -*- | |
21 ## @deftypefn {Function File} {} print (@var{filename}, @var{options}) | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
22 ## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options}) |
5361 | 23 ## Print a graph, or save it to a file |
24 ## | |
25 ## @var{filename} defines the file name of the output file. If no | |
26 ## filename is specified, output is sent to the printer. | |
27 ## | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
28 ## @var{h} specifies the figure handle. If no handle is specified |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
29 ## the handle for the current figure is used. |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
30 ## |
5361 | 31 ## @var{options}: |
32 ## @table @code | |
33 ## @item -P@var{printer} | |
34 ## Set the @var{printer} name to which the graph is sent if no | |
35 ## @var{filename} is specified. | |
36 ## @item -color | |
37 ## @itemx -mono | |
38 ## Monochrome or colour lines. | |
39 ## @item -solid | |
40 ## @itemx -dashed | |
41 ## Solid or dashed lines. | |
42 ## @item -portrait | |
43 ## @itemx -landscape | |
44 ## Plot orientation, as returned by "orient". | |
45 ## @item -d@var{device} | |
46 ## Output device, where @var{device} is one of: | |
47 ## @table @code | |
48 ## @item ps | |
49 ## @itemx ps2 | |
50 ## @itemx psc | |
51 ## @itemx psc2 | |
52 ## Postscript (level 1 and 2, mono and color) | |
53 ## @item eps | |
54 ## @itemx eps2 | |
55 ## @itemx epsc | |
56 ## @itemx epsc2 | |
57 ## Encapsulated postscript (level 1 and 2, mono and color) | |
6739 | 58 ## @item tex |
59 ## @itemx epslatex | |
60 ## @itemx epslatexstandalone | |
61 ## @itemx pstex | |
62 ## @itemx pslatex | |
63 ## Generate a LaTeX (or TeX) file for labels, and eps/ps for | |
64 ## graphics. The file produced by @code{epslatexstandalone} can be | |
65 ## processed directly by LaTeX. The other formats are intended to | |
66 ## be included in a LaTeX (or TeX) document. The @code{tex} device | |
67 ## is the same as the @code{epslatex} device. | |
5361 | 68 ## @item ill |
69 ## @itemx aifm | |
70 ## Adobe Illustrator | |
71 ## @item cdr | |
72 ## @itemx corel | |
73 ## CorelDraw | |
6965 | 74 ## @item dxf |
75 ## AutoCAD | |
76 ## @item emf | |
77 ## Microsoft Enhanced Metafile | |
78 ## @item fig | |
7037 | 79 ## XFig. If this format is selected the additional options |
7040 | 80 ## @code{-textspecial} or @code{-textnormal} can be used to control |
7037 | 81 ## whether the special flag should be set for the text in the figure |
7040 | 82 ## (default is @code{-textnormal}). |
5361 | 83 ## @item hpgl |
84 ## HP plotter language | |
85 ## @item mf | |
86 ## Metafont | |
87 ## @item png | |
88 ## Portable network graphics | |
7543
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
89 ## @item jpg |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
90 ## @itemx jpeg |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
91 ## JPEG image |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
92 ## @item gif |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
93 ## GIF image |
5361 | 94 ## @item pbm |
95 ## PBMplus | |
6965 | 96 ## @item svg |
97 ## Scalable vector graphics | |
7396 | 98 ## @item pdf |
99 ## Portable document format | |
5361 | 100 ## @end table |
101 ## | |
102 ## Other devices are supported by "convert" from ImageMagick. Type | |
103 ## system("convert") to see what formats are available. | |
104 ## | |
105 ## If the device is omitted, it is inferred from the file extension, | |
106 ## or if there is no filename it is sent to the printer as postscript. | |
107 ## | |
6965 | 108 ## @itemx -S@var{xsize},@var{ysize} |
109 ## Plot size in pixels for PNG and SVG. If using the command form of | |
110 ## the print function, you must quote the @var{xsize},@var{ysize} | |
111 ## option. For example, by writing @code{"-S640,480"}. | |
112 ## | |
5361 | 113 ## @item -F@var{fontname} |
114 ## @itemx -F@var{fontname}:@var{size} | |
115 ## @itemx -F:@var{size} | |
116 ## @var{fontname} set the postscript font (for use with postscript, | |
117 ## aifm, corel and fig). By default, 'Helvetica' is set for PS/Aifm, | |
118 ## and 'SwitzerlandLight' for Corel. It can also be 'Times-Roman'. | |
119 ## @var{size} is given in points. @var{fontname} is ignored for the | |
120 ## fig device. | |
121 ## @end table | |
122 ## | |
123 ## The filename and options can be given in any order. | |
124 ## @end deftypefn | |
125 | |
126 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | |
5362 | 127 ## Adapted-By: jwe |
5361 | 128 |
5362 | 129 ## PKG_ADD: mark_as_command print |
130 | |
131 function print (varargin) | |
5361 | 132 |
5365 | 133 orientation = orient (); |
5361 | 134 use_color = 0; # 0=default, -1=mono, +1=color |
135 force_solid = 0; # 0=default, -1=dashed, +1=solid | |
5363 | 136 fontsize = ""; |
137 font = ""; | |
6965 | 138 size = ""; |
5363 | 139 name = ""; |
140 devopt = ""; | |
141 printer = ""; | |
6870 | 142 debug = false; |
6872 | 143 debug_file = "octave-print-commands.log"; |
7037 | 144 special_flag = "textnormal"; |
5361 | 145 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
146 old_fig = get (0, "currentfigure"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
147 unwind_protect |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
148 ## Ensure the last figure is on the screen for single line commands like |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
149 ## plot(...); print(...); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
150 drawnow (); |
7032 | 151 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
152 for i = 1:nargin |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
153 arg = varargin{i}; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
154 if (ischar (arg)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
155 if (strcmp (arg, "-color")) |
5361 | 156 use_color = 1; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
157 elseif (strcmp (arg, "-mono")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
158 use_color = -1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
159 elseif (strcmp (arg, "-solid")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
160 force_solid = 1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
161 elseif (strcmp (arg, "-dashed")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
162 force_solid = -1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
163 elseif (strcmp (arg, "-portrait")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
164 orientation = "portrait"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
165 elseif (strcmp (arg, "-landscape")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
166 orientation = "landscape"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
167 elseif (strcmp (arg, "-textspecial")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
168 special_flag = "textspecial"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
169 elseif (strncmp (arg, "-debug", 6)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
170 debug = true; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
171 if (length (arg) > 7) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
172 debug_file = arg(8:end); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
173 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
174 elseif (length (arg) > 2 && arg(1:2) == "-d") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
175 devopt = arg(3:end); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
176 elseif (length (arg) > 2 && arg(1:2) == "-P") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
177 printer = arg; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
178 elseif (length (arg) > 2 && arg(1:2) == "-F") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
179 idx = rindex (arg, ":"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
180 if (idx) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
181 font = arg(3:idx-1); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
182 fontsize = arg(idx+1:length(arg)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
183 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
184 font = arg(3:length(arg)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
185 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
186 elseif (length (arg) > 2 && arg(1:2) == "-S") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
187 size = arg(3:length(arg)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
188 elseif (length (arg) >= 1 && arg(1) == "-") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
189 error ("print: unknown option `%s'", arg); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
190 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
191 elseif (ishandle (arg)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
192 figure (arg); |
7555
df583cd2f21e
print.m: fix oops in applying last change
John W. Eaton <jwe@octave.org>
parents:
7550
diff
changeset
|
193 elseif (length (arg) > 0) |
df583cd2f21e
print.m: fix oops in applying last change
John W. Eaton <jwe@octave.org>
parents:
7550
diff
changeset
|
194 name = arg; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
195 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
196 error ("print: expecting inputs to be character string options or a figure handle"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
197 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
198 endfor |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
199 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
200 doprint = isempty (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
201 if (doprint) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
202 if (isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
203 printname = cstrcat (tmpnam, ".ps"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
204 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
205 printname = cstrcat (tmpnam, ".", devopt); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
206 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
207 name = printname; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
208 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
209 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
210 if (isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
211 dot = rindex (name, "."); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
212 if (dot == 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
213 error ("print: no format specified"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
214 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
215 dev = tolower (name(dot+1:end)); |
5361 | 216 endif |
217 else | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
218 dev = devopt; |
5361 | 219 endif |
220 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
221 if (strcmp (dev, "tex")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
222 dev = "epslatex"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
223 ## gnuplot 4.0 wants ".eps" in the output name |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
224 if (compare_versions (__gnuplot_version__, "4.2", "<")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
225 name = cstrcat (name(1:dot), "eps"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
226 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
227 elseif (strcmp (dev, "ill")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
228 dev = "aifm"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
229 elseif (strcmp (dev, "cdr")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
230 dev = "corel"; |
5361 | 231 endif |
232 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
233 ## check if we have to use convert |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
234 dev_list = {"aifm", "corel", "fig", "png", "jpg", "jpeg", ... |
7543
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
235 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
236 "ps", "ps2", "psc", "psc2", "eps", "eps2", ... |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
237 "epsc", "epsc2", "emf", "pdf", "pslatex", ... |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
238 "epslatex", "epslatexstandalone", "pstex"}; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
239 convertname = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
240 [idx, errmsg] = cellidx (dev_list, dev); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
241 if (! idx) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
242 if (! isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
243 convertname = cstrcat (devopt, ":", name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
244 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
245 convertname = name; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
246 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
247 dev = "epsc"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
248 name = cstrcat (tmpnam, ".eps"); |
5361 | 249 endif |
5363 | 250 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
251 if (strcmp (dev, "ps") || strcmp (dev, "ps2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
252 || strcmp (dev, "psc") || strcmp (dev, "psc2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
253 || strcmp (dev, "epsc") || strcmp (dev, "epsc2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
254 || strcmp (dev, "eps") || strcmp (dev, "eps2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
255 || strcmp (dev, "pstex")|| strcmp (dev, "pslatex") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
256 || strcmp (dev, "epslatex") || strcmp (dev, "epslatexstandalone")) |
6727 | 257 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
258 ## Various postscript options |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
259 if (strcmp (dev, "pstex")|| strcmp (dev, "pslatex") |
6727 | 260 || strcmp (dev, "epslatex")) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
261 termn = dev; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
262 options = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
263 elseif (strcmp (dev, "epslatexstandalone")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
264 if (compare_versions (__gnuplot_version__, "4.2", ">=")) |
6727 | 265 termn = "epslatex"; |
266 options = "standalone "; | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
267 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
268 error ("print: epslatexstandalone needs gnuplot 4.2 or higher"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
269 endif |
6727 | 270 else |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
271 if (dev(1) == "e") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
272 options = "eps "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
273 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
274 options = cstrcat (orientation, " "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
275 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
276 termn = "postscript"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
277 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
278 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
279 if (any (dev == "c") || use_color > 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
280 if (force_solid < 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
281 options = cstrcat (options, "color dashed "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
282 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
283 options = cstrcat (options, "color solid "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
284 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
285 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
286 if (force_solid > 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
287 options = cstrcat (options, "mono solid "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
288 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
289 options = cstrcat (options, "mono dashed "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
290 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
291 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
292 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
293 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
294 options = cstrcat (options, "\"", font, "\" "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
295 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
296 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
297 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
298 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
299 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
300 new_terminal = cstrcat (termn, " ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
301 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
302 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
303 ## Adobe Illustrator, CorelDraw |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
304 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
305 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
306 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
307 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
308 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
309 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
310 options = cstrcat (options, " \"", font, "\""); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
311 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
312 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
313 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
314 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
315 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
316 new_terminal = cstrcat (dev, " ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
317 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
318 elseif (strcmp (dev, "fig")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
319 ## XFig |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
320 options = orientation; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
321 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
322 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
323 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
324 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
325 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
326 options = cstrcat (options, " ", special_flag); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
327 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
328 options = cstrcat (options, " fontsize ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
329 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
330 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
331 new_terminal = cstrcat ("fig ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
332 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
333 elseif (strcmp (dev, "emf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
334 ## Enhanced Metafile format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
335 options = " "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
336 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
337 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
338 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
339 options = " mono"; |
6727 | 340 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
341 if (force_solid >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
342 options = cstrcat (options, " solid"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
343 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
344 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
345 options = cstrcat (options, " \"", font, "\""); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
346 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
347 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
348 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
349 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
350 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
351 new_terminal = cstrcat ("emf ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
352 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
353 elseif (strcmp (dev, "png") || strcmp (dev, "gif") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
354 || strcmp (dev, "jpg") || strcmp (dev, "jpeg") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
355 || strcmp (dev, "pbm")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
356 if (strcmp (dev, "jpg")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
357 dev = "jpeg"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
358 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
359 ## Portable network graphics, PBMplus |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
360 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
361 ## FIXME -- New PNG interface takes color as "xRRGGBB" |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
362 ## where x is the literal character 'x' and 'RRGGBB' are the red, |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
363 ## green and blue components in hex. For now we just ignore it |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
364 ## and use default. The png terminal now is so rich with options, |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
365 ## that one perhaps has to write a separate printpng.m function. |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
366 ## DAS |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
367 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
368 ## if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
369 ## eval (sprintf ("__gnuplot_set__ term %s color medium", dev)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
370 ##else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
371 ##eval (sprintf ("__gnuplot_set__ term %s mono medium", dev)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
372 ##endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
373 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
374 if (isempty (size)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
375 options = " large"; |
6727 | 376 else |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
377 options = cstrcat (" size ", size); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
378 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
379 new_terminal = cstrcat (dev, options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
380 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
381 elseif (strcmp (dev, "dxf") || strcmp (dev, "mf") || strcmp (dev, "hpgl")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
382 ## AutoCad DXF, METAFONT, HPGL |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
383 new_terminal = dev; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
384 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
385 elseif (strcmp (dev, "svg")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
386 ## SVG |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
387 options = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
388 if (! isempty (size)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
389 options = cstrcat (" size ", size); |
6727 | 390 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
391 new_terminal = cstrcat ("svg", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
392 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
393 elseif (strcmp (dev, "pdf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
394 ## Portable Document format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
395 options = " "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
396 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
397 options = "color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
398 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
399 options = "mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
400 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
401 if (force_solid > 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
402 options = cstrcat (options, " solid"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
403 elseif (force_solid < 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
404 options = cstrcat (options, " dashed"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
405 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
406 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
407 options = cstrcat (options, "\"", font, "\" "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
408 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
409 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
410 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
411 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
412 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
413 new_terminal = cstrcat ("pdf ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
414 |
6179 | 415 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
416 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
417 mono = use_color < 0; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
418 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
419 if (debug) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
420 drawnow (new_terminal, name, mono, debug_file); |
6179 | 421 else |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
422 drawnow (new_terminal, name, mono); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
423 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
424 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
425 if (! isempty (convertname)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
426 command = sprintf ("convert '%s' '%s'", name, convertname); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
427 [errcode, output] = system (command); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
428 unlink (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
429 if (errcode) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
430 error ("print: could not convert"); |
5625 | 431 endif |
6179 | 432 endif |
6178 | 433 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
434 ## FIXME -- This looks like a dirty, Unix-specific hack. |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
435 ## DAS |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
436 if (doprint) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
437 system (sprintf ("lpr %s '%s'", printer, printname)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
438 unlink (printname); |
6179 | 439 endif |
440 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
441 unwind_protect_cleanup |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
442 if (ishandle (old_fig)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
443 figure (old_fig) |
6965 | 444 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
445 end_unwind_protect |
5363 | 446 |
5361 | 447 endfunction |