1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
#
# load.tk
#
proc load(build) name {
global Load unformat Model
build_Title $name "Load"
# for unformatted data types -- default type is "Traj"
set unformat(mem_names) [get_pm_elem_names Memory MEMRY]
set unformat(Load_Data_Type) 3
build_DismissButtonbar $name dbbar "window(dismiss) load" \
{"Load..." load(preload) }
set cmd [build_CmdFrame $name cmd]
build_Filename $cmd f Load(Filename) Load(Directory)
bind_LabelEntryColumns $cmd.f 1 <Return> load(update)
build_Choicefield $cmd ch0 "Data style:" Load(Format_Flag) \
{"Unformatted" "DsTool 1.x" "DsTool 2.0" "DsTool Tk"}
$cmd.ch0.c1 configure -state disabled
for {set i 0} {$i<4} {incr i} {
bind $cmd.ch0.c$i <Button-1> [list load(build) $name]
bindtags $cmd.ch0.c$i [list Radiobutton $name all $cmd.ch0.c$i]
}
set i 0
while {[winfo exists $cmd.uf$i]} {
destroy $cmd.uf$i
incr i
}
if {$Load(Format_Flag) == 0} { # unformatted data fields
build_PopupMenu $cmd uf0 "Data type:" \
unformat(Load_Data_Type) load(change_utype) $unformat(mem_names)
build_Choicefield $cmd uf1 "Color: " Load(Color_Flag) \
{"Off" "On"}
build_Choicefield $cmd uf2 "Symbol:" Load(Symbol_Flag) \
{"Off" "On"}
set uf3 [build_StdFrame $cmd uf3]
pack $uf3 -side top -fill both -expand 1
set listb0 [build_Listbox $uf3 lb0 "Variables: " $Model(Varb_Dim) 4 \
[array_to_listvalues Model Varb_Names] ]
pack $uf3.lb0 -side left -expand 1 -fill both
bind $listb0 <Button-1> [list load(change_selected) $name]
bindtags $listb0 [list Listbox $name all $listb0]
set listb1 [build_Listbox $uf3 lb1 "Parameters: " $Model(Param_Dim) 4 \
[array_to_listvalues Model Param_Names] ]
pack $uf3.lb1 -side left -expand 1 -fill both
bind $listb1 <Button-1> [list load(change_selected) $name]
bindtags $listb1 [list Listbox $name all $listb1]
}
pack $cmd -fill both -expand 1
}
proc load(enter) {} {
pm_to_tcl Load
}
proc load(leave) {} {
tcl_to_pm Load
pm_to_tcl Load
}
proc load(update) {} {
tcl_to_pm Load
pm_to_tcl Load
}
proc load(upfile) {} {
global Load
global File
set Load(Filename) $File(Filename)
set Load(Directory) $File(Directory)
}
proc load(preload) {} {
global Load
window(open) filesl
filesl(init) "Load" \
"*.config" \
$Load(Directory) \
$Load(Filename) \
"load(upfile)" \
"load(go_win)"
}
proc load(go_win) {} {
global Load
window(destroy_almost_all)
if { ![load(go)] } {
# cannot read file
set filename $Load(Directory)/$Load(Filename)
build_Dialog dialog "DsTool: Load" "Cannot read: \n$filename" 0 OK
}
browser(load_init)
window(rebuild_nonview)
window(refresh_all)
}
# proc load(change_selected)
#
# Saves the list of selected variables and parameters to the postmaster
#
proc load(change_selected) name {
global Load Model unformat
if {$Load(Format_Flag) != 0} {
return 1
}
for {set i 0} {$i<$Model(Varb_Dim)} {incr i} {
if [$name.cmd.uf3.lb0.lb selection includes $i] {
pm PUT Load.Varb_Index $i 1
} else {
pm PUT Load.Varb_Index $i 0
}
}
for {set i 0} {$i<$Model(Param_Dim)} {incr i} {
if [$name.cmd.uf3.lb1.lb selection includes $i] {
pm PUT Load.Param_Index $i 1
} else {
pm PUT Load.Param_Index $i 0
}
}
pm_to_tcl Load
}
proc load(change_utype) {} {
global unformat
pm PUT Load.Data_Type Memory.[lindex $unformat(mem_names) $unformat(Load_Dat
a_Type)]
pm_to_tcl Load
}
|