home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Divers
/
angela-1.28-BETA-bin-Linux-i586.tar.gz
/
angela-1.28-BETA-bin-Linux-i586.tar
/
angela-1.28-BETA
/
module_plingread.tcl
< prev
next >
Wrap
Text File
|
1998-05-05
|
5KB
|
204 lines
# This is a module for PLING implementation
proc pling_in { command { arg1 "" } { arg2 "" } { arg3 "" } { arg4 "" } } {
switch $command {
long_info
{
return "{ Pling input }\
{ Pling input }\
{ Oliver Pabst }\
{ 1.0 }\
{ Pling input/Tcl } \
{ Pling input filter as Tcl module for angela! }\
{ Oliver Pabst }\
{ 1.0 }\
{ filter_in }\
{ pling }"
}
extension
{
return ".pling"
}
init
{
}
load
{
pling_in:load $arg1 $arg2 $arg3 $arg4
}
}
}
proc pling_in:load_line { handle } {
# Must load a line without comments and without meta breaks
set line ""
set finished 0
while { 1 } {
if { [eof $handle] } { break }
set thisline [string trim [gets $handle]]
# Get rid of comments
#set length [string length $thisline]
#for { set i 0 } { $i < $length } { incr i } {
#if { [string index $thisline $i] == "\#" } {
#if { [string index $thisline [expr $i-1]] != "\\" } {
#set thisline [string range $thisline 0 [expr $i-1]]
#break
#}
#}
#}
set done 0
set start 0
set end end
while { !$done } {
#debug 7 "Start is at $start"
#debug 7 "End is at $end"
set pointer [ string first \# [string range $thisline $start $end] ]
#debug 7 "Portion is \"[string range $thisline $start $end]\""
#debug 7 "Pointer is at $pointer"
if { $pointer == -1 } {
set done 1;
break;
}
if { [string index $thisline [expr $pointer-1]] != "\\" } {
set thisline [string range $thisline 0 [expr $pointer-1]]
set done 1;
break;
}
set start [expr $pointer+1]
}
# Check if meta-break
set thisline [string trim $thisline]
set length [string length $thisline]
if { [string index $thisline [expr $length-1]]=="\\" } {
set thisline [string range $thisline 0 [expr $length-2]]
} else { set finished 1 }
set line [string trim "$line $thisline"]
if { $finished } {
if { $line==""} {
set finished 0
set line ""
} else { break }
}
}
#debug 5 "Returned line is \"$line\""
return $line
}
proc pling_in:load { handle msg nodes edges } {
# Bypass graph info
pling_in:load_line $handle
pling_in:load_line $handle
# Read node count
set nodecount [pling_in:load_line $handle]
for { set i 0 } { $i < $nodecount } { incr i } {
set node [pling_in:load_line $handle]
# Example of PLING line for a node:
# 1 Node white 50 c "Arial 12" c ""
# 250.0 225.0 0 250.000000 225.000000 steelblue 1 black "" 0 oval "50 50"
foreach { nodeid node_text node_textcolor node_textwidth \
node_textanchor node_textfont node_textjust stipple text_x text_y \
node_type node_x node_y node_color node_width node_outline \
node_stipple shape_type node_dummy_node_shape node_shapeargs } $node {
# build node capabilities and node values
set nc(node) "type"
set nc(text) "text textcolor width anchor font coords"
set nc(shape) "x y color width outline shape shapeargs"
set ncv(node:type) $node_type
set ncv(text:text) "$node_text"
set ncv(text:textcolor) $node_textcolor
set ncv(text:width) $node_textwidth
set ncv(text:anchor) $node_textanchor
set ncv(text:font) "$node_textfont"
set ncv(text:coords) "$text_x $text_y"
set ncv(shape:x) $node_x
set nvc(shape:y) $node_y
set ncv(shape:color) $node_color
set ncv(shape:width) $node_width
set ncv(shape:outline) $node_outline
set ncv(shape:shape) $node_dummy_node_shape
set ncv(shape:shapeargs) "$node_shapeargs"
set realnodeid [$msg NODE:CREATE:DIRECT $node_x $node_y [array get nc] [array get ncv]]
set hash($nodeid) $realnodeid
}
}
# Read edge count
set edgecount [pling_in:load_line $handle]
for { set i 0 } { $i < $edgecount } { incr i } {
set edge [pling_in:load_line $handle]
# Example of PLING line for an edge:
# 0 9 10 0 black 2 both "" 0 0 0 <optional points>
set optional [lrange $edge 11 end]
set done 0
foreach { edgeid node1 node2 type color width arrow arrowshape \
bezier steps line_type } $edge {
if { $done } break
set done 1
# build edge capabilities and node values
set ec(edge) "type"
set ec(line) "color width arrow arrowshape bezier"
set ecv(edge:type) $type
set ecv(line:color) $color
set ecv(line:width) $width
set ecv(line:arrow) $arrow
set ecv(line:arrowshape) "$arrowshape"
if { $bezier == 1 } {
set ecv(line:bezier) $steps
} else {
set ecv(line:bezier) 0
}
if { $optional != "" } {
set ecv(line:coords) "0 0 $optional"
set ec(line) "$ec(line) coords"
}
$msg EDGE:CREATE:DIRECT $hash($node1) $hash($node2) [array get ec] [array get ecv]
}
}
}