Mercurial > hg > octave-lyh
annotate scripts/plot/__gnuplot_print__.m @ 10821:693e22af08ae
Grammarcheck documentation of m-files
Add newlines between @item fields for readability.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 26 Jul 2010 21:25:36 -0700 |
parents | be55736a0783 |
children | 05ba991794d4 |
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 -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10789
diff
changeset
|
21 ## @deftypefn {Function File} {} __gnuplot_ginput__ (@var{@dots{}}) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
22 ## Undocumented internal function. |
5361 | 23 ## @end deftypefn |
24 | |
25 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | |
5362 | 26 ## Adapted-By: jwe |
5361 | 27 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
28 function __gnuplot_print__ (varargin) |
5361 | 29 |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
30 persistent warn_on_inconsistent_orientation = true |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
31 |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
32 persistent ghostscript_binary = ""; |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
33 if (isempty (ghostscript_binary)) |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
34 ghostscript_binary = getenv ("GSC"); |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
35 ng = 0; |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
36 if (isunix ()) |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
37 ## Unix - Includes Mac OSX and Cygwin. |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
38 gs_binaries = {"gs", "gs.exe"}; |
9249
470af0f93ca9
ghostscript handling for windows in print.m
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
9209
diff
changeset
|
39 else |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
40 ## pc - Includes Win32 and mingw. |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
41 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
|
42 endif |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
43 while (ng < numel (gs_binaries) && isempty (ghostscript_binary)) |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
44 ng = ng + 1; |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
45 ghostscript_binary = file_in_path (EXEC_PATH, gs_binaries{ng}); |
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
46 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
|
47 endif |
5361 | 48 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
49 old_fig = get (0, "currentfigure"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
50 unwind_protect |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
51 opts = __print_parse_opts__ (varargin{:}); |
9847
131d8c70920a
print.m: Properly set the default ghostscript_binary under Windows.
Ben Abbott <bpabbott@mac.com>
parents:
9758
diff
changeset
|
52 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
|
53 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
54 doprint = isempty (opts.name); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
55 if (doprint) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
56 if (isempty (opts.devopt)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
57 if (opts.use_color < 0) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
58 opts.devopt = "ps"; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
59 printname = cstrcat (tmpnam, ".ps"); |
10422 | 60 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
61 opts.devopt = "psc"; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
62 printname = cstrcat (tmpnam, ".psc"); |
10422 | 63 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
64 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
65 printname = cstrcat (tmpnam, ".", devopt); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
66 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
67 opts.name = printname; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
68 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
69 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
70 dot = rindex (opts.name, "."); |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
71 if (isempty (opts.devopt)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
72 if (dot == 0) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
73 error ("print: no format specified"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
74 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
75 dev = tolower (opts.name(dot+1:end)); |
5361 | 76 endif |
77 else | |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
78 dev = opts.devopt; |
5361 | 79 endif |
80 | |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
81 dev_list = {"aifm", "corel", "fig", "png", "jpeg", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
82 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
83 "ps", "ps2", "psc", "psc2", "eps", "eps2", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
84 "epsc", "epsc2", "emf", "pdf", "pslatex", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
85 "epslatex", "epslatexstandalone", "pstex", "tikz"}; |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
86 suffixes = {"ai", "cdr", "fig", "png", "jpeg", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
87 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
88 "ps", "ps", "ps", "ps", "eps", "eps", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
89 "eps", "eps", "emf", "pdf", "tex", ... |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
90 "tex", "tex", "tex", "tikz"}; |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
91 if (dot == 0) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
92 opts.name = strcat (opts.name, ".", suffixes {strcmpi (dev_list, dev)}); |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
93 dot = rindex (name, "."); |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
94 endif |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
95 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
96 if (opts.append_to_file) |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
97 if (any (strcmpi (dev, {"ps", "ps2", "psc", "psc2", "pdf"}))) |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
98 if (have_ghostscript) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
99 file_exists = ((numel (dir (opts.name)) == 1) && (! isdir (opts.name))); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
100 if (! file_exists) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
101 opts.append_to_file = 0; |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
102 end |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
103 end |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
104 else |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
105 warning ("print.m: appended output is not supported for device '%s'", dev) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
106 opts.append_to_file = 0; |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
107 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
108 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
109 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
110 if (strcmp (dev, "tex")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
111 dev = "epslatex"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
112 elseif (strcmp (dev, "ill")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
113 dev = "aifm"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
114 elseif (strcmp (dev, "cdr")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
115 dev = "corel"; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
116 elseif (strcmp (dev, "meta")) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
117 dev = "emf"; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
118 elseif (strcmp (dev, "jpg")) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
119 dev = "jpeg"; |
5361 | 120 endif |
121 | |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
122 if (strcmp (dev, "epslatex")) |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
123 ## gnuplot 4.0 wants ".eps" in the output name |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
124 if (! __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
125 opts.name = cstrcat (name(1:dot), "eps"); |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
126 endif |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
127 endif |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
128 |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
129 ## 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
|
130 ## If not, assume it is a device/format supported by Ghostscript. |
9337
878df7c11e3d
print.m: Fix logic associated with 'have_ghostscript'.
Ben Abbott <bpabbott@mac.com>
parents:
9334
diff
changeset
|
131 if (! any (strcmp (dev, dev_list)) && have_ghostscript) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
132 ghostscript_output = opts.name; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
133 ghostscript_device = dev; |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
134 if (doprint) |
10422 | 135 ## If printing, use color postscript. |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
136 dev = "psc"; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
137 opts.name = cstrcat (tmpnam, ".ps"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
138 else |
10422 | 139 ## If saving to a file, use color encapsulated postscript. |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
140 dev = "epsc"; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
141 opts.name = cstrcat (tmpnam, ".eps"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
142 endif |
10472
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
143 elseif (doprint && all (! strcmpi (suffixes {strcmpi (dev_list, dev)}, |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
144 {"ps", "eps", "hpgl"}))) |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
145 ## When not using Ghostscript, verify the format is compatible with |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
146 ## hard copy output. |
944aa97069ed
print.m: Provide default suffixes & validate hardcopy format.
Ben Abbott <bpabbott@mac.com>
parents:
10423
diff
changeset
|
147 error ("print: missing file name, or invalid print format."); |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
148 else |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
149 ghostscript_output = ""; |
5361 | 150 endif |
5363 | 151 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
152 termn = dev; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
153 |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
154 ## 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
|
155 ## does the bitmap terminals. |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
156 bitmap_devices = {"emf", "gif", "jpeg", "pbm", "png", "svg"}; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
157 |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
158 if (any (strcmp (dev, {"ps", "ps2", "psc", "psc2", "epsc", "epsc2", ... |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
159 "eps", "eps2", "pstex", "pslatex", "epslatex", ... |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
160 "epslatexstandalone"}))) |
6727 | 161 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
162 ## Various postscript options |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
163 if (any (strcmp (dev, {"pstex", "pslatex", "epslatex"}))) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
164 options = ""; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
165 elseif (strcmp (dev, "epslatexstandalone")) |
8639
399af34bb4bf
# User Ben Abbott <bpabbott@mac.com>
John W. Eaton <jwe@octave.org>
parents:
8239
diff
changeset
|
166 if (__gnuplot_has_feature__ ("epslatexstandalone_terminal")) |
10422 | 167 termn = "epslatex"; |
168 options = "standalone "; | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
169 else |
10422 | 170 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
|
171 endif |
6727 | 172 else |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
173 if (dev(1) == "e") |
10422 | 174 options = "eps "; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
175 else |
10422 | 176 options = ""; |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
177 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
178 termn = "postscript"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
179 endif |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
180 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
181 if (any (dev == "c") || opts.use_color > 0 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
182 || (! isempty (strfind (dev, "tex")) && opts.use_color == 0)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
183 opts.use_color = 1; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
184 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
185 opts.use_color = -1; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
186 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
187 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
188 if (opts.use_color > 0) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
189 if (opts.force_solid < 0) |
10422 | 190 options = cstrcat (options, "color dashed "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
191 else |
10422 | 192 options = cstrcat (options, "color solid "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
193 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
194 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
195 if (opts.force_solid > 0) |
10422 | 196 options = cstrcat (options, "mono solid "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
197 else |
10422 | 198 options = cstrcat (options, "mono dashed "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
199 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
200 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
201 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
202 if (! isempty (opts.font)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
203 options = cstrcat (options, "\"", opts.font, "\" "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
204 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
205 if (! isempty (opts.fontsize)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
206 options = cstrcat (options, " ", opts.fontsize); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
207 endif |
9468
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
208 |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
209 elseif (strcmp (dev, "tikz")) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
210 if (! isempty (font) && ! isempty (opts.fontsize)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
211 options = cstrcat (options, "\"", opts.font, ",", opts.fontsize, "\" "); |
9468
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
212 elseif (! isempty (font)) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
213 options = cstrcat (options, "\"", opts.font, "\" "); |
9468
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
214 else |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
215 options = ""; |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
216 endif |
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9393
diff
changeset
|
217 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
218 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
219 ## Adobe Illustrator, CorelDraw |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
220 if (opts.use_color >= 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
221 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
222 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
223 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
224 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
225 if (! isempty (opts.font)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
226 options = cstrcat (options, " \"", opts.font, "\""); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
227 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
228 if (! isempty (opts.fontsize)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
229 options = cstrcat (options, " ", opts.fontsize); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
230 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
231 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
232 elseif (strcmp (dev, "fig")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
233 ## XFig |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
234 options = opts.orientation; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
235 if (opts.use_color >= 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
236 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
237 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
238 options = " mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
239 endif |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
240 options = cstrcat (options, " ", opts.special_flag); |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
241 if (! isempty (opts.fontsize)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
242 options = cstrcat (options, " fontsize ", opts.fontsize); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
243 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
244 |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
245 elseif (strcmp (dev, "emf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
246 ## Enhanced Metafile format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
247 options = " "; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
248 if (opts.use_color >= 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
249 options = " color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
250 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
251 options = " mono"; |
6727 | 252 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
253 if (opts.force_solid >= 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
254 options = cstrcat (options, " solid"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
255 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
256 if (! isempty (opts.font)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
257 options = cstrcat (options, " \"", opts.font, "\""); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
258 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
259 if (! isempty (opts.fontsize)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
260 options = cstrcat (options, " ", opts.fontsize); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
261 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
262 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
263 elseif (any (strcmp (dev, bitmap_devices))) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
264 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
265 if (isempty (opts.canvas_size) && isempty (opts.resolution) |
10422 | 266 && any (strcmp (dev, {"pbm", "gif", "jpeg", "png"}))) |
267 options = ""; | |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
268 elseif (strcmp (dev, "svg")) |
10422 | 269 ## Referring to size, either "dynamic" or "fixed" |
270 options = "fixed"; | |
6727 | 271 else |
10422 | 272 options = ""; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
273 end |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
274 if (! isempty (opts.canvas_size)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
275 options = cstrcat (options, " size ", opts.canvas_size); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
276 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
277 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
278 elseif (any (strcmp (dev, {"dxf", "mf", "hpgl"}))) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
279 ## AutoCad DXF, METAFONT, HPGL |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
280 options = ""; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
281 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
282 elseif (strcmp (dev, "pdf")) |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
283 ## Portable Document format |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
284 options = " "; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
285 if (opts.use_color >= 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
286 options = "color"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
287 else |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
288 options = "mono"; |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
289 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
290 if (opts.force_solid >= 0) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
291 options = cstrcat (options, " solid"); |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
292 elseif (opts.force_solid < 0) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
293 options = cstrcat (options, " dashed"); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
294 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
295 if (! isempty (opts.font)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
296 options = cstrcat (options, "\"", opts.font, "\" "); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
297 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
298 if (! isempty (opts.fontsize)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
299 options = cstrcat (options, " ", opts.fontsize); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
300 endif |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
301 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
302 endif |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
303 |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
304 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
305 available_terminals = __gnuplot_get_var__ (gcf, "GPVAL_TERMINALS"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
306 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
307 ## Favor the cairo terminals. |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
308 if (strcmp (termn, "pdf") |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
309 && any (strcmp (available_terminals, "pdfcairo"))) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
310 termn = "pdfcairo"; |
10422 | 311 gnuplot_supports_term = true; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
312 elseif (strcmp (termn, "png") |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
313 && any (strcmp (available_terminals, "pngcairo"))) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
314 termn = "pngcairo"; |
10422 | 315 gnuplot_supports_term = true; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
316 else |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
317 gnuplot_supports_term = any (strcmp (available_terminals, termn)); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
318 endif |
9337
878df7c11e3d
print.m: Fix logic associated with 'have_ghostscript'.
Ben Abbott <bpabbott@mac.com>
parents:
9334
diff
changeset
|
319 elseif (strcmp (termn, "pdf")) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
320 ## 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
|
321 ## To be safe, use Ghostscript. |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
322 if (have_ghostscript) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
323 gnuplot_supports_term = false; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
324 ghostscript_device = "pdfwrite"; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
325 else |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
326 gnuplot_supports_term = true; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
327 endif |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
328 else |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
329 gnuplot_supports_term = true; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
330 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
331 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
332 if (! gnuplot_supports_term) |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
333 if (strcmp (termn, "pdf")) |
10422 | 334 ## If there the installed gnuplot does not support pdf, use Ghostscript. |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
335 ghostscript_device = "pdfwrite"; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
336 if (strfind (opts.name, ".pdf") == numel (opts.name) - 3) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
337 ghostscript_output = opts.name; |
10422 | 338 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
339 ghostscript_output = strcat (opts.name, ".pdf"); |
10422 | 340 endif |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
341 name = cstrcat (tmpnam, ".ps"); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
342 termn = "postscript"; |
10422 | 343 ## All "options" for pdf work for postscript as well. |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
344 else |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
345 error ("print: the device, \"%s\", is not available.", dev) |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
346 endif |
6179 | 347 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
348 |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
349 is_eps_file = strncmp (dev, "eps", 3); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
350 p.units = get (gcf, "units"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
351 p.paperunits = get (gcf, "paperunits"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
352 p.papersize = get (gcf, "papersize"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
353 p.paperposition = get (gcf, "paperposition"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
354 p.paperpositionmode = get (gcf, "paperpositionmode"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
355 p.paperorientation = get (gcf, "paperorientation"); |
10567
79410269cd21
print.m: Set figure color property to 'none' when printing.
Ben Abbott <bpabbott@mac.com>
parents:
10472
diff
changeset
|
356 p.color = get (gcf, "color"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
357 if (p.papersize(1) > p.papersize(2)) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
358 paperorientation = "landscape"; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
359 else |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
360 paperorientation = "portrait"; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
361 endif |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
362 if (! strcmp (paperorientation, get (gcf, "paperorientation")) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
363 && warn_on_inconsistent_orientation) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
364 msg = {"print.m - inconsistent papersize and paperorientation properties.\n", |
10422 | 365 sprintf(" papersize = %.2f, %.2f\n", p.papersize), |
366 sprintf(" paperorientation = \"%s\"\n", p.paperorientation), | |
367 " the paperorientation property has been ignored"}; | |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
368 warning ("%s",msg{:}) |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
369 warn_on_inconsistent_orientation = false; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
370 endif |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
371 |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
372 if (strcmp (termn, "postscript") && ! strncmp (dev, "eps", 3)) |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
373 if (isempty (opts.orientation)) |
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
374 opts.orientation = paperorientation; |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
375 endif |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
376 ## This is done here to accommodate ghostscript conversion. |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
377 options = cstrcat (opts.orientation, " ", options); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
378 end |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
379 |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
380 new_terminal = cstrcat (termn, " ", options); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
381 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
382 mono = (opts.use_color < 0); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
383 |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
384 terminals_for_prn = {"postscript", "pdf", "pdfcairo"}; |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
385 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
|
386 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
387 if (isempty (opts.resolution)) |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
388 if (any (strcmp (dev, {"emf", "svg"})) || output_for_printer) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
389 opts.resolution = get (0, "screenpixelsperinch"); |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
390 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
391 opts.resolution = 150; |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
392 endif |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
393 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
394 opts.resolution = str2num (opts.resolution); |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
395 if (opts.resolution == 0) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
396 opts.resolution = get (0, "screenpixelsperinch"); |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
397 endif |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
398 endif |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
399 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
|
400 if (! isfield (figure_properties, "__pixels_per_inch__")) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
401 addproperty ("__pixels_per_inch__", gcf, "double", opts.resolution); |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
402 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
403 set (gcf, "__pixels_per_inch__", opts.resolution) |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8746
diff
changeset
|
404 |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
405 unwind_protect |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
406 set (gcf, "paperunits", "inches"); |
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
407 set (gcf, "units", "pixels"); |
10567
79410269cd21
print.m: Set figure color property to 'none' when printing.
Ben Abbott <bpabbott@mac.com>
parents:
10472
diff
changeset
|
408 set (gcf, "color", "none"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
409 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
|
410 if ((! output_for_printer || is_eps_file) && ! doprint) |
10422 | 411 ## If not PDF or PostScript, and the result is not being sent to a printer, |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
412 ## render an image the size of the paperposition box. |
10422 | 413 ## Trigger the listener to convert all paper props to inches. |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
414 if (! isempty (opts.canvas_size)) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
415 size_in_pixels = sscanf (opts.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
|
416 size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]); |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
417 papersize_in_inches = size_in_pixels ./ opts.resolution; |
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
|
418 paperposition_in_inches = [0, 0, papersize_in_inches]; |
10422 | 419 else |
9107
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
420 paperposition_in_inches = get (gcf, "paperposition"); |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
421 paperposition_in_inches(1:2) = 0; |
d0d507cbd123
Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents:
9056
diff
changeset
|
422 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
|
423 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
|
424 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
|
425 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
|
426 set (gcf, "paperpositionmode", "manual"); |
9393
d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
Ben Abbott <bpabbott@mac.com>
parents:
9337
diff
changeset
|
427 else |
10422 | 428 if (strcmp (p.paperpositionmode, "auto")) |
429 size_in_pixels = get (gcf, "position")(3:4); | |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
430 paperposition_in_inches(3:4) = size_in_pixels ./ opts.resolution; |
10422 | 431 paperposition_in_inches(1:2) = (p.papersize - paperposition_in_inches(3:4))/2; |
432 else | |
433 paperposition_in_inches = p.paperposition; | |
434 endif | |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
435 if (! isempty (opts.orientation) && ! strcmp (opts.orientation, paperorientation)) |
10422 | 436 ## When -landscape/portrait changes the orientation, flip both the |
437 ## papersize and paperposition. | |
438 restore_properties = true; | |
439 set (gcf, "papersize", p.papersize([2, 1])); | |
440 set (gcf, "paperposition", paperposition_in_inches([2, 1, 4, 3])); | |
441 else | |
442 set (gcf, "paperposition", paperposition_in_inches); | |
443 endif | |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
444 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
445 if (opts.use_color < 0) |
10422 | 446 [objs_with_color, color_of_objs] = convert_color2mono (gcf); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
447 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
448 if (opts.append_to_file) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
449 appended_file_name = opts.name; |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
450 if (index(termn, "pdf")) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
451 opts.name = cstrcat (tmpnam, ".pdf"); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
452 temp_name = cstrcat (tmpnam, ".pdf"); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
453 ghostscript_device = "pdfwrite"; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
454 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
455 opts.name = cstrcat (tmpnam, ".ps"); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
456 temp_name = cstrcat (tmpnam, ".ps"); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
457 ghostscript_device = "pswrite"; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
458 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
459 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
460 if (opts.debug) |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
461 drawnow (new_terminal, opts.name, mono, opts.debug_file); |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
462 else |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
463 drawnow (new_terminal, opts.name, mono); |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
464 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
465 if (opts.append_to_file) |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
466 ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE"; |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
467 command = sprintf ("%s %s -sDEVICE=%s -sOutputFile=%s %s %s -q", ... |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
468 ghostscript_binary, ghostscript_options, ghostscript_device, ... |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
469 temp_name, appended_file_name, opts.name); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
470 status1 = system (command); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
471 status2 = system (sprintf ("mv %s %s", temp_name, appended_file_name)); |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
472 if (status1 != 0 || status2 != 0) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10567
diff
changeset
|
473 error ("print: output failed to append to '%s'.", appended_file_name); |
10423
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
474 endif |
dfc662a47b7a
print.m: Add '-append' option.
Ben Abbott <bpabbott@mac.com>
parents:
10422
diff
changeset
|
475 endif |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
476 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
|
477 ## 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
|
478 if (restore_properties) |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
479 props = fieldnames (p); |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
480 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
|
481 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
|
482 endfor |
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
483 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
484 if (opts.use_color < 0) |
10422 | 485 convert_mono_to_or_from_color (objs_with_color, color_of_objs, false); |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
486 endif |
9000
cc916241e811
print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
487 end_unwind_protect |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
488 |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
489 if (! isempty (ghostscript_output)) |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
490 if (is_eps_file && opts.tight_flag) |
10422 | 491 ## If gnuplot's output is an eps-file then crop at the bounding box. |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
492 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
|
493 endif |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
494 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
|
495 if (is_eps_file) |
10422 | 496 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
|
497 endif |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
498 if (isempty (strfind (lower (ghostscript_device), "write"))) |
10422 | 499 ## If output is a bitmap then include the resolution |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
500 ghostscript_options = sprintf ("%s -r%d", ghostscript_options, opts.resolution); |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
501 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
502 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
|
503 ghostscript_device); |
9249
470af0f93ca9
ghostscript handling for windows in print.m
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
9209
diff
changeset
|
504 command = sprintf ("\"%s\" %s -sOutputFile=\"%s\" \"%s\" 2>&1", ghostscript_binary, |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
505 ghostscript_options, ghostscript_output, opts.name); |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
506 [errcode, output] = system (command); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
507 unlink (name); |
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
508 if (errcode) |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
509 error ("print: Conversion failed, %s -> %s.\nError was:\n%s\n", |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
510 name, ghostscript_output, output); |
5625 | 511 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10711
diff
changeset
|
512 elseif (is_eps_file && opts.tight_flag && ! doprint) |
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
|
513 ## 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
|
514 ## This may result in a smaller or larger bbox geometry. |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
515 if (have_ghostscript) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
516 fix_eps_bbox (name, ghostscript_binary); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
517 endif |
6179 | 518 endif |
6178 | 519 |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
520 if (doprint) |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
521 if (isunix ()) |
10422 | 522 prn_opt = "-l"; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
523 elseif (ispc ()) |
10422 | 524 prn_opt = "-o l"; |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
525 else |
10422 | 526 ## FIXME - besides Unix and Windows, what other OS's might be considered. |
527 prn_opt = ""; | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
528 endif |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
529 if (isempty (opts.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
|
530 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
|
531 else |
10789
6f640ed5bb93
__gnuplot_print__.m: Fix broken options.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
532 prn_cmd = sprintf ("lpr %s -P %s '%s' 2>&1", prn_opt, opts.printer, printname); |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
533 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
534 [status, output] = system (prn_cmd); |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
535 if (status != 0) |
10422 | 536 disp (output) |
537 warning ("print.m: printing failed.") | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
538 endif |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
539 [status, output] = unlink (printname); |
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
540 if (status != 0) |
10422 | 541 disp (output) |
542 warning ("print.m: failed to delete temporay file, '%s'.", printname) | |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
543 endif |
6179 | 544 endif |
545 | |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
546 unwind_protect_cleanup |
8239
041bb0c64f07
orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents:
8049
diff
changeset
|
547 if (isfigure (old_fig)) |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
548 figure (old_fig) |
6965 | 549 endif |
7550
bffb1e2ab732
print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents:
7543
diff
changeset
|
550 end_unwind_protect |
5363 | 551 |
5361 | 552 endfunction |
9152
4c9aff0c9a61
print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents:
9107
diff
changeset
|
553 |
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
|
554 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
|
555 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
556 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
|
557 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
558 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
|
559 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
560 ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4 -sDEVICE=bbox"; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
561 cmd = sprintf ("\"%s\" %s \"%s\" 2>&1", ghostscript_binary, |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
562 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
|
563 [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
|
564 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
565 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
|
566 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
567 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
|
568 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
|
569 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
|
570 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
|
571 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
|
572 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
|
573 ## 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
|
574 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
|
575 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
576 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
|
577 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
|
578 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
|
579 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
|
580 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
|
581 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
|
582 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
|
583 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
|
584 if (numel (current_line) < numel (bbox_line)) |
10422 | 585 ## If there new line is longer, continue with the current line. |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
586 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
|
587 else |
10422 | 588 new_line = bbox_line; |
589 new_line(end+1:numel(current_line)) = " "; | |
9157
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
590 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
|
591 ## 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 warn_on_no_ghostscript = false; |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
609 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
|
610 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
|
611 |
fce7315c1eee
print.m: Fix typo, improvments to code, and allow for creation of tight bbox.
Ben Abbott <bpabbott@mac.com>
parents:
9152
diff
changeset
|
612 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
|
613 |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
614 function [h, c] = convert_color2mono (hfig) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
615 unwind_protect |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
616 showhiddenhandles = get (0, "showhiddenhandles"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
617 set (0, "showhiddenhandles", "on"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
618 h.color = findobj (hfig, "-property", "color"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
619 h.facecolor = findobj (hfig, "-property", "facecolor"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
620 h.edgecolor = findobj (hfig, "-property", "edgecolor"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
621 h.backgroundcolor = findobj (hfig, "-property", "backgroundcolor"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
622 h.colormap = findobj (hfig, "-property", "colormap"); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
623 unwind_protect_cleanup |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
624 set (0, "showhiddenhandles", showhiddenhandles); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
625 end_unwind_protect |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
626 f = fieldnames (h); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
627 for nf = 1:numel(f) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
628 if (! isempty (h.(f{nf}))) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
629 v = get (h.(f{nf}), f{nf}); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
630 if (! iscell (v)) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
631 v = {v}; |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
632 endif |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
633 c.(f{nf}) = v; |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
634 endif |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
635 endfor |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
636 convert_mono_to_or_from_color (h, c, true) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
637 endfunction |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
638 |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
639 function convert_mono_to_or_from_color (h, c, mono) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
640 f = fieldnames (h); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
641 for nf = 1:numel(f) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
642 for nh = 1:numel (h.(f{nf})) |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
643 color = c.(f{nf}){nh}; |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
644 ## Ignore color == {"none", "flat", ...} |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
645 if (isfloat (color)) |
10422 | 646 if (mono) |
647 ## Same method as used by rgb2gray in the image pkg. | |
648 color = rgb2ntsc (color)(:,1) * ones (1, 3); | |
649 endif | |
9334
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
650 set (h.(f{nf})(nh), f{nf}, color); |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
651 endif |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
652 endfor |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
653 endfor |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
654 endfunction |
4f96a7770492
print.m: properly render mono figures, and favor cairo terminals.
Ben Abbott <bpabbott@mac.com>
parents:
9249
diff
changeset
|
655 |