Mercurial > hg > octave-lyh
annotate scripts/plot/ishold.m @ 13256:41c2f4633a62
Properly process 'cdata' property for patches (Bug #34417).
* __patch__.m: Guarantee that 'cdata' and 'facevertexcdata' are transposes of
each other.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 28 Sep 2011 09:14:45 -0700 |
parents | be7bfd59300a |
children | eb0ce6ffefb0 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2005-2011 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 -*- | |
12546
39ca02387a32
Improve docstrings for a number of functions.
Rik <octave@nomad.inbox5.com>
parents:
11563
diff
changeset
|
20 ## @deftypefn {Command} {} ishold |
39ca02387a32
Improve docstrings for a number of functions.
Rik <octave@nomad.inbox5.com>
parents:
11563
diff
changeset
|
21 ## @deftypefnx {Function File} {} ishold (@var{h}) |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
22 ## Return true if the next plot will be added to the current plot, or |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
23 ## false if the plot device will be cleared before drawing the next plot. |
12546
39ca02387a32
Improve docstrings for a number of functions.
Rik <octave@nomad.inbox5.com>
parents:
11563
diff
changeset
|
24 ## |
39ca02387a32
Improve docstrings for a number of functions.
Rik <octave@nomad.inbox5.com>
parents:
11563
diff
changeset
|
25 ## Optionally, operate on the graphics handle @var{h} rather than the current |
39ca02387a32
Improve docstrings for a number of functions.
Rik <octave@nomad.inbox5.com>
parents:
11563
diff
changeset
|
26 ## plot. |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
27 ## @seealso{hold} |
5406 | 28 ## @end deftypefn |
29 | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
30 function retval = ishold (h) |
5406 | 31 |
32 if (nargin == 0) | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
33 ax = gca (); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
34 fig = gcf (); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
35 elseif (nargin == 1) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
36 if (ishandle (h)) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
37 if (isfigure (h)) |
10549 | 38 ax = get (h, "currentaxes"); |
39 if (isempty (ax)) | |
40 ax = __go_axes__ (h); | |
41 set (h, "currentaxes", ax); | |
42 endif | |
43 fig = h; | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
44 elseif (strcmpi (get (h, "type"), "axes")) |
10549 | 45 ax = h; |
46 fig = get (h, "parent"); | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
47 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
48 error ("ishold: expecting argument to be axes or figure graphics handle"); |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
49 endif |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
50 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
51 error ("ishold: expecting argument to be axes or figure graphics handle"); |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
52 endif |
5406 | 53 else |
6046 | 54 print_usage (); |
5406 | 55 endif |
56 | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
57 retval = (strcmpi (get (fig, "nextplot"), "add") |
10549 | 58 && strcmpi (get (ax, "nextplot"), "add")); |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
59 |
5406 | 60 endfunction |
13204 | 61 |
62 %!test | |
63 %! hf = figure ("visible", "off"); | |
64 %! unwind_protect | |
65 %! l = plot ([0 1]); | |
66 %! assert (!ishold); | |
67 %! assert (!ishold (gca)); | |
68 %! assert (get (gca, "NextPlot"), "replace"); | |
69 %! assert (get (hf, "NextPlot"), "add"); | |
70 %! hold; | |
71 %! assert (ishold); | |
72 %! assert (ishold (gca)); | |
73 %! assert (get (gca, "NextPlot"), "add"); | |
74 %! assert (get (hf, "NextPlot"), "add"); | |
75 %! p = fill ([0 1 1], [0 0 1],"black"); | |
76 %! assert (length (get (hf, "children")), 1); | |
77 %! assert (length (get (gca, "children")), 2); | |
78 %! unwind_protect_cleanup | |
79 %! close (hf); | |
80 %! end_unwind_protect |