Mercurial > hg > octave-lyh
annotate scripts/plot/private/__fltk_print__.m @ 14820:452be8dab49b stable
__go_draw_axes__.m: Add missing terminating semicolon.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 29 Jun 2012 17:17:47 -0400 |
parents | 447b57ebc27b |
children | 6b2448555bbd d174210ce1ec |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12793
diff
changeset
|
1 ## Copyright (C) 2010-2012 Shai Ayal |
10727
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 -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10727
diff
changeset
|
20 ## @deftypefn {Function File} {} __fltk_print__ (@var{@dots{}}) |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
21 ## Undocumented internal function. |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
22 ## @end deftypefn |
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
23 |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
24 function opts = __fltk_print__ (opts) |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
25 |
11009 | 26 dos_shell = (ispc () && ! isunix ()); |
27 | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
28 figure (opts.figure); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
29 drawnow ("expose"); |
11398
f1a4db353da5
__fltk_print__.m: Update figure for FLTK printing, bug 31884.
Ben Abbott <bpabbott@mac.com>
parents:
11120
diff
changeset
|
30 __fltk_redraw__ (); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
31 |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
32 if (! isempty (opts.fig2dev_binary)) |
11009 | 33 ## fig2dev is prefered for conversion to emf |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
34 fig2dev_devices = {"pstex", "mf", "emf"}; |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
35 else |
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
36 fig2dev_devices = {"pstex", "mf"}; |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
37 endif |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
38 |
11009 | 39 gl2ps_device = {}; |
40 pipeline = {}; | |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11009
diff
changeset
|
41 switch (lower (opts.devopt)) |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
42 case {"eps", "eps2", "epsc", "epsc2"} |
11009 | 43 ## format GL2PS_EPS |
44 gl2ps_device = {"eps"}; | |
45 ## FIXME - use epstool to tighten bbox and provide preview. | |
46 pipeline = {opts.epstool_cmd(opts, "-", opts.name)}; | |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
47 case {"epslatex", "pslatex", "pdflatex", "epslatexstandalone", ... |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
48 "pslatexstandalone", "pdflatexstandalone"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
49 ## format GL2PS_TEX |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
50 n = find (opts.devopt == "l", 1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
51 suffix = opts.devopt(1:n-1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
52 dot = find (opts.name == ".", 1, "last"); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
53 if ((! isempty (dot)) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
54 && any (strcmpi (opts.name(dot:end), ... |
14174
447b57ebc27b
Validate suffix when printing to {eps,ps,pdf}latex devices.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
55 {strcat(".", suffix), ".tex", "."}))) |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
56 name = opts.name(1:dot-1); |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
57 if (dot < numel (opts.name) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
58 && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"}))) |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
59 ## If user provides eps/ps/pdf suffix, use it. |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
60 suffix = opts.name(dot+1:end); |
10861 | 61 endif |
14174
447b57ebc27b
Validate suffix when printing to {eps,ps,pdf}latex devices.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
62 else |
447b57ebc27b
Validate suffix when printing to {eps,ps,pdf}latex devices.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
63 error ("print:invalid-suffix", |
447b57ebc27b
Validate suffix when printing to {eps,ps,pdf}latex devices.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
64 "invalid suffix `%s' for device `%s'.", |
447b57ebc27b
Validate suffix when printing to {eps,ps,pdf}latex devices.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
65 opts.name(dot:end), lower (opts.devopt)); |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
66 endif |
11009 | 67 gl2ps_device = {sprintf("%snotxt", lower (suffix))}; |
68 gl2ps_device{2} = "tex"; | |
69 if (dos_shell) | |
12199
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
70 ## FIXME - this will only work on MinGW with the MSYS shell |
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
71 pipeline = {sprintf("cat > %s-inc.%s", name, suffix)}; |
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
72 pipeline{2} = sprintf ("cat > %s.tex", name); |
11009 | 73 else |
12199
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
74 pipeline = {sprintf("cat > %s-inc.%s", name, suffix)}; |
11009 | 75 pipeline{2} = sprintf ("cat > %s.tex", name); |
10854
d5a7db05d591
Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10834
diff
changeset
|
76 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11009
diff
changeset
|
77 case "tikz" |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
78 ## format GL2PS_PGF |
11009 | 79 gl2ps_device = {"pgf"}; |
80 pipeline = {sprintf("cat > %s", opts.name)}; | |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11009
diff
changeset
|
81 case "svg" |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
82 ## format GL2PS_SVG |
11009 | 83 gl2ps_device = {"svg"}; |
84 pipeline = {sprintf("cat > %s", opts.name)}; | |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
85 case fig2dev_devices |
11009 | 86 cmd_pstoedit = opts.pstoedit_cmd (opts, "fig"); |
87 cmd_fig2dev = opts.fig2dev_cmd (opts, opts.devopt); | |
88 if (strcmp (opts.devopt, "pstex")) | |
89 [~, ~, ext] = fileparts (opts.name); | |
90 if (any (strcmpi (ext, {".ps", ".tex", "."}))) | |
91 opts.name = opts.name(1:end-numel(ext)); | |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10864
diff
changeset
|
92 endif |
11009 | 93 opts.name = strcat (opts.name, ".ps"); |
94 cmd = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, opts.name); | |
95 gl2ps_device = {"eps"}; | |
96 pipeline = {cmd}; | |
97 cmd_fig2dev = opts.fig2dev_cmd (opts, "pstex_t"); | |
98 gl2ps_device{2} = "eps"; | |
99 pipeline{2} = sprintf ("%s | %s > %s", cmd_pstoedit, | |
100 cmd_fig2dev, strrep(opts.name, ".ps", ".tex")); | |
101 else | |
102 cmd = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, opts.name); | |
103 gl2ps_device = {"eps"}; | |
104 pipeline = {cmd}; | |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
105 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11009
diff
changeset
|
106 case "aifm" |
11009 | 107 cmd = opts.pstoedit_cmd (opts, "ps2ai"); |
108 gl2ps_device = {"eps"}; | |
109 pipeline = {sprintf("%s > %s", cmd, opts.name)}; | |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
110 case {"dxf", "emf", "fig", "hpgl"} |
11009 | 111 cmd = opts.pstoedit_cmd (opts); |
112 gl2ps_device = {"eps"}; | |
113 pipeline = {sprintf("%s > %s", cmd, opts.name)}; | |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
114 case {"corel", "gif"} |
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
115 error ("print:unsupporteddevice", |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
116 "print.m: %s output is not available for the FLTK graphics toolkit", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
117 upper (opts.devopt)); |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
118 case opts.ghostscript.device |
11009 | 119 opts.ghostscript.source = "-"; |
120 opts.ghostscript.output = opts.name; | |
121 if (opts.send_to_printer) | |
122 opts.unlink(strcmp (opts.unlink, opts.ghostscript.output)) = []; | |
123 opts.ghostscript.output = "-"; | |
124 endif | |
125 [cmd_gs, cmd_cleanup] = __ghostscript__ (opts.ghostscript); | |
126 if (opts.send_to_printer || isempty (opts.name)) | |
127 cmd_lpr = opts.lpr_cmd (opts); | |
128 cmd = sprintf("%s | %s", cmd_gs, cmd_lpr); | |
129 else | |
130 cmd = sprintf("%s", cmd_gs); | |
131 endif | |
132 if (! isempty (cmd_cleanup)) | |
133 gl2ps_device = {"eps"}; | |
134 if (dos_shell) | |
135 pipeline = {sprintf("%s & %s", cmd, cmd_cleanup)}; | |
136 else | |
137 pipeline = {sprintf("%s ; %s", cmd, cmd_cleanup)}; | |
138 endif | |
139 else | |
140 gl2ps_device = {"eps"}; | |
141 pipeline = {cmd}; | |
142 endif | |
143 otherwise | |
144 error (sprintf ("print:no%soutput", opts.devopt), | |
11588
d5bd2766c640
style fixes for warning and error messages in script files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
145 "print.m: %s output is not available for GL2PS output", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
146 upper (opts.devopt)); |
10954
ee9d74048827
Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents:
10913
diff
changeset
|
147 endswitch |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
148 |
11009 | 149 opts.pipeline = pipeline; |
150 | |
151 for n = 1:numel(pipeline) | |
152 if (opts.debug) | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
153 fprintf ("fltk-pipeline: '%s'\n", pipeline{n}); |
11009 | 154 endif |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12199
diff
changeset
|
155 drawnow (gl2ps_device{n}, strcat('|',pipeline{n})); |
11009 | 156 endfor |
157 | |
12199
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
158 if (! isempty (strfind (opts.devopt, "standalone"))) |
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
159 opts.latex_standalone (opts); |
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
160 endif |
3fc07861449b
Fix {eps,ps,pdf}latexstandalone printing for fltk, bug 32262.
Ben Abbott <bpabbott@mac.com>
parents:
11589
diff
changeset
|
161 |
10727
570f30a48732
split printing between backends
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
162 endfunction |
10834
05ba991794d4
Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
163 |