octave-maintainers
[Top][All Lists]
Advanced

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

Re: Patch proposal for axes.m


From: David Bateman
Subject: Re: Patch proposal for axes.m
Date: Wed, 29 Aug 2007 16:48:19 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

You'll need a help string for ancestor.. If you need help turning into
texinfo, I could convert it if you send me the text..

D.

Michael Goffioul wrote:
> The following changes allow to specify a parent when creating axes object,
> which might not necessarily be a figure object (uipanel and uibuttongroup
> objects can also contain axes objects). This relies on the ancestor.m
> function, which is currently part of JHandles.
>
> Michael.
>
> 2007-08-29  Michael goffioul <address@hidden>
>
>     * plot/axes.m: allow to specify a parent when creating axes objects;
>     also support non-figure parents
>
>     * plot/ancestor.m: new function
>
>
> Index: ../../../octave-cvs/scripts/plot/axes.m
> ===================================================================
> RCS file: /cvs/octave/scripts/plot/axes.m,v
> retrieving revision 1.4
> diff -c -p -r1.4 axes.m
> *** ../../../octave-cvs/scripts/plot/axes.m     4 Jun 2007 06:25:21
> -0000       1.4
> --- ../../../octave-cvs/scripts/plot/axes.m     29 Aug 2007 14:15:21 -0000
> *************** function h = axes (varargin)
> *** 31,45 ****
>     if (nargin == 0 || nargin > 1)
>       ## make default axes object, and make it the current axes for the
>       ## current figure.
> !     cf = gcf ();
>       tmp = __go_axes__ (cf, varargin{:});
> !     set (cf, "currentaxes", tmp);
>     else
>       ## arg is axes handle, make it the current axes for the current
>       ## figure.
>       tmp = varargin{1};
>       if (ishandle (tmp) && strcmp (get (tmp, "type"), "axes"))
> !       parent = get (tmp, "parent");
>         set (0, "currentfigure", parent);
>         set (parent, "currentaxes", tmp);
>       else
> --- 31,51 ----
>     if (nargin == 0 || nargin > 1)
>       ## make default axes object, and make it the current axes for the
>       ## current figure.
> !     idx = find (strcmpi (varargin(1:2:end), "parent"), 1, "first");
> !     if (! isempty (idx) && length (varargin) >= 2*idx)
> !       cf = varargin{2*idx};
> !       varargin([2*idx-1, 2*idx]) = [];
> !     else
> !       cf = gcf ();
> !     endif
>       tmp = __go_axes__ (cf, varargin{:});
> !     set (ancestor (cf, "figure"), "currentaxes", tmp);
>     else
>       ## arg is axes handle, make it the current axes for the current
>       ## figure.
>       tmp = varargin{1};
>       if (ishandle (tmp) && strcmp (get (tmp, "type"), "axes"))
> !       parent = ancestor (tmp, "figure");
>         set (0, "currentfigure", parent);
>         set (parent, "currentaxes", tmp);
>       else
>   
> ------------------------------------------------------------------------
>
> ## Copyright (C) 2007 Michael Goffioul
> ##
> ## This program is free software; you can redistribute it and/or modify
> ## it under the terms of the GNU General Public License as published by
> ## the Free Software Foundation; either version 2 of the License, or
> ## (at your option) any later version.
> ##
> ## This program is distributed in the hope that it will be useful,
> ## but WITHOUT ANY WARRANTY; without even the implied warranty of
> ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ## GNU General Public License for more details.
> ##
> ## You should have received a copy of the GNU General Public License
> ## along with this program; if not, write to the Free Software
> ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> ## 02110-1301  USA
>
> function [ p ] = ancestor (h, type, toplevel)
>
>   if (nargin == 2 || nargin == 3)
>     p = [];
>     if (ischar (type))
>       type = { type };
>     endif
>     if (iscellstr (type))
>       look_first = true;
>       if (nargin == 3)
>         if (ischar (toplevel) && strcmp (toplevel, "toplevel"))
>           look_first = false;
>         else
>           error ("3rd argument must be `toplevel'");
>         endif
>       endif
>       while (true)
>         if (isempty (h) || ! ishandle (h))
>           break
>         endif
>         if (any (strcmpi (get (h, "type"), type)))
>           p = h;
>           if (look_first)
>             break
>           endif
>         endif
>               h = get (h, "Parent");
>       endwhile
>     else
>       error ("`type' argument must be a string or cell array of strings");
>     endif
>   else
>     print_usage ();
>   endif
>
> endfunction
>   


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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