comparison scripts/plot/clf.m @ 8250:8a2559a1aefa

clf.m: Improve Matlab compatibility.
author Ben Abbott <bpabbott@mac.com>
date Tue, 21 Oct 2008 15:12:40 -0400
parents a1dbe9d80eee
children 85c9906abfd1 c2bfc6440e18
comparison
equal deleted inserted replaced
8249:1f429086565c 8250:8a2559a1aefa
16 ## along with Octave; see the file COPYING. If not, see 16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} clf () 20 ## @deftypefn {Function File} {} clf ()
21 ## Clear the current figure. 21 ## @deftypefnx {Function File} {} clf ("reset")
22 ## @seealso{close, delete} 22 ## @deftypefnx {Function File} {} clf (@var{hfig})
23 ## @deftypefnx {Function File} {} clf (@var{hfig}, "reset")
24 ## @deftypefnx {Function File} {@var{hfig} =} clf (@dots{})
25 ## Delete the children of the current figure with visible handles.
26 ## If @var{hfig} is specified and is an figure object handle, operate on it
27 ## instead of the current figure. If the optional argument @code{"reset"}
28 ## is specified, also delete the figure's children with hidden handles.
29 ## @seealso{cla, close, delete}
23 ## @end deftypefn 30 ## @end deftypefn
24 31
25 ## Author: jwe 32 ## Author: jwe
26 33
27 function clf () 34 function clf (varargin)
28 35
29 if (nargin == 0) 36 if (nargin > 2)
30 cf = gcf (); 37 print_usage ();
31 set (cf, "currentaxes", []); 38 elseif (nargin > 1)
32 for k = get (cf, "children") 39 if (isfigure (varargin{1}) && ischar (varargin{2})
33 if (ishandle (k)) 40 && strcmpi (varargin{2}, "reset"))
34 delete (k); 41 oldfig = gcf;
35 endif 42 hfig = varargin{1};
36 endfor 43 do_reset = true;
44 else
45 print_usage ();
46 endif
47 elseif (nargin == 1)
48 if (isfigure (varargin{1}))
49 oldfig = gcf;
50 hfig = varargin{1};
51 do_reset = false;
52 elseif (ischar (varargin{1}) && strcmpi (varargin{1}, "reset"))
53 hfig = gcf;
54 oldfig = hfig;
55 do_reset = true;
56 else
57 print_usage ();
58 endif
37 else 59 else
38 print_usage (); 60 hfig = gcf;
61 oldfig = hfig;
62 do_reset = false;
63 end
64
65 if (do_reset)
66 ## Select all the children, including the one with hidden handles.
67 hc = allchild (hfig);
68 reset (hfig)
69 else
70 ## Select only the chilren with visible handles.
71 hc = get (hfig, "children");
39 endif 72 endif
40 73
74 ## Delete the children.
75 delete (hc);
76
41 endfunction 77 endfunction