Mercurial > hg > octave-nkf
annotate scripts/plot/print.m @ 10635:d1978e7364ad
Print name of function in error() string messages.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 16 May 2010 22:26:54 -0700 |
parents | 79410269cd21 |
children | fbd7843974fa |
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 -*- | |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
21 ## @deftypefn {Function File} {} print () |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
22 ## @deftypefnx {Function File} {} print (@var{options}) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
23 ## @deftypefnx {Function File} {} print (@var{filename}, @var{options}) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
24 ## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options}) |
5361 | 25 ## Print a graph, or save it to a file |
26 ## | |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
27 ## @var{filename} defines the file name of the output file. If the |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
28 ## file name has no suffix, one is inferred from the specified |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
29 ## device and appended to the file name. If no |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
30 ## filename is specified, the output is sent to the printer. |
5361 | 31 ## |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
32 ## @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
|
33 ## the handle for the current figure is used. |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
34 ## |
5361 | 35 ## @var{options}: |
36 ## @table @code | |
37 ## @item -P@var{printer} | |
38 ## Set the @var{printer} name to which the graph is sent if no | |
39 ## @var{filename} is specified. | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
40 ## @item -G@var{ghostscript_command} |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
41 ## Specify the command for calling Ghostscript. For Unix and Windows, |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
42 ## the defaults are 'gs' and 'gswin32c', respectively. |
5361 | 43 ## @item -color |
44 ## @itemx -mono | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
45 ## Monochrome or color lines. |
5361 | 46 ## @item -solid |
47 ## @itemx -dashed | |
48 ## Solid or dashed lines. | |
49 ## @item -portrait | |
50 ## @itemx -landscape | |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
51 ## Specify the orientation of the plot for printed output. |
5361 | 52 ## @item -d@var{device} |
53 ## Output device, where @var{device} is one of: | |
54 ## @table @code | |
55 ## @item ps | |
56 ## @itemx ps2 | |
57 ## @itemx psc | |
58 ## @itemx psc2 | |
59 ## Postscript (level 1 and 2, mono and color) | |
60 ## @item eps | |
61 ## @itemx eps2 | |
62 ## @itemx epsc | |
63 ## @itemx epsc2 | |
64 ## Encapsulated postscript (level 1 and 2, mono and color) | |
6739 | 65 ## @item tex |
66 ## @itemx epslatex | |
67 ## @itemx epslatexstandalone | |
68 ## @itemx pstex | |
69 ## @itemx pslatex | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
70 ## Generate a @LaTeX{} (or @TeX{}) file for labels, and eps/ps for |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
71 ## graphics. The file produced by @code{epslatexstandalone} can be |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
72 ## processed directly by @LaTeX{}. The other formats are intended to |
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
73 ## be included in a @LaTeX{} (or @TeX{}) document. The @code{tex} device |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
74 ## is the same as the @code{epslatex} device. |
9468
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
75 ## @item tikz |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9468
diff
changeset
|
76 ## Generate a @LaTeX{} file using gnuplot's Lua/TikZ terminal. |
5361 | 77 ## @item ill |
78 ## @itemx aifm | |
79 ## Adobe Illustrator | |
80 ## @item cdr | |
81 ## @itemx corel | |
82 ## CorelDraw | |
6965 | 83 ## @item dxf |
84 ## AutoCAD | |
85 ## @item emf | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
86 ## @itemx meta |
6965 | 87 ## Microsoft Enhanced Metafile |
88 ## @item fig | |
7037 | 89 ## XFig. If this format is selected the additional options |
7040 | 90 ## @code{-textspecial} or @code{-textnormal} can be used to control |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
91 ## whether the special flag should be set for the text in |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
92 ## the figure (default is @code{-textnormal}). |
5361 | 93 ## @item hpgl |
94 ## HP plotter language | |
95 ## @item mf | |
96 ## Metafont | |
97 ## @item png | |
98 ## Portable network graphics | |
7543
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
99 ## @item jpg |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
100 ## @itemx jpeg |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
101 ## JPEG image |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
102 ## @item gif |
b84c5cbc0812
print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents:
7540
diff
changeset
|
103 ## GIF image |
5361 | 104 ## @item pbm |
105 ## PBMplus | |
6965 | 106 ## @item svg |
107 ## Scalable vector graphics | |
7396 | 108 ## @item pdf |
109 ## Portable document format | |
5361 | 110 ## @end table |
111 ## | |
112 ## If the device is omitted, it is inferred from the file extension, | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
113 ## or if there is no filename it is sent to the printer as postscript. |
5361 | 114 ## |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
115 ## @item -d@var{ghostscript_device} |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
116 ## Additional devices are supported by Ghostscript. |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
117 ## Some examples are; |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
118 ## |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
119 ## @table @code |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
120 ## @item ljet2p |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
121 ## HP LaserJet IIP |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
122 ## @item ljet3 |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
123 ## HP LaserJet III |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
124 ## @item deskjet |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
125 ## HP DeskJet and DeskJet Plus |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
126 ## @item cdj550 |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
127 ## HP DeskJet 550C |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
128 ## @item paintjet |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
129 ## HP PointJet |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
130 ## @item pcx24b |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
131 ## 24-bit color PCX file format |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
132 ## @item ppm |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
133 ## Portable Pixel Map file format |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
134 ## @end table |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
135 ## |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
136 ## For a complete list, type `system ("gs -h")' to see what formats |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
137 ## and devices are available. |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
138 ## |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
139 ## When the ghostscript is sent to a printer the size is determined |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
140 ## by the figure's "papersize" property. When the ghostscript output |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
141 ## is sent to a file the size is determined by the figure's |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
142 ## "paperposition" property. |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
143 ## |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
144 ## @itemx -append |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
145 ## Appends the output to a pre-existing file. Presently only PDF, |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
146 ## and Postscript files are supported. |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
147 ## |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
148 ## @itemx -r@var{NUM} |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
149 ## Resolution of bitmaps in pixels per inch. For both metafiles and |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
150 ## SVG the default is the screen resolution, for other it is 150 dpi. |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
151 ## To specify screen resolution, use "-r0". |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
152 ## |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
153 ## @item -tight |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
154 ## Forces a tight bounding box for eps-files. Since the ghostscript |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
155 ## devices are conversion of an eps-file, this option works the those |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
156 ## devices as well. |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
157 ## |
6965 | 158 ## @itemx -S@var{xsize},@var{ysize} |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
159 ## Plot size in pixels for EMF, GIF, JPEG, PBM, PNG and SVG. If |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
160 ## using the command form of the print function, you must quote the |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
161 ## @var{xsize},@var{ysize} option. For example, by writing |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9157
diff
changeset
|
162 ## @w{@code{"-S640,480"}}. The size defaults to that specified by the |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
163 ## figure's paperposition property. |
6965 | 164 ## |
5361 | 165 ## @item -F@var{fontname} |
166 ## @itemx -F@var{fontname}:@var{size} | |
167 ## @itemx -F:@var{size} | |
168 ## @var{fontname} set the postscript font (for use with postscript, | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
169 ## aifm, corel and fig). By default, 'Helvetica' is set for PS/Aifm, |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
170 ## and 'SwitzerlandLight' for Corel. It can also be 'Times-Roman'. |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
171 ## @var{size} is given in points. @var{fontname} is ignored for the |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
172 ## fig device. |
5361 | 173 ## @end table |
174 ## | |
175 ## The filename and options can be given in any order. | |
176 ## @end deftypefn | |
177 | |
178 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | |
5362 | 179 ## Adapted-By: jwe |
5361 | 180 |
5362 | 181 function print (varargin) |
5361 | 182 |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
183 persistent warn_on_inconsistent_orientation = true |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
184 orientation = ""; |
5361 | 185 use_color = 0; # 0=default, -1=mono, +1=color |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
186 append_to_file = 0; |
5361 | 187 force_solid = 0; # 0=default, -1=dashed, +1=solid |
5363 | 188 fontsize = ""; |
189 font = ""; | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
190 canvas_size = ""; |
5363 | 191 name = ""; |
192 devopt = ""; | |
193 printer = ""; | |
6870 | 194 debug = false; |
6872 | 195 debug_file = "octave-print-commands.log"; |
7037 | 196 special_flag = "textnormal"; |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
197 tight_flag = false; |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
198 resolution = ""; |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
199 |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
200 persistent ghostscript_binary = ""; |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
201 if (isempty (ghostscript_binary)) |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
202 ghostscript_binary = getenv ("GSC"); |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
203 ng = 0; |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
204 if (isunix ()) |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
205 ## Unix - Includes Mac OSX and Cygwin. |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
206 gs_binaries = {"gs", "gs.exe"}; |
9249
470af0f93ca9
ghostscript handling for windows in print.m
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
9209
diff
changeset
|
207 else |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
208 ## pc - Includes Win32 and mingw. |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
209 gs_binaries = {"gs.exe", "gswin32c.exe"}; |
9249
470af0f93ca9
ghostscript handling for windows in print.m
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
9209
diff
changeset
|
210 endif |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
211 while (ng < numel (gs_binaries) && isempty (ghostscript_binary)) |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
212 ng = ng + 1; |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
213 ghostscript_binary = file_in_path (EXEC_PATH, gs_binaries{ng}); |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
214 endwhile |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
215 endif |
5361 | 216 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
217 old_fig = get (0, "currentfigure"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
218 unwind_protect |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
219 ## 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
|
220 ## plot(...); print(...); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
221 drawnow (); |
7032 | 222 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
223 for i = 1:nargin |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
224 arg = varargin{i}; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
225 if (ischar (arg)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
226 if (strcmp (arg, "-color")) |
10422 | 227 use_color = 1; |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
228 elseif (strcmp (arg, "-append")) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
229 append_to_file = 1; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
230 elseif (strcmp (arg, "-mono")) |
10422 | 231 use_color = -1; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
232 elseif (strcmp (arg, "-solid")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
233 force_solid = 1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
234 elseif (strcmp (arg, "-dashed")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
235 force_solid = -1; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
236 elseif (strcmp (arg, "-portrait")) |
10422 | 237 orientation = "portrait"; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
238 elseif (strcmp (arg, "-landscape")) |
10422 | 239 orientation = "landscape"; |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
240 elseif (strcmp (arg, "-tight")) |
10422 | 241 tight_flag = true; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
242 elseif (strcmp (arg, "-textspecial")) |
10422 | 243 special_flag = "textspecial"; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
244 elseif (strncmp (arg, "-debug", 6)) |
10422 | 245 debug = true; |
246 if (length (arg) > 7) | |
247 debug_file = arg(8:end); | |
248 endif | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
249 elseif (length (arg) > 2 && arg(1:2) == "-d") |
10422 | 250 devopt = tolower(arg(3:end)); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
251 elseif (length (arg) > 2 && arg(1:2) == "-P") |
10422 | 252 printer = arg; |
253 elseif ((length (arg) > 2) && arg(1:2) == "-G") | |
254 ghostscript_binary = arg(3:end); | |
255 if (exist (ghostscript_binary, "file") != 2) | |
256 ghostscript_binary = file_in_path (EXEC_PATH, ghostscript_binary); | |
257 endif | |
258 if (isempty (ghostscript_binary)) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10567
diff
changeset
|
259 error ("print: Ghostscript binary ""%s"" could not be located", arg(3:end)) |
10422 | 260 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
261 elseif (length (arg) > 2 && arg(1:2) == "-F") |
10422 | 262 idx = rindex (arg, ":"); |
263 if (idx) | |
264 font = arg(3:idx-1); | |
265 fontsize = arg(idx+1:length(arg)); | |
266 else | |
267 font = arg(3:length(arg)); | |
268 endif | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
269 elseif (length (arg) > 2 && arg(1:2) == "-S") |
10422 | 270 canvas_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
|
271 elseif (length (arg) > 2 && arg(1:2) == "-r") |
10422 | 272 resolution = arg(3:length(arg)); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
273 elseif (length (arg) >= 1 && arg(1) == "-") |
10422 | 274 error ("print: unknown option `%s'", arg); |
275 elseif (length (arg) > 0) | |
276 name = arg; | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
277 endif |
8239
041bb0c64f07
orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents:
8049
diff
changeset
|
278 elseif (isfigure (arg)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
279 figure (arg); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
280 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
281 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
|
282 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
283 endfor |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
284 |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
285 have_ghostscript = (exist (ghostscript_binary, "file") == 2); |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
286 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
287 doprint = isempty (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
288 if (doprint) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
289 if (isempty (devopt)) |
10422 | 290 if (use_color < 0) |
291 devopt = "ps"; | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
292 printname = cstrcat (tmpnam, ".ps"); |
10422 | 293 else |
294 devopt = "psc"; | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
295 printname = cstrcat (tmpnam, ".psc"); |
10422 | 296 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
297 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
298 printname = cstrcat (tmpnam, ".", devopt); |
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 name = printname; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
301 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
302 |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
303 dot = rindex (name, "."); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
304 if (isempty (devopt)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
305 if (dot == 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
306 error ("print: no format specified"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
307 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
308 dev = tolower (name(dot+1:end)); |
5361 | 309 endif |
310 else | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
311 dev = devopt; |
5361 | 312 endif |
313 | |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
314 dev_list = {"aifm", "corel", "fig", "png", "jpeg", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
315 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
316 "ps", "ps2", "psc", "psc2", "eps", "eps2", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
317 "epsc", "epsc2", "emf", "pdf", "pslatex", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
318 "epslatex", "epslatexstandalone", "pstex", "tikz"}; |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
319 suffixes = {"ai", "cdr", "fig", "png", "jpeg", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
320 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
321 "ps", "ps", "ps", "ps", "eps", "eps", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
322 "eps", "eps", "emf", "pdf", "tex", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
323 "tex", "tex", "tex", "tikz"}; |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
324 if (dot == 0) |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
325 name = strcat (name, ".", suffixes {strcmpi (dev_list, dev)}); |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
326 dot = rindex (name, "."); |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
327 endif |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
328 |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
329 if (append_to_file) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
330 if (any (strcmpi (dev, {"ps", "ps2", "psc", "psc2", "pdf"}))) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
331 if (have_ghostscript) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
332 file_exists = ((numel (dir (name)) == 1) && (! isdir (name))); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
333 if (! file_exists) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
334 append_to_file = 0; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
335 end |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
336 end |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
337 else |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
338 warning ("print.m: appended output is not supported for device '%s'", dev) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
339 append_to_file = 0; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
340 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
341 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
342 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
343 if (strcmp (dev, "tex")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
344 dev = "epslatex"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
345 elseif (strcmp (dev, "ill")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
346 dev = "aifm"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
347 elseif (strcmp (dev, "cdr")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
348 dev = "corel"; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
349 elseif (strcmp (dev, "meta")) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
350 dev = "emf"; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
351 elseif (strcmp (dev, "jpg")) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
352 dev = "jpeg"; |
5361 | 353 endif |
354 | |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
355 if (strcmp (dev, "epslatex")) |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
356 ## gnuplot 4.0 wants ".eps" in the output name |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
357 if (! __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
358 name = cstrcat (name(1:dot), "eps"); |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
359 endif |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
360 endif |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
361 |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
362 ## Check if the specified device is one that is supported by gnuplot. |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
363 ## If not, assume it is a device/format supported by Ghostscript. |
9337
878df7c11e3d
print.m: Fix logic associated with 'have_ghostscript'.
Ben Abbott <bpabbott@mac.com>
parents:
9334
diff
changeset
|
364 if (! any (strcmp (dev, dev_list)) && have_ghostscript) |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
365 ghostscript_output = name; |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
366 ghostscript_device = dev; |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
367 if (doprint) |
10422 | 368 ## If printing, use color postscript. |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
369 dev = "psc"; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
370 name = cstrcat (tmpnam, ".ps"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
371 else |
10422 | 372 ## If saving to a file, use color encapsulated postscript. |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
373 dev = "epsc"; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
374 name = cstrcat (tmpnam, ".eps"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
375 endif |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
376 elseif (doprint && all (! strcmpi (suffixes {strcmpi (dev_list, dev)}, |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
377 {"ps", "eps", "hpgl"}))) |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
378 ## When not using Ghostscript, verify the format is compatible with |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
379 ## hard copy output. |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
380 error ("print: missing file name, or invalid print format."); |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
381 else |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
382 ghostscript_output = ""; |
5361 | 383 endif |
5363 | 384 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
385 termn = dev; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
386 |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
387 ## SVG isn't actually a bitmap, but gnuplot treats its size option as it |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
388 ## does the bitmap terminals. |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
389 bitmap_devices = {"emf", "gif", "jpeg", "pbm", "png", "svg"}; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
390 |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
391 if (any (strcmp (dev, {"ps", "ps2", "psc", "psc2", "epsc", "epsc2", ... |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
392 "eps", "eps2", "pstex", "pslatex", "epslatex", ... |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
393 "epslatexstandalone"}))) |
6727 | 394 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
395 ## Various postscript options |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
396 if (any (strcmp (dev, {"pstex", "pslatex", "epslatex"}))) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
397 options = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
398 elseif (strcmp (dev, "epslatexstandalone")) |
8639
399af34bb4bf
# User Ben Abbott <bpabbott@mac.com>
John W. Eaton <jwe@octave.org>
parents:
8239
diff
changeset
|
399 if (__gnuplot_has_feature__ ("epslatexstandalone_terminal")) |
10422 | 400 termn = "epslatex"; |
401 options = "standalone "; | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
402 else |
10422 | 403 error ("print: epslatexstandalone needs gnuplot 4.2 or higher"); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
404 endif |
6727 | 405 else |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
406 if (dev(1) == "e") |
10422 | 407 options = "eps "; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
408 else |
10422 | 409 options = ""; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
410 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
411 termn = "postscript"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
412 endif |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
413 |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
414 if (any (dev == "c") || use_color > 0 |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
415 || (! isempty (strfind (dev, "tex")) && use_color == 0)) |
10422 | 416 use_color = 1; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
417 else |
10422 | 418 use_color = -1; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
419 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
420 |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
421 if (use_color > 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
422 if (force_solid < 0) |
10422 | 423 options = cstrcat (options, "color dashed "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
424 else |
10422 | 425 options = cstrcat (options, "color solid "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
426 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
427 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
428 if (force_solid > 0) |
10422 | 429 options = cstrcat (options, "mono solid "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
430 else |
10422 | 431 options = cstrcat (options, "mono dashed "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
432 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
433 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
434 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
435 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
436 options = cstrcat (options, "\"", font, "\" "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
437 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
438 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
439 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
440 endif |
9468
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
441 |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
442 elseif (strcmp (dev, "tikz")) |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
443 if (! isempty (font) && ! isempty (fontsize)) |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
444 options = cstrcat (options, "\"", font, ",", fontsize, "\" "); |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
445 elseif (! isempty (font)) |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
446 options = cstrcat (options, "\"", font, "\" "); |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
447 else |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
448 options = ""; |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
449 endif |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
450 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
451 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
452 ## Adobe Illustrator, CorelDraw |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
453 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
454 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
455 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
456 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
457 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
458 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
459 options = cstrcat (options, " \"", font, "\""); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
460 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
461 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
462 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
463 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
464 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
465 elseif (strcmp (dev, "fig")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
466 ## XFig |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
467 options = orientation; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
468 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
469 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
470 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
471 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
472 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
473 options = cstrcat (options, " ", special_flag); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
474 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
475 options = cstrcat (options, " fontsize ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
476 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
477 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
478 elseif (strcmp (dev, "emf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
479 ## Enhanced Metafile format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
480 options = " "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
481 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
482 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
483 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
484 options = " mono"; |
6727 | 485 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
486 if (force_solid >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
487 options = cstrcat (options, " solid"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
488 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
489 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
490 options = cstrcat (options, " \"", font, "\""); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
491 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
492 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
493 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
494 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
495 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
496 elseif (any (strcmp (dev, bitmap_devices))) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
497 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
498 if (isempty (canvas_size) && isempty (resolution) |
10422 | 499 && any (strcmp (dev, {"pbm", "gif", "jpeg", "png"}))) |
500 options = ""; | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
501 elseif (strcmp (dev, "svg")) |
10422 | 502 ## Referring to size, either "dynamic" or "fixed" |
503 options = "fixed"; | |
6727 | 504 else |
10422 | 505 options = ""; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
506 end |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
507 if (! isempty (canvas_size)) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
508 options = cstrcat (options, " size ", canvas_size); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
509 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
510 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
511 elseif (any (strcmp (dev, {"dxf", "mf", "hpgl"}))) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
512 ## AutoCad DXF, METAFONT, HPGL |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
513 options = ""; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
514 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
515 elseif (strcmp (dev, "pdf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
516 ## Portable Document format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
517 options = " "; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
518 if (use_color >= 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
519 options = "color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
520 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
521 options = "mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
522 endif |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
523 if (force_solid >= 0) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
524 options = cstrcat (options, " solid"); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
525 elseif (force_solid < 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
526 options = cstrcat (options, " dashed"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
527 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
528 if (! isempty (font)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
529 options = cstrcat (options, "\"", font, "\" "); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
530 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
531 if (! isempty (fontsize)) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
532 options = cstrcat (options, " ", fontsize); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
533 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
534 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
535 endif |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
536 |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
537 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
538 available_terminals = __gnuplot_get_var__ (gcf, "GPVAL_TERMINALS"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
539 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
540 ## Favor the cairo terminals. |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
541 if (strcmp (termn, "pdf") |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
542 && any (strcmp (available_terminals, "pdfcairo"))) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
543 termn = "pdfcairo"; |
10422 | 544 gnuplot_supports_term = true; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
545 elseif (strcmp (termn, "png") |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
546 && any (strcmp (available_terminals, "pngcairo"))) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
547 termn = "pngcairo"; |
10422 | 548 gnuplot_supports_term = true; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
549 else |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
550 gnuplot_supports_term = any (strcmp (available_terminals, termn)); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
551 endif |
9337
878df7c11e3d
print.m: Fix logic associated with 'have_ghostscript'.
Ben Abbott <bpabbott@mac.com>
parents:
9334
diff
changeset
|
552 elseif (strcmp (termn, "pdf")) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
553 ## Some Linux variants do not include a "pdf" capable gnuplot. |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
554 ## To be safe, use Ghostscript. |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
555 if (have_ghostscript) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
556 gnuplot_supports_term = false; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
557 ghostscript_device = "pdfwrite"; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
558 else |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
559 gnuplot_supports_term = true; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
560 endif |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
561 else |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
562 gnuplot_supports_term = true; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
563 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
564 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
565 if (! gnuplot_supports_term) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
566 if (strcmp (termn, "pdf")) |
10422 | 567 ## If there the installed gnuplot does not support pdf, use Ghostscript. |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
568 ghostscript_device = "pdfwrite"; |
10422 | 569 if (strfind (name, ".pdf") == numel (name) - 3) |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
570 ghostscript_output = name; |
10422 | 571 else |
572 ghostscript_output = strcat (name, ".pdf"); | |
573 endif | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
574 name = cstrcat (tmpnam, ".ps"); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
575 termn = "postscript"; |
10422 | 576 ## All "options" for pdf work for postscript as well. |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
577 else |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
578 error ("print: the device, \"%s\", is not available.", dev) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
579 endif |
6179 | 580 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
581 |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
582 is_eps_file = strncmp (dev, "eps", 3); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
583 p.units = get (gcf, "units"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
584 p.paperunits = get (gcf, "paperunits"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
585 p.papersize = get (gcf, "papersize"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
586 p.paperposition = get (gcf, "paperposition"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
587 p.paperpositionmode = get (gcf, "paperpositionmode"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
588 p.paperorientation = get (gcf, "paperorientation"); |
10567
79410269cd21
print.m: Set figure color property to 'none' when printing.
Ben Abbott <bpabbott@mac.com>
parents:
10472
diff
changeset
|
589 p.color = get (gcf, "color"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
590 if (p.papersize(1) > p.papersize(2)) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
591 paperorientation = "landscape"; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
592 else |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
593 paperorientation = "portrait"; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
594 endif |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
595 if (! strcmp (paperorientation, get (gcf, "paperorientation")) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
596 && warn_on_inconsistent_orientation) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
597 msg = {"print.m - inconsistent papersize and paperorientation properties.\n", |
10422 | 598 sprintf(" papersize = %.2f, %.2f\n", p.papersize), |
599 sprintf(" paperorientation = \"%s\"\n", p.paperorientation), | |
600 " the paperorientation property has been ignored"}; | |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
601 warning ("%s",msg{:}) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
602 warn_on_inconsistent_orientation = false; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
603 endif |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
604 |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
605 if (strcmp (termn, "postscript") && ! strncmp (dev, "eps", 3)) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
606 if (isempty (orientation)) |
10422 | 607 orientation = paperorientation; |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
608 endif |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
609 ## This is done here to accommodate ghostscript conversion. |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
610 options = cstrcat (orientation, " ", options); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
611 end |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
612 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
613 new_terminal = cstrcat (termn, " ", options); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
614 |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
615 mono = (use_color < 0); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
616 |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
617 terminals_for_prn = {"postscript", "pdf", "pdfcairo"}; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
618 output_for_printer = any (strncmp (termn, terminals_for_prn, numel(termn))); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
619 |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
620 if (isempty (resolution)) |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
621 if (any (strcmp (dev, {"emf", "svg"})) || output_for_printer) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
622 resolution = get (0, "screenpixelsperinch"); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
623 else |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
624 resolution = 150; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
625 endif |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
626 else |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
627 resolution = str2num (resolution); |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
628 if (resolution == 0) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
629 resolution = get (0, "screenpixelsperinch"); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
630 endif |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
631 endif |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
632 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
|
633 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
|
634 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
|
635 endif |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
636 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
|
637 |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
638 unwind_protect |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
639 set (gcf, "paperunits", "inches"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
640 set (gcf, "units", "pixels"); |
10567
79410269cd21
print.m: Set figure color property to 'none' when printing.
Ben Abbott <bpabbott@mac.com>
parents:
10472
diff
changeset
|
641 set (gcf, "color", "none"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
642 restore_properties = true; |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
643 if ((! output_for_printer || is_eps_file) && ! doprint) |
10422 | 644 ## If not PDF or PostScript, and the result is not being sent to a printer, |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
645 ## render an image the size of the paperposition box. |
10422 | 646 ## Trigger the listener to convert all paper props to inches. |
647 if (! isempty (canvas_size)) | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
648 size_in_pixels = sscanf (canvas_size ,"%d, %d"); |
9056
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
649 size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]); |
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
650 papersize_in_inches = size_in_pixels ./ resolution; |
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
651 paperposition_in_inches = [0, 0, papersize_in_inches]; |
10422 | 652 else |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
653 paperposition_in_inches = get (gcf, "paperposition"); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
654 paperposition_in_inches(1:2) = 0; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
655 papersize_in_inches = paperposition_in_inches(3:4); |
9056
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
656 endif |
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
657 set (gcf, "papersize", papersize_in_inches); |
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
658 set (gcf, "paperposition", paperposition_in_inches); |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
659 set (gcf, "paperpositionmode", "manual"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
660 else |
10422 | 661 if (strcmp (p.paperpositionmode, "auto")) |
662 size_in_pixels = get (gcf, "position")(3:4); | |
663 paperposition_in_inches(3:4) = size_in_pixels ./ resolution; | |
664 paperposition_in_inches(1:2) = (p.papersize - paperposition_in_inches(3:4))/2; | |
665 else | |
666 paperposition_in_inches = p.paperposition; | |
667 endif | |
668 if (! isempty (orientation) && ! strcmp (orientation, paperorientation)) | |
669 ## When -landscape/portrait changes the orientation, flip both the | |
670 ## papersize and paperposition. | |
671 restore_properties = true; | |
672 set (gcf, "papersize", p.papersize([2, 1])); | |
673 set (gcf, "paperposition", paperposition_in_inches([2, 1, 4, 3])); | |
674 else | |
675 set (gcf, "paperposition", paperposition_in_inches); | |
676 endif | |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
677 endif |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
678 if (use_color < 0) |
10422 | 679 [objs_with_color, color_of_objs] = convert_color2mono (gcf); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
680 endif |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
681 if (append_to_file) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
682 appended_file_name = name; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
683 if (index(termn, "pdf")) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
684 name = cstrcat (tmpnam, ".pdf"); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
685 temp_name = cstrcat (tmpnam, ".pdf"); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
686 ghostscript_device = "pdfwrite"; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
687 else |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
688 name = cstrcat (tmpnam, ".ps"); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
689 temp_name = cstrcat (tmpnam, ".ps"); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
690 ghostscript_device = "pswrite"; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
691 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
692 endif |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
693 if (debug) |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
694 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
|
695 else |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
696 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
|
697 endif |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
698 if (append_to_file) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
699 ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE"; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
700 command = sprintf ("%s %s -sDEVICE=%s -sOutputFile=%s %s %s -q", ... |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
701 ghostscript_binary, ghostscript_options, ghostscript_device, ... |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
702 temp_name, appended_file_name, name); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
703 status1 = system (command); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
704 status2 = system (sprintf ("mv %s %s", temp_name, appended_file_name)); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
705 if (status1 != 0 || status2 != 0) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10567
diff
changeset
|
706 error ("print: output failed to append to '%s'.", appended_file_name); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
707 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
708 endif |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
709 unwind_protect_cleanup |
9056
b06dc393ac42
print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents:
9042
diff
changeset
|
710 ## FIXME - it would be nice to delete "__pixels_per_inch__" property here. |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
711 if (restore_properties) |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
712 props = fieldnames (p); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
713 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
|
714 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
|
715 endfor |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
716 endif |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
717 if (use_color < 0) |
10422 | 718 convert_mono_to_or_from_color (objs_with_color, color_of_objs, false); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
719 endif |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
720 end_unwind_protect |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
721 |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
722 if (! isempty (ghostscript_output)) |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
723 if (is_eps_file && tight_flag) |
10422 | 724 ## If gnuplot's output is an eps-file then crop at the bounding box. |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
725 fix_eps_bbox (name, ghostscript_binary); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
726 endif |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
727 ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4"; |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
728 if (is_eps_file) |
10422 | 729 ghostscript_options = sprintf ("%s -dEPSCrop", ghostscript_options); |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
730 endif |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
731 if (isempty (strfind (lower (ghostscript_device), "write"))) |
10422 | 732 ## If output is a bitmap then include the resolution |
733 ghostscript_options = sprintf ("%s -r%d", ghostscript_options, resolution); | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
734 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
735 ghostscript_options = sprintf ("%s -sDEVICE=%s", ghostscript_options, |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
736 ghostscript_device); |
9249
470af0f93ca9
ghostscript handling for windows in print.m
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
9209
diff
changeset
|
737 command = sprintf ("\"%s\" %s -sOutputFile=\"%s\" \"%s\" 2>&1", ghostscript_binary, |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
738 ghostscript_options, ghostscript_output, name); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
739 [errcode, output] = system (command); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
740 unlink (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
741 if (errcode) |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
742 error ("print: Conversion failed, %s -> %s.\nError was:\n%s\n", |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
743 name, ghostscript_output, output); |
5625 | 744 endif |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
745 elseif (is_eps_file && tight_flag && ! doprint) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
746 ## If the saved output file is an eps file, use ghostscript to set a tight bbox. |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
747 ## This may result in a smaller or larger bbox geometry. |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
748 if (have_ghostscript) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
749 fix_eps_bbox (name, ghostscript_binary); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
750 endif |
6179 | 751 endif |
6178 | 752 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
753 if (doprint) |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
754 if (isunix ()) |
10422 | 755 prn_opt = "-l"; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
756 elseif (ispc ()) |
10422 | 757 prn_opt = "-o l"; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
758 else |
10422 | 759 ## FIXME - besides Unix and Windows, what other OS's might be considered. |
760 prn_opt = ""; | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
761 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
762 if (isempty (printer)) |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
763 prn_cmd = sprintf ("lpr %s '%s' 2>&1", prn_opt, printname); |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
764 else |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
765 prn_cmd = sprintf ("lpr %s -P %s '%s' 2>&1", prn_opt, printer, printname); |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
766 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
767 [status, output] = system (prn_cmd); |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
768 if (status != 0) |
10422 | 769 disp (output) |
770 warning ("print.m: printing failed.") | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
771 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
772 [status, output] = unlink (printname); |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
773 if (status != 0) |
10422 | 774 disp (output) |
775 warning ("print.m: failed to delete temporay file, '%s'.", printname) | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
776 endif |
6179 | 777 endif |
778 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
779 unwind_protect_cleanup |
8239
041bb0c64f07
orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents:
8049
diff
changeset
|
780 if (isfigure (old_fig)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
781 figure (old_fig) |
6965 | 782 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
783 end_unwind_protect |
5363 | 784 |
5361 | 785 endfunction |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
786 |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
787 function bb = fix_eps_bbox (eps_file_name, ghostscript_binary) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
788 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
789 persistent warn_on_no_ghostscript = true |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
790 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
791 box_string = "%%BoundingBox:"; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
792 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
793 ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4 -sDEVICE=bbox"; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
794 cmd = sprintf ("\"%s\" %s \"%s\" 2>&1", ghostscript_binary, |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
795 ghostscript_options, eps_file_name); |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
796 [status, output] = system (cmd); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
797 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
798 if (status == 0) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
799 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
800 pattern = strcat (box_string, "[^%]*"); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
801 pattern = pattern(1:find(double(pattern)>32, 1, "last")); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
802 bbox_line = regexp (output, pattern, "match"); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
803 if (iscell (bbox_line)) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
804 bbox_line = bbox_line{1}; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
805 endif |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
806 ## Remore the EOL characters. |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
807 bbox_line(double(bbox_line)<32) = ""; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
808 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
809 fid = fopen (eps_file_name, "r+"); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
810 unwind_protect |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
811 bbox_replaced = false; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
812 while (! bbox_replaced) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
813 current_line = fgetl (fid); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
814 if (strncmpi (current_line, box_string, numel(box_string))) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
815 line_length = numel (current_line); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
816 num_spaces = line_length - numel (bbox_line); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
817 if (numel (current_line) < numel (bbox_line)) |
10422 | 818 ## If there new line is longer, continue with the current line. |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
819 new_line = current_line; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
820 else |
10422 | 821 new_line = bbox_line; |
822 new_line(end+1:numel(current_line)) = " "; | |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
823 endif |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
824 ## Back up to the beginning of the line (include EOL characters). |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
825 if (ispc ()) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
826 fseek (fid, -line_length-2, "cof"); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
827 else |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
828 fseek (fid, -line_length-1, "cof"); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
829 endif |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
830 count = fprintf (fid, "%s", new_line); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
831 bbox_replaced = true; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
832 elseif (! ischar (current_line)) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
833 bbox_replaced = true; |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
834 warning ("print.m: no bounding box found in '%s'.", eps_file_name) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
835 endif |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
836 endwhile |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
837 unwind_protect_cleanup |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
838 fclose (fid); |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
839 end_unwind_protect |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
840 elseif (warn_on_no_ghostscript) |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
841 warn_on_no_ghostscript = false; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
842 warning ("print.m: Ghostscript failed to determine the bounding box.\nError was:\n%s\n", output) |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
843 endif |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
844 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
845 endfunction |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
846 |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
847 function [h, c] = convert_color2mono (hfig) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
848 unwind_protect |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
849 showhiddenhandles = get (0, "showhiddenhandles"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
850 set (0, "showhiddenhandles", "on"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
851 h.color = findobj (hfig, "-property", "color"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
852 h.facecolor = findobj (hfig, "-property", "facecolor"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
853 h.edgecolor = findobj (hfig, "-property", "edgecolor"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
854 h.backgroundcolor = findobj (hfig, "-property", "backgroundcolor"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
855 h.colormap = findobj (hfig, "-property", "colormap"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
856 unwind_protect_cleanup |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
857 set (0, "showhiddenhandles", showhiddenhandles); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
858 end_unwind_protect |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
859 f = fieldnames (h); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
860 for nf = 1:numel(f) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
861 if (! isempty (h.(f{nf}))) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
862 v = get (h.(f{nf}), f{nf}); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
863 if (! iscell (v)) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
864 v = {v}; |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
865 endif |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
866 c.(f{nf}) = v; |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
867 endif |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
868 endfor |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
869 convert_mono_to_or_from_color (h, c, true) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
870 endfunction |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
871 |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
872 function convert_mono_to_or_from_color (h, c, mono) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
873 f = fieldnames (h); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
874 for nf = 1:numel(f) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
875 for nh = 1:numel (h.(f{nf})) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
876 color = c.(f{nf}){nh}; |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
877 ## Ignore color == {"none", "flat", ...} |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
878 if (isfloat (color)) |
10422 | 879 if (mono) |
880 ## Same method as used by rgb2gray in the image pkg. | |
881 color = rgb2ntsc (color)(:,1) * ones (1, 3); | |
882 endif | |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
883 set (h.(f{nf})(nh), f{nf}, color); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
884 endif |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
885 endfor |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
886 endfor |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
887 endfunction |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
888 |