package require tdom proc getSimLayout { curframe {dirname ./} {xmlFile Sim.SimInfo} {txtFile graph.txt} {pngFile graph.gif} } { #set xmlFile ./Sim.SimInfo #set txtFile ./graph.txt #set pngFile ./graph.png set size [file size $dirname$xmlFile] set fd [open $dirname$xmlFile] set xml [read $fd $size] close $fd set doc [dom parse -simple $xml] set root [$doc documentElement] set fh [open $dirname$txtFile "w"] puts $fh "digraph finite_state_machine {" puts $fh "size=\"7,7\";" puts connection foreach connection [$root selectNodes Connection] { # remove the next two lines puts aa puts $connection set DotCommand "" set SourceId [[$connection child 1 Source] getAttribute id] set SourceName [[$root find id $SourceId] getAttribute Name] set TargetId [[$connection child 1 Target] getAttribute id] set TargetName [[$root find id $TargetId] getAttribute Name] append DotCommand "\"" $SourceName "\" -> \"" $TargetName "\"" set InputNr [[$connection child 1 InputNumber] getAttribute value] switch $InputNr { 0 {} 1 {append DotCommand " \[arrowhead = tee\]"} 2 {} 3 {append DotCommand " \[arrowhead = tee\]"} } puts "Dot= $DotCommand" append DotCommand " ;" puts $fh $DotCommand } puts $fh "}" close $fh exec dot -Tgif $dirname$txtFile -o $dirname$pngFile $doc delete LayoutImage read $dirname$pngFile -shrink set imageWidth [image width LayoutImage] set imageHeight [image height LayoutImage] ${curframe}.layoutCanvas configure -width $imageWidth -height $imageHeight } proc ShowLayoutWindow {LayoutWindowName SimDataDir {pngFile graph.gif} } { set ::VisibleSimLayout 1 toplevel $LayoutWindowName wm protocol $LayoutWindowName WM_DELETE_WINDOW "HideWin $LayoutWindowName ::VisibleSimLayout" set curframe ${::LayoutWindowName} puts "getSimLayout $SimDataDir" pack [button ${curframe}.actualize -command "getSimLayout $curframe $SimDataDir" -text "actualize Picture"] image create photo LayoutImage if {[file exists $SimDataDir$pngFile] == 1} { LayoutImage read $SimDataDir$pngFile set imageWidth [image width LayoutImage] set imageHeight [image height LayoutImage] } else { set imageWidth 100 set imageHeight 20 } pack [canvas ${curframe}.layoutCanvas -height $imageHeight -width $imageWidth] ${curframe}.layoutCanvas create image 0 0 -image LayoutImage -anchor nw } proc doSomething {} { puts dlskjfsdlk }