octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with __plt_get_axis_arg__.m


From: David Bateman
Subject: Re: Problem with __plt_get_axis_arg__.m
Date: Sun, 02 Dec 2007 17:27:07 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Michael Goffioul wrote:
> On 12/1/07, David Bateman <address@hidden> wrote:
>> I tried to copy the hggroup code you had in one of the other functions
>> to __get_plt_axis__ so I'd say as JHandles is the only thing with
>> hggroups at the moment, change it how you need it to be changed..
> 
> IIRC, I used the "ancestor" call, because the next statement was
> something like "axes(h)", so I needed an axes object. I think that
> __plt_get_axis_arg__ should not call ancestor, otherwise you screw
> up the actual parent given as argument if it's not an axes object.

Huh? Doesn't ancestor just call h = get(h,"Parent") till get(h,"Type")
is "axes"? Why should that screw up the parent object? IT shouldn't
alter it...

> OTOH, functions that make use of the returned handle, should be
> aware that it might not be an axes object. I see 2 possible ways to
> deal with that:
> 1) use an additional output to __plt_get_axis_arg__ for the actual
> axes object, so any function that needs an axes object can get
> access to it

This is what I previously did with a NaN handle returned and no call to
gca() to prevent a figure window appearing for calls like "[x,y,z] =
sphere(20)". How I solved this was that if the leading argument to
__plt_get_axis__ is a logical value then it sets the value nogca. If the
nogca variable is logically true don't call gca, and let the parent
function deal with it..

In fact what you seem to be saying is the same issue, and the nogca flag
 should be expanded to also protect the call to ancestor.. What about
something like the attached patch in that case.


> 2) make "axes" function to call "ancestor" if the given handle is not
> an axes object

This is not compatible and will likely cause other issues.


D.
Index: scripts/plot/__plt_get_axis_arg__.m
===================================================================
RCS file: /usr/local/cvsroot/octave/scripts/plot/__plt_get_axis_arg__.m,v
retrieving revision 1.9
diff -c -r1.9 __plt_get_axis_arg__.m
*** scripts/plot/__plt_get_axis_arg__.m 29 Nov 2007 19:07:29 -0000      1.9
--- scripts/plot/__plt_get_axis_arg__.m 2 Dec 2007 16:24:48 -0000
***************
*** 23,47 ****
  function [h, varargin, narg] = __plt_get_axis_arg__ (caller, varargin)
  
    if (islogical (caller))
!     nogca = caller;
      caller = varargin{1};
      varargin(1) = [];
    else
!     nogca = false;
    endif
  
    if (nargin > 1 && length (varargin) > 0 && ishandle (varargin{1}))
      tmp = varargin{1};
      obj = get (tmp);
!     if (strcmp (obj.type, "axes") || strcmp (obj.type, "hggroup"))
!       h = ancestor (tmp, "axes");
!       varargin(1) = [];
!       if (isempty (varargin))
!       varargin = {};
        endif
      else
        error ("%s: expecting first argument to be axes handle", caller);
      endif
    else
      f = get (0, "currentfigure");
      if (isempty (f))
--- 23,53 ----
  function [h, varargin, narg] = __plt_get_axis_arg__ (caller, varargin)
  
    if (islogical (caller))
!     nogcaancestor = caller;
      caller = varargin{1};
      varargin(1) = [];
    else
!     nogcaancestor = false;
    endif
  
    if (nargin > 1 && length (varargin) > 0 && ishandle (varargin{1}))
      tmp = varargin{1};
      obj = get (tmp);
!     if (strcmp (obj.type, "axes"))
!       h = tmp;
!     elseif (strcmp (obj.type, "hggroup"))
!       if (nogcaancestor)
!       h = NaN;
!       else
!       h = ancestor (tmp, "axes");
        endif
      else
        error ("%s: expecting first argument to be axes handle", caller);
      endif
+     varargin(1) = [];
+     if (isempty (varargin))
+       varargin = {};
+     endif
    else
      f = get (0, "currentfigure");
      if (isempty (f))
***************
*** 50,56 ****
        h = get (f, 'currentaxes');
      endif
      if (isempty (h))
!       if (nogca)
        h = NaN;
        else
        h = gca ();
--- 56,62 ----
        h = get (f, 'currentaxes');
      endif
      if (isempty (h))
!       if (nogcaancsetor)
        h = NaN;
        else
        h = gca ();
2007-12-02  David Bateman  <address@hidden>

        * plot/__plt_get_axis__.m: Expand nogca flag to also prevent calls
        to ancestor.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]