annotate scripts/plot/findobj.m @ 17119:bd50e0660545

test: Add missing semicolons to suppress output in some plot %!tests. * scripts/plot/allchild.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/legend.m, scripts/plot/uimenu.m: Add missing semicolons to suppress output in some plot %!tests.
author Rik <rik@octave.org>
date Wed, 31 Jul 2013 13:31:01 -0700
parents dbd64c9a16da
children eaab03308c0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
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
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
8 ## your option) any later version.
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
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
13 ## 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
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
17 ## <http://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 -*-
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
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 8506
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
28 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
31 ## @end example
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
32 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
38 ## @code{findobj}.
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
39 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
42 ## to search to @var{d} generations of children, and example is
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
43 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
46 ## @end example
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
47 ##
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
60 ## @seealso{get, set}
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
61 ## @end deftypefn
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
62
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
63 ## Author: Ben Abbott <bpabbott@mac.com>
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
64
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
65 function h = findobj (varargin)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
66
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
67 depth = NaN;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
68 if (nargin == 0)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
69 handles = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
70 n1 = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
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
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
84 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
85 if (n1 <= nargin)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
86 if (ischar (varargin{n1}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
87 if (strcmpi (varargin{n1}, "flat"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
88 depth = 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
89 n1 = n1 + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
90 elseif (strcmpi (varargin{n1}, "-depth"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
91 depth = varargin{n1+1};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
92 n1 = n1 + 2;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
93 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
94 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
95 error ("findobj: properties and options must be strings");
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
96 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
97 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
98 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
99
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
100 if (n1 <= nargin && nargin > 0)
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
101 args = varargin(n1 : nargin);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
102 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
103 args = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
104 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
105
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
106 regularexpression = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
107 property = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
108 logicaloperator = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
109 pname = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
110 pvalue = {};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
111 np = 1;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
112 na = 1;
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
113 operatorprecedence = {"-not", "-and", "-or", "-xor"};
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
114
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
115 while (na <= numel (args))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
116 regularexpression(np) = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
117 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
118 logicaloperator{np} = "and";
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7151
diff changeset
119 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
120 if (strcmpi (args{na}, "-regexp"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
121 if (na + 2 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
122 regularexpression(np) = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
123 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
124 pname{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
125 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
126 pvalue{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
127 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
128 np = np + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
129 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
130 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
131 endif
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7208
diff changeset
132 elseif (strcmpi (args{na}, "-property"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
133 if (na + 1 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
134 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
135 property(np) = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
136 pname{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
137 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
138 pvalue{np} = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
139 np = np + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
140 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
141 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
142 endif
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8265
diff changeset
143 elseif (! strcmp (args{na}(1), "-"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
144 ## Parameter/value pairs.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
145 if (na + 1 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
146 pname{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
147 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
148 pvalue{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
149 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
150 if (na <= numel (args))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
151 if (ischar (args{na}))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
152 if (any (strcmpi (args{na}, operatorprecedence)))
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
153 logicaloperator{np} = args{na}(2:end);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
154 na = na+1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
155 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
156 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
157 error ("findobj: properties and options must be strings");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
158 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
159 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
160 logicaloperator{np} = "and";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
161 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
162 np = np + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
163 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
164 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
165 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
166 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
167 ## 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
168 if (strcmpi (args{na}, "-not"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
169 h = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
170 return
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
171 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
172 na = na + 1;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
173 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
174 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
175 error ("findobj: properties and options must be strings");
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
176 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
177 endwhile
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
178
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
179 numpairs = np - 1;
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
180 if (~ isempty (logicaloperator))
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
181 logicaloperator = shift (logicaloperator, 1);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
182 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
183
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8265
diff changeset
184 ## Load all objects which qualify for being searched.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
185 idepth = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
186 h = handles;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
187 while (numel (handles) && ! (idepth >= depth))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
188 children = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
189 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
190 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
191 endfor
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
192 handles = children;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
193 h = union (h, children);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
194 idepth = idepth + 1;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
195 endwhile
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
196
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
197 if (numpairs > 0)
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
198 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
199 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
200 p = get (h(nh));
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
201 for np = 1 : numpairs
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
202 fields = fieldnames (p);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
203 fieldindex = find (strcmpi (fields, pname{np}), 1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
204 if (numel (fieldindex))
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
205 pname{np} = fields{fieldindex};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
206 if (property(np))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
207 match(nh,np) = true;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
208 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
209 if (regularexpression(np))
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
210 foo = regexp (p.(pname{np}), pvalue{np}, "once");
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
211 if (isempty (foo))
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
212 match(nh,np) = false;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
213 else
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
214 match(nh,np) = foo;
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
215 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
216 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
217 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
218 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
219 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
220 match(nh,np) = (pvalue{np} == p.(pname{np}));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
221 else
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
222 match(nh,np) = isequal (pvalue{np}, p.(pname{np}));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
223 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
224 else
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
225 match(nh,np) = false;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
226 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
227 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
228 else
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
229 match(nh,np) = false;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
230 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
231 endfor
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
232 endfor
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
233
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
234 if (numpairs > 1)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
235 for no = 1 : numel (operatorprecedence)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
236 pairs = find (strcmp (logicaloperator(2:end), ...
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
237 operatorprecedence{no}(2:end)));
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
238 for np = sort (pairs, "descend")
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
239 if (no == 1)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
240 match(:,np+1) = ! match(:,np+1);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
241 logicaloperator(np+1) = {"and"};
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
242 else
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
243 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
244 match(:,np+1));
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
245 logicaloperator(np+1) = [];
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
246 match(:,np+1) = [];
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
247 numpairs = numpairs - 1;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
248 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
249 if (numpairs < 2)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
250 break;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
251 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
252 endfor
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
253 if (numpairs < 2)
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
254 break;
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
255 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
256 endfor
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
257 endif
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
258 else
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
259 match = true (numel (h), 1);
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
260 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
261
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
262 h = h(match);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
263 h = h(:);
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
264 endfunction
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
265
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
266 %!test
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
267 %! hf = figure ("visible", "off");
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
268 %! clf (hf);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
269 %! unwind_protect
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
270 %! h = findobj (gca (), "-property", "foo");
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
271 %! assert (h, zeros (0, 1))
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
272 %! unwind_protect_cleanup
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
273 %! close (hf);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
274 %! end_unwind_protect
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
275
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
276 %!test
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
277 %! hf = figure ("visible", "off");
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
278 %! unwind_protect
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
279 %! h = plot (1:10);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
280 %! set (h, "tag", "foobar")
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
281 %! g = findobj (gcf (), "tag", "foobar", "type", "line", "color", [0 0 1]);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
282 %! assert (g, h)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
283 %! unwind_protect_cleanup
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
284 %! close (hf);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
285 %! 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
286
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
287 %!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
288 %! 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
289 %! unwind_protect
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
290 %! l = line;
13111
ebb42fb2da04 Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
291 %! obj = findobj (hf, "type", "line");
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
292 %! assert (l, obj);
13111
ebb42fb2da04 Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
293 %! 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
294 %! 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
295 %! assert (isempty (findobj (hf, "type", "xyzxyz")));
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
296 %! unwind_protect_cleanup
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
297 %! close (hf);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
298 %! 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
299
16673
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
300 %!test
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
301 %! hf = figure ("visible", "off");
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
302 %! unwind_protect
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
303 %! subplot (2, 2, 1)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
304 %! imagesc (rand (10))
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
305 %! subplot (2, 2, 2)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
306 %! surf (peaks)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
307 %! subplot (2, 2, 3)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
308 %! contour (peaks)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
309 %! subplot (2, 2, 4)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
310 %! plot (peaks)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
311 %! h1 = findobj (gcf (), "-regexp", "Type", "image|surface|hggroup");
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
312 %! h2 = findobj (gcf (), "Type", "image", "-or", "Type", "surface", "-or", "Type", "hggroup");
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
313 %! unwind_protect_cleanup
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
314 %! close (hf);
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
315 %! end_unwind_protect
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
316 %! assert (h2, h1)
092d0a685546 Fix bug # 38885.
Ben Abbott <bpabbott@mac.com>
parents: 14868
diff changeset
317
16895
b8c37a855074 Modify findobj() to work with cells and structures.
Ben Abbott <bpabbott@mac.com>
parents: 16673
diff changeset
318 %!test
17107
dbd64c9a16da Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents: 16905
diff changeset
319 %! toolkit = graphics_toolkit ("gnuplot");
17119
bd50e0660545 test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents: 17107
diff changeset
320 %! 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
321 %! unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
322 %! 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
323 %! 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
324 %! 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
325 %! 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
326 %! userdata = struct ("foo", "bar");
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
327 %! set (h3, "userdata", userdata);
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
328 %! 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
329 %! unwind_protect_cleanup
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
330 %! close (hf);
17107
dbd64c9a16da Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents: 16905
diff changeset
331 %! graphics_toolkit (toolkit);
16897
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
332 %! end_unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
333 %! assert (h, h3)
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
334
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
335 %!test
17107
dbd64c9a16da Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents: 16905
diff changeset
336 %! toolkit = graphics_toolkit ("gnuplot");
17119
bd50e0660545 test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents: 17107
diff changeset
337 %! 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
338 %! unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
339 %! 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
340 %! set (h1, 'tag', '1')
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
341 %! 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
342 %! set (h2, 'tag', '2')
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
343 %! 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
344 %! set (h3, 'tag', '3')
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
345 %! 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
346 %! set (h4, 'tag', '4')
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
347 %! 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
348 %! unwind_protect_cleanup
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
349 %! close (hf);
17107
dbd64c9a16da Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents: 16905
diff changeset
350 %! graphics_toolkit (toolkit);
16897
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
351 %! end_unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
352 %! 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
353
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
354 %!test
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
355 %! hf = figure ("visible", "off");
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
356 %! unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
357 %! 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
358 %! 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
359 %! 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
360 %! 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
361 %! 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
362 %! 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
363 %! 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
364 %! 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
365 %! 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
366 %! 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
367 %! unwind_protect_cleanup
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
368 %! close (hf);
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
369 %! end_unwind_protect
21d5e76891fe Fix typo/bug for "-not" qualifier in findobj(). Add tests.
Ben Abbott <bpabbott@mac.com>
parents: 16895
diff changeset
370 %! 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
371
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
372 %!test
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
373 %! hf = figure ("visible", "off");
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
374 %! unwind_protect
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
375 %! ha = axes ();
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
376 %! plot (1:10);
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
377 %! h = findobj (hf, 'type', 'figure', ...
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
378 %! '-or', 'parent', hf, ...
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
379 %! '-and', 'type', 'axes');
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
380 %! unwind_protect_cleanup
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
381 %! close (hf)
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
382 %! end_unwind_protect
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
383 %! assert (h, [ha; hf])
16900
434a0b29ab12 Add xtest for findobj() for pecedence of logical operations.
Ben Abbott <bpabbott@mac.com>
parents: 16897
diff changeset
384
16905
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
385 %!test
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
386 %! hf = figure ("visible", "off");
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
387 %! set (hf, 'tag', 'foo');
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
388 %! unwind_protect
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
389 %! h1 = subplot (2, 2, 1);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
390 %! set (h1, 'tag', 'foo');
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
391 %! h2 = subplot (2, 2, 2);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
392 %! set (h2, 'tag', 'bar');
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
393 %! h3 = subplot (2, 2, 3);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
394 %! set (h3, 'tag', 'foo');
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
395 %! h4 = subplot (2, 2, 4);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
396 %! set (h4, 'tag', 'bar')
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
397 %! h = findobj (hf, 'type', 'axes', '-xor', ...
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
398 %! 'tag', 'foo');
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
399 %! unwind_protect_cleanup
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
400 %! close (hf);
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
401 %! end_unwind_protect
562301c71bd3 Respect logical operator precedence for findobj()'s inputs.
Ben Abbott <bpabbott@mac.com>
parents: 16900
diff changeset
402 %! assert (h, [h2; h4; hf])