1## Copyright (C) 2008, 2009 Ben Abbott
3## This program is free software; you can redistribute it and/or modify
4## it under the terms of the GNU General Public License as published by
5## the Free Software Foundation; either version 2 of the License, or
6## (at your option) any later version.
8## This program is distributed in the hope that it will be useful,
9## but WITHOUT ANY WARRANTY; without even the implied warranty of
10## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11## GNU General Public License for more details.
13## You should have received a copy of the GNU General Public License
14## along with Octave; see the file COPYING. If not, see
15## <http://www.gnu.org/licenses/>.
18## @deftypefn {Function File} {} cla ()
19## @deftypefnx {Function File} {} cla ("reset")
20## @deftypefnx {Function File} {} cla (@var{hax})
21## @deftypefnx {Function File} {} cla (@var{hax}, "reset")
22## Delete the children of the current axes with visible handles.
23## If @var{hax} is specified and is an axes object handle, operate on it
24## instead of the current axes. If the optional argument @code{"reset"}
25## is specified, also delete the children with hidden handles.
29## Author: Ben Abbott <bpabbott@mac.com>
32function cla (varargin)
37 if (ishandle (varargin{1})
38 && strcmp (get (varargin{1}, "type"), "axes")
39 && ischar (varargin{2}) && strcmpi (varargin{2}, "reset"))
47 if (ishandle (varargin{1})
48 && strcmp (get (varargin{1}, "type"), "axes"))
52 elseif (ischar (varargin{1}) && strcmpi (varargin{1}, "reset"))
65 hc = get (hax, "children");
67 if (! do_reset && ! isempty (hc))
68 hc = findobj (hc, "flat", "visible", "on");
69 hc = setdiff (hc, hax);
73 ## Delete the children of the axis.
77 ## FIXME: The defaults should be "reset()" below, but so far there is
78 ## no method to determine the defaults, much less return an object's
79 ## properties to their default values. Instead make a close
85 ## Set the current axis back to where it was upon entry.
91%! hf = figure (1, "visible", "off");
96%! kids = get (gca, "children");
98%! unwind_protect_cleanup
101%! assert (numel (kids), 0)