annotate scripts/plot/util/findobj.m @ 26376:00f796120a6d stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Jan 2019 16:32:43 -0500
parents 6652d3823428
children d4ee26280bb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1 ## Copyright (C) 2007-2019 Ben Abbott
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
2 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
3 ## This file is part of Octave.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
6 ## 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
7 ## 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
8 ## (at your option) any later version.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22443
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22443
diff changeset
13 ## GNU General Public License for more details.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
14 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
16 ## 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
17 ## <https://www.gnu.org/licenses/>.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
18
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20489
diff changeset
20 ## @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
21 ## @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
22 ## @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
23 ## @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
24 ## @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
25 ## @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
26 ## @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
27 ## @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
28 ## Find graphics objects with specified properties.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
29 ##
24407
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
30 ## 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
31 ## root object (0) and including all of its descendants.
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
32 ##
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
33 ## The simplest form for narrowing the results is
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
34 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
35 ## @example
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
36 ## findobj (@var{prop_name}, @var{prop_value})
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
37 ## @end example
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
38 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
39 ## @noindent
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
40 ## 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
41 ## @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
42 ## 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
43 ## conditions (equivalent to @code{-and}) are returned.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
44 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
45 ## 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
46 ## 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
47 ## argument.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
48 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17238
diff changeset
49 ## 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
50 ## @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
51 ## generations of children is:
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
52 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
53 ## @example
17478
0ad2f93fd83c doc: Fix a typo in findobj docstring.
Rik <rik@octave.org>
parents: 17312
diff changeset
54 ## findobj (@var{hlist}, "-depth", 3, @var{prop_name}, @var{prop_value})
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
55 ## @end example
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
56 ##
24407
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
57 ## 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
58 ## 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
59 ## @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
60 ## includes all descendants.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
61 ##
24407
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
62 ## 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
63 ## @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
64 ## @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
65 ## to locate all figure and axes objects is
24407
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
66 ##
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
67 ## @example
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
68 ## findobj ("type", "figure", "-or", "type", "axes")
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
69 ## @end example
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
70 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
71 ## 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
72 ## property values, where property values that match
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
73 ## @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
74 ##
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75 ## 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
76 ## @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
77 ## @qcode{"meshstyle"} property is
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
78 ##
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
79 ## @example
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
80 ## findobj ("-property", "meshstyle")
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
81 ## @end example
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
82 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
83 ## Implementation Note: The search only includes objects with visible
24407
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
84 ## handles (@w{HandleVisibility} = @qcode{"on"}). @xref{XREFfindall,,findall},
5528840346e7 doc: Improve documentation for findobj, findall.
Rik <rik@octave.org>
parents: 23219
diff changeset
85 ## to search for all objects including hidden ones.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17119
diff changeset
86 ## @seealso{findall, allchild, get, set}
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
87 ## @end deftypefn
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
88
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
89 ## Author: Ben Abbott <bpabbott@mac.com>
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
90
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
91 function h = findobj (varargin)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
92
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
93 depth = NaN;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
94 if (nargin == 0)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
95 handles = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
96 n1 = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
97 else
8265
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
98 if (! isempty (varargin{1}))
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 24409
diff changeset
99 if (ishghandle (varargin{1}(1)))
8265
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
100 handles = varargin{1};
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
101 n1 = 2;
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
102 else
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
103 handles = 0;
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
104 n1 = 1;
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
105 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
106 else
8265
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
107 ## Return [](0x1) for compatibility.
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
108 h = zeros (0, 1);
1c213dff76fc findobj.m: allow handle to be empty
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
109 return;
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
110 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
111 if (n1 <= nargin)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
112 if (ischar (varargin{n1}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
113 if (strcmpi (varargin{n1}, "flat"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
114 depth = 0;
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
115 n1 += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
116 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
117 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
118 error ("findobj: properties and options must be strings");
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
119 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
120 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
121 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
122
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
123 if (n1 <= nargin && nargin > 0)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
124 args = varargin(n1 : nargin);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
125 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
126 args = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
127 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
128
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
129 regularexpression = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
130 property = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
131 logicaloperator = {};
18507
dca6ecfd622c findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents: 17744
diff changeset
132 extranegation = [];
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
133 pname = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
134 pvalue = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
135 np = 1;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
136 na = 1;
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
137 operatorprecedence = {"-not", "-and", "-or", "-xor"};
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
138
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
139 while (na <= numel (args))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
140 regularexpression(np) = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
141 property(np) = 0;
18507
dca6ecfd622c findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents: 17744
diff changeset
142 if (numel (extranegation) < np)
dca6ecfd622c findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents: 17744
diff changeset
143 extranegation(np) = false;
dca6ecfd622c findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents: 17744
diff changeset
144 endif
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7208
diff changeset
145 logicaloperator{np} = "and";
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7151
diff changeset
146 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
147 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
148 if (na + 1 <= numel (args))
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
149 na += 1;
19365
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
150 property(np) = 1;
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
151 pname{np} = args{na};
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
152 na += 1;
19365
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
153 pvalue{np} = [];
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
154 np += 1;
19365
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
155 else
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
156 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
157 endif
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
158 elseif (strcmpi (args{na}, "-regexp"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
159 if (na + 2 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
160 regularexpression(np) = 1;
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
161 na += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
162 pname{np} = args{na};
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
163 na += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
164 pvalue{np} = args{na};
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
165 na += 1;
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
166 np += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
167 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
168 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
169 endif
19365
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
170 elseif (strcmpi (args{na}, "-depth"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
171 if (na + 1 <= numel (args))
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
172 na += 1;
19365
c446da1da9ff findobj.m: Allow -depth argument anywhere in input arg list (bug #43136).
Rik <rik@octave.org>
parents: 18507
diff changeset
173 depth = args{na};
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
174 na += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
175 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
176 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
177 endif
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8265
diff changeset
178 elseif (! strcmp (args{na}(1), "-"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
179 ## Parameter/value pairs.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
180 if (na + 1 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
181 pname{np} = 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
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
183 pvalue{np} = args{na};
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
184 na += 1;
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14552
diff changeset
185 if (na <= numel (args))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
186 if (ischar (args{na}))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
187 if (any (strcmpi (args{na}, operatorprecedence)))
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
188 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
189 na += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
190 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
191 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
192 error ("findobj: properties and options must be strings");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
193 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
194 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
195 logicaloperator{np} = "and";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
196 endif
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
197 np += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
198 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
199 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
200 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
201 else
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
202 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
203 extranegation(np) = true;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
204 endif
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
205 na += 1;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
206 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
207 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
208 error ("findobj: properties and options must be strings");
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
209 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
210 endwhile
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
211
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
212 numpairs = np - 1;
17307
4448cc742880 Use '!' not operator rather than '~' in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
213 if (! isempty (logicaloperator))
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
214 logicaloperator = shift (logicaloperator, 1);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
215 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
216
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8265
diff changeset
217 ## Load all objects which qualify for being searched.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
218 idepth = 0;
21816
acc95f403d73 Let findobj work with a row vector of handles (bug #48113).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
219 h = handles(:);
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
220 while (numel (handles) && ! (idepth >= depth))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
221 children = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
222 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
223 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
224 endfor
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
225 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
226 h = [h; children];
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
227 idepth += 1;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
228 endwhile
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
229
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
230 if (numpairs > 0)
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
231 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
232 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
233 p = get (h(nh));
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
234 for np = 1 : numpairs
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
235 fields = fieldnames (p);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
236 fieldindex = find (strcmpi (fields, pname{np}), 1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
237 if (numel (fieldindex))
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
238 pname{np} = fields{fieldindex};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
239 if (property(np))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
240 match(nh,np) = true;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
241 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
242 if (regularexpression(np))
19980
ed53c87050e8 findobj.m: Stop warning message when using -regexp option (bug #44610).
Rik <rik@octave.org>
parents: 19697
diff changeset
243 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
244 if (isempty (found))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
245 match(nh,np) = false;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
246 else
19980
ed53c87050e8 findobj.m: Stop warning message when using -regexp option (bug #44610).
Rik <rik@octave.org>
parents: 19697
diff changeset
247 match(nh,np) = true;
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
248 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
249 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
250 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
251 match(nh,np) = 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
252 elseif (isnumeric (pvalue{np} && isnumeric (p.(pname{np}))))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
253 match(nh,np) = (pvalue{np} == p.(pname{np}));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
254 else
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
255 match(nh,np) = isequal (pvalue{np}, p.(pname{np}));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
256 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
257 else
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
258 match(nh,np) = false;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
259 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
260 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
261 else
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
262 match(nh,np) = false;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
263 endif
18507
dca6ecfd622c findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents: 17744
diff changeset
264 if (extranegation(np))
dca6ecfd622c findobj.m: let leading negation work (bug #41588).
Sergey Plotnikov <seryozha.plotnikov@gmail.com>
parents: 17744
diff changeset
265 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
266 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
267 endfor
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
268 endfor
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
269
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
270 if (numpairs > 1)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
271 for no = 1 : numel (operatorprecedence)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
272 pairs = find (strcmp (logicaloperator(2:end), ...
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
273 operatorprecedence{no}(2:end)));
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
274 for np = sort (pairs, "descend")
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
275 if (no == 1)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
276 match(:,np+1) = ! match(:,np+1);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
277 logicaloperator(np+1) = {"and"};
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
278 else
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
279 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
280 match(:,np+1));
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
281 logicaloperator(np+1) = [];
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
282 match(:,np+1) = [];
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 19980
diff changeset
283 numpairs -= 1;
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
284 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
285 if (numpairs < 2)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
286 break;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
287 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
288 endfor
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
289 if (numpairs < 2)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
290 break;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
291 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
292 endfor
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
293 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
294 else
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
295 match = true (numel (h), 1);
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
296 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
297
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
298 h = h(match);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
299 h = h(:);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21580
diff changeset
300
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
301 endfunction
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
302
17238
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
303
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
304 %!test
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
305 %! hf = figure ("visible", "off");
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
306 %! unwind_protect
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
307 %! 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
308 %! assert (isempty (h));
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
309 %! unwind_protect_cleanup
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
310 %! close (hf);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
311 %! end_unwind_protect
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
312
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
313 %!test
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
314 %! hf = figure ("visible", "off");
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
315 %! 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
316 %! 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
317 %! set (h, "tag", "foobar");
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
318 %! 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
319 %! assert (g, h);
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
320 %! unwind_protect_cleanup
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
321 %! close (hf);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
322 %! 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
323
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
324 %!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
325 %! 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
326 %! unwind_protect
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
327 %! l = line;
13111
ebb42fb2da04 Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
328 %! obj = findobj (hf, "type", "line");
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
329 %! assert (l, obj);
13111
ebb42fb2da04 Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
330 %! 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
331 %! 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
332 %! assert (isempty (findobj (hf, "type", "xyzxyz")));
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
333 %! unwind_protect_cleanup
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
334 %! close (hf);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
335 %! 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
336
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
337 %!test
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
338 %! hf = figure ("visible", "off");
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
339 %! 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
340 %! 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
341 %! 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
342 %! 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
343 %! surf (peaks);
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
344 %! 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
345 %! contour (peaks);
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
346 %! 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
347 %! plot (peaks);
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
348 %! 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
349 %! 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
350 %! "-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
351 %! "-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
352 %! assert (h2, h1);
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
353 %! unwind_protect_cleanup
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
354 %! close (hf);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
355 %! end_unwind_protect
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
356
16895
b8c37a855074 Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents: 16673
diff changeset
357 %!test
17119
bd50e0660545 test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents: 17107
diff changeset
358 %! 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
359 %! 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
360 %! 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
361 %! 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
362 %! 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
363 %! 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
364 %! 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
365 %! assert (h, h3);
16897
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
366 %! unwind_protect_cleanup
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
367 %! close (hf);
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
368 %! end_unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
369
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
370 %!test
17119
bd50e0660545 test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents: 17107
diff changeset
371 %! 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
372 %! 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
373 %! 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
374 %! 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
375 %! 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
376 %! 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
377 %! 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
378 %! 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
379 %! unwind_protect_cleanup
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
380 %! close (hf);
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
381 %! end_unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
382
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
383 %!test
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
384 %! hf = figure ("visible", "off");
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
385 %! unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
386 %! 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
387 %! 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
388 %! 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
389 %! 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
390 %! 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
391 %! 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
392 %! 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
393 %! 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
394 %! 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
395 %! "-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
396 %! unwind_protect_cleanup
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
397 %! close (hf);
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
398 %! end_unwind_protect
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
399 %! 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
400
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
401 %!test
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
402 %! hf = figure ("visible", "off");
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
403 %! unwind_protect
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
404 %! ha = axes ();
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
405 %! 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
406 %! 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
407 %! "-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
408 %! "-and", "type", "axes");
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
409 %! unwind_protect_cleanup
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
410 %! close (hf);
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
411 %! end_unwind_protect
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
412 %! assert (h, [hf; ha]);
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
413
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
414 %!test
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
415 %! hf = figure ("visible", "off");
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
416 %! 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
417 %! 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
418 %! 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
419 %! 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
420 %! 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
421 %! 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
422 %! 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
423 %! assert (h, [hf; h4; h2]);
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
424 %! unwind_protect_cleanup
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
425 %! close (hf);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
426 %! 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
427
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
428 %!test
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
429 %! 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
430 %! unwind_protect
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
431 %! 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
432 %! 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
433 %! 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
434 %! 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
435 %! 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
436 %! 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
437 %! 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
438 %! close (hf);
3fd617363762 findobj.m: Return handles in hierarchy order rather than sorted order (bug #39767).
Rik <rik@octave.org>
parents: 17122
diff changeset
439 %! end_unwind_protect