2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
2290
|
19 |
3368
|
20 ## -*- texinfo -*- |
6308
|
21 ## @deftypefn {Function File} {} figure (@var{n}, @var{p}, @var{v}, @dots{}) |
|
22 ## Set the current plot window to plot window @var{n}. If no arguments are |
|
23 ## specified, the next available window number is chosen. Parameters @var{p} |
|
24 ## and settings @var{v} can be given in pairs if @var{n} is specified. |
3368
|
25 ## @end deftypefn |
2290
|
26 |
6257
|
27 ## Author: jwe, Bill Denney |
2314
|
28 |
6257
|
29 function h = figure (varargin) |
3263
|
30 |
6257
|
31 nargs = nargin; |
5406
|
32 |
6405
|
33 f = NaN; |
6283
|
34 |
6293
|
35 init_new_figure = false; |
6283
|
36 if (mod (nargs, 2) == 1) |
6257
|
37 tmp = varargin{1}; |
|
38 if (ishandle (tmp) && strcmp (get (tmp, "type"), "figure")) |
|
39 f = tmp; |
|
40 varargin(1) = []; |
|
41 nargs--; |
|
42 elseif (isnumeric (tmp) && tmp > 0 && round (tmp) == tmp) |
|
43 f = tmp; |
6293
|
44 init_new_figure = true; |
6257
|
45 varargin(1) = []; |
|
46 nargs--; |
|
47 else |
|
48 error ("figure: expecting figure handle or figure number"); |
|
49 endif |
3263
|
50 endif |
|
51 |
6293
|
52 ## Check to see if we already have a figure on the screen. If we do, |
|
53 ## then update it if it is different from the figure we are creating |
|
54 ## or switching to. |
|
55 cf = get (0, "currentfigure"); |
|
56 if (! isempty (cf) && cf != 0) |
6405
|
57 if (isnan (f) || cf != f) |
6293
|
58 drawnow (); |
|
59 endif |
|
60 endif |
|
61 |
6257
|
62 if (rem (nargs, 2) == 0) |
6405
|
63 if (isnan (f) || init_new_figure) |
|
64 f = __go_figure__ (f); |
6283
|
65 endif |
6257
|
66 if (nargs > 0) |
|
67 set (f, varargin{:}); |
2290
|
68 endif |
6257
|
69 set (0, "currentfigure", f); |
2290
|
70 else |
6046
|
71 print_usage (); |
2290
|
72 endif |
3263
|
73 |
6283
|
74 if (nargout > 0) |
|
75 h = f; |
|
76 endif |
|
77 |
2290
|
78 endfunction |