Mercurial > hg > octave-lyh
annotate scripts/plot/__plt_get_axis_arg__.m @ 17535:c12c688a35ed default tip lyh
Fix warnings
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Fri, 27 Sep 2013 17:43:27 +0800 |
parents | b5d6314314fc |
children |
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 |
17129
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
31 |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
32 ## 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
|
33 ## Root Figure (0) or an ordinary figure (integer). |
17129
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
34 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
|
35 && 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
|
36 htmp = varargin{1}; |
17129
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
37 if (! isaxes (htmp)) |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
38 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
|
39 endif |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
40 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
|
41 h = htmp; |
6925 | 42 varargin(1) = []; |
6257 | 43 endif |
17129
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
44 ## 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
|
45 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
|
46 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
|
47 htmp = varargin{parent+1}; |
17129
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17036
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 else |
17025
75d115e329b7
__plt_get_axis_arg__.m: Correctly handle 'parent' property when parent is hggroup.
Rik <rik@octave.org>
parents:
17015
diff
changeset
|
52 ## '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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 |
7215 | 60 narg = length (varargin); |
61 | |
6257 | 62 endfunction |
13044
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 |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
65 ## 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
|
66 %!assert (1) |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
67 |