6257
|
1 ## Copyright (C) 2005 John W. Eaton |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} drawnow () |
|
22 ## Display the current graphics. |
|
23 ## @end deftypefn |
|
24 |
|
25 ## Author: jwe |
|
26 |
|
27 function drawnow (term, file) |
|
28 |
|
29 ## Use this instead of calling gcf to avoid creating a figure. |
|
30 |
|
31 h = get (0, "currentfigure"); |
|
32 |
|
33 if (h) |
|
34 |
|
35 f = get (h); |
|
36 |
|
37 plot_stream = f.__plot_stream__; |
|
38 |
|
39 if (isempty (plot_stream)) |
|
40 plot_stream = popen (sprintf ("gnuplot -title \"Figure %d\"", h), "w"); |
|
41 if (plot_stream < 0) |
|
42 error ("drawnow: failed to open connection to gnuplot"); |
|
43 else |
|
44 set (h, "__plot_stream__", plot_stream); |
|
45 if (isempty (getenv ("DISPLAY"))) |
|
46 fprintf (plot_stream, "set terminal dumb\n;"); |
|
47 endif |
|
48 endif |
|
49 endif |
|
50 |
|
51 if (nargin == 2) |
|
52 fprintf (plot_stream, |
|
53 "set terminal push; set terminal %s; set output '%s'\n", |
|
54 term, file); |
|
55 endif |
|
56 |
|
57 if (nargin == 2 || strcmp (f.visible, "on")) |
|
58 __uiobject_draw_figure__ (f, plot_stream); |
|
59 endif |
|
60 |
|
61 __request_drawnow__ (false); |
|
62 |
|
63 if (nargin == 2) |
|
64 fputs (plot_stream, "set terminal pop; set output;\n"); |
|
65 endif |
|
66 |
|
67 else |
|
68 |
|
69 __request_drawnow__ (false); |
|
70 |
|
71 endif |
|
72 |
|
73 |
|
74 endfunction |