Mercurial > hg > octave-lyh
annotate scripts/plot/findobj.m @ 16900:434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
* scripts/plot/findobj.m: Add xtest to indicate logical operations do not
respect precedence.
While adding the test, remove "drawnow()" from earlier tests.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 05 Jul 2013 07:12:18 -0400 |
parents | 21d5e76891fe |
children | 562301c71bd3 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14001
diff
changeset
|
1 ## Copyright (C) 2007-2012 Ben Abbott |
6935 | 2 ## |
7016 | 3 ## This file is part of Octave. |
6935 | 4 ## |
7016 | 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 | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
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. | |
6935 | 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/>. | |
6935 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {@var{h} =} findobj () |
8507 | 21 ## @deftypefnx {Function File} {@var{h} =} findobj (@var{prop_name}, @var{prop_value}) |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{h} =} findobj ("-property", @var{prop_name}) |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{h} =} findobj ("-regexp", @var{prop_name}, @var{pattern}) |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
24 ## @deftypefnx {Function File} {@var{h} =} findobj ("flat", @dots{}) |
6935 | 25 ## @deftypefnx {Function File} {@var{h} =} findobj (@var{h}, @dots{}) |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
26 ## @deftypefnx {Function File} {@var{h} =} findobj (@var{h}, "-depth", @var{d}, @dots{}) |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
27 ## Find graphics object with specified property values. The simplest form is |
6935 | 28 ## |
29 ## @example | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
30 ## findobj (@var{prop_name}, @var{prop_value}) |
6935 | 31 ## @end example |
32 ## | |
33 ## @noindent | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
34 ## which returns all of the handles to the objects with the name |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
35 ## @var{prop_name} and the name @var{prop_value}. The search can be limited |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
36 ## to a particular object or set of objects and their descendants by |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
37 ## passing a handle or set of handles @var{h} as the first argument to |
6935 | 38 ## @code{findobj}. |
39 ## | |
40 ## The depth of hierarchy of objects to which to search to can be limited | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
41 ## with the "-depth" argument. To limit the number depth of the hierarchy |
6935 | 42 ## to search to @var{d} generations of children, and example is |
43 ## | |
44 ## @example | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
45 ## findobj (@var{h}, "-depth", @var{d}, @var{prop_name}, @var{prop_value}) |
6935 | 46 ## @end example |
47 ## | |
48 ## Specifying a depth @var{d} of 0, limits the search to the set of object | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
49 ## passed in @var{h}. A depth @var{d} of 0 is equivalent to the "-flat" |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
50 ## argument. |
6935 | 51 ## |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
52 ## A specified logical operator may be applied to the pairs of @var{prop_name} |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
53 ## and @var{prop_value}. The supported logical operators are "-and", "-or", |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 ## "-xor", "-not". |
6935 | 55 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 ## The objects may also be matched by comparing a regular expression to the |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 ## property values, where property values that match @code{regexp |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 ## (@var{prop_value}, @var{pattern})} are returned. Finally, objects may be |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 ## matched by property name only, using the "-property" option. |
6935 | 60 ## @seealso{get, set} |
61 ## @end deftypefn | |
62 | |
7017 | 63 ## Author: Ben Abbott <bpabbott@mac.com> |
64 | |
6935 | 65 function h = findobj (varargin) |
66 | |
67 depth = NaN; | |
68 if (nargin == 0) | |
69 handles = 0; | |
70 n1 = 0; | |
71 else | |
8265
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
72 if (! isempty (varargin{1})) |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
73 if (ishandle (varargin{1}(1))) |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
74 handles = varargin{1}; |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
75 n1 = 2; |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
76 else |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
77 handles = 0; |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
78 n1 = 1; |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
79 endif |
6935 | 80 else |
8265
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
81 ## Return [](0x1) for compatibility. |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
82 h = zeros (0, 1); |
1c213dff76fc
findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
83 return; |
7151 | 84 endif |
6935 | 85 if (n1 <= nargin) |
86 if (ischar (varargin{n1})) | |
10549 | 87 if (strcmpi (varargin{n1}, "flat")) |
88 depth = 0; | |
89 n1 = n1 + 1; | |
90 elseif (strcmpi (varargin{n1}, "-depth")) | |
91 depth = varargin{n1+1}; | |
92 n1 = n1 + 2; | |
93 endif | |
6935 | 94 else |
10549 | 95 error ("findobj: properties and options must be strings"); |
6935 | 96 endif |
97 endif | |
98 endif | |
99 | |
100 if (n1 <= nargin && nargin > 0) | |
101 args = varargin(n1 : nargin); | |
102 else | |
103 args = {}; | |
104 endif | |
105 | |
106 regularexpression = []; | |
107 property = []; | |
108 logicaloperator = {}; | |
109 pname = {}; | |
110 pvalue = {}; | |
111 np = 1; | |
112 na = 1; | |
113 | |
114 while (na <= numel (args)) | |
115 regularexpression(np) = 0; | |
116 property(np) = 0; | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7208
diff
changeset
|
117 logicaloperator{np} = "and"; |
7208 | 118 if (ischar (args{na})) |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7208
diff
changeset
|
119 if (strcmpi (args{na}, "-regexp")) |
10549 | 120 if (na + 2 <= numel (args)) |
121 regularexpression(np) = 1; | |
122 na = na + 1; | |
123 pname{np} = args{na}; | |
124 na = na + 1; | |
125 pvalue{np} = args{na}; | |
126 na = na + 1; | |
127 np = np + 1; | |
128 else | |
129 error ("findobj: inconsistent number of arguments"); | |
130 endif | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7208
diff
changeset
|
131 elseif (strcmpi (args{na}, "-property")) |
10549 | 132 if (na + 1 <= numel (args)) |
133 na = na + 1; | |
134 property(np) = 1; | |
135 pname{np} = args{na}; | |
136 na = na + 1; | |
137 pvalue{np} = []; | |
138 np = np + 1; | |
139 else | |
140 error ("findobj: inconsistent number of arguments"); | |
141 endif | |
8506 | 142 elseif (! strcmp (args{na}(1), "-")) |
10549 | 143 ## Parameter/value pairs. |
144 if (na + 1 <= numel (args)) | |
145 pname{np} = args{na}; | |
146 na = na + 1; | |
147 pvalue{np} = args{na}; | |
148 na = na + 1; | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
149 if (na <= numel (args)) |
10549 | 150 if (ischar (args{na})) |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
151 if (strcmpi (args{na}, "-and")) |
10549 | 152 logicaloperator{np} = "and"; |
153 na = na+1; | |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
154 elseif (strcmpi (args{na}, "-or")) |
10549 | 155 logicaloperator{np} = "or"; |
156 na = na+1; | |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
157 elseif (strcmpi (args{na}, "-xor")) |
10549 | 158 logicaloperator{np} = "xor"; |
159 na = na+1; | |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
160 elseif (strcmpi (args{na}, "-not")) |
10549 | 161 logicaloperator{np} = "not"; |
162 na = na+1; | |
163 endif | |
164 else | |
165 error ("findobj: properties and options must be strings"); | |
166 endif | |
167 else | |
168 logicaloperator{np} = "and"; | |
169 endif | |
170 np = np + 1; | |
171 else | |
172 error ("findobj: inconsistent number of arguments"); | |
173 endif | |
6935 | 174 else |
10549 | 175 ## This is sloppy ... but works like Matlab. |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
176 if (strcmpi (args{na}, "-not")) |
10549 | 177 h = []; |
178 return | |
179 endif | |
180 na = na + 1; | |
6935 | 181 endif |
182 else | |
183 error ("findobj: properties and options must be strings"); | |
184 endif | |
185 endwhile | |
186 | |
187 numpairs = np - 1; | |
16673 | 188 if (~ isempty (logicaloperator)) |
189 logicaloperator = shift (logicaloperator, 1); | |
190 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
191 |
8506 | 192 ## Load all objects which qualify for being searched. |
6935 | 193 idepth = 0; |
194 h = handles; | |
195 while (numel (handles) && ! (idepth >= depth)) | |
196 children = []; | |
197 for n = 1 : numel (handles) | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
198 children = union (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
|
199 endfor |
6935 | 200 handles = children; |
201 h = union (h, children); | |
202 idepth = idepth + 1; | |
203 endwhile | |
204 | |
205 keepers = ones (size (h)); | |
206 if (numpairs > 0) | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
207 for nh = 1 : numel (h) |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
208 p = get (h(nh)); |
6935 | 209 for np = 1 : numpairs |
10549 | 210 fields = fieldnames (p); |
211 fieldindex = find (strcmpi (fields, pname{np}), 1); | |
212 if (numel (fieldindex)) | |
6935 | 213 pname{np} = fields{fieldindex}; |
214 if (property(np)) | |
215 match = 1; | |
216 else | |
217 if (regularexpression(np)) | |
10549 | 218 match = regexp (p.(pname{np}), pvalue{np}); |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14327
diff
changeset
|
219 if (isempty (match)) |
6935 | 220 match = 0; |
7151 | 221 endif |
6935 | 222 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
|
223 if (ischar (pvalue{np}) && ischar (p.(pname{np}))) |
10549 | 224 match = strcmpi (pvalue{np}, p.(pname{np})); |
16895
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
225 elseif (isnumeric (pvalue{np} && isnumeric (p.(pname{np})))) |
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
226 match = (pvalue{np} == p.(pname{np})); |
10549 | 227 else |
16895
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
228 match = isequal (pvalue{np}, p.(pname{np})); |
10549 | 229 endif |
6935 | 230 else |
10549 | 231 match = 0; |
6935 | 232 endif |
233 match = all (match); | |
234 endif | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7208
diff
changeset
|
235 if (strcmpi (logicaloperator{np}, "not")) |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
236 keepers(nh) = keepers(nh) & ! match; |
6935 | 237 else |
238 keepers(nh) = feval (logicaloperator{np}, keepers(nh), match); | |
239 endif | |
10549 | 240 else |
241 keepers(nh) = 0; | |
242 endif | |
6935 | 243 endfor |
244 endfor | |
245 endif | |
246 | |
247 h = h (keepers != 0); | |
248 h = reshape (h, [numel(h), 1]); | |
249 endfunction | |
13096 | 250 |
16673 | 251 %!test |
252 %! hf = figure ("visible", "off"); | |
253 %! unwind_protect | |
254 %! h = plot (1:10); | |
255 %! set (h, "tag", "foobar") | |
256 %! g = findobj (gcf (), "tag", "foobar", "type", "line", "color", [0 0 1]); | |
257 %! assert (g, h) | |
258 %! unwind_protect_cleanup | |
259 %! close (hf); | |
260 %! 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
|
261 |
13096 | 262 %!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
|
263 %! 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
|
264 %! unwind_protect |
13096 | 265 %! l = line; |
13111
ebb42fb2da04
Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
266 %! obj = findobj (hf, "type", "line"); |
13096 | 267 %! assert (l, obj); |
13111
ebb42fb2da04
Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
268 %! 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
|
269 %! 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
|
270 %! assert (isempty (findobj (hf, "type", "xyzxyz"))); |
13096 | 271 %! unwind_protect_cleanup |
272 %! close (hf); | |
273 %! 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
|
274 |
16673 | 275 %!test |
276 %! hf = figure ("visible", "off"); | |
277 %! unwind_protect | |
278 %! subplot (2, 2, 1) | |
279 %! imagesc (rand (10)) | |
280 %! subplot (2, 2, 2) | |
281 %! surf (peaks) | |
282 %! subplot (2, 2, 3) | |
283 %! contour (peaks) | |
284 %! subplot (2, 2, 4) | |
285 %! plot (peaks) | |
286 %! h1 = findobj (gcf (), "-regexp", "Type", "image|surface|hggroup"); | |
287 %! h2 = findobj (gcf (), "Type", "image", "-or", "Type", "surface", "-or", "Type", "hggroup"); | |
288 %! unwind_protect_cleanup | |
289 %! close (hf); | |
290 %! end_unwind_protect | |
291 %! assert (h2, h1) | |
292 | |
16895
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
293 %!test |
16897
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
294 %! graphics_toolkit gnuplot; |
16895
b8c37a855074
Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents:
16673
diff
changeset
|
295 %! 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
|
296 %! unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
297 %! h1 = subplot (2, 2, 1); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
298 %! h2 = subplot (2, 2, 2); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
299 %! h3 = subplot (2, 2, 3); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
300 %! h4 = subplot (2, 2, 4); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
301 %! userdata = struct ("foo", "bar"); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
302 %! set (h3, "userdata", userdata); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
303 %! h = findobj (hf, "userdata", userdata); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
304 %! unwind_protect_cleanup |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
305 %! close (hf); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
306 %! end_unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
307 %! assert (h, h3) |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
308 |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
309 %!test |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
310 %! graphics_toolkit gnuplot; |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
311 %! hf = figure ("visible", "off"); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
312 %! unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
313 %! h1 = subplot (2, 2, 1); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
314 %! set (h1, 'tag', '1') |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
315 %! h2 = subplot (2, 2, 2); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
316 %! set (h2, 'tag', '2') |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
317 %! h3 = subplot (2, 2, 3); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
318 %! set (h3, 'tag', '3') |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
319 %! h4 = subplot (2, 2, 4); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
320 %! set (h4, 'tag', '4') |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
321 %! h = findobj (hf, 'type', 'axes', '-not', 'tag', '1'); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
322 %! unwind_protect_cleanup |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
323 %! close (hf); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
324 %! end_unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
325 %! assert (h, [h2; h3; h4]) |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
326 |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
327 %!test |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
328 %! hf = figure ("visible", "off"); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
329 %! unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
330 %! h1 = subplot (2, 2, 1); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
331 %! set (h1, 'userdata', struct ('column', 1, 'row', 1)); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
332 %! h2 = subplot (2, 2, 2); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
333 %! set (h2, 'userdata', struct ('column', 2, 'row', 1)); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
334 %! h3 = subplot (2, 2, 3); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
335 %! set (h3, 'userdata', struct ('column', 1, 'row', 2)); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
336 %! h4 = subplot (2, 2, 4); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
337 %! set (h4, 'userdata', struct ('column', 2, 'row', 2)); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
338 %! h = findobj (hf, 'type', 'axes', '-not', 'userdata', ... |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
339 %! struct ('column', 1, 'row', 1)); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
340 %! unwind_protect_cleanup |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
341 %! close (hf); |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
342 %! end_unwind_protect |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
343 %! assert (h, [h2; h3; h4]) |
21d5e76891fe
Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
16895
diff
changeset
|
344 |
16900
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
345 %!xtest |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
346 %! hf = figure ("visible", "off"); |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
347 %! unwind_protect |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
348 %! ha = axes (); |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
349 %! plot (1:10); |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
350 %! h = findobj (hf, 'type', 'figure', ... |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
351 %! '-or', 'parent', 1, ... |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
352 %! '-and', 'type', 'axes') |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
353 %! unwind_protect_cleanup |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
354 %! close (hf) |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
355 %! end_unwind_protect |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
356 %! assert (h, [hf; ha]) |
434a0b29ab12
Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents:
16897
diff
changeset
|
357 |