]> Creatis software - CreaPhase.git/blob - octave_packages/m/plot/__plt_get_axis_arg__.m
update packages
[CreaPhase.git] / octave_packages / m / plot / __plt_get_axis_arg__.m
1 ## Copyright (C) 1996-2012 John W. Eaton
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
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
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {[@var{h}, @var{varargin}, @var{narg}] =} __plt_get_axis_arg__ (@var{caller}, @var{varargin})
21 ## Undocumented internal function.
22 ## @end deftypefn
23
24 ## Author: jwe
25
26 function [h, varargin, narg] = __plt_get_axis_arg__ (caller, varargin)
27
28   if (islogical (caller))
29     nogca = caller;
30     caller = varargin{1};
31     varargin(1) = [];
32   else
33     nogca = false;
34   endif
35
36   ## Figure handles are integers, but object handles are non-integer,
37   ## therefore ignore integer scalars.
38   if (nargin > 1 && length (varargin) > 0 && isnumeric (varargin{1})
39       && numel (varargin{1}) == 1 && ishandle (varargin{1}(1))
40       && varargin{1}(1) != 0 && ! isfigure (varargin{1}(1)))
41     tmp = varargin{1};
42     obj = get (tmp);
43     if ((strcmp (obj.type, "axes") && ! strcmp (obj.tag, "legend"))
44         || strcmp (obj.type, "hggroup"))
45       h = ancestor (tmp, "axes");
46       varargin(1) = [];
47       if (isempty (varargin))
48         varargin = {};
49       endif
50     else
51       error ("%s: expecting first argument to be axes handle", caller);
52     endif
53   else
54     f = get (0, "currentfigure");
55     if (isempty (f))
56       h = [];
57     else
58       h = get (f, "currentaxes");
59     endif
60     if (isempty (h))
61       if (nogca)
62         h = NaN;
63       else
64         h = gca ();
65       endif
66     endif
67     if (nargin < 2)
68       varargin = {};
69     endif
70   endif
71
72   if (ishandle (h) && strcmp (get (h, "nextplot"), "new"))
73     h = axes ();
74   endif
75
76   narg = length (varargin);
77
78 endfunction
79
80
81 ## No test needed for internal helper function.
82 %!assert (1)