annotate scripts/plot/findobj.m @ 14868:5d3a684236b0

maint: Use Octave coding conventions for cuddling parentheses in scripts directory * lin2mu.m, loadaudio.m, wavread.m, accumarray.m, bicubic.m, celldisp.m, colon.m, cplxpair.m, dblquad.m, divergence.m, genvarname.m, gradient.m, int2str.m, interp1.m, interp1q.m, interp2.m, interpn.m, loadobj.m, nthargout.m, __isequal__.m, __splinen__.m, quadgk.m, quadl.m, quadv.m, rat.m, rot90.m, rotdim.m, saveobj.m, subsindex.m, triplequad.m, delaunay3.m, griddata.m, inpolygon.m, tsearchn.m, voronoi.m, get_first_help_sentence.m, which.m, gray2ind.m, pink.m, dlmwrite.m, strread.m, textread.m, textscan.m, housh.m, ishermitian.m, issymmetric.m, krylov.m, logm.m, null.m, rref.m, compare_versions.m, copyfile.m, dump_prefs.m, edit.m, fileparts.m, getappdata.m, isappdata.m, movefile.m, orderfields.m, parseparams.m, __xzip__.m, rmappdata.m, setappdata.m, swapbytes.m, unpack.m, ver.m, fminbnd.m, fminunc.m, fsolve.m, glpk.m, lsqnonneg.m, qp.m, sqp.m, configure_make.m, copy_files.m, describe.m, get_description.m, get_forge_pkg.m, install.m, installed_packages.m, is_architecture_dependent.m, load_package_dirs.m, print_package_description.m, rebuild.m, repackage.m, save_order.m, shell.m, allchild.m, ancestor.m, area.m, axes.m, axis.m, clabel.m, close.m, colorbar.m, comet.m, comet3.m, contour.m, cylinder.m, ezmesh.m, ezsurf.m, findobj.m, fplot.m, hist.m, isocolors.m, isonormals.m, isosurface.m, isprop.m, legend.m, mesh.m, meshz.m, pareto.m, pcolor.m, peaks.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, print.m, __add_datasource__.m, __add_default_menu__.m, __axes_limits__.m, __bar__.m, __clabel__.m, __contour__.m, __errcomm__.m, __errplot__.m, __ezplot__.m, __file_filter__.m, __fltk_print__.m, __ghostscript__.m, __gnuplot_print__.m, __go_draw_axes__.m, __go_draw_figure__.m, __interp_cube__.m, __marching_cube__.m, __patch__.m, __pie__.m, __plt__.m, __print_parse_opts__.m, __quiver__.m, __scatter__.m, __stem__.m, __tight_eps_bbox__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiputfile_fltk__.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m, scatter.m, semilogy.m, shading.m, slice.m, subplot.m, surface.m, surfl.m, surfnorm.m, text.m, uigetfile.m, uiputfile.m, whitebg.m, deconv.m, mkpp.m, pchip.m, polyaffine.m, polyder.m, polygcd.m, polyout.m, polyval.m, ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, splinefit.m, addpref.m, getpref.m, setpref.m, ismember.m, setxor.m, arch_fit.m, arch_rnd.m, arch_test.m, autoreg_matrix.m, diffpara.m, fftconv.m, filter2.m, hanning.m, hurst.m, periodogram.m, triangle_sw.m, sinc.m, spectral_xdf.m, spencer.m, stft.m, synthesis.m, unwrap.m, yulewalker.m, bicgstab.m, gmres.m, pcg.m, pcr.m, __sprand_impl__.m, speye.m, spfun.m, sprandn.m, spstats.m, svds.m, treelayout.m, treeplot.m, bessel.m, factor.m, legendre.m, perms.m, primes.m, magic.m, toeplitz.m, corr.m, cov.m, mean.m, median.m, mode.m, qqplot.m, quantile.m, ranks.m, zscore.m, logistic_regression_likelihood.m, bartlett_test.m, chisquare_test_homogeneity.m, chisquare_test_independence.m, kolmogorov_smirnov_test.m, run_test.m, u_test.m, wilcoxon_test.m, z_test.m, z_test_2.m, bin2dec.m, dec2base.m, mat2str.m, strcat.m, strchr.m, strjust.m, strtok.m, substr.m, untabify.m, assert.m, demo.m, example.m, fail.m, speed.m, test.m, now.m: Use Octave coding conventions for cuddling parentheses in scripts directory.
author Rik <octave@nomad.inbox5.com>
date Tue, 17 Jul 2012 07:08:39 -0700
parents 86854d032a37
children 092d0a685546
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;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
113
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
114 while (na <= numel (args))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
115 regularexpression(np) = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
116 property(np) = 0;
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7208
diff changeset
117 logicaloperator{np} = "and";
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7151
diff changeset
118 if (ischar (args{na}))
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7208
diff changeset
119 if (strcmpi (args{na}, "-regexp"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
120 if (na + 2 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
121 regularexpression(np) = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
122 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
123 pname{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
124 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
125 pvalue{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
126 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
127 np = np + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
128 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
129 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
130 endif
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7208
diff changeset
131 elseif (strcmpi (args{na}, "-property"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
132 if (na + 1 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
133 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
134 property(np) = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
135 pname{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
136 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
137 pvalue{np} = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
138 np = np + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
139 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
140 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
141 endif
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8265
diff changeset
142 elseif (! strcmp (args{na}(1), "-"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
143 ## Parameter/value pairs.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
144 if (na + 1 <= numel (args))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
145 pname{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
146 na = na + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
147 pvalue{np} = args{na};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
148 na = na + 1;
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14552
diff changeset
149 if (na <= numel (args))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
150 if (ischar (args{na}))
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
151 if (strcmpi (args{na}, "-and"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
152 logicaloperator{np} = "and";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
153 na = na+1;
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
154 elseif (strcmpi (args{na}, "-or"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
155 logicaloperator{np} = "or";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
156 na = na+1;
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
157 elseif (strcmpi (args{na}, "-xor"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
158 logicaloperator{np} = "xor";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
159 na = na+1;
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
160 elseif (strcmpi (args{na}, "-not"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
161 logicaloperator{np} = "not";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
162 na = na+1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
163 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
164 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
165 error ("findobj: properties and options must be strings");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
166 endif
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 logicaloperator{np} = "and";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
169 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
170 np = np + 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
171 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
172 error ("findobj: inconsistent number of arguments");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
173 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
174 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
175 ## This is sloppy ... but works like Matlab.
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
176 if (strcmpi (args{na}, "-not"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
177 h = [];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
178 return
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
179 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
180 na = na + 1;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
181 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
182 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
183 error ("findobj: properties and options must be strings");
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
184 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
185 endwhile
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
186
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
187 numpairs = np - 1;
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
188
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8265
diff changeset
189 ## Load all objects which qualify for being searched.
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
190 idepth = 0;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
191 h = handles;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
192 while (numel (handles) && ! (idepth >= depth))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
193 children = [];
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
194 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
195 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
196 endfor
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
197 handles = children;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
198 h = union (h, children);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
199 idepth = idepth + 1;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
200 endwhile
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
201
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
202 keepers = ones (size (h));
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
203 if (numpairs > 0)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14552
diff changeset
204 for nh = 1 : numel (h)
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
205 p = get (h (nh));
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
206 for np = 1 : numpairs
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
207 fields = fieldnames (p);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
208 fieldindex = find (strcmpi (fields, pname{np}), 1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
209 if (numel (fieldindex))
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
210 pname{np} = fields{fieldindex};
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
211 if (property(np))
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
212 match = 1;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
213 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
214 if (regularexpression(np))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
215 match = regexp (p.(pname{np}), pvalue{np});
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14327
diff changeset
216 if (isempty (match))
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
217 match = 0;
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7017
diff changeset
218 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
219 elseif (numel (p.(pname{np})) == numel (pvalue{np}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
220 if (ischar (pvalue{np}))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
221 match = strcmpi (pvalue{np}, p.(pname{np}));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
222 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
223 match = (pvalue{np} == p.(pname{np}));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
224 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
225 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
226 match = 0;
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
227 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
228 match = all (match);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
229 endif
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7208
diff changeset
230 if (strcmpi (logicaloperator{np}, "not"))
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
231 keepers(nh) = ! keepers(nh) & ! match;
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
232 else
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
233 keepers(nh) = feval (logicaloperator{np}, keepers(nh), match);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
234 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
235 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
236 keepers(nh) = 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9040
diff changeset
237 endif
6935
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
238 endfor
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
239 endfor
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
240 endif
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
241
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
242 h = h (keepers != 0);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
243 h = reshape (h, [numel(h), 1]);
5cd272497aae [project @ 2007-09-30 19:16:49 by dbateman]
dbateman
parents:
diff changeset
244 endfunction
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
245
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13141
diff changeset
246
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
247 %!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
248 %! 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
249 %! unwind_protect
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
250 %! l = line;
13111
ebb42fb2da04 Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
251 %! obj = findobj (hf, "type", "line");
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
252 %! assert (l, obj);
13111
ebb42fb2da04 Various fixes for tests in scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
253 %! 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
254 %! 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
255 %! assert (isempty (findobj (hf, "type", "xyzxyz")));
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
256 %! unwind_protect_cleanup
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
257 %! close (hf);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
258 %! 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
259