Your IP : 216.73.216.48


Current Path : /usr/X11R6/share/ddd-3.3.12/vsllib/
Upload File :
Current File : //usr/X11R6/share/ddd-3.3.12/vsllib/ctree.vsl

// $Id$ 
// Drawing compact trees

// Copyright (C) 1993 Technische Universitaet Braunschweig, Germany.
// Written by Andreas Zeller <zeller@gnu.org>.
// 
// This file is part of DDD.
// 
// DDD 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 3 of the License, or (at your option) any later version.
// 
// DDD 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 DDD -- see the file COPYING.
// If not, see <http://www.gnu.org/licenses/>.
// 
// DDD is the data display debugger.
// For details, see the DDD World-Wide-Web page, 
// `http://www.gnu.org/software/ddd/',
// or send a mail to the DDD developers <ddd@gnu.org>.

#include "tree.vsl"

// Version
ctree_version() = "$Revision$";

// Horizontal tree

hreplaceEven([], _) = [];
hreplaceEven([arg], _) = [arg];
hreplaceEven([arg1, arg2], join) = 
	[arg1, join ^ safe]
	where safe = vspace(arg2 - arg1);
hreplaceEven([arg1, arg2, arg3, argtail...], join) = 
	[arg1, join ^ safe, hreplaceEven([arg3 : argtail], join)...]
	where safe = vspace(arg2 - arg1) ^ vspace(arg2 - arg3);

_hattachEven(_, [], []) = 0;
_hattachEven(_, [_], [_]) = 0;

_hattachEven(sum, [_, son2, sontail...], [new1, new2, newtail...]) =
  (vspace((sum | new1 | (new2 / 2)) - son2 / 2) | (vcenter(new2 ^ 2) & son2)) ^ 
  _hattachEven(sum | new1 | new2, sontail, newtail);

hattachEven(sons, newsons) = _hattachEven(0, sons, newsons);

hctree(root, sons...) = 
	(let newsons = hreplaceEven(sons, join) in
	    vfix(htree(root, newsons...)) 
	  & hattachEven(sons, newsons))
	where join = vcenter(hwhite() | hrule() | hwhite());


// Vertical tree

vreplaceEven([], _) = [];
vreplaceEven([arg], _) = [arg];
vreplaceEven([arg1, arg2], join) = 
	[arg1, join ^ safe]
	where safe = hspace(arg2 - arg1);
vreplaceEven([arg1, arg2, arg3, argtail...], join) = 
	[arg1, join ^ safe, vreplaceEven([arg3 : argtail], join)...]
	where safe = hspace(arg2 - arg1) ^ hspace(arg2 - arg3);

_vattachEven(_, [], []) = 0;
_vattachEven(_, [_], [_]) = 0;

_vattachEven(sum, [_, son2, sontail...], [new1, new2, newtail...]) =
  (hspace((sum & new1 & (new2 / 2)) - son2 / 2) & (hcenter(new2 ^ 2) | son2)) ^ 
  _vattachEven(sum & new1 & new2, sontail, newtail);

vattachEven(sons, newsons) = _vattachEven(0, sons, newsons);

vctree(root, sons...) = 
	(let newsons = vreplaceEven(sons, join) in
	    hfix(vtree(root, newsons...)) 
	  | vattachEven(sons, newsons))
	where join = hcenter(vwhite() & vrule() & vwhite());