Home > atmlab > graphs > children.m

children

PURPOSE ^

CHILDREN Returns the children of all figure objects.

SYNOPSIS ^

function hc = children(h,all_generations)

DESCRIPTION ^

 CHILDREN   Returns the children of all figure objects.

    The function returns the children of all generations, or only the closest
    generation, of a figure or figure objects. To get a handle to all
    objects of a figure, type
       hc = children( gcf );

    The input argument *h* can be a vector of handles. No object in *h*
    can be children (in any generation) of any other object in *h*. If this
    is the case, some handles will be duplicated in *hc*.

    This function returns more handles than the Matlab function *allchild*.
    (I am not totally sure how that function is defined.)

 FORMAT   hc = children(h,all_generations)
        
 OUT   hc                Handle to children.
 IN    h                 Handle to bject(s) for which children shall be 
                         returned.
 OPT   all_generations   If set to 0, only the first generation is returned.
                         Otherwise handles for all generations are returned.
                         Default is 1.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

children.m

SOURCE CODE ^

0001 % CHILDREN   Returns the children of all figure objects.
0002 %
0003 %    The function returns the children of all generations, or only the closest
0004 %    generation, of a figure or figure objects. To get a handle to all
0005 %    objects of a figure, type
0006 %       hc = children( gcf );
0007 %
0008 %    The input argument *h* can be a vector of handles. No object in *h*
0009 %    can be children (in any generation) of any other object in *h*. If this
0010 %    is the case, some handles will be duplicated in *hc*.
0011 %
0012 %    This function returns more handles than the Matlab function *allchild*.
0013 %    (I am not totally sure how that function is defined.)
0014 %
0015 % FORMAT   hc = children(h,all_generations)
0016 %
0017 % OUT   hc                Handle to children.
0018 % IN    h                 Handle to bject(s) for which children shall be
0019 %                         returned.
0020 % OPT   all_generations   If set to 0, only the first generation is returned.
0021 %                         Otherwise handles for all generations are returned.
0022 %                         Default is 1.
0023 
0024 % 2002-12-12   Created by Patrick Eriksson.
0025 
0026 
0027 function hc = children(h,all_generations)
0028 
0029 
0030 %=== Defaults
0031 %
0032 if nargin < 2
0033   all_generations = 1;
0034 end
0035 
0036 
0037 %=== Allocate space for 100 children (if they happen to be more, that is OK)
0038 %
0039 hc = zeros(100,1);
0040 
0041 
0042 %=== Read children of input handles
0043 %
0044 ntot = 0;
0045 %
0046 for ih = 1 : length( h )
0047   %
0048   hl = get( h(ih), 'children' );
0049   n  = length( hl );
0050   %
0051   if n
0052     hc(ntot+(1:n)) = hl;
0053     ntot           = ntot +n;    
0054   end
0055   %
0056 end
0057 
0058 
0059 %=== Remove empty part
0060 %
0061 hc = hc(1:ntot);
0062 
0063 
0064 %=== Read younger generations by recursive call
0065 %
0066 if all_generations
0067   %
0068   hc = [ hc; children( hc, 0 ) ];
0069   %
0070 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005