}
-proc removeGUILink { link } {
- global .c
+proc removeGUILink { link atomic } {
+ global changed
set nodes [linkPeers $link]
set node1 [lindex $nodes 0]
removeLink $link
}
.c delete $link
+ if { $atomic == "atomic" } {
+ set changed 1
+ updateUndoLog
+ }
return
}
proc removeGUINode { node } {
- global .c
-
set type [nodeType $node]
foreach ifc [ifcList $node] {
set peer [peerByIfc $node $ifc]
set link [lindex [.c gettags "link && $node && $peer"] 1]
- removeGUILink $link
+ removeGUILink $link non-atomic
}
if { $type != "pseudo" } {
removeNode $node
proc redrawLink { link } {
- global .c $link
+ global $link
set limages [.c find withtag "link && $link"]
set limage1 [lindex $limages 0]
#
if { $oper_mode != "exec" } {
.button3menu add command -label "Delete" \
- -command "removeGUILink $link"
+ -command "removeGUILink $link atomic"
} else {
.button3menu add command -label "Delete" \
- -command "removeGUILink $link" -state disabled
+ -state disabled
}
set x [winfo pointerx .]
[ifcByLogicalPeer $node $peer_node] == "" } {
.button3menu.connect.$canvas add command \
-label [getNodeName $peer_node] \
- -command "newLink $c $node $peer_node"
+ -command "newLink $node $peer_node atomic"
} elseif { [nodeType $peer_node] != "pseudo" } {
.button3menu.connect.$canvas add command \
-label [getNodeName $peer_node] \
#
if { $oper_mode != "exec" } {
.button3menu add command -label "Delete" \
- -command "delete_object $c $x $y"
+ -command deleteSelection
} else {
.button3menu add command -label "Delete" \
- -command "delete_object $c $x $y" -state disabled
+ -state disabled
}
#
}
-proc newLink { c lnode1 lnode2 } {
+proc newLink { lnode1 lnode2 atomic } {
global link_list
global $lnode1 $lnode2
global defEthBandwidth defSerBandwidth defSerDelay
global defLinkColor defLinkWidth
- global curcanvas
+ global curcanvas changed
#
# When linking nodes residing in different canvases, we actually
set pnode1 [newNode pseudo]
setNodeCanvas $pnode1 [getNodeCanvas $lnode1]
setNodeName $pnode1 $lnode2
- setNodeCoords $pnode1 "100 100"
- setNodeLabelCoords $pnode1 "100 100"
+ setNodeCoords $pnode1 [getNodeCoords $lnode2]
+ setNodeLabelCoords $pnode1 [getNodeCoords $lnode2]
if { [getNodeCanvas $lnode1] == $curcanvas } {
drawNode $pnode1
}
set pnode2 [newNode pseudo]
setNodeCanvas $pnode2 [getNodeCanvas $lnode2]
setNodeName $pnode2 $lnode1
- setNodeCoords $pnode2 "100 100"
- setNodeLabelCoords $pnode2 "100 100"
+ setNodeCoords $pnode2 [getNodeCoords $lnode1]
+ setNodeLabelCoords $pnode2 [getNodeCoords $lnode1]
if { [getNodeCanvas $lnode2] == $curcanvas } {
drawNode $pnode2
}
setNodeMirror $pnode1 $pnode2
setNodeMirror $pnode2 $pnode1
- newLink $c $lnode1 $pnode1
- newLink $c $lnode2 $pnode2
+ newLink $lnode1 $pnode1 recursive
+ newLink $lnode2 $pnode2 recursive
set link1 [linkByPeers $lnode1 $pnode1]
set link2 [linkByPeers $lnode2 $pnode2]
# Redraw our node so interface labels gets properly populated
#
if { [getNodeCanvas $lnode1] == $curcanvas } {
- $c delete -withtags "node && $pnode1"
- $c delete -withtags "nodelabel && $pnode1"
+ .c delete -withtags "node && $pnode1"
+ .c delete -withtags "nodelabel && $pnode1"
drawNode $pnode1
updateIfcLabel $lnode1 $pnode1
} else {
- $c delete -withtags "node && $pnode2"
- $c delete -withtags "nodelabel && $pnode2"
+ .c delete -withtags "node && $pnode2"
+ .c delete -withtags "nodelabel && $pnode2"
drawNode $pnode2
updateIfcLabel $lnode2 $pnode2
}
+ if { $atomic == "atomic" } {
+ set changed 1
+ updateUndoLog
+ }
return yes
}
# XXX what is this -> makes no sense / cannot work!
#
global $link
- if { [$c find withtag "link && $lnode1 && $lnode2"] != "" } {
+ if { [.c find withtag "link && $lnode1 && $lnode2"] != "" } {
set regular no
}
}
if { [getNodeCanvas $lnode1] == $curcanvas } {
drawLink $link
updateLinkLabel $link
- nodeEnter $c
+ nodeEnter .c
redrawLink $link
}
+ if { $atomic == "atomic" } {
+ set changed 1
+ updateUndoLog
+ }
}
return $regular
if {$destobj != "" && $curobj != "" && $destobj != $curobj} {
set lnode1 [lindex [$c gettags $curobj] 1]
set lnode2 [lindex [$c gettags $destobj] 1]
- if { [newLink $c $lnode1 $lnode2] == "yes" } {
+ if { [newLink $lnode1 $lnode2 non-atomic] == "yes" } {
set changed 1
}
}
}
-proc delete_object { c x y } {
+proc deleteSelection { } {
global changed
global background
- set node [lindex [$c gettags {node && current}] 1]
- set link [lindex [$c gettags {link && current}] 1]
- if { $link == "" } {
- set link [lindex [$c gettags {linklabel && current}] 1]
- }
- if { $link != "" } {
- removeGUILink $link
- set changed 1
- }
- if { $node != "" } {
- removeGUINode $node
- set changed 1
- }
- foreach obj [$c find withtag "node && selected"] {
- removeGUINode [lindex [$c gettags $obj] 1]
+ foreach obj [.c find withtag "node && selected"] {
+ set lnode [lindex [.c gettags $obj] 1]
+ if { $lnode != "" } {
+ removeGUINode $lnode
+ }
set changed 1
}
- $c raise link background
- $c raise linklabel "link || background"
- $c raise interface "linklabel || link || background"
- $c raise node "interface || linklabel || link || background"
- $c raise nodelabel "node || interface || linklabel || link || background"
+ .c raise link background
+ .c raise linklabel "link || background"
+ .c raise interface "linklabel || link || background"
+ .c raise node "interface || linklabel || link || background"
+ .c raise nodelabel "node || interface || linklabel || link || background"
updateUndoLog
}
proc rearrange { mode } {
global link_list autorearrange_enabled sizex sizey curcanvas
- set c .c
set autorearrange_enabled 1
.menubar.tools entryconfigure "Rearrange all" -state disabled
.menubar.tools entryconfigure "Rearrange selected" -state disabled
set otime $ntime
}
- set objects [$c find withtag $tagmatch]
- set peer_objects [$c find withtag node]
+ set objects [.c find withtag $tagmatch]
+ set peer_objects [.c find withtag node]
foreach obj $peer_objects {
- set node [lindex [$c gettags $obj] 1]
- set coords [$c coords $obj]
+ set node [lindex [.c gettags $obj] 1]
+ set coords [.c coords $obj]
set x [lindex $coords 0]
set y [lindex $coords 1]
set x_t($node) $x
}
foreach obj $objects {
- set node [lindex [$c gettags $obj] 1]
+ set node [lindex [.c gettags $obj] 1]
set i [lsearch -exact $peer_objects $obj]
set peer_objects [lreplace $peer_objects $i $i]
set x $x_t($node)
set y $y_t($node)
foreach other_obj $peer_objects {
- set other [lindex [$c gettags $other_obj] 1]
+ set other [lindex [.c gettags $other_obj] 1]
set o_x $x_t($other)
set o_y $y_t($other)
set dx [expr $x - $o_x]
}
foreach obj $objects {
- set node [lindex [$c gettags $obj] 1]
+ set node [lindex [.c gettags $obj] 1]
if { [catch "set v_t($node)" v] } {
set vx 0.0
set vy 0.0
set v_t($node) "$vx $vy"
setNodeCoords $node "$x $y"
- $c move $obj $dx $dy
- set img [$c find withtag "selectmark && $node"]
- $c move $img $dx $dy
- set img [$c find withtag "nodelabel && $node"]
- $c move $img $dx $dy
- setNodeLabelCoords $node [$c coords $img]
- $c addtag need_redraw withtag "link && $node"
- }
- foreach link [$c find withtag "link && need_redraw"] {
- redrawLink [lindex [$c gettags $link] 1]
- }
- $c dtag link need_redraw
+ .c move $obj $dx $dy
+ set img [.c find withtag "selectmark && $node"]
+ .c move $img $dx $dy
+ set img [.c find withtag "nodelabel && $node"]
+ .c move $img $dx $dy
+ setNodeLabelCoords $node [.c coords $img]
+ .c addtag need_redraw withtag "link && $node"
+ }
+ foreach link [.c find withtag "link && need_redraw"] {
+ redrawLink [lindex [.c gettags $link] 1]
+ }
+ .c dtag link need_redraw
update
}
.menubar.tools entryconfigure "Rearrange all" -state normal
.menubar.tools entryconfigure "Rearrange selected" -state normal
.bottom.mbuf config -text ""
+ return
+}
+
+
+proc switchCanvas { direction } {
+ global canvas_list curcanvas
+
+ set i [lsearch $canvas_list $curcanvas]
+ switch -exact -- $direction {
+ prev {
+ incr i -1
+ if { $i < 0 } {
+ set curcanvas [lindex $canvas_list end]
+ } else {
+ set curcanvas [lindex $canvas_list $i]
+ }
+ }
+ next {
+ incr i
+ if { $i >= [llength $canvas_list] } {
+ set curcanvas [lindex $canvas_list 0]
+ } else {
+ set curcanvas [lindex $canvas_list $i]
+ }
+ }
+ }
+ redrawAll
+ return
}
global canvas_list curcanvas
.menubar.canvas delete 0 end
+ .menubar.canvas add command -label "Previous" -accelerator "PgUp" \
+ -command { switchCanvas prev }
+ .menubar.canvas add command -label "Next" -accelerator "PgDown" \
+ -command { switchCanvas next }
+ .menubar.canvas add separator
foreach canvas $canvas_list {
.menubar.canvas add radiobutton -label [getCanvasName $canvas] \
-command redrawAll -indicatoron true \
-value $canvas -variable curcanvas
}
+ return
}
} else {
after 1500 animate
}
+ return
}