Mercurial > hg > octave-lyh
annotate scripts/plot/ishold.m @ 9618:e381f80a5f7a
correctly toggle hold state
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 05 Sep 2009 16:50:21 -0400 |
parents | eb63fbe60fab |
children | 95c3e38098bf |
rev | line source |
---|---|
9618
e381f80a5f7a
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 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5406 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5406 | 18 |
19 ## -*- texinfo -*- | |
6713 | 20 ## @deftypefn {Function File} {} ishold |
6895 | 21 ## Return true if the next line will be added to the current plot, or |
22 ## false if the plot device will be cleared before drawing the next line. | |
5406 | 23 ## @end deftypefn |
24 | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
25 function retval = ishold (h) |
5406 | 26 |
27 if (nargin == 0) | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
28 ax = gca (); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
29 fig = gcf (); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
30 elseif (nargin == 1) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
31 if (ishandle (h)) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
32 if (isfigure (h)) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
33 ax = get (h, "currentaxes"); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
34 if (isempty (ax)) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
35 ax = __go_axes__ (h); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
36 set (h, "currentaxes", ax); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
37 endif |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
38 fig = h; |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
39 elseif (strcmpi (get (h, "type"), "axes")) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
40 ax = h; |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
41 fig = get (h, "parent"); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
42 else |
e381f80a5f7a
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"); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
44 endif |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
45 else |
e381f80a5f7a
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"); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
47 endif |
5406 | 48 else |
6046 | 49 print_usage (); |
5406 | 50 endif |
51 | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
52 retval = (strcmpi (get (fig, "nextplot"), "add") |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
53 && strcmpi (get (ax, "nextplot"), "add")); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
54 |
5406 | 55 endfunction |