Mercurial > hg > octave-lyh
annotate scripts/plot/print.m @ 9042:97aa01a85ea4
Merge documentation cleanup changes to main branch.
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Wed, 25 Mar 2009 18:13:08 -0700 |
parents | cc916241e811 dbd0c77e575e |
children | b06dc393ac42 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1999, 2005, 2006, 2007, 2008, 2009 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 ## | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 ## @var{filename} defines the file name of the output file. If no |
5361 | 26 ## filename is specified, output is sent to the printer. |
27 ## | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
28 ## @var{h} specifies the figure handle. If no handle is specified |
7550
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 | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
38 ## Monochrome or color lines. |
5361 | 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 ## | |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
108 ## @itemx -r@var{NUM} |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
109 ## Resolution of bitmaps in pixels per inch. |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
110 ## |
6965 | 111 ## @itemx -S@var{xsize},@var{ysize} |
112 ## Plot size in pixels for PNG and SVG. If using the command form of | |
113 ## the print function, you must quote the @var{xsize},@var{ysize} | |
114 ## option. For example, by writing @code{"-S640,480"}. | |
115 ## | |
5361 | 116 ## @item -F@var{fontname} |
117 ## @itemx -F@var{fontname}:@var{size} | |
118 ## @itemx -F:@var{size} | |
119 ## @var{fontname} set the postscript font (for use with postscript, | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
120 ## aifm, corel and fig). By default, 'Helvetica' is set for PS/Aifm, |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
121 ## and 'SwitzerlandLight' for Corel. It can also be 'Times-Roman'. |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
122 ## @var{size} is given in points. @var{fontname} is ignored for the |
5361 | 123 ## fig device. |
124 ## @end table | |
125 ## | |
126 ## The filename and options can be given in any order. | |
127 ## @end deftypefn | |
128 | |
129 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | |
5362 | 130 ## Adapted-By: jwe |
5361 | 131 |
5362 | 132 function print (varargin) |
5361 | 133 |
5365 | 134 orientation = orient (); |
5361 | 135 use_color = 0; # 0=default, -1=mono, +1=color |
136 force_solid = 0; # 0=default, -1=dashed, +1=solid | |
5363 | 137 fontsize = ""; |
138 font = ""; | |
6965 | 139 size = ""; |
5363 | 140 name = ""; |
141 devopt = ""; | |
142 printer = ""; | |
6870 | 143 debug = false; |
6872 | 144 debug_file = "octave-print-commands.log"; |
7037 | 145 special_flag = "textnormal"; |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
146 resolution = ""; |
5361 | 147 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
148 old_fig = get (0, "currentfigure"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
149 unwind_protect |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
150 ## 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
|
151 ## plot(...); print(...); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
152 drawnow (); |
7032 | 153 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
154 for i = 1:nargin |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
155 arg = varargin{i}; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
156 if (ischar (arg)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
157 if (strcmp (arg, "-color")) |
5361 | 158 use_color = 1; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
159 elseif (strcmp (arg, "-mono")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
160 use_color = -1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
161 elseif (strcmp (arg, "-solid")) |
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, "-dashed")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
164 force_solid = -1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
165 elseif (strcmp (arg, "-portrait")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
166 orientation = "portrait"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
167 elseif (strcmp (arg, "-landscape")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
168 orientation = "landscape"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
169 elseif (strcmp (arg, "-textspecial")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
170 special_flag = "textspecial"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
171 elseif (strncmp (arg, "-debug", 6)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
172 debug = true; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
173 if (length (arg) > 7) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
174 debug_file = arg(8:end); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
175 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
176 elseif (length (arg) > 2 && arg(1:2) == "-d") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
177 devopt = arg(3:end); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
178 elseif (length (arg) > 2 && arg(1:2) == "-P") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
179 printer = arg; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
180 elseif (length (arg) > 2 && arg(1:2) == "-F") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
181 idx = rindex (arg, ":"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
182 if (idx) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
183 font = arg(3:idx-1); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
184 fontsize = arg(idx+1:length(arg)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
185 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
186 font = arg(3:length(arg)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
187 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
188 elseif (length (arg) > 2 && arg(1:2) == "-S") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
189 size = arg(3:length(arg)); |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
190 elseif (length (arg) > 2 && arg(1:2) == "-r") |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
191 resolution = arg(3:length(arg)); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
192 elseif (length (arg) >= 1 && arg(1) == "-") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
193 error ("print: unknown option `%s'", arg); |
7556
c69d4732d877
print.m: fix oops in applying last change (really, I mean it this time)
John W. Eaton <jwe@octave.org>
parents:
7555
diff
changeset
|
194 elseif (length (arg) > 0) |
c69d4732d877
print.m: fix oops in applying last change (really, I mean it this time)
John W. Eaton <jwe@octave.org>
parents:
7555
diff
changeset
|
195 name = arg; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
196 endif |
8239
041bb0c64f07
orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents:
8049
diff
changeset
|
197 elseif (isfigure (arg)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
198 figure (arg); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
199 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
200 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
|
201 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
202 endfor |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
203 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
204 doprint = isempty (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
205 if (doprint) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
206 if (isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
207 printname = cstrcat (tmpnam, ".ps"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
208 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
209 printname = cstrcat (tmpnam, ".", devopt); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
210 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
211 name = printname; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
212 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
213 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
214 if (isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
215 dot = rindex (name, "."); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
216 if (dot == 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
217 error ("print: no format specified"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
218 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
219 dev = tolower (name(dot+1:end)); |
5361 | 220 endif |
221 else | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
222 dev = devopt; |
5361 | 223 endif |
224 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
225 if (strcmp (dev, "tex")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
226 dev = "epslatex"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
227 ## gnuplot 4.0 wants ".eps" in the output name |
8639
399af34bb4bf
# User Ben Abbott <bpabbott@mac.com>
John W. Eaton <jwe@octave.org>
parents:
8239
diff
changeset
|
228 if (! __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
229 name = cstrcat (name(1:dot), "eps"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
230 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
231 elseif (strcmp (dev, "ill")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
232 dev = "aifm"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
233 elseif (strcmp (dev, "cdr")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
234 dev = "corel"; |
5361 | 235 endif |
236 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
237 ## check if we have to use convert |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
238 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
|
239 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
240 "ps", "ps2", "psc", "psc2", "eps", "eps2", ... |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
241 "epsc", "epsc2", "emf", "pdf", "pslatex", ... |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
242 "epslatex", "epslatexstandalone", "pstex"}; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
243 convertname = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
244 [idx, errmsg] = cellidx (dev_list, dev); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
245 if (! idx) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
246 if (! isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
247 convertname = cstrcat (devopt, ":", name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
248 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
249 convertname = name; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
250 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
251 dev = "epsc"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
252 name = cstrcat (tmpnam, ".eps"); |
5361 | 253 endif |
5363 | 254 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
255 if (strcmp (dev, "ps") || strcmp (dev, "ps2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
256 || strcmp (dev, "psc") || strcmp (dev, "psc2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
257 || strcmp (dev, "epsc") || strcmp (dev, "epsc2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
258 || strcmp (dev, "eps") || strcmp (dev, "eps2") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
259 || strcmp (dev, "pstex")|| strcmp (dev, "pslatex") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
260 || strcmp (dev, "epslatex") || strcmp (dev, "epslatexstandalone")) |
6727 | 261 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
262 ## Various postscript options |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
263 if (strcmp (dev, "pstex")|| strcmp (dev, "pslatex") |
6727 | 264 || strcmp (dev, "epslatex")) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
265 termn = dev; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
266 options = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
267 elseif (strcmp (dev, "epslatexstandalone")) |
8639
399af34bb4bf
# User Ben Abbott <bpabbott@mac.com>
John W. Eaton <jwe@octave.org>
parents:
8239
diff
changeset
|
268 if (__gnuplot_has_feature__ ("epslatexstandalone_terminal")) |
6727 | 269 termn = "epslatex"; |
270 options = "standalone "; | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
271 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
272 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
|
273 endif |
6727 | 274 else |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
275 if (dev(1) == "e") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
276 options = "eps "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
277 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
278 options = cstrcat (orientation, " "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
279 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
280 termn = "postscript"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
281 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
282 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
283 if (any (dev == "c") || use_color > 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
284 if (force_solid < 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
285 options = cstrcat (options, "color dashed "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
286 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
287 options = cstrcat (options, "color solid "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
288 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
289 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
290 if (force_solid > 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
291 options = cstrcat (options, "mono solid "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
292 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
293 options = cstrcat (options, "mono dashed "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
294 endif |
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 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
297 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
298 options = cstrcat (options, "\"", font, "\" "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
299 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
300 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
301 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
302 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
303 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
304 new_terminal = cstrcat (termn, " ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
305 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
306 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
307 ## Adobe Illustrator, CorelDraw |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
308 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
309 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
310 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
311 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
312 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
313 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
314 options = cstrcat (options, " \"", font, "\""); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
315 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
316 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
317 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
318 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
319 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
320 new_terminal = cstrcat (dev, " ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
321 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
322 elseif (strcmp (dev, "fig")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
323 ## XFig |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
324 options = orientation; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
325 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
326 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
327 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
328 options = " mono"; |
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 options = cstrcat (options, " ", special_flag); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
331 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
332 options = cstrcat (options, " fontsize ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
333 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
334 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
335 new_terminal = cstrcat ("fig ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
336 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
337 elseif (strcmp (dev, "emf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
338 ## Enhanced Metafile format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
339 options = " "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
340 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
341 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
342 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
343 options = " mono"; |
6727 | 344 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
345 if (force_solid >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
346 options = cstrcat (options, " solid"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
347 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
348 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
349 options = cstrcat (options, " \"", font, "\""); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
350 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
351 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
352 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
353 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
354 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
355 new_terminal = cstrcat ("emf ", options); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
356 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
357 elseif (strcmp (dev, "png") || strcmp (dev, "gif") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
358 || strcmp (dev, "jpg") || strcmp (dev, "jpeg") |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
359 || strcmp (dev, "pbm")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
360 if (strcmp (dev, "jpg")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
361 dev = "jpeg"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
362 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
363 ## Portable network graphics, PBMplus |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
364 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
365 ## FIXME -- New PNG interface takes color as "xRRGGBB" |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
366 ## 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
|
367 ## 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
|
368 ## 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
|
369 ## 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
|
370 ## DAS |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
371 |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
372 if (isempty (size) && isempty (resolution)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
373 options = " large"; |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
374 elseif (! isempty (size)) |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
375 options = cstrcat (" size ", size); |
6727 | 376 else |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
377 options = ""; |
7550
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 |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
419 if (isempty (resolution)) |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
420 resolution = get (0, "screenpixelsperinch"); |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
421 else |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
422 resolution = str2num (resolution); |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
423 endif |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
424 figure_properties = get (gcf); |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
425 if (! isfield (figure_properties, "__pixels_per_inch__")) |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
426 addproperty ("__pixels_per_inch__", gcf, "double", resolution); |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
427 endif |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
428 set (gcf, "__pixels_per_inch__", resolution) |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
429 |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
430 unwind_protect |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
431 if (! isempty (size)) |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
432 size_in_pixels = sscanf (size ,"%d, %d"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
433 size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
434 size_in_inches = size_in_pixels ./ resolution; |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
435 p.paperunits = get (gcf, "paperunits"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
436 p.papertype = get (gcf, "papertype"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
437 p.papersize = get (gcf, "papersize"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
438 p.paperposition = get (gcf, "paperposition"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
439 p.paperpositionmode = get (gcf, "paperpositionmode"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
440 set (gcf, "paperunits", "inches"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
441 set (gcf, "papertype", "<custom>"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
442 set (gcf, "papersize", size_in_inches); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
443 set (gcf, "paperposition", [0, 0, size_in_inches]); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
444 set (gcf, "paperpositionmode", "manual"); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
445 endif |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
446 if (debug) |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
447 drawnow (new_terminal, name, mono, debug_file); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
448 else |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
449 drawnow (new_terminal, name, mono); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
450 endif |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
451 unwind_protect_cleanup |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
452 ## FIXME - it would be preferred to delete the added properties here. |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
453 if (! isempty (size)) |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
454 props = fieldnames (p); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
455 for n = 1:numel(props) |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
456 set (gcf, props{n}, p.(props{n})) |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
457 endfor |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
458 endif |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
459 end_unwind_protect |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
460 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
461 if (! isempty (convertname)) |
8049
e36e891f2349
undo spurious change in last commit
John W. Eaton <jwe@octave.org>
parents:
8048
diff
changeset
|
462 command = sprintf ("convert '%s' '%s'", name, convertname); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
463 [errcode, output] = system (command); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
464 unlink (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
465 if (errcode) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
466 error ("print: could not convert"); |
5625 | 467 endif |
6179 | 468 endif |
6178 | 469 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
470 ## 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
|
471 ## DAS |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
472 if (doprint) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
473 system (sprintf ("lpr %s '%s'", printer, printname)); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
474 unlink (printname); |
6179 | 475 endif |
476 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
477 unwind_protect_cleanup |
8239
041bb0c64f07
orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents:
8049
diff
changeset
|
478 if (isfigure (old_fig)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
479 figure (old_fig) |
6965 | 480 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
481 end_unwind_protect |
5363 | 482 |
5361 | 483 endfunction |