function sbhndltree(cmd,varargin) 
%SBHNDLTREE Manages the model tree structure.
%
%  SBHNDLTREE creates a new figure or opens the existing one which
%  has been made invisible.
%  SBHNDLTREE(CMD) is used internally for managing callback calls.
%
%  See also

% Initial coding by A. S. Bozin, 5-3-97.
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.7 $ $Date: 2000/06/14 16:08:16 $

   % 
   % Handle input arguments, if any
   % 
   if (nargin == 0)
      cmd = 'create';
   end
   %
   % Action depends on CMD argument
   %
   switch (cmd)
   case 'scroll'
      %
      %
      %
      hFig = get(0,'CurrentFigure');
      ud = get(hFig,'UserData');
      direction = varargin{1};
      switch (direction)
      case 'fb'
	 set(ud.axes,'XLim',ud.xlim+get(ud.sliders(1),'Value'));
      case 'ud'
	 set(ud.axes,'YLim',ud.ylim+get(ud.sliders(2),'Value'));
      otherwise
	 error('sb2sl: sbhndltree called with wrong argument.');
      end
   case 'zoom'
      %
      %
      %
      shh = get(0,'ShowHiddenHandles');
      set(0,'ShowHiddenHandles','on');
      kids = get(0,'Children');
      set(0,'ShowHiddenHandles',shh);
      hFig = findobj(kids,'flat','Tag','hndltreeTag');
      ud = get(hFig,'UserData');
      zoomindex = ud.zoomindex;
      opt = varargin{1};
      switch (opt)
      case 'in'
	 direction = ud.direction(zoomindex);
	 if (direction < 0)
	    nextindex = zoomindex-1;
	 else
	    nextindex = zoomindex+1;
	    ud.direction(nextindex,1) = 1;
	    ud.xzoom(nextindex,:) = 0.75*ud.xzoom(zoomindex,:);
	    ud.yzoom(nextindex,:) = 0.75*ud.yzoom(zoomindex,:);
	 end
      case 'out'
	 direction = ud.direction(zoomindex);
	 if (direction > 0)
	    nextindex = zoomindex-1;
	 else
	    nextindex = zoomindex+1;
	    ud.direction(nextindex,1) = -1;
	    ud.xzoom(nextindex,:) = 1.25*ud.xzoom(zoomindex,:);
	    ud.yzoom(nextindex,:) = 1.25*ud.yzoom(zoomindex,:);
	 end
      case 'fit'
	 nextindex = 0;
	 if (zoomindex)
	    set(ud.glasses,'Enable','off');
	    factor = max((ud.xmax+1)/ud.xlim(2),(ud.ymin-1)/ud.ylim(1));
	    ud.xlim(:) = factor*ud.xlim;
	    ud.ylim(:) = factor*ud.ylim;
	 end
      case 'normal'
	 nextindex = 1;
	 set(ud.glasses,'Enable','on');
      otherwise
      end
      ud.zoomindex = nextindex;
      if (nextindex)
	 ud.xlim = ud.xzoom(nextindex,:);
	 ud.ylim = ud.yzoom(nextindex,:);
      end
      xy = get(ud.sliders,{'Value'});
      xmax = max(ud.xmax-ud.xlim(2)+1,0);
      ymin = min(ud.ymin-ud.ylim(1)-1,0);
      xy(:) = {min(xy{1},xmax);max(xy{2},ymin)};
      set(ud.axes,'XLim',ud.xlim+xy{1},'YLim',ud.ylim+xy{2});
      xmax = max(ud.xmax-ud.xlim(2)+1,0);
      ymin = min(ud.ymin-ud.ylim(1)-1,0);
      propName = {'Min';'Max';'SliderStep';'Visible'};
      propVal = {0,1,[0.1 0.5],'on';-1,0,[0.1 0.5],'on'};
      if (xmax == 0)
	 propVal{1,4} = 'off';
      else
	 propVal{1,2} = xmax;
      end
      if (ymin == 0)
	 propVal{2,4} = 'off';
      else
	 propVal{2,1} = ymin;
      end
      set(ud.sliders,propName,propVal);
      set(hFig,'UserData',ud);
      drawnow;
   case 'plot'
      %
      %
      %
      shh = get(0,'ShowHiddenHandles');
      set(0,'ShowHiddenHandles','on');
      kids = get(0,'Children');
      set(0,'ShowHiddenHandles',shh);
      hFig = findobj(kids,'flat','Tag','hndltreeTag');
      if (isempty(hFig))
	 checkOn = 'off';
      else
	 checkOn = get(hFig,'Visible');
      end
      if strcmp(checkOn,'on')
	 sFig = findobj(kids,'flat','Tag','sb2slTag');
	 ud = get(sFig,'UserData');
	 winpref = ud.winpref;
	 catalog = get(ud.catalog,'UserData');
	 ud = get(hFig,'UserData');		   % Get handles
	 node = size(catalog,1);
	 delete(get(ud.axes,'Children'));
	 if (node)
	    sFig = get(0,'CurrentFigure');
	    set(0,'CurrentFigure',hFig);
	    set(hFig,'Pointer','watch',...
		     'CurrentAxes',ud.axes);
	    ud.xlim = ud.xzoom(1,:);
	    ud.ylim = ud.yzoom(1,:);
	    ud.direction = 0;
	    ud.zoomindex = 1;
	    set(ud.axes,'XLim',ud.xlim,'YLim',ud.ylim);
	    sbhndlmsgs('write','Building model tree structure ...','append');
	    drawnow;
	    [xr,yr] = treedraw(cat(1,catalog,catalog(end)),...
			       node,ud.axes,ud.level,[1 -1],1,-1,winpref.varSize(3));
	    sbhndlmsgs('write',' Done.','newline');
	    drawnow;
	    %
	    % Set slider limits
	    %
	    ud.xmax = xr;
	    ud.ymin = yr;
	    xmax = max(xr-ud.xlim(2)+1,0);
	    ymin = min(yr-ud.ylim(1)-1,0);
	    propName = {'Min';'Max';'Value';'SliderStep';'Visible'};
	    propVal = {0,1,0,[0.1 0.5],'on';-1,0,0,[0.1 0.5],'on'};
	    if (xmax == 0)
	       propVal{1,5} = 'off';
	    else
	       propVal{1,2} = xmax;
	    end
	    if (ymin == 0)
	       propVal{2,5} = 'off';
	    else
	       propVal{2,1} = ymin;
	    end
	    set(ud.sliders,propName,propVal);
	    set(hFig,'UserData',ud,...
		     'Pointer','arrow');
	    set(0,'CurrentFigure',sFig);	   % Restore current figure
	 end
      end
   case 'level'
      %
      %
      %
      hFig = get(0,'CurrentFigure');
      ud = get(hFig,'UserData');
      level = varargin{1};
      if (ud.level ~= level)
	 set(ud.glasses,'Enable','on');
	 set(ud.kids(ud.level),'Checked','off');
	 ud.level = level;
	 set(ud.kids(level),'Checked','on');
	 set(hFig,'UserData',ud);
	 sbhndltree('plot');
      end
   case 'inimenu'
      %
      %
      %
      shh = get(0,'ShowHiddenHandles');
      set(0,'ShowHiddenHandles','on');
      kids = get(0,'Children');
      set(0,'ShowHiddenHandles',shh);
      hFig = findobj(kids,'flat','Tag','sb2slTag');
      ud = get(hFig,'UserData');
      depth = ud.depth;
      hFig = findobj(kids,'flat','Tag','hndltreeTag');
      if (~isempty(hFig))
	 ud = get(hFig,'UserData');
	 level = 1;
	 ud.level = level;
	 ud.depth = depth;
	 if (~isempty(ud.kids))
	    delete(ud.kids);
	 end
	 topMenu = ud.leyer;
	 if (depth <= 1)
	    set(topMenu,'Enable','off');
	    kids = [];
	 else
	    set(topMenu,'Enable','on');
	    kids = zeros(1,depth);
	    for (k = 1:depth)
	       kids(k) = uimenu('Parent',topMenu,...
				'Label',int2str(k),...
				'CallBack',sprintf('sbhndltree(''level'',%d);',k),...
				'Checked','off',...
				'Position',k);
	    end
	    set(kids(level),'Checked','on');
	 end
	 ud.kids = kids;
	 set(hFig,'UserData',ud);
      end
   case 'select'
      %
      %
      %
      node = varargin{1};
      if (node)
	 selType = get(get(0,'CurrentFigure'),'SelectionType');
	 switch (selType)
	 case 'normal'
	    %
	    %
	    %
	    shh = get(0,'ShowHiddenHandles');
	    set(0,'ShowHiddenHandles','on');
	    hFig = findobj(get(0,'Children'),'flat','Tag','sb2slTag');
	    set(0,'ShowHiddenHandles',shh);
	    ud = get(hFig,'UserData');
	    ud.node = node;		   	   % Selected block
	    set(hFig,'UserData',ud);
	    catalog = get(ud.catalog,'UserData');
	    sbkids = cell(size(catalog));
	    [sbkids{:}] = deal(catalog.sbChild);
	    bkkids = cell(size(catalog));
	    [bkkids{:}] = deal(catalog.bkChild);
	    ind = mgetkids(sbkids,bkkids,node);
	    set(ud.catalog,'Value',cat(1,node,ind));
	 case 'alt'
	    %
	    %
	    %
	    sbhndlinfo('show',node);
	 otherwise
	    sbhndlmsgs('write','Unsupported selection type. No action invoked.');
	 end
      else
	 sbhndlmsgs('write','Click acknowledged. No action invoked.');
      end
   case 'delete'
      %
      %
      %
      shh = get(0,'ShowHiddenHandles');
      set(0,'ShowHiddenHandles','on');
      kids = get(0,'Children');
      set(0,'ShowHiddenHandles',shh);
      hFig = findobj(kids,'flat','Tag','sb2slTag');
      if (~isempty(hFig))
	 ud = get(hFig,'UserData');
	 set(ud.toggle(3),'CallBack','sbhndltree(''create'');',...
			  'Checked','off');
	 set(ud.toggle(7),'ClickedCallBack','sbhndltree(''create'');',...
			  'State','off');
      end
   case 'resize'
      %
      % Resize the model tree structure window
      %
      kids = get(0,'Children');
      hFig = findobj(kids,'flat','Tag','hndltreeTag');
      prop = get(hFig,{'UserData';'Position'});
      [ud,rect] = deal(prop{:});
      w = floor(max(0,rect(3)-52)/3)*3;
      h = floor(max(0,rect(4)-52)/3)*3;
      ud.xlim = [0 ud.xlim(1)+w/30];
      ud.ylim = [-h/30 0];
      ud.xzoom = ud.xlim;
      ud.yzoom = ud.ylim;
      ud.direction = 0;
      ud.zoomindex = 1;
      xy = get(ud.sliders,{'Value'});
      xmax = max(ud.xmax-ud.xlim(2)+1,0);
      ymin = min(ud.ymin-ud.ylim(1)-1,0);
      xy(:) = {min(xy{1},xmax);max(xy{2},ymin)};
      set(ud.axes,'Position',[20 32 w h],...
		  'XLim',ud.xlim+xy{1},...
		  'YLim',ud.ylim+xy{2});
      propName = {'Position';'Min';'Max';'Value';'Visible'};
      propVal = {[20 10 w 16],0,xmax,0,'on';...
		 [w+26 32 16 h],ymin,0,0,'on'};
      if (xmax == 0)
	 propVal{1,5} = 'off';
      else
	 propVal(1,[3 4]) = {xmax,xy{1}};
      end
      if (ymin == 0)
	 propVal{2,5} = 'off';
      else
	 propVal(2,[2 4]) = {ymin,xy{2}};
      end
      set(ud.sliders,propName,propVal);
      set(hFig,'UserData',ud);
      drawnow;
   case 'print'
      %
      %
      %
      hFig = get(0,'CurrentFigure');
      cws = warning;			   % Current warning state
      warning('off');
      opt = varargin{1};
      switch (opt)
      case 'hardcopy'
	 printdlg('-crossplatform',hFig);
      case 'printer'
	 filemenufcn(hFig,'FilePrintSetup');
      case 'page'
	 pagesetupdlg(hFig);
      end
      warning(cws);			   % Restore warning state
   case 'close'
      %
      % Close the tree structure window
      %
      kids = get(0,'Children');
      hFig = findobj(kids,'flat','Tag','hndltreeTag');
      % 
      % Just in case somebody has deleted tree structure window
      % 
      if (~isempty(hFig))
	 set(hFig,'Visible','off');
      end
      hFig = findobj(kids,'flat','Tag','sb2slTag');
      ud = get(hFig,'UserData');
      set(ud.toggle(3),'CallBack','sbhndltree(''create'');',...
		       'Checked','off');
      if (get(0,'CallBackObject') == ud.toggle(7))
	 set(ud.toggle(7),'ClickedCallBack','sbhndltree(''create'');');
      else
	 set(ud.toggle(7),'State','off',...
			  'ClickedCallBack','sbhndltree(''create'');');
      end
   case 'create'
      %
      % Open a model tree structure window
      %
      shh = get(0,'ShowHiddenHandles');
      set(0,'ShowHiddenHandles','on');
      kids = get(0,'Children');
      hFig = findobj(kids,'flat','Tag','hndltreeTag');
      set(0,'ShowHiddenHandles',shh);
      if (length(hFig) > 1)
	 % 
	 % Something wrong (there is another figure with the same tag)
	 % 
	 error('sb2sl: sbhndltree detected more than one window.');
      elseif (length(hFig) == 1)
	 % 
	 % Tree structure window already created
	 %
	 sFig = findobj(kids,'flat','Tag','sb2slTag');
	 ud = get(sFig,'UserData');
	 set(ud.toggle(3),'CallBack','sbhndltree(''close'');',...
			  'Checked','on');
	 if (get(0,'CallBackObject') == ud.toggle(7))
	    set(ud.toggle(7),'ClickedCallBack','sbhndltree(''close'');');
	 else
	    set(ud.toggle(7),'State','on',...
			     'ClickedCallBack','sbhndltree(''close'');');
	 end
	 set(hFig,'Visible','on');
      else
	 %
	 % Get preferences
	 %
	 sFig = findobj(kids,'flat','Tag','sb2slTag');
	 ud = get(sFig,'UserData');
	 winpref = ud.winpref;
	 % 
	 % Create a new tree structure window.
	 %
	 bgc = get(0,'DefaultUIControlBackGroundColor');
	 rect = [490 168 412 412];
	 hFig = figure('Units','pixels',...
		       'Position',rect,...
		       'Color',bgc,...
		       'Resize','on',...
		       'Tag','hndltreeTag',...
		       'IntegerHandle','off',...
		       'HandleVisibility','callback',...
		       'MenuBar','none',...
		       'Name','SB2SL: Model Tree Structure',...
		       'NumberTitle','off',...
		       'RendererMode','manual',...
		       'Renderer','painters',...
		       'NextPlot','replacechildren',...
		       'DeleteFcn','sbhndltree(''delete'');',...
		       'ResizeFcn','sbhndltree(''resize'');');
	 %
	 % Create menus
	 %
	 topLabls = {'&File';'&View'};
	 subLabls = {{'Print';'Print Set&up';'Pa&ge Setup';'Close'},...
		     {'Level';'Zoom In';'Zoom Out';'Fit to View';'Normal'}};
	 subAccel = {{'P';'';'';'W'},...
		     {'';'';'';'';''}};
	 subCalls = {{'sbhndltree(''print'',''hardcopy'');';...
		      'sbhndltree(''print'',''printer'');';...
		      'sbhndltree(''print'',''page'');';...
		      'sbhndltree(''close'');'},...
		     {'';...
		      'sbhndltree(''zoom'',''in'');';...
		      'sbhndltree(''zoom'',''out'');';...
		      'sbhndltree(''zoom'',''fit'');';...
		      'sbhndltree(''zoom'',''normal'');'}};
	 m = size(topLabls,1);
	 topHndls = zeros(m,1);
	 subHndls = cell(1,m);
	 for (k = 1:m)
	    topMenu = uimenu('Parent',hFig,...
			     'Label',topLabls{k},...
			     'Position',k);
	    topHndls(k) = topMenu;
	    labls = subLabls{k};
	    accel = subAccel{k};
	    calls = subCalls{k};
	    n = size(labls,1);
	    subMenus = zeros(n,1);
	    for (l = 1:n)
	       subMenus(l) = uimenu('Parent',topMenu,...
				    'Label',labls{l},...
				    'Accelerator',accel{l},...
				    'CallBack',calls{l},...
				    'Position',l);
	    end
	    subHndls{k} = subMenus;
	 end
	 %
	 % Toolbar
	 %
	 hTool = uitoolbar('Parent',hFig,...
			   'HandleVisibility','off',...
			   'Interruptible','on',...
			   'Clipping','on');
	 tptLabls = {'Zoom in';...
		     'Zoom out';...
		     'Fit to view';...
		     'Normal view'};
	 tptIcons = {'zoomIn';...
		     'zoomOut';...
		     'zoomFit';...
		     'zoomOne'};
	 tptCalls = {'sbhndltree(''zoom'',''in'');';...
		     'sbhndltree(''zoom'',''out'');';...
		     'sbhndltree(''zoom'',''fit'');';...
		     'sbhndltree(''zoom'',''normal'');'};
	 m = size(tptLabls,1);
	 tptHndls = zeros(m,1);
	 for (k = 1:m)			   	   % Create the pushtools
	    hPush = uipushtool('Parent',hTool,...
			       'TooltipString',tptLabls{k},...
			       'CData',toolicon(tptIcons{k}),...
			       'ClickedCallback',tptCalls{k},...
			       'Separator','off',...
			       'Interruptible','on',...
			       'Clipping','on',...
			       'Enable','on',...
			       'HandleVisibility','callback');
	    tptHndls(k) = hPush;
	 end
	 % 
	 %  Add sliders
	 %
	 hSliders = zeros(2,1);
	 rect = [20 10 360 16
		 386 32 16 360];
	 calls = {'sbhndltree(''scroll'',''fb'');';'sbhndltree(''scroll'',''ud'');'};
	 for (k=1:2)
	    hSliders(k) = uicontrol('Parent',hFig,...
				    'Style','slider',...
				    'Units','pixels',...
				    'Position',rect(k,:),...
				    'CallBack',calls{k},...
				    'Visible','off',...
				    'Min',0,...
				    'Max',1,...
				    'Value',0);
	 end
	 %
	 % Create a canvas
	 %
	 rect = [20 32 360 360];		   % Canvas position
	 xlim = [0 12];
	 ylim = [-12 0];
	 hAxes = axes('Parent',hFig,...
		      'Units','pixels',...
		      'Position',rect,...
		      'NextPlot','replacechildren',...
		      'Box','on',...
		      'Layer','top',...
		      'Color',[1 1 1],...
		      'DrawMode','fast',...
		      'Clipping','on',...
		      'XDir','normal',...
		      'YDir','normal',...
		      'XLimMode','manual',...
		      'YLimMode','manual',...
		      'XLim',xlim,...
		      'YLim',ylim,...
		      'XTick',[],...
		      'YTick',[],...
		      'XGrid','off',...
		      'YGrid','off',...
		      'XColor',[0 0 0],...
		      'YColor',[0 0 0]);
	 %
	 % Save handles and create the rest of the windows.
	 %
	 ud = struct('level',0,...
		     'depth',0,...
		     'leyer',subHndls{2}(1),...
		     'kids',[],...
		     'axes',hAxes,...
		     'xlim',xlim,...
		     'ylim',ylim,...
		     'xmax',max(xlim),...
		     'ymin',min(ylim),...
		     'glasses',[subHndls{2}(2:3) tptHndls(1:2)],...
		     'direction',0,...
		     'zoomindex',1,...
		     'xzoom',xlim,...
		     'yzoom',ylim,...
		     'sliders',hSliders);
	 set(hFig,'UserData',ud);
	 drawnow;				   % Flush the event queue
	 % 
	 % Install the window driver and check out the tree menu item.
	 % 
	 hFig = findobj(kids,'flat','Tag','sb2slTag');
	 ud = get(hFig,'UserData');
	 set(ud.toggle(3),'CallBack','sbhndltree(''close'');',...
			  'Checked','on');
	 if (get(0,'CallBackObject') == ud.toggle(7))
	    set(ud.toggle(7),'ClickedCallBack','sbhndltree(''close'');');
	 else
	    set(ud.toggle(7),'State','on',...
			     'ClickedCallBack','sbhndltree(''close'');');
	 end
	 sbhndltree('inimenu');
      end
      sbhndltree('plot');			   % Update tree plot
   case 'compile'
      % 
      % Compilation message
      % 
      sbhndlmsgs('write','.','append');	   % Show progress
   otherwise
      error('sb2sl: sbhndltree called with incorrect argument.');
   end 
   return					   % Last card of SBHNDLTREE

