Mercurial > octave-nkf
comparison scripts/plot/gnuplot_drawnow.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 1ca904d74f78 |
children | d1978e7364ad |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
68 if (! isempty (plot_stream)) | 68 if (! isempty (plot_stream)) |
69 pclose (plot_stream(1)); | 69 pclose (plot_stream(1)); |
70 if (numel (plot_stream) > 1) | 70 if (numel (plot_stream) > 1) |
71 pclose (plot_stream(2)); | 71 pclose (plot_stream(2)); |
72 endif | 72 endif |
73 if (numel (plot_stream) > 2) | 73 if (numel (plot_stream) > 2) |
74 waitpid (plot_stream(3)); | 74 waitpid (plot_stream(3)); |
75 endif | 75 endif |
76 endif | 76 endif |
77 if (! isempty (fid)) | 77 if (! isempty (fid)) |
78 fclose (fid); | 78 fclose (fid); |
79 endif | 79 endif |
80 end_unwind_protect | 80 end_unwind_protect |
107 ## reprint the plot on screen | 107 ## reprint the plot on screen |
108 [a, count] = fscanf (fid, '%c', Inf); | 108 [a, count] = fscanf (fid, '%c', Inf); |
109 fclose (fid); | 109 fclose (fid); |
110 if (count>0) | 110 if (count>0) |
111 if (a(1)==12) | 111 if (a(1)==12) |
112 ## avoid ^L at the beginning | 112 ## avoid ^L at the beginning |
113 a = a(2:end); | 113 a = a(2:end); |
114 end | 114 end |
115 puts (a); | 115 puts (a); |
116 end | 116 end |
117 unlink (dumb_tmp_file); | 117 unlink (dumb_tmp_file); |
118 endif | 118 endif |
188 endif | 188 endif |
189 else | 189 else |
190 title_str = ""; | 190 title_str = ""; |
191 endif | 191 endif |
192 if (! (any (strfind (opts_str, " size ") > 0) | 192 if (! (any (strfind (opts_str, " size ") > 0) |
193 || any (strfind (opts_str, "size ") == 1))) | 193 || any (strfind (opts_str, "size ") == 1))) |
194 ## Convert position to units used by gnuplot. | 194 ## Convert position to units used by gnuplot. |
195 if (output_to_screen (term)) | 195 if (output_to_screen (term)) |
196 ## Get figure size in pixels. Rely on listener | 196 ## Get figure size in pixels. Rely on listener |
197 ## to handle coversion of position property. | 197 ## to handle coversion of position property. |
198 units = get (h, "units"); | 198 units = get (h, "units"); |
199 unwind_protect | 199 unwind_protect |
200 set (h, "units", "pixels"); | 200 set (h, "units", "pixels"); |
201 position_in_pixesl = get (h, "position"); | 201 position_in_pixesl = get (h, "position"); |
202 unwind_protect_cleanup | 202 unwind_protect_cleanup |
203 set (h, "units", units); | 203 set (h, "units", units); |
204 end_unwind_protect | 204 end_unwind_protect |
205 gnuplot_pos = position_in_pixesl(1:2); | 205 gnuplot_pos = position_in_pixesl(1:2); |
206 gnuplot_size = position_in_pixesl(3:4); | 206 gnuplot_size = position_in_pixesl(3:4); |
207 else | 207 else |
208 ## Get size of the printed plot in inches. Rely on listener | 208 ## Get size of the printed plot in inches. Rely on listener |
209 ## to handle coversion of papersize property. | 209 ## to handle coversion of papersize property. |
210 paperunits = get (h, "paperunits"); | 210 paperunits = get (h, "paperunits"); |
211 unwind_protect | 211 unwind_protect |
212 set (h, "paperunits", "inches"); | 212 set (h, "paperunits", "inches"); |
213 gnuplot_size = get (h, "papersize"); | 213 gnuplot_size = get (h, "papersize"); |
214 unwind_protect_cleanup | 214 unwind_protect_cleanup |
215 set (h, "paperunits", paperunits); | 215 set (h, "paperunits", paperunits); |
216 end_unwind_protect | 216 end_unwind_protect |
217 if (term_units_are_pixels (term)) | 217 if (term_units_are_pixels (term)) |
218 ## Convert to inches using the property set by print(). | 218 ## Convert to inches using the property set by print(). |
219 gnuplot_size = gnuplot_size * get (h, "__pixels_per_inch__"); | 219 gnuplot_size = gnuplot_size * get (h, "__pixels_per_inch__"); |
220 else | 220 else |
221 ## Implicit margins are in units of "inches" | 221 ## Implicit margins are in units of "inches" |
222 gnuplot_size = gnuplot_size - implicit_margin; | 222 gnuplot_size = gnuplot_size - implicit_margin; |
223 endif | 223 endif |
224 endif | 224 endif |
225 [begin_match, end_match, te, match] = regexp (opts_str, "(\\s-r\\d+)|(^-r\\d+)"); | 225 [begin_match, end_match, te, match] = regexp (opts_str, "(\\s-r\\d+)|(^-r\\d+)"); |
226 if (! isempty (begin_match)) | 226 if (! isempty (begin_match)) |
227 error ("gnuplot_drawnow.m: specifying resultion, '%s', not supported for terminal '%s'", | 227 error ("gnuplot_drawnow.m: specifying resultion, '%s', not supported for terminal '%s'", |
228 strtrim (match{1}), term) | 228 strtrim (match{1}), term) |
229 endif | 229 endif |
230 if (all (gnuplot_size > 0)) | 230 if (all (gnuplot_size > 0)) |
231 ## Set terminal size. | 231 ## Set terminal size. |
232 terminals_with_size = {"emf", "gif", "jpeg", "latex", "pbm", ... | 232 terminals_with_size = {"emf", "gif", "jpeg", "latex", "pbm", ... |
233 "pdf", "png", "postscript", "svg", ... | 233 "pdf", "png", "postscript", "svg", ... |
234 "epslatex", "pstex", "pslatex", "tikz"}; | 234 "epslatex", "pstex", "pslatex", "tikz"}; |
237 endif | 237 endif |
238 if (__gnuplot_has_feature__ ("wxt_figure_size")) | 238 if (__gnuplot_has_feature__ ("wxt_figure_size")) |
239 terminals_with_size{end+1} = "wxt"; | 239 terminals_with_size{end+1} = "wxt"; |
240 endif | 240 endif |
241 if (any (strncmpi (term, terminals_with_size, 3))) | 241 if (any (strncmpi (term, terminals_with_size, 3))) |
242 if (term_units_are_pixels (term)) | 242 if (term_units_are_pixels (term)) |
243 size_str = sprintf ("size %d,%d", gnuplot_size); | 243 size_str = sprintf ("size %d,%d", gnuplot_size); |
244 elseif (strcmp (term, "tikz")) | 244 elseif (strcmp (term, "tikz")) |
245 size_str = sprintf ("size %.15gin,%.15gin", gnuplot_size); | 245 size_str = sprintf ("size %.15gin,%.15gin", gnuplot_size); |
246 else | 246 else |
247 size_str = sprintf ("size %.15g,%.15g", gnuplot_size); | 247 size_str = sprintf ("size %.15g,%.15g", gnuplot_size); |
248 endif | 248 endif |
249 if (strncmpi (term, "X11", 3) && __gnuplot_has_feature__ ("x11_figure_position")) | 249 if (strncmpi (term, "X11", 3) && __gnuplot_has_feature__ ("x11_figure_position")) |
250 ## X11 allows the window to be positioned as well. | 250 ## X11 allows the window to be positioned as well. |
251 units = get (0, "units"); | 251 units = get (0, "units"); |
252 unwind_protect | 252 unwind_protect |
253 set (0, "units", "pixels"); | 253 set (0, "units", "pixels"); |
254 screen_size = get (0, "screensize")(3:4); | 254 screen_size = get (0, "screensize")(3:4); |
255 unwind_protect_cleanup | 255 unwind_protect_cleanup |
256 set (0, "units", units); | 256 set (0, "units", units); |
257 end_unwind_protect | 257 end_unwind_protect |
258 if (all (screen_size > 0)) | 258 if (all (screen_size > 0)) |
259 ## For X11, set the figure positon as well as the size | 259 ## For X11, set the figure positon as well as the size |
260 ## gnuplot position is UL, Octave's is LL (same for screen/window) | 260 ## gnuplot position is UL, Octave's is LL (same for screen/window) |
261 gnuplot_pos(2) = screen_size(2) - gnuplot_pos(2) - gnuplot_size(2); | 261 gnuplot_pos(2) = screen_size(2) - gnuplot_pos(2) - gnuplot_size(2); |
262 gnuplot_pos = max (gnuplot_pos, 1); | 262 gnuplot_pos = max (gnuplot_pos, 1); |
273 ## Let dumb use full text screen size (minus prompt lines). | 273 ## Let dumb use full text screen size (minus prompt lines). |
274 n = sprintf ("%i", -2 - length (find (sprintf ("%s", PS1) == "\n"))); | 274 n = sprintf ("%i", -2 - length (find (sprintf ("%s", PS1) == "\n"))); |
275 ## n = the number of times \n appears in PS1 | 275 ## n = the number of times \n appears in PS1 |
276 size_str = ["size ", getenv("COLUMNS"), ",", getenv("LINES"), n]; | 276 size_str = ["size ", getenv("COLUMNS"), ",", getenv("LINES"), n]; |
277 else | 277 else |
278 ## Use the gnuplot default. | 278 ## Use the gnuplot default. |
279 size_str = ""; | 279 size_str = ""; |
280 end | 280 end |
281 elseif (strncmpi (term, "fig", 3)) | 281 elseif (strncmpi (term, "fig", 3)) |
282 ## Fig also has size, but the format is different. | 282 ## Fig also has size, but the format is different. |
283 size_str = sprintf ("size %.15g %.15g", gnuplot_size); | 283 size_str = sprintf ("size %.15g %.15g", gnuplot_size); |
290 else | 290 else |
291 size_str = ""; | 291 size_str = ""; |
292 endif | 292 endif |
293 else | 293 else |
294 size_str = ""; | 294 size_str = ""; |
295 warning ("gnuplot_set_term: size is zero") | 295 warning ("gnuplot_set_term: size is zero") |
296 endif | 296 endif |
297 else | 297 else |
298 ## A specified size take priority over the figure properies. | 298 ## A specified size take priority over the figure properies. |
299 size_str = ""; | 299 size_str = ""; |
300 endif | 300 endif |