7017
|
1 ## Copyright (C) 1996, 1997, 1999, 2000, 2004, 2005, 2006, 2007 |
|
2 ## John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
2290
|
19 |
3368
|
20 ## -*- texinfo -*- |
6895
|
21 ## @deftypefn {Function File} {} figure (@var{n}) |
|
22 ## @deftypefnx {Function File} {} figure (@var{n}, @var{property}, @var{value}, @dots{}) |
6308
|
23 ## Set the current plot window to plot window @var{n}. If no arguments are |
6895
|
24 ## specified, the next available window number is chosen. |
|
25 ## |
|
26 ## Multiple property-value pairs may be specified for the figure, but they |
|
27 ## must appear in pairs. |
3368
|
28 ## @end deftypefn |
2290
|
29 |
6257
|
30 ## Author: jwe, Bill Denney |
2314
|
31 |
6257
|
32 function h = figure (varargin) |
3263
|
33 |
6257
|
34 nargs = nargin; |
5406
|
35 |
6405
|
36 f = NaN; |
6283
|
37 |
6293
|
38 init_new_figure = false; |
6283
|
39 if (mod (nargs, 2) == 1) |
6257
|
40 tmp = varargin{1}; |
|
41 if (ishandle (tmp) && strcmp (get (tmp, "type"), "figure")) |
|
42 f = tmp; |
|
43 varargin(1) = []; |
|
44 nargs--; |
|
45 elseif (isnumeric (tmp) && tmp > 0 && round (tmp) == tmp) |
|
46 f = tmp; |
6293
|
47 init_new_figure = true; |
6257
|
48 varargin(1) = []; |
|
49 nargs--; |
|
50 else |
|
51 error ("figure: expecting figure handle or figure number"); |
|
52 endif |
3263
|
53 endif |
|
54 |
6293
|
55 ## Check to see if we already have a figure on the screen. If we do, |
|
56 ## then update it if it is different from the figure we are creating |
|
57 ## or switching to. |
|
58 cf = get (0, "currentfigure"); |
|
59 if (! isempty (cf) && cf != 0) |
6405
|
60 if (isnan (f) || cf != f) |
6293
|
61 drawnow (); |
|
62 endif |
|
63 endif |
|
64 |
6257
|
65 if (rem (nargs, 2) == 0) |
6405
|
66 if (isnan (f) || init_new_figure) |
6780
|
67 f = __go_figure__ (f, varargin{:}); |
|
68 elseif (nargs > 0) |
6257
|
69 set (f, varargin{:}); |
2290
|
70 endif |
6257
|
71 set (0, "currentfigure", f); |
2290
|
72 else |
6046
|
73 print_usage (); |
2290
|
74 endif |
3263
|
75 |
6283
|
76 if (nargout > 0) |
|
77 h = f; |
|
78 endif |
|
79 |
2290
|
80 endfunction |