Mercurial > hg > octave-lyh
comparison scripts/plot/gnuplot_drawnow.m @ 9107:d0d507cbd123
Improvements to printing functionality.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 10 Apr 2009 12:11:14 -0400 |
parents | 8651fcc89556 |
children | 4bb94a71913b |
comparison
equal
deleted
inserted
replaced
9106:1eb5b24186b6 | 9107:d0d507cbd123 |
---|---|
39 plot_stream = []; | 39 plot_stream = []; |
40 fid = []; | 40 fid = []; |
41 printing = ! output_to_screen (gnuplot_trim_term (term)); | 41 printing = ! output_to_screen (gnuplot_trim_term (term)); |
42 default_plot_stream = get (h, "__plot_stream__"); | 42 default_plot_stream = get (h, "__plot_stream__"); |
43 unwind_protect | 43 unwind_protect |
44 plot_stream = open_gnuplot_stream (2, []); | 44 plot_stream = open_gnuplot_stream (2, h); |
45 set (h, "__plot_stream__", plot_stream); | |
46 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) | 45 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) |
47 available_terminals = __gnuplot_get_var__ (plot_stream, "GPVAL_TERMINALS"); | 46 available_terminals = __gnuplot_get_var__ (plot_stream, "GPVAL_TERMINALS"); |
48 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); | 47 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); |
49 gnuplot_supports_term = any (strcmpi (available_terminals, | 48 gnuplot_supports_term = any (strcmpi (available_terminals, |
50 gnuplot_trim_term (term))); | 49 gnuplot_trim_term (term))); |
189 [gnuplot_size, gnuplot_pos] = get_figsize (h); | 188 [gnuplot_size, gnuplot_pos] = get_figsize (h); |
190 else | 189 else |
191 ## Get size of the printed plot in inches. | 190 ## Get size of the printed plot in inches. |
192 gnuplot_size = get_papersize (h); | 191 gnuplot_size = get_papersize (h); |
193 if (term_units_are_pixels (term)) | 192 if (term_units_are_pixels (term)) |
194 ## Convert to inches using the property set by print(). | 193 ## Convert to inches using the property set by print(). |
195 gnuplot_size = gnuplot_size * get (h, "__pixels_per_inch__"); | 194 gnuplot_size = gnuplot_size * get (h, "__pixels_per_inch__"); |
196 else | 195 else |
197 ## Implicit margins are in units of "inches" | 196 ## Implicit margins are in units of "inches" |
198 gnuplot_size = gnuplot_size - implicit_margin; | 197 gnuplot_size = gnuplot_size - implicit_margin; |
199 endif | 198 endif |
275 term_str = sprintf ("%s %s", term_str, enh_str); | 274 term_str = sprintf ("%s %s", term_str, enh_str); |
276 endif | 275 endif |
277 if (! isempty (title_str)) | 276 if (! isempty (title_str)) |
278 term_str = sprintf ("%s %s", term_str, title_str); | 277 term_str = sprintf ("%s %s", term_str, title_str); |
279 endif | 278 endif |
279 if (nargin > 3 && ischar (opts_str)) | |
280 ## Options must go last. | |
281 term_str = sprintf ("%s %s", term_str, opts_str); | |
282 endif | |
280 if (! isempty (size_str) && new_stream) | 283 if (! isempty (size_str) && new_stream) |
281 ## size_str goes last to permit specification of canvas size | 284 ## size_str goes last to permit specification of canvas size |
282 ## for terminals cdr/corel. | 285 ## for terminals cdr/corel. |
283 term_str = sprintf ("%s %s", term_str, size_str); | 286 term_str = sprintf ("%s %s", term_str, size_str); |
284 endif | 287 endif |
285 if (nargin > 3 && ischar (opts_str)) | 288 fprintf (plot_stream, "%s\n", term_str); |
286 ## Options must go last. | |
287 term_str = sprintf ("%s %s", term_str, opts_str); | |
288 endif | |
289 fprintf (plot_stream, sprintf ("%s;\n", term_str)); | |
290 else | 289 else |
291 ## gnuplot will pick up the GNUTERM environment variable itself | 290 ## gnuplot will pick up the GNUTERM environment variable itself |
292 ## so no need to set the terminal type if not also setting the | 291 ## so no need to set the terminal type if not also setting the |
293 ## figure title, enhanced mode, or position. | 292 ## figure title, enhanced mode, or position. |
294 endif | 293 endif |
354 function ret = output_to_screen (term) | 353 function ret = output_to_screen (term) |
355 ret = any (strcmpi ({"aqua", "wxt", "x11", "windows", "pm"}, term)); | 354 ret = any (strcmpi ({"aqua", "wxt", "x11", "windows", "pm"}, term)); |
356 endfunction | 355 endfunction |
357 | 356 |
358 function ret = term_units_are_pixels (term) | 357 function ret = term_units_are_pixels (term) |
359 ret = any (strcmpi ({"png", "jpeg", "gif", "pbm", "svg"}, term)); | 358 ret = any (strcmpi ({"emf", "gif", "jpeg", "pbm", "png", "svg"}, term)); |
360 endfunction | 359 endfunction |
361 | 360 |
362 function [fig_size, fig_pos] = get_figsize (h) | 361 function [fig_size, fig_pos] = get_figsize (h) |
363 ## Determine the size of the figure in pixels. | 362 ## Determine the size of the figure in pixels. |
364 position = get (h, "position"); | 363 position = get (h, "position"); |