Mercurial > octave
annotate scripts/plot/util/findobj.m @ 31088:06c64a878fc0
findobj.m: Also report properties with aliased names (bug #62612).
* findobj.m: Call "__get__" which returns visible and hidden properties
of a graphics object rather than "get" which only returns visible
properties.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 10 Jun 2022 15:09:53 +0200 |
parents | 29573bab8328 |
children | 597f3ee61a48 |
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) 2007-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27482
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/>. |
6935 | 7 ## |
7016 | 8 ## This file is part of Octave. |
6935 | 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 |
7016 | 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:
22443
diff
changeset
|
13 ## (at your option) any later version. |
7016 | 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:
22443
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22443
diff
changeset
|
18 ## GNU General Public License for more details. |
6935 | 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 ######################################################################## |
6935 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
27 ## @deftypefn {} {@var{h} =} findobj () |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
28 ## @deftypefnx {} {@var{h} =} findobj (@var{prop_name}, @var{prop_value}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
29 ## @deftypefnx {} {@var{h} =} findobj (@var{prop_name}, @var{prop_value}, "-@var{logical_op}", @var{prop_name}, @var{prop_value}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
30 ## @deftypefnx {} {@var{h} =} findobj ("-property", @var{prop_name}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
31 ## @deftypefnx {} {@var{h} =} findobj ("-regexp", @var{prop_name}, @var{pattern}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
32 ## @deftypefnx {} {@var{h} =} findobj (@var{hlist}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
33 ## @deftypefnx {} {@var{h} =} findobj (@var{hlist}, "flat", @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20489
diff
changeset
|
34 ## @deftypefnx {} {@var{h} =} findobj (@var{hlist}, "-depth", @var{d}, @dots{}) |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
35 ## Find graphics objects with specified properties. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
36 ## |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
37 ## When called without arguments, return all graphic objects beginning with the |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
38 ## root object (0) and including all of its descendants. |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
39 ## |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
40 ## The simplest form for narrowing the results is |
6935 | 41 ## |
42 ## @example | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 ## findobj (@var{prop_name}, @var{prop_value}) |
6935 | 44 ## @end example |
45 ## | |
46 ## @noindent | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
47 ## which returns the handles of all objects which have a property named |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
48 ## @var{prop_name} that has the value @var{prop_value}. If multiple |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
49 ## property/value pairs are specified then only objects meeting all of the |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
50 ## conditions (equivalent to @code{-and}) are returned. |
6935 | 51 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
52 ## The search can be limited to a particular set of objects and their |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
53 ## descendants, by passing a handle or set of handles @var{hlist} as the first |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
54 ## argument. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
55 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17238
diff
changeset
|
56 ## The depth of the object hierarchy to search can be limited with the |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
57 ## @qcode{"-depth"} argument. An example of searching through only three |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
58 ## generations of children is: |
6935 | 59 ## |
60 ## @example | |
17478
0ad2f93fd83c
doc: Fix a typo in findobj docstring.
Rik <rik@octave.org>
parents:
17312
diff
changeset
|
61 ## findobj (@var{hlist}, "-depth", 3, @var{prop_name}, @var{prop_value}) |
6935 | 62 ## @end example |
63 ## | |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
64 ## Specifying a depth @var{d} of 0 limits the search to the set of objects |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
65 ## passed in @var{hlist}. A depth of 0 is also equivalent to the |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
66 ## @qcode{"flat"} argument. The default depth value is @code{Inf} which |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
67 ## includes all descendants. |
6935 | 68 ## |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
69 ## A specified logical operator may be used between @var{prop_name}, |
24985
d85b2485af9e
doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24634
diff
changeset
|
70 ## @var{prop_value} pairs. The supported logical operators are: |
d85b2485af9e
doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24634
diff
changeset
|
71 ## @qcode{"-and"}, @qcode{"-or"}, @qcode{"-xor"}, @qcode{"-not"}. Example code |
d85b2485af9e
doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24634
diff
changeset
|
72 ## to locate all figure and axes objects is |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
73 ## |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
74 ## @example |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
75 ## findobj ("type", "figure", "-or", "type", "axes") |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
76 ## @end example |
6935 | 77 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
78 ## Objects may also be matched by comparing a regular expression to the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
79 ## property values, where property values that match |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
80 ## @code{regexp (@var{prop_value}, @var{pattern})} are returned. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
81 ## |
24634
ab2321d4ba03
maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
82 ## Finally, objects which have a property name can be found with the |
24407
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
83 ## @qcode{"-property"} option. For example, code to locate objects with a |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
84 ## @qcode{"meshstyle"} property is |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
85 ## |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
86 ## @example |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
87 ## findobj ("-property", "meshstyle") |
5528840346e7
doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
88 ## @end example |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
89 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
90 ## Implementation Note: The search only includes objects with visible |
28959
5394d688d456
doc: Use @code{} within alternate text for @xref,@pxref macros for better Info display.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
91 ## handles (@w{HandleVisibility} = @qcode{"on"}). |
5394d688d456
doc: Use @code{} within alternate text for @xref,@pxref macros for better Info display.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
92 ## @xref{XREFfindall,,@code{findall}}, to search for all objects including |
5394d688d456
doc: Use @code{} within alternate text for @xref,@pxref macros for better Info display.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
93 ## hidden ones. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
94 ## @seealso{findall, allchild, get, set} |
6935 | 95 ## @end deftypefn |
96 | |
97 function h = findobj (varargin) | |
98 | |
99 depth = NaN; | |
100 if (nargin == 0) | |
101 handles = 0; | |
102 n1 = 0; | |
103 else | |
30968
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
104 if (isempty (varargin{1})) |
8265
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
105 ## Return [](0x1) for compatibility. |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
106 h = zeros (0, 1); |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
107 return; |
7151 | 108 endif |
30968
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
109 arg1 = varargin{1}; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
110 if (isnumeric (arg1)) |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
111 if (! all (ishghandle (arg1))) |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
112 error ("findobj: invalid graphics handles in input HLIST"); |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
113 endif |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
114 handles = arg1; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
115 n1 = 2; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
116 else |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
117 handles = 0; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
118 n1 = 1; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
119 endif |
6935 | 120 if (n1 <= nargin) |
30968
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
121 if (! ischar (varargin{n1})) |
10549 | 122 error ("findobj: properties and options must be strings"); |
6935 | 123 endif |
30968
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
124 if (strcmpi (varargin{n1}, "flat")) |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
125 depth = 0; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
126 n1 += 1; |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
127 endif |
6935 | 128 endif |
129 endif | |
130 | |
131 if (n1 <= nargin && nargin > 0) | |
132 args = varargin(n1 : nargin); | |
133 else | |
134 args = {}; | |
135 endif | |
136 | |
137 regularexpression = []; | |
138 property = []; | |
139 logicaloperator = {}; | |
18507
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
140 extranegation = []; |
6935 | 141 pname = {}; |
142 pvalue = {}; | |
143 np = 1; | |
144 na = 1; | |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
145 operatorprecedence = {"-not", "-and", "-or", "-xor"}; |
6935 | 146 |
147 while (na <= numel (args)) | |
148 regularexpression(np) = 0; | |
149 property(np) = 0; | |
18507
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
150 if (numel (extranegation) < np) |
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
151 extranegation(np) = false; |
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
152 endif |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7208
diff
changeset
|
153 logicaloperator{np} = "and"; |
7208 | 154 if (ischar (args{na})) |
19365
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
155 if (strcmpi (args{na}, "-property")) |
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
156 if (na + 1 <= numel (args)) |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
157 na += 1; |
19365
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
158 property(np) = 1; |
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
159 pname{np} = args{na}; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
160 na += 1; |
19365
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
161 pvalue{np} = []; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
162 np += 1; |
19365
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
163 else |
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
164 error ("findobj: inconsistent number of arguments"); |
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
165 endif |
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
166 elseif (strcmpi (args{na}, "-regexp")) |
10549 | 167 if (na + 2 <= numel (args)) |
168 regularexpression(np) = 1; | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
169 na += 1; |
10549 | 170 pname{np} = args{na}; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
171 na += 1; |
10549 | 172 pvalue{np} = args{na}; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
173 na += 1; |
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
174 np += 1; |
10549 | 175 else |
176 error ("findobj: inconsistent number of arguments"); | |
177 endif | |
19365
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
178 elseif (strcmpi (args{na}, "-depth")) |
10549 | 179 if (na + 1 <= numel (args)) |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
180 na += 1; |
19365
c446da1da9ff
findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents:
18507
diff
changeset
|
181 depth = args{na}; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
182 na += 1; |
10549 | 183 else |
184 error ("findobj: inconsistent number of arguments"); | |
185 endif | |
8506 | 186 elseif (! strcmp (args{na}(1), "-")) |
10549 | 187 ## Parameter/value pairs. |
188 if (na + 1 <= numel (args)) | |
189 pname{np} = args{na}; | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
190 na += 1; |
10549 | 191 pvalue{np} = args{na}; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
192 na += 1; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
193 if (na <= numel (args)) |
10549 | 194 if (ischar (args{na})) |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
195 if (any (strcmpi (args{na}, operatorprecedence))) |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
196 logicaloperator{np} = args{na}(2:end); |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
197 na += 1; |
10549 | 198 endif |
199 else | |
200 error ("findobj: properties and options must be strings"); | |
201 endif | |
202 else | |
203 logicaloperator{np} = "and"; | |
204 endif | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
205 np += 1; |
10549 | 206 else |
207 error ("findobj: inconsistent number of arguments"); | |
208 endif | |
6935 | 209 else |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
210 if (strcmpi (args{na}, "-not")) |
18507
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
211 extranegation(np) = true; |
10549 | 212 endif |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
213 na += 1; |
6935 | 214 endif |
215 else | |
216 error ("findobj: properties and options must be strings"); | |
217 endif | |
218 endwhile | |
219 | |
220 numpairs = np - 1; | |
17307
4448cc742880
Use '!' not operator rather than '~' in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
221 if (! isempty (logicaloperator)) |
30603
397d29f7135c
shift.m: Deprecate function in favor of circshift for Matlab compatibility.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
222 logicaloperator = circshift (logicaloperator, 1); |
16673 | 223 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
224 |
8506 | 225 ## Load all objects which qualify for being searched. |
6935 | 226 idepth = 0; |
21816
acc95f403d73
Let findobj work with a row vector of handles (bug #48113).
mmuetzel <markus.muetzel@gmx.de>
parents:
21758
diff
changeset
|
227 h = handles(:); |
6935 | 228 while (numel (handles) && ! (idepth >= depth)) |
229 children = []; | |
230 for n = 1 : numel (handles) | |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
231 children = [children; get(handles(n), "children")]; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
232 endfor |
6935 | 233 handles = children; |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
234 h = [h; children]; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
235 idepth += 1; |
6935 | 236 endwhile |
237 | |
238 if (numpairs > 0) | |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
239 match = true (numel (h), numpairs); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
240 for nh = 1 : numel (h) |
31088
06c64a878fc0
findobj.m: Also report properties with aliased names (bug #62612).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30969
diff
changeset
|
241 p = __get__ (h(nh)); |
6935 | 242 for np = 1 : numpairs |
10549 | 243 fields = fieldnames (p); |
244 fieldindex = find (strcmpi (fields, pname{np}), 1); | |
245 if (numel (fieldindex)) | |
6935 | 246 pname{np} = fields{fieldindex}; |
247 if (property(np)) | |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
248 match(nh,np) = true; |
6935 | 249 else |
250 if (regularexpression(np)) | |
19980
ed53c87050e8
findobj.m: Stop warning message when using -regexp option (bug #44610).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
251 found = regexp (p.(pname{np}), pvalue{np}, "once"); |
ed53c87050e8
findobj.m: Stop warning message when using -regexp option (bug #44610).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
252 if (isempty (found)) |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
253 match(nh,np) = false; |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
254 else |
19980
ed53c87050e8
findobj.m: Stop warning message when using -regexp option (bug #44610).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
255 match(nh,np) = true; |
7151 | 256 endif |
6935 | 257 elseif (numel (p.(pname{np})) == numel (pvalue{np})) |
16895
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
258 if (ischar (pvalue{np}) && ischar (p.(pname{np}))) |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
259 match(nh,np) = strcmpi (pvalue{np}, p.(pname{np})); |
27482
d4ee26280bb9
findobj.m: Fix typo and correctly handle numeric properties (bug #57030)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
260 elseif (isnumeric (pvalue{np}) && isnumeric (p.(pname{np}))) |
d4ee26280bb9
findobj.m: Fix typo and correctly handle numeric properties (bug #57030)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
261 match(nh,np) = all ((pvalue{np} == p.(pname{np}))(:)); |
10549 | 262 else |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
263 match(nh,np) = isequal (pvalue{np}, p.(pname{np})); |
10549 | 264 endif |
6935 | 265 else |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
266 match(nh,np) = false; |
6935 | 267 endif |
268 endif | |
10549 | 269 else |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
270 match(nh,np) = false; |
10549 | 271 endif |
18507
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
272 if (extranegation(np)) |
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
273 match(nh,np) = ! match(nh,np); |
dca6ecfd622c
findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents:
17744
diff
changeset
|
274 endif |
6935 | 275 endfor |
276 endfor | |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
277 |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
278 if (numpairs > 1) |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
279 for no = 1 : numel (operatorprecedence) |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
280 pairs = find (strcmp (logicaloperator(2:end), ... |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
281 operatorprecedence{no}(2:end))); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
282 for np = sort (pairs, "descend") |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
283 if (no == 1) |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
284 match(:,np+1) = ! match(:,np+1); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
285 logicaloperator(np+1) = {"and"}; |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
286 else |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
287 match(:,np) = feval (logicaloperator{np+1}, match(:,np), ... |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
288 match(:,np+1)); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
289 logicaloperator(np+1) = []; |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
290 match(:,np+1) = []; |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
19980
diff
changeset
|
291 numpairs -= 1; |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
292 endif |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
293 if (numpairs < 2) |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
294 break; |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
295 endif |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
296 endfor |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
297 if (numpairs < 2) |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
298 break; |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
299 endif |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
300 endfor |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
301 endif |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
302 else |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
303 match = true (numel (h), 1); |
6935 | 304 endif |
305 | |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
306 h = h(match); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
307 h = h(:); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
308 |
6935 | 309 endfunction |
13096 | 310 |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
311 |
16673 | 312 %!test |
313 %! hf = figure ("visible", "off"); | |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
314 %! unwind_protect |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
315 %! h = findobj (gca (), "-property", "foo"); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
316 %! assert (isempty (h)); |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
317 %! unwind_protect_cleanup |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
318 %! close (hf); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
319 %! end_unwind_protect |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
320 |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
321 %!test |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
322 %! hf = figure ("visible", "off"); |
16673 | 323 %! unwind_protect |
22443
70aa2b362a31
* findobj.m: Fix failing test after default color change in cset 638625a0186f.
Mike Miller <mtmiller@octave.org>
parents:
22323
diff
changeset
|
324 %! h = plot (1:10, "b"); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
325 %! set (h, "tag", "foobar"); |
16673 | 326 %! g = findobj (gcf (), "tag", "foobar", "type", "line", "color", [0 0 1]); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
327 %! assert (g, h); |
16673 | 328 %! unwind_protect_cleanup |
329 %! close (hf); | |
330 %! end_unwind_protect | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
331 |
13096 | 332 %!test |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13111
diff
changeset
|
333 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
334 %! unwind_protect |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
27978
diff
changeset
|
335 %! l = line (); |
13111
ebb42fb2da04
Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
336 %! obj = findobj (hf, "type", "line"); |
13096 | 337 %! assert (l, obj); |
13111
ebb42fb2da04
Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
338 %! assert (gca, findobj (hf, "type", "axes")); |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13111
diff
changeset
|
339 %! assert (hf, findobj (hf, "type", "figure")); |
13111
ebb42fb2da04
Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
340 %! assert (isempty (findobj (hf, "type", "xyzxyz"))); |
13096 | 341 %! unwind_protect_cleanup |
342 %! close (hf); | |
343 %! end_unwind_protect | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
344 |
16673 | 345 %!test |
346 %! hf = figure ("visible", "off"); | |
347 %! unwind_protect | |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
348 %! subplot (2,2,1); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
349 %! imagesc (rand (10)); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
350 %! subplot (2,2,2); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
351 %! surf (peaks); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
352 %! subplot (2,2,3); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
353 %! contour (peaks); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
354 %! subplot (2,2,4); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
355 %! plot (peaks); |
16673 | 356 %! h1 = findobj (gcf (), "-regexp", "Type", "image|surface|hggroup"); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
357 %! h2 = findobj (gcf (), "Type", "image", |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
358 %! "-or", "Type", "surface", |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
359 %! "-or", "Type", "hggroup"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
360 %! assert (h2, h1); |
16673 | 361 %! unwind_protect_cleanup |
362 %! close (hf); | |
363 %! end_unwind_protect | |
364 | |
16895
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
365 %!test |
17119
bd50e0660545
test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents:
17107
diff
changeset
|
366 %! hf = figure ("visible", "off"); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
367 %! unwind_protect |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
368 %! h1 = subplot (2,2,1); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
369 %! h2 = subplot (2,2,2); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
370 %! h3 = subplot (2,2,3, "userdata", struct ("foo", "bar")); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
371 %! h4 = subplot (2,2,4); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
372 %! h = findobj (hf, "userdata", struct ("foo", "bar")); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
373 %! assert (h, h3); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
374 %! unwind_protect_cleanup |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
375 %! close (hf); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
376 %! end_unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
377 |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
378 %!test |
17119
bd50e0660545
test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents:
17107
diff
changeset
|
379 %! hf = figure ("visible", "off"); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
380 %! unwind_protect |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
381 %! h1 = subplot (2,2,1, "tag", "1"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
382 %! h2 = subplot (2,2,2, "tag", "2"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
383 %! h3 = subplot (2,2,3, "tag", "3"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
384 %! h4 = subplot (2,2,4, "tag", "4"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
385 %! h = findobj (hf, "type", "axes", "-not", "tag", "1"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
386 %! assert (h, [h4; h3; h2]); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
387 %! unwind_protect_cleanup |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
388 %! close (hf); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
389 %! end_unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
390 |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
391 %!test |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
392 %! hf = figure ("visible", "off"); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
393 %! unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
394 %! h1 = subplot (2, 2, 1); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
395 %! set (h1, "userdata", struct ("column", 1, "row", 1)); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
396 %! h2 = subplot (2, 2, 2); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
397 %! set (h2, "userdata", struct ("column", 2, "row", 1)); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
398 %! h3 = subplot (2, 2, 3); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
399 %! set (h3, "userdata", struct ("column", 1, "row", 2)); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
400 %! h4 = subplot (2, 2, 4); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
401 %! set (h4, "userdata", struct ("column", 2, "row", 2)); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
402 %! h = findobj (hf, "type", "axes", |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
403 %! "-not", "userdata", struct ("column", 1, "row", 1)); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
404 %! unwind_protect_cleanup |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
405 %! close (hf); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
406 %! end_unwind_protect |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
407 %! assert (h, [h4; h3; h2]); |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
408 |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
409 %!test |
16900
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
410 %! hf = figure ("visible", "off"); |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
411 %! unwind_protect |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
412 %! ha = axes (); |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
413 %! plot (1:10); |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
414 %! h = findobj (hf, "type", "figure", |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
415 %! "-or", "parent", hf, |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
416 %! "-and", "type", "axes"); |
16900
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
417 %! unwind_protect_cleanup |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
418 %! close (hf); |
16900
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
419 %! end_unwind_protect |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
420 %! assert (h, [hf; ha]); |
16900
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
421 |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
422 %!test |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
423 %! hf = figure ("visible", "off"); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
424 %! unwind_protect |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
425 %! set (hf, "tag", "foo"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
426 %! h1 = subplot (2,2,1, "tag", "foo"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
427 %! h2 = subplot (2,2,2, "tag", "bar"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
428 %! h3 = subplot (2,2,3, "tag", "foo"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
429 %! h4 = subplot (2,2,4, "tag", "bar"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
430 %! h = findobj (hf, "type", "axes", "-xor", "tag", "foo"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
431 %! assert (h, [hf; h4; h2]); |
16905
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
432 %! unwind_protect_cleanup |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
433 %! close (hf); |
562301c71bd3
Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents:
16900
diff
changeset
|
434 %! end_unwind_protect |
17238
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
435 |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
436 %!test |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
437 %! hf = figure ("visible", "off"); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
438 %! unwind_protect |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
439 %! hax1 = subplot (2,1,1); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
440 %! hl1 = plot (rand (10,1)); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
441 %! hax2 = subplot (2,1,2); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
442 %! hl2 = plot (rand (10,1)); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
443 %! hobj = findobj (hf); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
444 %! assert (hobj, [hf; hax2; hax1; hl2; hl1]); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
445 %! unwind_protect_cleanup |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
446 %! close (hf); |
3fd617363762
findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
447 %! end_unwind_protect |
30968
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
448 |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
449 ## Test input validation |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
450 %!error <invalid graphics handles in input HLIST> findobj ([0 1 10], "flat") |
9a9374ed5270
findobj.m: Fix input validation of graphics handles (bug #62378)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
451 %!error <properties and options must be strings> findobj ({0}, "flat") |