Mercurial > hg > octave-nkf
annotate scripts/plot/util/__plt_get_axis_arg__.m @ 17720:1ab8e21d9cfc
Further corrections to parenting of axes (bug #39813)
* scripts/plot/util/newplot.m: Accept multiple graphic handles to save.
Also save handles when axis nextplot property is "replacechildren".
Correct failing %!test.
* scripts/plot/util/__plt_get_axis_arg__.m: Return axis as first value,
"parent" handle as second value.
* scripts/plot/draw/surface.m: Get axis from __plt_get_axis_arg__ and ignore
any other returned handles.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 21 Oct 2013 22:25:15 -0700 |
parents | ed9a21a90221 |
children | d63878346099 |
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 | |
17036
08dd9458684a
Overhaul __plt_get_axis_arg__ and newplot functions to avoid creating unnecessary axes.
Rik <rik@octave.org>
parents:
17025
diff
changeset
|
28 h = []; |
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
|
29 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
|
30 |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
31 ## Look for a scalar which is a graphics handle but not the |
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
|
32 ## Root Figure (0) or an ordinary figure (integer). |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
33 if (numel (varargin) > 0 && numel (varargin{1}) == 1 |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
34 && ishandle (varargin{1}) && varargin{1} != 0 && ! isfigure (varargin{1})) |
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
|
35 htmp = varargin{1}; |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
36 if (! isaxes (htmp)) |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
37 error ("%s: expecting first argument to be axes handle", caller); |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
38 endif |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
39 if (! strcmp (get (htmp, "tag"), "legend")) |
17025
75d115e329b7
__plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents:
17015
diff
changeset
|
40 h = htmp; |
6925 | 41 varargin(1) = []; |
6257 | 42 endif |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
43 ## Look for "parent"/axis prop/value pair |
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
|
44 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
|
45 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
|
46 htmp = varargin{parent+1}; |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
47 if (isaxes (htmp) && ! strcmp (get (htmp, "tag"), "legend")) |
17025
75d115e329b7
__plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents:
17015
diff
changeset
|
48 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
|
49 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
|
50 else |
17025
75d115e329b7
__plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents:
17015
diff
changeset
|
51 ## 'parent' property for some other type like hggroup |
17720
1ab8e21d9cfc
Further corrections to parenting of axes (bug #39813)
Rik <rik@octave.org>
parents:
17719
diff
changeset
|
52 h = [ancestor(htmp, "axes"), htmp]; |
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
|
53 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
|
54 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
|
55 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
|
56 endif |
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
|
57 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
|
58 |
7215 | 59 narg = length (varargin); |
60 | |
6257 | 61 endfunction |
13044
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
62 |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
63 |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
64 ## 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
|
65 %!assert (1) |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
66 |