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