Home > classes > @history > getNodes.m

getNodes

PURPOSE ^

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

SYNOPSIS ^

function varargout = getNodes(varargin)

DESCRIPTION ^

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

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

 CALL:        [n,a, nodes] = getNodes(hist, [], 0, 1, []);

 OUTPUT:      n:     A vector of parent pointers
              a:     Number of nodes
              nodes: Struct of the nodes

 M-FILE INFO: Get information about this methods by calling
              >> history.getInfo('getNodes')

              Get information about a specified set-plist by calling:
              >> history.getInfo('getNodes', 'set')

 VERSION:     $Id: getNodes.m,v 1.19 2008/09/04 15:29:30 ingo Exp $

 HISTORY:     02-02-2007 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % GETNODES converts a history object to a nodes structure suitable for plotting as a tree.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: GETNODES converts a history object to a nodes structure suitable
0005 %              for plotting as a tree.
0006 %
0007 % CALL:        [n,a, nodes] = getNodes(hist, [], 0, 1, []);
0008 %
0009 % OUTPUT:      n:     A vector of parent pointers
0010 %              a:     Number of nodes
0011 %              nodes: Struct of the nodes
0012 %
0013 % M-FILE INFO: Get information about this methods by calling
0014 %              >> history.getInfo('getNodes')
0015 %
0016 %              Get information about a specified set-plist by calling:
0017 %              >> history.getInfo('getNodes', 'set')
0018 %
0019 % VERSION:     $Id: getNodes.m,v 1.19 2008/09/04 15:29:30 ingo Exp $
0020 %
0021 % HISTORY:     02-02-2007 M Hewitson
0022 %                 Creation
0023 %
0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0025 
0026 function varargout = getNodes(varargin)
0027 
0028   import utils.const.*
0029   
0030   %%% Check if this is a call for parameters
0031   if utils.helper.isinfocall(varargin{:})
0032     varargout{1} = getInfo(varargin{3});
0033     return
0034   end
0035 
0036   %%% Set inputs
0037   h     = varargin{1};
0038   n     = varargin{2}; % list of current node values
0039   pn    = varargin{3}; % current node value
0040   a     = varargin{4}; % number of nodes
0041   nodes = varargin{5};
0042 
0043   n = [n pn];
0044   pl = h.plistUsed;
0045   nodes(a).pn     = pn;
0046   nodes(a).invars = h.methodInvars;
0047   nodes(a).n      = a;
0048   nodes(a).names  = h.methodInfo.mname;
0049   nodes(a).params = char(pl);
0050   nodes(a).pl     = pl;
0051   nodes(a).h      = history(h);
0052   utils.helper.msg(msg.OPROC1, 'scanning node %03d [%s]', a, char(nodes(a).names));
0053 
0054   % set the current node value to the number of the child
0055   pn = a-1;
0056 
0057   ih  = h.inhists;
0058 
0059   % Now decide what to do with my children
0060   if isa(ih, 'history')
0061     for i=1:length(ih)
0062       a = a + 1;
0063 
0064       [n, a, nodes] = getNodes(ih(i), n, pn+1, a, nodes);
0065 
0066     end
0067   end
0068 
0069   % Set outputs
0070   varargout{1} = n;
0071   varargout{2} = a;
0072   varargout{3} = nodes;
0073 end
0074 
0075 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0076 %                               Local Functions                               %
0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078 
0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080 %
0081 % FUNCTION:    getInfo
0082 %
0083 % DESCRIPTION: Get Info Object
0084 %
0085 % HISTORY:     11-07-07 M Hewitson
0086 %                Creation.
0087 %
0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0089 
0090 function ii = getInfo(varargin)
0091   if nargin == 1 && strcmpi(varargin{1}, 'None')
0092     sets = {};
0093     pl   = [];
0094   else
0095     sets = {'Default'};
0096     pl   = getDefaultPlist;
0097   end
0098   % Build info object
0099   ii = minfo(mfilename, 'history', '', utils.const.categories.internal, '$Id: getNodes.m,v 1.19 2008/09/04 15:29:30 ingo Exp $', sets, pl);
0100 end
0101 
0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0103 %
0104 % FUNCTION:    getDefaultPlist
0105 %
0106 % DESCRIPTION: Get Default Plist
0107 %
0108 % HISTORY:     11-07-07 M Hewitson
0109 %                Creation.
0110 %
0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0112 
0113 function plo = getDefaultPlist()
0114   plo = plist();
0115 end
0116

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003