function [xr,yr,vskip] = treedraw(tree,node,haxes,level,nodepos,xr,yr,fontsize)
%TREEDRAW Recursive drawing routine called by sbhndltree.
%
%

   x = nodepos(1);				   % Where to draw the current node.
   y = nodepos(2);
   xr = max(xr,x);
   yr = min(yr,y);
   vskip = 2;
   if (level)
      %
      % At non-leaf node, draw/label branches to children.
      %
      xch = 1;
      ych = 0;
      kids = tree(node).sbChild;
      if (~isempty(kids))
	 nch = size(kids,2);
	 for (ch = 1:nch)
	    %
	    % Draw a branch
	    %
	    h = line('Parent',haxes,...
		     'XData',x+[0;xch;xch;2*xch],...
		     'YData',y+[0;0;ych;ych],...
		     'ZData',-ones(4,1),...
		     'LineStyle','-',...
		     'Color',[0 0 0]);
	    newpos = [x+2*xch,y+ych];
	    [xr,yr,dy] = treedraw(tree,kids(ch),haxes,level-1,newpos,xr,yr,fontsize);
	    ych = ych-dy;
	 end
	 vskip = -ych;
      end
      parents = tree(node).bkChild;
      if (~isempty(parents))
	 sibling = tree(node).sibling;
	 npr = size(parents,2);
	 for (pr = 1:npr)
	    kids = parents{pr};
	    if (sibling(pr))
	       %
	       % Draw a branch
	       %
	       h = line('Parent',haxes,...
			'XData',x+[0;xch;xch;2*xch],...
			'YData',y+[0;0;ych;ych],...
			'ZData',-ones(4,1),...
			'LineStyle','-',...
			'Color',[0 0 0]);
	       newpos = [x+2*xch,y+ych];
	       tree(end).name = tree(node).bkName{pr};
	       tree(end).type = -2;
	       tree(end).sbChild = kids;  	   % Overlay the tree entry
	       [xr,yr,dy] = treedraw(tree,size(tree,1),haxes,level-1,newpos,xr,yr,fontsize);
	       ych = ych-dy;
	    else
	       nch = size(kids,2);
	       for (ch = 1:nch)
		  %
		  % Draw a branch
		  %
		  h = line('Parent',haxes,...
			   'XData',x+[0;xch;xch;2*xch],...
			   'YData',y+[0;0;ych;ych],...
			   'ZData',-ones(4,1),...
			   'LineStyle','-',...
			   'Color',[0 0 0]);
		  newpos = [x+2*xch,y+ych];
		  [xr,yr,dy] = treedraw(tree,kids(ch),haxes,level-1,newpos,xr,yr,fontsize);
		  ych = ych-dy;
	       end
	    end
	 end
	 vskip = -ych;
      end
   end
   %
   % Draw the icon
   %
   sbind = node;
   bkind = 0;
   switch (tree(node).type)
      case -2					   % Condional block
	 hicon = treeicon(haxes,'cndblk',x,y);
	 sbind = 0;
      case -1					   % Folder
	 hicon = treeicon(haxes,'folder',x,y);
	 sbind = 0;
      case {0,1}
	 hicon = treeicon(haxes,'supblk',x,y);
      case 33				   	   % State Transition Diagram
	 hicon = treeicon(haxes,'stdblk',x,y);
      case 73				   	   % Data Store
	 hicon = treeicon(haxes,'dstblk',x,y);
      case 129				   	   % Triggered Superblock
	 hicon = treeicon(haxes,'supblk',x,y);
      otherwise				   	   % Procedures
	 hicon = treeicon(haxes,'supblk',x,y);
   end
   set(hicon,'Interruptible','on',...
	     'ButtonDownFcn',sprintf('sbhndltree(''select'',%d,%d);',sbind,bkind));
   %
   % Label the node
   %
   h = text('Parent',haxes,...
	    'Position',[x y-1],...
	    'Color',[0 0 0],...
	    'Clipping','on',...
	    'Interpreter','none',...
	    'FontName','Helvetica',...
	    'FontSize',fontsize,...
	    'Tag','varSmall',...
	    'HitTest','off',...
	    'VerticalAlignment','bottom',...
	    'HorizontalAlignment','center',...
	    'String',tree(node).name);
   return					   % Last card of TREEDRAW
