Mercurial > octave-nkf
annotate scripts/plot/__print_parse_opts__.m @ 10918:811f8611995d
__print_parse_opts__.m: Fix tests.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 27 Aug 2010 19:38:49 -0400 |
parents | dd6b90f44ae5 |
children | ee9d74048827 |
rev | line source |
---|---|
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
1 ## Copyright (C) 2008, 2009 David Bateman |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
2 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
4 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
8 ## your option) any later version. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
9 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
13 ## General Public License for more details. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
14 ## |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
18 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} ginput (@var{n}) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
21 ## Return which mouse buttons were pressed and keys were hit on the current |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
22 ## figure. If @var{n} is defined, then wait for @var{n} mouse clicks |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
23 ## before returning. If @var{n} is not defined, then @code{ginput} will |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
24 ## loop until the return key is pressed. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
25 ## @end deftypefn |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
26 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
27 function arg_st = __print_parse_opts__ (varargin) |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
28 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
29 arg_st.append_to_file = false; |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
30 arg_st.canvas_size = []; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
31 arg_st.debug = false; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
32 arg_st.debug_file = "octave-print-commands.log"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
33 arg_st.devopt = ""; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
34 arg_st.figure = get (0, "currentfigure"); |
10889
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
35 arg_st.fig2dev_binary = __quote_path__ (__find_binary__ ("fig2dev")); |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
36 arg_st.fontsize = ""; |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
37 arg_st.font = ""; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
38 arg_st.force_solid = 0; # 0=default, -1=dashed, +1=solid |
10889
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
39 arg_st.ghostscript.binary = __quote_path__ (__ghostscript_binary__ ()); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
40 arg_st.ghostscript.device = ""; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
41 arg_st.ghostscript.output = ""; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
42 arg_st.ghostscript.papersize = ""; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
43 arg_st.ghostscript.pageoffset = []; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
44 arg_st.ghostscript.debug = false; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
45 arg_st.ghostscript.epscrop = false; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
46 arg_st.ghostscript.resolution = 150; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
47 arg_st.orientation = ""; |
10889
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
48 arg_st.pstoedit_binary = __quote_path__ (__find_binary__ ("pstoedit")); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
49 arg_st.name = ""; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
50 arg_st.printer = ""; |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
51 arg_st.special_flag = "textnormal"; |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
52 arg_st.tight_flag = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
53 arg_st.use_color = 0; # 0=default, -1=mono, +1=color |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
54 arg_st.send_to_printer = false; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
55 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
56 if (isunix ()) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
57 arg_st.lpr_options = "-l"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
58 elseif (ispc ()) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
59 arg_st.lpr_options = "-o l"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
60 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
61 arg_st.lpr_options = ""; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
62 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
63 arg_st.unlink = {}; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
64 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
65 for i = 1:nargin |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
66 arg = varargin{i}; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
67 if (ischar (arg)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
68 if (strcmp (arg, "-color")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
69 arg_st.use_color = 1; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
70 elseif (strcmp (arg, "-append")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
71 arg_st.append_to_file = true; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
72 elseif (strcmp (arg, "-mono")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
73 arg_st.use_color = -1; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
74 elseif (strcmp (arg, "-solid")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
75 arg_st.force_solid = 1; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
76 elseif (strcmp (arg, "-dashed")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
77 arg_st.force_solid = -1; |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
78 elseif (strncmp (arg, "-portrait", numel (arg))) |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
79 arg_st.orientation = "portrait"; |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
80 elseif (strncmp (arg, "-landscape", numel (arg))) |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
81 arg_st.orientation = "landscape"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
82 elseif (strcmp (arg, "-tight")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
83 arg_st.tight_flag = true; |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
84 elseif (strcmp (arg, "-loose")) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
85 arg_st.tight_flag = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
86 elseif (strcmp (arg, "-textspecial")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
87 arg_st.special_flag = "textspecial"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
88 elseif (strncmp (arg, "-debug", 6)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
89 arg_st.debug = true; |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
90 arg_st.ghostscript.debug = true; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
91 if (length (arg) > 7) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
92 arg_st.debug_file = arg(8:end); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
93 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
94 elseif (length (arg) > 2 && arg(1:2) == "-d") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
95 arg_st.devopt = tolower (arg(3:end)); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
96 elseif (length (arg) > 2 && arg(1:2) == "-P") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
97 arg_st.printer = arg; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
98 elseif ((length (arg) > 2) && arg(1:2) == "-G") |
10889
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
99 arg_st.ghostscript.binary = file_in_path (EXEC_PATH, arg(3:end)); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
100 if (isempty (arg_st.ghostscript.binary)) |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
101 error ("print: Ghostscript binary ""%s"" could not be located", arg(3:end)) |
10889
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
102 else |
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
103 arg_st.ghostscript_binary = __quote_path__ (arg_st.ghostscript_binary); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
104 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
105 elseif (length (arg) > 2 && arg(1:2) == "-F") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
106 idx = rindex (arg, ":"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
107 if (idx) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
108 arg_st.font = arg(3:idx-1); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
109 arg_st.fontsize = str2num (arg(idx+1:end)); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
110 else |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
111 arg_st.font = arg(3:end); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
112 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
113 elseif (length (arg) > 2 && arg(1:2) == "-S") |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
114 arg_st.canvas_size = str2num (arg(3:end)); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
115 elseif (length (arg) > 2 && arg(1:2) == "-r") |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
116 arg_st.ghostscript.resolution = arg(3:end); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
117 elseif (length (arg) > 2 && arg(1:2) == "-f") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
118 arg_st.figure = str2num (arg(3:end)); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
119 elseif (length (arg) >= 1 && arg(1) == "-") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
120 error ("print: unknown option `%s'", arg); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
121 elseif (length (arg) > 0) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
122 arg_st.name = arg; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
123 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
124 elseif (isfigure (arg)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
125 arg_st.figure = arg; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
126 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
127 error ("print: expecting inputs to be character string options or a figure handle"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
128 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
129 endfor |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
130 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
131 if (arg_st.ghostscript.resolution == 0) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
132 ## Do as Matlab does. |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
133 arg_st.ghostscript.resolution = num2str (get (0, "screenpixelsperinch")); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
134 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
135 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
136 if (isempty (arg_st.orientation)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
137 if (isfigure (arg_st.figure)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
138 arg_st.orientation = get (arg_st.figure, "paperorientation"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
139 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
140 ## Allows tests to be run without error. |
10861 | 141 arg_st.orientation = "portrait"; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
142 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
143 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
144 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
145 if (isempty (arg_st.ghostscript.binary)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
146 arg_st.ghostscript.binary = __ghostscript_binary__ (); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
147 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
148 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
149 dot = rindex (arg_st.name, "."); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
150 if (isempty (arg_st.devopt)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
151 if (dot == 0) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
152 arg_st.devopt = "psc"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
153 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
154 arg_st.devopt = tolower (arg_st.name(dot+1:end)); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
155 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
156 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
157 |
10918
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
158 if (arg_st.use_color == 0) |
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
159 if (any (strcmp ({"ps", "ps2", "eps", "eps2"}, arg_st.devopt))) |
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
160 arg_st.use_color = -1; |
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
161 else |
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
162 arg_st.use_color = 1; |
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
163 endif |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
164 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
165 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
166 if (arg_st.tight_flag) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
167 if (any (strcmpi (arg_st.devopt, {"ps", "ps2", "psc", "psc2", "pdf"}))) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
168 arg_st.tight_flag = false; |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
169 warning ("print.m: '-tight' is not supported for device '%s'", |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
170 arg_st.devopt) |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
171 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
172 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
173 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
174 if (strcmp (arg_st.devopt, "tex")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
175 arg_st.devopt = "epslatex"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
176 elseif (strcmp (arg_st.devopt, "ill")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
177 arg_st.devopt = "aifm"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
178 elseif (strcmp (arg_st.devopt, "cdr")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
179 arg_st.devopt = "corel"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
180 elseif (strcmp (arg_st.devopt, "meta")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
181 arg_st.devopt = "emf"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
182 elseif (strcmp (arg_st.devopt, "jpg")) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
183 arg_st.devopt = "jpeg"; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
184 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
185 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
186 dev_list = {"aifm", "corel", "fig", "png", "jpeg", ... |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
187 "gif", "pbm", "pbmraw", "dxf", "mf", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
188 "svg", "hpgl", "ps", "ps2", "psc", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
189 "psc2", "eps", "eps2", "epsc", "epsc2", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
190 "emf", "pdf", "pslatex", "epslatex", "epslatexstandalone", ... |
10861 | 191 "pslatexstandalone", "pdflatexstandalone", ... |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
192 "pstex", "tiff", "tiffn" "tikz", "pcxmono", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
193 "pcx24b", "pcx256", "pcx16", "pgm", "pgmraw", ... |
10861 | 194 "ppm", "ppmraw", "pdflatex"}; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
195 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
196 suffixes = {"ai", "cdr", "fig", "png", "jpg", ... |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
197 "gif", "pbm", "pbm", "dxf", "mf", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
198 "svg", "hpgl", "ps", "ps", "ps", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
199 "ps", "eps", "eps", "eps", "eps", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
200 "emf", "pdf", "tex", "tex", "tex", ... |
10861 | 201 "tex", "tex", ... |
10876
53ec464300ef
__print_parse_opts__.m: Default pstex suffix should be '.ps'.
Ben Abbott <bpabbott@mac.com>
parents:
10862
diff
changeset
|
202 "ps", "tiff", "tiff", "tikz", "pcx", ... |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
203 "pcx", "pcx", "pcx", "pgm", "pgm", ... |
10861 | 204 "ppm", "ppm", "tex"}; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
205 |
10918
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
206 if (isfigure (arg_st.figure) |
811f8611995d
__print_parse_opts__.m: Fix tests.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
207 && strcmp (get (arg_st.figure, "__backend__"), "gnuplot") |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
208 && __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
209 suffixes(strncmp (dev_list, "epslatex", 8)) = {"eps"}; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
210 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
211 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
212 match = strcmpi (dev_list, arg_st.devopt); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
213 if (any (match)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
214 default_suffix = suffixes {match}; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
215 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
216 default_suffix = arg_st.devopt; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
217 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
218 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
219 if (dot == 0 && ! isempty (arg_st.name)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
220 arg_st.name = strcat (arg_st.name, ".", default_suffix); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
221 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
222 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
223 if (arg_st.append_to_file) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
224 if (isempty (arg_st.name)) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
225 arg_st.append_to_file = false; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
226 elseif (any (strcmpi (arg_st.devopt, {"eps", "eps2", "epsc", "epsc2", ... |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
227 "ps", "ps2", "psc", "psc2", "pdf"}))) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
228 have_ghostscript = ! isempty (__ghostscript_binary__ ()); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
229 if (have_ghostscript) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
230 file_exists = ((numel (dir (arg_st.name)) == 1) && (! isdir (arg_st.name))); |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
231 if (! file_exists) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
232 arg_st.append_to_file = false; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
233 end |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
234 else |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
235 arg_st.append_to_file = false; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
236 warning ("print.m: appended output requires ghostscript to be installed.") |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
237 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
238 else |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
239 warning ("print.m: appended output is not supported for device '%s'", arg_st.devopt) |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
240 arg_st.append_to_file = false; |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
241 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
242 endif |
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
243 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
244 if (! isempty (arg_st.printer) || isempty (arg_st.name)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
245 arg_st.send_to_printer = true; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
246 if (isempty (arg_st.name)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
247 arg_st.name = strcat (tmpnam (), ".", default_suffix); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
248 arg_st.unlink{end+1} = arg_st.name; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
249 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
250 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
251 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
252 if (all (! strcmp (arg_st.devopt, dev_list))) |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
253 arg_st.ghostscript.device = arg_st.devopt; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
254 arg_st.ghostscript.output = arg_st.name; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
255 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
256 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
257 if (isempty (arg_st.canvas_size)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
258 if (isfigure (arg_st.figure)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
259 [arg_st.ghostscript.papersize, paperposition] = gs_papersize (arg_st.figure, |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
260 arg_st.orientation); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
261 else |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
262 ## allows tests to be run |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
263 arg_st.ghostscript.papersize = "letter"; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
264 paperposition = [0.25, 2.50, 8.00, 6.00] * 72; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
265 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
266 arg_st.canvas_size = paperposition(3:4); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
267 arg_st.ghostscript.pageoffset = paperposition(1:2); |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
268 else |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
269 ## Canvas size in points. |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
270 arg_st.canvas_size = arg_st.canvas_size * 72 / arg_st.ghostscript.resolution; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
271 arg_st.ghostscript.papersize = arg_st.canvas_size; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
272 arg_st.ghostscript.epscrop = true; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
273 arg_st.ghostscript.pageoffset = [0, 0]; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
274 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
275 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
276 endfunction |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
277 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
278 %!test |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
279 %! opts = __print_parse_opts__ (); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
280 %! assert (opts.devopt, "psc"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
281 %! assert (opts.use_color, 1); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
282 %! assert (opts.send_to_printer, true); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
283 %! assert (opts.name, opts.unlink{1}) |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
284 %! assert (opts.canvas_size, [576, 432]); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
285 %! assert (opts.ghostscript.device, "") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
286 %! for n = 1:numel(opts.unlink) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
287 %! unlink (opts.unlink{n}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
288 %! endfor |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
289 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
290 %!test |
10861 | 291 %! opts = __print_parse_opts__ ("test.pdf", "-S640,480"); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
292 %! assert (opts.canvas_size, [307.2, 230.4], 0.1); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
293 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
294 %!test |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
295 %! opts = __print_parse_opts__ ("-dpsc", "-append"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
296 %! assert (opts.devopt, "psc"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
297 %! assert (opts.name(end+(-2:0)), ".ps"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
298 %! assert (opts.send_to_printer, true); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
299 %! assert (opts.use_color, 1); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
300 %! assert (opts.append_to_file, false); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
301 %! assert (opts.ghostscript.device, "") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
302 %! for n = 1:numel(opts.unlink) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
303 %! unlink (opts.unlink{n}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
304 %! endfor |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
305 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
306 %!test |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
307 %! opts = __print_parse_opts__ ("-deps", "-tight"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
308 %! assert (opts.name, opts.unlink{1}) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
309 %! assert (opts.tight_flag, true); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
310 %! assert (opts.send_to_printer, true); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
311 %! assert (opts.use_color, -1); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
312 %! assert (opts.ghostscript.device, "") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
313 %! for n = 1:numel(opts.unlink) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
314 %! unlink (opts.unlink{n}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
315 %! endfor |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
316 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
317 %!test |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
318 %! opts = __print_parse_opts__ ("-djpg", "foobar", "-mono"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
319 %! assert (opts.devopt, "jpeg") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
320 %! assert (opts.name, "foobar.jpg") |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
321 %! assert (opts.ghostscript.device, "") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
322 %! assert (opts.send_to_printer, false); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
323 %! assert (opts.printer, ""); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
324 %! assert (opts.use_color, -1); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
325 %! assert (opts.ghostscript.device, "") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
326 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
327 %!test |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
328 %! opts = __print_parse_opts__ ("-ddeskjet", "foobar", "-mono", "-Pmyprinter"); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
329 %! assert (opts.ghostscript.output, "foobar.deskjet") |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
330 %! assert (opts.ghostscript.device, "deskjet") |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
331 %! assert (opts.devopt, "deskjet") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
332 %! assert (opts.send_to_printer, true); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
333 %! assert (opts.printer, "-Pmyprinter"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
334 %! assert (opts.use_color, -1); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
335 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
336 %!test |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
337 %! opts = __print_parse_opts__ ("-f5", "-dljet3"); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
338 %! assert (opts.name, opts.unlink{1}) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
339 %! assert (opts.ghostscript.output, opts.unlink{1}) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
340 %! assert (opts.ghostscript.device, "ljet3") |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
341 %! assert (strfind (opts.ghostscript.output, ".ljet3")) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
342 %! assert (opts.devopt, "ljet3") |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
343 %! assert (opts.send_to_printer, true); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
344 %! assert (opts.figure, 5) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
345 %! for n = 1:numel(opts.unlink) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
346 %! unlink (opts.unlink{n}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
347 %! endfor |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
348 |
10889
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
349 function cmd = __quote_path__ (cmd) |
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
350 if (any (cmd == " ") && ! (cmd(1) == """" && cmd(end) == """")) |
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
351 cmd = strcat ("""", strrep (cmd, """", """"""), """"); |
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
352 endif |
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
353 endfunction |
1d7a7fb5074b
__print_parse_opts__.m: Double quote paths with spaces.
Ben Abbott <bpabbott@mac.com>
parents:
10876
diff
changeset
|
354 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
355 function gs = __ghostscript_binary__ () |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
356 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
357 persistent ghostscript_binary = "" |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
358 persistent warn_on_no_ghostscript = true |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
359 persistent warn_on_bad_gsc = true |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
360 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
361 if (isempty (ghostscript_binary)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
362 GSC = getenv ("GSC"); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
363 if (exist (GSC, "file") || (! isempty (GSC) && file_in_path (EXEC_PATH, GSC))) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
364 gs_binaries = {GSC}; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
365 elseif (! isempty (GSC) && warn_on_bad_gsc) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
366 warning ("print:badgscenv", |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
367 "print.m: GSC environment variable not set properly.") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
368 warn_on_bad_gsc = false; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
369 gs_binaries = {}; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
370 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
371 gs_binaries = {}; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
372 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
373 if (isunix ()) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
374 ## Unix - Includes Mac OSX and Cygwin. |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
375 gs_binaries = horzcat (gs_binaries, {"gs", "gs.exe"}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
376 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
377 ## pc - Includes Win32 and mingw. |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
378 gs_binaries = horzcat (gs_binaries, {"gs.exe", "gswin32c.exe"}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
379 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
380 n = 0; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
381 while (n < numel (gs_binaries) && isempty (ghostscript_binary)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
382 n = n + 1; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
383 ghostscript_binary = file_in_path (EXEC_PATH, gs_binaries{n}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
384 endwhile |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
385 if (warn_on_no_ghostscript && isempty (ghostscript_binary)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
386 warning ("print:noghostscript", |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
387 "print.m: ghostscript not found in EXEC_PATH.") |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
388 warn_on_no_ghostscript = false; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
389 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
390 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
391 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
392 gs = ghostscript_binary; |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
393 |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
394 endfunction |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
395 |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
396 function bin = __find_binary__ (binary) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
397 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
398 persistent data = struct () |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
399 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
400 if (! isfield (data, binary)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
401 ## Reinitialize when `user_binaries' is present. |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
402 data.(binary).bin = ""; |
10862
337db4e1342d
Warn on absence of fig2dev/pstoedit only when needed.
Ben Abbott <bpabbott@mac.com>
parents:
10861
diff
changeset
|
403 data.(binary).warn_on_absence = false; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
404 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
405 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
406 if (isempty (data.(binary).bin)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
407 if (isunix ()) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
408 ## Unix - Includes Mac OSX and Cygwin. |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
409 binaries = strcat (binary, {"", ".exe"}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
410 else |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
411 ## pc - Includes Win32 and mingw. |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
412 binaries = strcat (binary, {".exe"}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
413 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
414 n = 0; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
415 while (n < numel (binaries) && isempty (data.(binary).bin)) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
416 n = n + 1; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
417 data.(binary).bin = file_in_path (EXEC_PATH, binaries{n}); |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
418 endwhile |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
419 if (isempty (data.(binary).bin) && data.(binary).warn_on_absence) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
420 warning (sprintf ("print:no%s", binary), |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
421 "print.m: '%s' not found in EXEC_PATH", binary) |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
422 data.(binary).warn_on_absence = false; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
423 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
424 endif |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
425 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
426 bin = data.(binary).bin; |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
427 |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
428 endfunction |
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
429 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
430 function [papersize, paperposition] = gs_papersize (hfig, paperorientation) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
431 persistent papertypes papersizes |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10727
diff
changeset
|
432 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
433 if (isempty (papertypes)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
434 papertypes = {"usletter", "uslegal", "a0", "a1", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
435 "a2", "a3", "a4", "a5", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
436 "b0", "b1", "b2", "b3", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
437 "b4", "b5", "arch-a", "arch-b", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
438 "arch-c", "arch-d", "arch-e", "a", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
439 "b", "c", "d", "e", ... |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
440 "tabloid"}; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
441 papersizes = [ 8.5, 11.0; 8.5, 14.0; 33.1, 46.8; 23.4, 33.1; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
442 16.5, 23.4; 11.7, 16.5; 8.3, 11.7; 5.8, 8.3; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
443 39.4, 55.7; 27.8, 39.4; 19.7, 27.8; 13.9, 19.7; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
444 9.8, 13.9; 6.9, 9.8; 9.0, 12.0; 12.0, 18.0; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
445 18.0, 24.0; 24.0, 36.0; 36.0, 48.0; 8.5, 11.0; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
446 11.0, 17.0; 18.0, 24.0; 24.0, 36.0; 36.0, 48.0; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
447 11.0, 17.0] * 72; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
448 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
449 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
450 papertype = get (hfig, "papertype"); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
451 paperunits = get (hfig, "paperunits"); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
452 paperposition = get (hfig, "paperposition"); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
453 if (strcmp (papertype, "<custom>")) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
454 papersize = get (hfig, "papersize"); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
455 papersize = convert2points (papersize , paperunits); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
456 else |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
457 papersize = papersizes (strcmp (papertypes, papertype), :); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
458 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
459 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
460 if (strcmp (paperunits, "normalized")) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
461 paperposition = paperposition .* papersize([1,2,1,2]); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
462 else |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
463 paperposition = convert2points (paperposition, paperunits); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
464 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
465 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
466 ## FIXME - This will be obsoleted by listeners for paper properties. |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10889
diff
changeset
|
467 ## Papersize is tall when portrait,and wide when landscape. |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
468 if ((papersize(1) > papersize(2) && strcmpi (paperorientation, "portrait")) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
469 || (papersize(1) < papersize(2) && strcmpi (paperorientation, "landscape"))) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
470 papersize = papersize ([2,1]); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
471 paperposition = paperposition([2,1,4,3]); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
472 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
473 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
474 if ((! strcmp (papertype, "<custom>")) && (strcmp (paperorientation, "portrait"))) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
475 ## For portrait use the ghostscript name |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
476 papersize = papertype; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
477 papersize(papersize=="-") = ""; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
478 papersize = strrep (papersize, "us", ""); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
479 switch papersize |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
480 case "a" |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
481 papersize = "letter"; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
482 case {"b", "tabloid"} |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
483 papersize = "11x17"; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
484 case {"c", "d", "e"} |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
485 papersize = strcat ("arch", papersize); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
486 endswitch |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
487 if (strncmp (papersize, "arch", 4)) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
488 papersize(end) = upper (papersize(end)); |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
489 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
490 endif |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
491 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
492 endfunction |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
493 |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
494 function value = convert2points (value, units) |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
495 switch units |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
496 case {"inches"} |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
497 value = value * 72; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
498 case {"centimeters"} |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
499 value = value * 72 / 25.4; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
500 case {"normalized"} |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
501 error ("print:customnormalized", |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
502 "print.m: papersize=='<custom>' and paperunits='normalized' may not be combined.") |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
503 endswitch |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
504 endfunction |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
505 |