Home > classes > @history > getNodes_plot.m

getNodes_plot

PURPOSE ^

GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree.

SYNOPSIS ^

function [n,a,nodes] = getNodes_plot(h, n, pn, a, nodes, depth, MAX_DEPTH)

DESCRIPTION ^

 GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: GETNODES_PLOT converts a history object to a nodes structure suitable for
              plotting as a tree.

 REMARK:      This version is equivalent to getNodes with the different that
              this function only return the nodes up to the MAX_DEPTH.

 VERSION:     $Id: getNodes_plot.m,v 1.2 2007/06/22 10:19:57 ingo Exp $

 HISTORY:     14-06-07 M Hewitson
                Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [n,a,nodes] = getNodes_plot(h, n, pn, a, nodes, depth, MAX_DEPTH)
0002 % GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: GETNODES_PLOT converts a history object to a nodes structure suitable for
0007 %              plotting as a tree.
0008 %
0009 % REMARK:      This version is equivalent to getNodes with the different that
0010 %              this function only return the nodes up to the MAX_DEPTH.
0011 %
0012 % VERSION:     $Id: getNodes_plot.m,v 1.2 2007/06/22 10:19:57 ingo Exp $
0013 %
0014 % HISTORY:     14-06-07 M Hewitson
0015 %                Creation
0016 %
0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0018 
0019 % set my node to next number
0020 nn = get(h,'n');
0021 if nn<0
0022   h = set(h, 'n', a);
0023 end
0024 
0025 % set my parent node
0026 nn = get(h,'pn');
0027 if nn<0
0028   h = set(h, 'pn', pn);
0029   n = [n pn];
0030   nodes(a).pn     = pn;
0031   nodes(a).invars = get(h, 'invars');
0032   nodes(a).n      = get(h, 'n');
0033   nodes(a).names  = get(h, 'name');
0034   nodes(a).params = char(get(h, 'plist'));
0035   nodes(a).pl     = get(h, 'plist');
0036 
0037   if depth == MAX_DEPTH+1
0038     nodes(a).names  = '...';
0039     nodes(a).params = '';
0040     nodes(a).invars = {};
0041   end
0042 
0043 end
0044 % disp(['parent node: ' num2str(get(h, 'pn')) ' node: ' num2str(get(h, 'n')) ' depth: ' num2str(depth)]);
0045 
0046 % I need my parent node
0047 pn = get(h, 'n');
0048 
0049 % get my children nodes
0050 ihs = get(h, 'inhists');
0051 
0052 % Now decide what to do with my children
0053 if isa(ihs, 'history')
0054   for i=1:length(ihs)
0055     % get child number
0056     nn = get(ihs(i), 'n');
0057     % if this child is not set
0058     if nn < 0
0059       if depth <= MAX_DEPTH
0060 
0061         depth = depth + 1;
0062 
0063         % set it
0064         a = a + 1;
0065         [n,a, nodes] = getNodes_plot(ihs(i), n, pn, a, nodes, depth, MAX_DEPTH);
0066 
0067       end
0068     else % else go back to my parent
0069       asd
0070       [n,a, nodes] = getNodes_plot(h, n, get(h,'pn'), a, nodes, depth, MAX_DEPTH);
0071     end
0072     depth = depth - 1;
0073   end
0074 
0075 end
0076

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003