#!/bin/sh
# next line is a comment in tcl \
exec tclsh "$0" ${1+"$@"}
package require Tcldgr
package require Tcldgl
Requires the dynamic loading facilities of tcl7.6 or later. Does not require tk, but the layout facilities are typically used to drive a tk display.
Tcldgl is a tcl dynamically loaded extension that uses the incremental graph layout capabilities of libincr(3) . Typically it is expected to be used in conjunction with Tcldgr (and libgraph(3) ) which provide for maniplutation of graph structures.
This program is a significant evolution from its tcldot heritage. The major differences are the addition of "bindings" to graph and layout events to support incremental graphs. The various built in renderers that were available in tcldot are no longer provided. Instead the script writer is expected to use the facilities of Tk. An example graph editor, dge, is provided in the distribution which provides an example of the use of Tk as a renderer.
Tcldgl uses Tcl (Tool Command Language). Tcl provides control flow (e.g., if, for, break), expression evaluation and several other features such as recursion, procedure definition, etc. Commands used here but not defined (e.g., set, if, exec) are Tcl commands (see Tcl(n) ). Tcldgl supports several additional commands, described below. Nearly all Tcldgl commands return a value, usually the handle of a layout (graph), node, or edge. The handles are themselves registered as commands to permit direct operations on the objects after they have been created. Tcldgl initially adds only one user commands to the tcl interpreter at start up, namely dglayout.
All other "commands" are of the form: handle command parameters" where the handle refers to an existing layout.
The commands are described in detail below, but in summary:
creates a new layout and returns its layoutHandle.
switch can be any of the following:
-engine (enum) (default geograph)
The possible engines are:
-orientation (int) (default 0)
-resolution (float) (default 1.0)
-xseparation (float) (default 10.0)
-yseparation (float) (default 40.0)
-ticks (float) (default 1.0)
dynadag provides a strict-digraph layout with
The possible orientations are:
automatic node repositioning and spline
curves used for edges.
geograph leaves the nodes as placed and draws
"as-the-crow-flies" edges between them.
orthogrid leaves the nodes as placed and routes
the edges in a "Manhattan" grid style.
0 top to bottom
1 left to right
2 bottom to top
3 right to left
When set, batches up all events in a buffer until cleared. Initially batch is cleared so that events immediately invoke any scripts that have been attached with "bind".
attaches a script to be executed whenever a specified even occurs.
layoutEvent can be any one of:
insert_node %l %n %P
Where the substitutions are:
%l the layout handle
insert_edge %l %e %t %h %P
modify_node %l %n %P
modify_edge %l %e %P
delete_node %l %n
delete_edge %l %e
%n the node handle
%t the tail_node handle
%e the edge handle
%h the head_node handle
%P the coordinates of an edge for insert_edge/modify_edge
or the center position of a node for insert_node/modify_node
Set the default node and edge shapes in a layout. Can be changed at anytime but only affects the shape of nodes or edges created afterwards.
The possible shape switches are described in SHAPES.
Delete all data structures associated with the layout from the internal storage of the interpreter. This command returns a null string.
Delete a node or edge from a layout. The nodes existance in the underlying graph is unaffected by this operation.
Execution of node or edge delete from a layout will have the side effect of also executing any scripts that have been attached to the delete_node, or delete_edge, events by the bind command on the layout.
For nodes returns: x y shape {coordinates} {nodedistances}
for edges returns: shape {coordinates} {edgedistances}
If the node or edge handle is ommitted then the command returns the values of the default node or edge.
Insert a node or edge into a layout.
The possible shape switches are described in SHAPES.
Execution of insert_node, will have the side effect of also executing any scripts that have been attached to the insert_node event by the bind command on the layout.
Modify a node or edge in a layout.
The possible shape switches are described in SHAPES.
Execution of modify_node, will have the side effect of also executing any scripts that have been attached to the modify_node event by the bind command on the layout.
These are the node shape switches.
The shape must be either oval or polygon. Oval accepts just two coordinates in boundary representing a the diagonal corners of a bounding box for the oval. Polygons accept three or more coordinates, each coordinate representing a vertex of the
polygon
For -boundary the center of the coordinates is first computed and subtracted from all points. This allows shapes to be cloned without concern for their original position.
-at x y is taken as a strong hint as to the absolute location of the node. Some layout engines, such as dynadag, will modify this if the position violates some layout constraint, such as overlapping nodes.
-by dx dy is taken as a strong hint as to the relative movement of the node. Some layout engines, such as dynadag, will modify this if the new position violates some layout constraint, such as overlapping nodes.
These are the edge shape switches.
The shape must be either line or spline.
-coordinates are taken as a strpng hint as to the absolute location of the edge.
John Ellson (ellson@graphviz.org)
John Ousterhout, of course, for tcl and tk. Steven North and Eleftherios Koutsofios for dot, libgraph and libincr. Karl Lehenbauer and Mark Diekhans of NeoSoft for the tclhandles.c code which was derived from tclXhandles.c.
Tcldgl, Tcldgr, graph, tcl, tk, dot, tcldot, graphviz.