# and Technology through the research contract #IP-2003-143.
#
-# $Id: cfgparse.tcl,v 1.38 2008/01/02 12:08:46 marko Exp $
+# $Id: cfgparse.tcl,v 1.39 2008/01/08 12:35:30 marko Exp $
#****h* imunes/cfgparse.tcl
upvar 0 ::cf::[set ::curcfg]::link_list link_list
upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+ upvar 0 ::cf::[set ::curcfg]::eid eid
global showIfNames showNodeLabels showLinkLabels
global showIfIPaddrs showIfIPv6addrs
global showIPsecConfig
set canvas_list {}
set class ""
set object ""
+ set eid ""
foreach entry $cfg {
if {"$class" == ""} {
set class $entry
upvar 0 ::cf::[set ::curcfg]::link_list link_list
upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+ global cfg_list
set mark [string range [set type] 0 0]
set id 0
# and Technology through the research contract #IP-2003-143.
#
-# $Id: filemgmt.tcl,v 1.16 2008/01/05 18:06:25 marko Exp $
+# $Id: filemgmt.tcl,v 1.17 2008/01/08 12:35:30 marko Exp $
##****h* imunes/filemgmt.tcl
#
# procedures used for loading and storing the configuration file:
#
-# newFile
+# newProject
# - creates an empty project
#
# openFile
# fileOpenStartUp
# - opens the file named as command line argument
#
-# fileNewDialogBox
-# - opens message box to optionally save the changes
-#
# fileOpenDialogBox
# - opens dialog box for selecting a file to open
#
}
-#****f* filemgmt.tcl/newFile
-# NAME
-# newFile -- new file
-# SYNOPSIS
-# newFile
-# FUNCTION
-# Loads an empty configuration, i.e. creates an empty project.
-#****
-proc newFile {} {
+proc newProject {} {
+ global curcfg cfg_list sizex sizey
+
+ set curcfg [newObjectId cfg]
+ lappend cfg_list $curcfg
+ namespace eval ::cf::[set curcfg] {}
+
upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
upvar 0 ::cf::[set ::curcfg]::curcanvas curcanvas
upvar 0 ::cf::[set ::curcfg]::undolevel undolevel
upvar 0 ::cf::[set ::curcfg]::redolevel redolevel
+ upvar 0 ::cf::[set ::curcfg]::undolog undolog
+ upvar 0 ::cf::[set ::curcfg]::zoom zoom
upvar 0 ::cf::[set ::curcfg]::oper_mode oper_mode
upvar 0 ::cf::[set ::curcfg]::eid eid
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
- if { $oper_mode == "exec" } {
- vimageCleanup $eid
- }
loadCfg ""
+ set oper_mode edit
set undolevel 0
set redolevel 0
+ set undolog(0) ""
+ set zoom 1.0
+ set canvas_list {}
+ newCanvas ""
set curcanvas [lindex $canvas_list 0]
+ set sizex [lindex [getCanvasSize $curcanvas] 0]
+ set sizey [lindex [getCanvasSize $curcanvas] 1]
switchCanvas none
redrawAll
set currentFile ""
- wm title . "IMUNES"
+ setWmTitle $currentFile
+}
+
+
+proc setWmTitle { fname } {
+ global curcfg
+
+ if { $fname == "" } {
+ wm title . "IMUNES - untitled[string range $curcfg 1 end]"
+ } else {
+ wm title . "IMUNES - $fname"
+ }
}
upvar 0 ::cf::[set ::curcfg]::undolevel undolevel
upvar 0 ::cf::[set ::curcfg]::redolevel redolevel
upvar 0 ::cf::[set ::curcfg]::undolog undolog
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
global activetool
set fileName [file tail $currentFile]
- wm title . "IMUNES $fileName"
set fileId [open $currentFile r]
set cfg ""
foreach entry [read $fileId] {
set redolevel 0
set undolog(0) $cfg
set activetool select
+ setWmTitle $fileName
}
# configuration is saved.
#****
proc saveFile { selectedFile } {
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
+
if { $selectedFile != ""} {
set currentFile $selectedFile
set fileName [file tail $currentFile]
- wm title . "IMUNES $fileName"
set fileId [open $currentFile w]
dumpCfg file $fileId
close $fileId
.bottom.textbox config -text "Saved $fileName"
- }
-}
-
-
-#****f* filemgmt.tcl/fileOpenStartUp
-# NAME
-# fileOpenStartUp -- file open in batch mode
-# SYNOPSIS
-# fileOpenStartUp
-# FUNCTION
-# Loads configuration from batch input file to the current
-# configuration.
-#****
-proc fileOpenStartUp {} {
- global argv
- global currentFile
-
- if { $argv != "" } {
- set currentFile $argv
- openFile
- }
-}
-
-
-#****f* filemgmt.tcl/fileNewDialogBox
-# NAME
-# fileNewDialogBox -- save changes dialog box
-# SYNOPSIS
-# fileNewDialogBox
-# FUNCTION
-# Opens message box to optionally save the changes.
-#****
-proc fileNewDialogBox {} {
- global currentFile
-
- set choice [tk_messageBox -type yesnocancel -default yes\
- -message "Save changes?" -icon question]
-
- if { $choice != "cancel"} {
- if { $choice == "yes"} {
- fileSaveDialogBox
- newFile
- } else {
- newFile
- }
+ setWmTitle $fileName
}
}
# Opens a open file dialog box.
#****
proc fileOpenDialogBox {} {
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
global fileTypes
+
set selectedFile [tk_getOpenFile -filetypes $fileTypes]
if { $selectedFile != ""} {
set currentFile $selectedFile
# current file.
#****
proc fileSaveDialogBox {} {
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
global fileTypes
if { $currentFile == "" } {
# Opens dialog box for saving a file under new name.
#****
proc fileSaveAsDialogBox {} {
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
global fileTypes
+
set selectedFile [tk_getSaveFile -filetypes $fileTypes -initialfile\
untitled -defaultextension .imn]
;#proc relpath {basedir target} {
proc relpath {target} {
- global currentFile
+ upvar 0 ::cf::[set ::curcfg]::currentFile currentFile
+
set basedir $currentFile
# Try and make a relative path to a target file/dir from base directory
set bparts [file split [file normalize $basedir]]
# and Technology through the research contract #IP-2003-143.
#
-# $Id: imunes.tcl,v 1.34 2008/01/05 18:06:25 marko Exp $
+# $Id: imunes.tcl,v 1.35 2008/01/08 12:35:30 marko Exp $
#****h* imunes/imunes.tcl
# this list is empty.
#*****
-# Default configuration
-namespace eval cf::cfg0 {}
-set cf::cfg0::node_list {}
-set cf::cfg0::link_list {}
-set cf::cfg0::annotation_list {}
-set cf::cfg0::canvas_list {}
-set cf::cfg0::eid $eid_base
-
-set cfg_list cfg0
-set curcfg cfg0
-
# Clipboard
namespace eval cf::clipboard {}
set cf::clipboard::node_list {}
set cf::clipboard::link_list {}
+set cf::clipboard::annotation_list {}
+set cf::clipboard::canvas_list {}
+
+set cfg_list {}
+set curcfg ""
#****v* imunes.tcl/exec_hosts
# NAME
source "$ROOTDIR/$LIBDIR/topogen.tcl"
source "$ROOTDIR/$LIBDIR/graph_partitioning.tcl"
source "$ROOTDIR/$LIBDIR/gpgui.tcl"
- setOperMode edit
- fileOpenStartUp
+ newProject
+ if { $argv != "" } {
+ set ::cf::[set curcfg]::currentFile $argv
+ openFile
+ }
+ # Fire up the animation loop
+ animate
} else {
if {$argv != ""} {
set fileId [open $argv r]
lappend cfg $entry
}
close $fileId
+
+ set curcfg [newObjectId cfg]
+ lappend cfg_list $curcfg
+ namespace eval ::cf::[set curcfg] {}
+
loadCfg $cfg
deployCfg
} else {
# and Technology through the research contract #IP-2003-143.
#
-# $Id: initgui.tcl,v 1.45 2008/01/07 10:53:15 marko Exp $
+# $Id: initgui.tcl,v 1.46 2008/01/08 12:35:30 marko Exp $
#****h* imunes/initgui.tcl
set newlink ""
set selectbox ""
set selected ""
-newCanvas ""
-
-set ::cf::cfg0::undolevel 0
-set ::cf::cfg0::redolevel 0
-set ::cf::cfg0::undolog(0) ""
-set ::cf::cfg0::curcanvas [lindex [set ::cf::cfg0::canvas_list] 0]
-set ::cf::cfg0::zoom 1.0
-set ::cf::cfg0::oper_mode edit
set animatephase 0
set changed 0
wm minsize . 640 400
wm geometry . 1016x716-30+30
-wm title . IMUNES
menu .menubar
. config -menu .menubar -bg white
menu .menubar.file -tearoff 0
.menubar.file add command -label New -underline 0 \
- -accelerator "Ctrl+N" -command { fileNewDialogBox }
-bind . <Control-n> "fileNewDialogBox"
+ -accelerator "Ctrl+N" -command { newProject }
+bind . <Control-n> "newProject"
.menubar.file add command -label Open -underline 0 \
-accelerator "Ctrl+O" -command { fileOpenDialogBox }
redrawAll
}
-#
-# Done with initialization, draw an empty canvas
-#
-switchCanvas first
-
focus -force .
-
-#
-# Fire up the animation loop - used basically for selectbox
-#
-animate