changelog shortlog tags changeset files revisions annotate raw

scripts/plot/figure.m

changeset 10289: 4b124317dc38
parent:93c65f2a5668
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (41 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 1996, 1997, 1999, 2000, 2004, 2005, 2006, 2007
2## John W. Eaton
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
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
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
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
19
20## -*- texinfo -*-
21## @deftypefn {Function File} {} figure (@var{n})
22## @deftypefnx {Function File} {} figure (@var{n}, @var{property}, @var{value}, @dots{})
23## Set the current plot window to plot window @var{n}. If no arguments are
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.
28## @end deftypefn
29
30## Author: jwe, Bill Denney
31
32function h = figure (varargin)
33
34 nargs = nargin;
35
36 f = NaN;
37
38 init_new_figure = false;
39 if (mod (nargs, 2) == 1)
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;
47 init_new_figure = true;
48 varargin(1) = [];
49 nargs--;
50 else
51 error ("figure: expecting figure handle or figure number");
52 endif
53 endif
54
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)
60 if (isnan (f) || cf != f)
61 drawnow ();
62 endif
63 endif
64
65 if (rem (nargs, 2) == 0)
66 if (isnan (f) || init_new_figure)
67 f = __go_figure__ (f, varargin{:});
68 elseif (nargs > 0)
69 set (f, varargin{:});
70 endif
71 set (0, "currentfigure", f);
72 else
73 print_usage ();
74 endif
75
76 if (nargout > 0)
77 h = f;
78 endif
79
80endfunction