annotate scripts/plot/cla.m @ 10793:be55736a0783

Grammarcheck the documentation from m-files.
author Rik <octave@nomad.inbox5.com>
date Sun, 18 Jul 2010 20:35:16 -0700
parents 95c3e38098bf
children 2c356a35d7f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
1 ## Copyright (C) 2008, 2009 Ben Abbott
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
2 ##
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
3 ## This program is free software; you can redistribute it and/or modify
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
4 ## it under the terms of the GNU General Public License as published by
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
5 ## the Free Software Foundation; either version 2 of the License, or
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
6 ## (at your option) any later version.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
7 ##
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
8 ## This program is distributed in the hope that it will be useful,
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
11 ## GNU General Public License for more details.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
12 ##
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
13 ## You should have received a copy of the GNU General Public License
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
14 ## along with Octave; see the file COPYING. If not, see
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
15 ## <http://www.gnu.org/licenses/>.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
16
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
17 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
18 ## @deftypefn {Function File} {} cla ()
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
19 ## @deftypefnx {Function File} {} cla ("reset")
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
20 ## @deftypefnx {Function File} {} cla (@var{hax})
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
21 ## @deftypefnx {Function File} {} cla (@var{hax}, "reset")
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
22 ## Delete the children of the current axes with visible handles.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
23 ## If @var{hax} is specified and is an axes object handle, operate on it
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
24 ## instead of the current axes. If the optional argument @code{"reset"}
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
25 ## is specified, also delete the children with hidden handles.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
26 ## @seealso{clf}
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
27 ## @end deftypefn
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
28
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
29 ## Author: Ben Abbott <bpabbott@mac.com>
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
30 ## Created: 2008-10-03
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
31
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
32 function cla (varargin)
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
33
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
34 if (nargin > 2)
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
35 print_usage ();
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
36 elseif (nargin > 1)
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
37 if (ishandle (varargin{1})
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
38 && strcmp (get (varargin{1}, "type"), "axes")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
39 && ischar (varargin{2}) && strcmpi (varargin{2}, "reset"))
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
40 oldhax = gca;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
41 hax = varargin{1};
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
42 do_reset = true;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
43 else
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
44 print_usage ();
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
45 endif
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
46 elseif (nargin == 1)
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
47 if (ishandle (varargin{1})
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
48 && strcmp (get (varargin{1}, "type"), "axes"))
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
49 oldhax = gca;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
50 hax = varargin{1};
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
51 do_reset = false;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
52 elseif (ischar (varargin{1}) && strcmpi (varargin{1}, "reset"))
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
53 hax = gca;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
54 oldhax = hax;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
55 do_reset = true;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
56 else
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
57 print_usage ();
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
58 endif
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
59 else
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
60 hax = gca;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
61 oldhax = hax;
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
62 do_reset = false;
8610
85c9906abfd1 use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents: 8285
diff changeset
63 endif
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
64
8264
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
65 hc = get (hax, "children");
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
66
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
67 if (! do_reset && ! isempty (hc))
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
68 hc = findobj (hc, "flat", "visible", "on");
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
69 hc = setdiff (hc, hax);
8610
85c9906abfd1 use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents: 8285
diff changeset
70 endif
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
71
8264
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
72 if (! isempty (hc))
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
73 ## Delete the children of the axis.
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
74 delete (hc);
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
75 endif
8199
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
76
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
77 ## FIXME: The defaults should be "reset()" below, but so far there is
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
78 ## no method to determine the defaults, much less return an object's
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
79 ## properties to their default values. Instead make a close
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
80 ## approximation.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
81
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
82 axes (hax);
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
83 axis auto
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
84
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
85 ## Set the current axis back to where it was upon entry.
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
86 axes (oldhax);
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
87
ec1b4cd5fbbb cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
88 endfunction
8264
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
89
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
90 %!test
8285
26f0e69e9f3a cla.m: in test, set visible off when creating figure
John W. Eaton <jwe@octave.org>
parents: 8264
diff changeset
91 %! hf = figure (1, "visible", "off");
8264
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
92 %! unwind_protect
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
93 %! clf
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
94 %! plot (1:10)
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
95 %! cla ()
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
96 %! kids = get (gca, "children");
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
97 %! cla ()
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
98 %! unwind_protect_cleanup
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
99 %! close (hf)
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
100 %! end_unwind_protect
bca580bbda02 cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents: 8199
diff changeset
101 %! assert (numel (kids), 0)