Mercurial > octave
annotate scripts/plot/util/ishold.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 7854d5752dd2 |
children | 83f9f8bda883 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 2005-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
5406 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24423
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
5406 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24423
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
5406 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
5406 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24423
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
5406 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19880
diff
changeset
|
27 ## @deftypefn {} {} ishold |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19880
diff
changeset
|
28 ## @deftypefnx {} {} ishold (@var{hax}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19880
diff
changeset
|
29 ## @deftypefnx {} {} ishold (@var{hfig}) |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
30 ## 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
|
31 ## 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
|
32 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
33 ## If the first argument is an axes handle @var{hax} or figure handle |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
34 ## @var{hfig} then operate on this plot rather than the current one. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
35 ## @seealso{hold, newplot} |
5406 | 36 ## @end deftypefn |
37 | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
38 function retval = ishold (h) |
5406 | 39 |
40 if (nargin == 0) | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
41 fig = gcf (); |
13319
eb0ce6ffefb0
ishold: don't create axes if none exists
John W. Eaton <jwe@octave.org>
parents:
13204
diff
changeset
|
42 ax = get (fig, "currentaxes"); |
17130
327862500f1c
ishold.m: Recode to follow modern Octave coding conventions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
43 else |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
44 if (! ishghandle (h)) |
22069
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
45 error ("ishold: H must be an axes or figure graphics handle"); |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
46 endif |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
47 |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
48 switch (get (h, "type")) |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
49 case "figure" |
10549 | 50 fig = h; |
17130
327862500f1c
ishold.m: Recode to follow modern Octave coding conventions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
51 ax = get (fig, "currentaxes"); |
22069
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
52 |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
53 case "axes" |
10549 | 54 ax = h; |
19880
f25fe5369022
Don't assume axes parent is a figure (bug #44394)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19697
diff
changeset
|
55 fig = ancestor (ax, "figure"); |
22069
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
56 |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
57 otherwise |
17130
327862500f1c
ishold.m: Recode to follow modern Octave coding conventions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
58 error ("ishold: H must be an axes or figure graphics handle"); |
22069
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
59 |
9121d6584f6a
Overhaul graphics implementation of hold() (bug #43559).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
60 endswitch |
5406 | 61 endif |
62 | |
17130
327862500f1c
ishold.m: Recode to follow modern Octave coding conventions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
63 retval = (strcmp (get (fig, "nextplot"), "add") |
327862500f1c
ishold.m: Recode to follow modern Octave coding conventions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
64 && ! isempty (ax) && strcmp (get (ax, "nextplot"), "add")); |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
65 |
5406 | 66 endfunction |
13204 | 67 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
68 |
13204 | 69 %!test |
70 %! hf = figure ("visible", "off"); | |
71 %! unwind_protect | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
72 %! assert (! ishold); |
13319
eb0ce6ffefb0
ishold: don't create axes if none exists
John W. Eaton <jwe@octave.org>
parents:
13204
diff
changeset
|
73 %! assert (isempty (get (hf, "currentaxes"))); |
eb0ce6ffefb0
ishold: don't create axes if none exists
John W. Eaton <jwe@octave.org>
parents:
13204
diff
changeset
|
74 %! assert (get (hf, "NextPlot"), "add"); |
13204 | 75 %! l = plot ([0 1]); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
76 %! assert (! ishold); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
77 %! assert (! ishold (gca)); |
13204 | 78 %! assert (get (gca, "NextPlot"), "replace"); |
79 %! assert (get (hf, "NextPlot"), "add"); | |
80 %! hold; | |
81 %! assert (ishold); | |
82 %! assert (ishold (gca)); | |
83 %! assert (get (gca, "NextPlot"), "add"); | |
84 %! assert (get (hf, "NextPlot"), "add"); | |
85 %! p = fill ([0 1 1], [0 0 1],"black"); | |
86 %! assert (length (get (hf, "children")), 1); | |
87 %! assert (length (get (gca, "children")), 2); | |
88 %! unwind_protect_cleanup | |
89 %! close (hf); | |
90 %! end_unwind_protect |