Mercurial > hg > octave-lyh
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 |
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 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6257 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6257 | 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 | 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 | 23 |
24 ## Author: jwe | |
25 | |
7215 | 26 function [h, varargin, narg] = __plt_get_axis_arg__ (caller, varargin) |
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 | 30 if (islogical (caller)) |
31 nogca = caller; | |
32 caller = varargin{1}; | |
33 varargin(1) = []; | |
34 else | |
35 nogca = false; | |
36 endif | |
6257 | 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 | 50 varargin(1) = []; |
6257 | 51 else |
6925 | 52 error ("%s: expecting first argument to be axes handle", caller); |
6257 | 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 | 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 | 70 f = get (0, "currentfigure"); |
7216 | 71 if (isempty (f)) |
72 h = []; | |
73 else | |
7286 | 74 h = get (f, "currentaxes"); |
7216 | 75 endif |
76 if (isempty (h)) | |
77 if (nogca) | |
10549 | 78 h = NaN; |
7216 | 79 else |
10549 | 80 h = gca (); |
7216 | 81 endif |
7215 | 82 endif |
6927 | 83 if (nargin < 2) |
84 varargin = {}; | |
85 endif | |
6257 | 86 endif |
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 | 92 narg = length (varargin); |
93 | |
6257 | 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 |