annotate scripts/plot/print.m @ 7543:b84c5cbc0812

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