1 ## Copyright (C) 2008-2012 Ben Abbott
3 ## This file is part of Octave.
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 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} cla ()
21 ## @deftypefnx {Function File} {} cla ("reset")
22 ## @deftypefnx {Function File} {} cla (@var{hax})
23 ## @deftypefnx {Function File} {} cla (@var{hax}, "reset")
24 ## Delete the children of the current axes with visible handles.
25 ## If @var{hax} is specified and is an axes object handle, operate on it
26 ## instead of the current axes. If the optional argument @code{"reset"}
27 ## is specified, also delete the children with hidden handles.
31 ## Author: Ben Abbott <bpabbott@mac.com>
32 ## Created: 2008-10-03
34 function cla (varargin)
39 if (ishandle (varargin{1})
40 && strcmp (get (varargin{1}, "type"), "axes")
41 && ischar (varargin{2}) && strcmpi (varargin{2}, "reset"))
49 if (ishandle (varargin{1})
50 && strcmp (get (varargin{1}, "type"), "axes"))
54 elseif (ischar (varargin{1}) && strcmpi (varargin{1}, "reset"))
67 hc = get (hax, "children");
69 if (! do_reset && ! isempty (hc))
70 hc = findobj (hc, "flat", "visible", "on");
71 hc = setdiff (hc, hax);
75 ## Delete the children of the axis.
79 ## FIXME: The defaults should be "reset()" below, but so far there is
80 ## no method to determine the defaults, much less return an object's
81 ## properties to their default values. Instead make a close
87 ## Set the current axis back to where it was upon entry.
93 %! hf = figure ("visible", "off");
97 %! kids = get (gca, "children");
99 %! unwind_protect_cleanup
101 %! end_unwind_protect
102 %! assert (numel (kids), 0)