annotate scripts/plot/__plt_get_axis_arg__.m @ 17025:75d115e329b7

__plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup. * scripts/plot/__plt_get_axis_arg__.m: Don't delete 'parent'/value pair if it represents an hggroup. Downstream plot function will use this property.
author Rik <rik@octave.org>
date Sat, 20 Jul 2013 18:42:25 -0700
parents 761d2be77e78
children 08dd9458684a
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: 13929
diff changeset
1 ## Copyright (C) 1996-2012 John W. Eaton
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
2 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
4 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6927
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: 6927
diff changeset
8 ## your option) any later version.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
9 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
14 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
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: 6927
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: 6927
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8236
diff changeset
19 ## -*- texinfo -*-
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8236
diff changeset
20 ## @deftypefn {Function File} {[@var{h}, @var{varargin}, @var{narg}] =} __plt_get_axis_arg__ (@var{caller}, @var{varargin})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6257
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8236
diff changeset
22 ## @end deftypefn
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
23
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
24 ## Author: jwe
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
25
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
26 function [h, varargin, narg] = __plt_get_axis_arg__ (caller, varargin)
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
27
17015
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
28 ## First argument can be a boolean which determines whether a new
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
29 ## axis will be created if none exists.
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
30 if (islogical (caller))
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
31 nogca = caller;
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
32 caller = varargin{1};
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
33 varargin(1) = [];
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
34 else
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
35 nogca = false;
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
36 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
37
17013
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
38 ## Search for parent property
17015
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
39 parent = find (strcmpi (varargin, "parent"), 1);
17013
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
40
17015
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
41 ## Look for numeric scalar which is a graphics handle but not the
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
42 ## Root Figure (0) or an ordinary figure (integer).
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
43 if (numel (varargin) > 0 && isnumeric (varargin{1})
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
44 && isscalar (varargin{1}) && ishandle (varargin{1})
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
45 && varargin{1} != 0 && ! isfigure (varargin{1}))
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
46 htmp = varargin{1};
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
47 obj = get (htmp);
17025
75d115e329b7 __plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents: 17015
diff changeset
48 if (strcmp (obj.type, "axes") && ! strcmp (obj.tag, "legend"))
75d115e329b7 __plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents: 17015
diff changeset
49 h = htmp;
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6895
diff changeset
50 varargin(1) = [];
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
51 else
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6895
diff changeset
52 error ("%s: expecting first argument to be axes handle", caller);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
53 endif
17015
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
54 elseif (numel (varargin) > 1 && ! isempty (parent))
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
55 if (parent < numel (varargin) && ishandle (varargin{parent+1}))
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
56 htmp = varargin{parent+1};
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
57 obj = get (htmp);
17025
75d115e329b7 __plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents: 17015
diff changeset
58 if (strcmp (obj.type, "axes") && ! strcmp (obj.tag, "legend"))
75d115e329b7 __plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents: 17015
diff changeset
59 h = htmp;
17015
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
60 varargin(parent:parent+1) = [];
17013
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
61 else
17025
75d115e329b7 __plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents: 17015
diff changeset
62 ## 'parent' property for some other type like hggroup
75d115e329b7 __plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents: 17015
diff changeset
63 h = ancestor (htmp, "axes");
17013
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
64 endif
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
65 else
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
66 error ("%s: expecting parent value to be axes handle", caller);
64d603f8bcd9 __get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 14363
diff changeset
67 endif
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6895
diff changeset
68 else
17015
761d2be77e78 __plt_get_axis_arg__.m: Simplify code for finding parent in axis PROP/VAL pairs.
Rik <rik@octave.org>
parents: 17013
diff changeset
69 ## No axis specified. Use current axis or create one as necessary.
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
70 f = get (0, "currentfigure");
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
71 if (isempty (f))
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
72 h = [];
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
73 else
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7216
diff changeset
74 h = get (f, "currentaxes");
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
75 endif
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
76 if (isempty (h))
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
77 if (nogca)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10510
diff changeset
78 h = NaN;
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
79 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10510
diff changeset
80 h = gca ();
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
81 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
82 endif
6927
cf07aa5666cb [project @ 2007-09-26 20:10:01 by dbateman]
dbateman
parents: 6925
diff changeset
83 if (nargin < 2)
cf07aa5666cb [project @ 2007-09-26 20:10:01 by dbateman]
dbateman
parents: 6925
diff changeset
84 varargin = {};
cf07aa5666cb [project @ 2007-09-26 20:10:01 by dbateman]
dbateman
parents: 6925
diff changeset
85 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
86 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
87
10510
62ebba45054e Respect the nextplot property value of 'new' for axes and 'replacechildren' for axes and figures.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
88 if (ishandle (h) && strcmp (get (h, "nextplot"), "new"))
62ebba45054e Respect the nextplot property value of 'new' for axes and 'replacechildren' for axes and figures.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
89 h = axes ();
62ebba45054e Respect the nextplot property value of 'new' for axes and 'replacechildren' for axes and figures.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
90 endif
62ebba45054e Respect the nextplot property value of 'new' for axes and 'replacechildren' for axes and figures.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
91
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
92 narg = length (varargin);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
93
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
94 endfunction
13044
a04e32272ecb codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
95
a04e32272ecb codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
96
a04e32272ecb codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
97 ## No test needed for internal helper function.
a04e32272ecb codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
98 %!assert (1)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
99