annotate scripts/plot/ishold.m @ 12085:c5ab026894ef release-3-2-x

correctly toggle hold state
author John W. Eaton <jwe@octave.org>
date Mon, 07 Sep 2009 08:01:41 +0200
parents eb63fbe60fab
children 95c3e38098bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12085
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1 ## Copyright (C) 2005, 2006, 2007, 2008 2009 John W. Eaton
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
2 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
4 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
9 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
14 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
18
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
6713
26f3d9bf9562 [project @ 2007-06-13 10:34:14 by dbateman]
dbateman
parents: 6257
diff changeset
20 ## @deftypefn {Function File} {} ishold
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6713
diff changeset
21 ## Return true if the next line will be added to the current plot, or
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6713
diff changeset
22 ## false if the plot device will be cleared before drawing the next line.
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
23 ## @end deftypefn
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
24
12085
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
25 function retval = ishold (h)
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
26
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
27 if (nargin == 0)
12085
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
28 ax = gca ();
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
29 fig = gcf ();
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
30 elseif (nargin == 1)
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
31 if (ishandle (h))
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
32 if (isfigure (h))
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
33 ax = get (h, "currentaxes");
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
34 if (isempty (ax))
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
35 ax = __go_axes__ (h);
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
36 set (h, "currentaxes", ax);
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
37 endif
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
38 fig = h;
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
39 elseif (strcmpi (get (h, "type"), "axes"))
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
40 ax = h;
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
41 fig = get (h, "parent");
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
42 else
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
43 error ("hold: expecting argument to be axes or figure graphics handle");
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
44 endif
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
45 else
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
46 error ("hold: expecting argument to be axes or figure graphics handle");
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
47 endif
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
48 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5406
diff changeset
49 print_usage ();
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
50 endif
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
51
12085
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
52 retval = (strcmpi (get (fig, "nextplot"), "add")
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
53 && strcmpi (get (ax, "nextplot"), "add"));
c5ab026894ef correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
54
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
55 endfunction