diff summerso/HHMI_tcl/HHMI_keys.tcl summers/HHMI_tcl/HHMI_keys.tcl
HHMI_keys.tcl
Use "nv_win ppm x" instead of "nv_win x" (and same for y,z,a)
bind Spectrum <X>             {nv_win x 500 -500; nv_win draw}
bind Spectrum <Y>             {nv_win y -500 500; nv_win draw}
bind Spectrum <X>             {nv_win ppm x 500 -500; nv_win draw}
bind Spectrum <Y>             {nv_win ppm y -500 500; nv_win draw}
Use NvSetPeakAnal, instead of "nv_peak panel" This change is no longer necessary.
bind Spectrum <i> {nv_peak panel [nv_peak nearest]; Nv_ShowPeakAnal}
bind Spectrum <KeyRelease> {NvSetCursorMode crosshairs}
bind Spectrum <i> {NvSetPeakAnal $Nv_Priv(peakAnal) [nv_peak nearest]; Nv_ShowPeakAnal}
bind Spectrum <KeyRelease> {NvSetCursorMode crosshair}
diff summerso/HHMI_tcl/dr3d.tcl summers/HHMI_tcl/dr3d.tcl
dr3d.tcl
Don't use "-" on subcommand names.
nv_win -draw
nv_win draw
diff summerso/HHMI_tcl/findpk.tcl summers/HHMI_tcl/findpk.tcl
findpk.tcl
Optimization to make use of the "nv_peak match" command, much faster than writing out the script to do the same.
Nv_ShowPeakAnal
set labs [nv_peak label]
set ntargs [llength $args]
set npks [nv_peak n]

for {set i 0} {$i < $ntargs} {incr i} {
set targ($i) [lindex $args $i]
set lab($i) [lindex $labs $i]
}

for {set j 0} {$j < $npks} {incr j} {
set nmatch 0
for {set i 0} {$i < $ntargs} {incr i} {
set asgn [nv_peak elem $lab($i).L $j]
if {[string compare $asgn $targ($i)] == 0} {
incr nmatch
}
}
if {$nmatch == $ntargs} {nv_peak pan $j; return}
global curr_list Nv_Priv
Nv_ShowPeakAnal
set matches [eval nv_peak match $curr_list $args]
if {[llength $matches] > 0} {
NvSetPeakAnal $Nv_Priv(peakAnal) [lindex $matches 0]
diff summerso/HHMI_tcl/getinput.tk summers/HHMI_tcl/getinput.tk
getinput.tk
The getinput proc relied on the "tkwait" command which doesn't yet exist in Swank, but the whole thing can be replaced with a tk_messageBox with -type set to "input".
# HHMI-UMBC Toolkit
# MFS 4Jun01
# Usage:  getinput "String to Prompt for User Input"

# Note:  Use Carriage Return or OK button to input data.
#        Use Control-C or Cancel button to halt data input.

proc getinput {promptstring} {

global promptvalue
#set old [focus]
set w .entry1
catch {destroy $w}
toplevel $w
wm title $w "getinput"

label $w.msg -justify left -text "$promptstring"

pack $w.msg -side top

frame $w.buttons
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.ok -text OK -command {set promptvalue(ok) 1}
button $w.buttons.cancel -text Cancel -command {set promptvalue(ok) 0}
pack $w.buttons.ok $w.buttons.cancel -side left -expand 1


set promptvalue(result) ""
entry $w.entry -textvariable promptvalue(result)
pack $w.entry -side top -pady 5 -padx 10 -fill x

#$w.entry insert 0 " "

bind $w <Control-c> {set promptvalue(ok) 0}
bind $w <Return> {set promptvalue(ok) 1}

grab $w
focus $w.entry
tkwait variable promptvalue(ok)
grab release $w
destroy $w
focus .tkcon
focus .tkcon.text
if {$promptvalue(ok)} {
return $promptvalue(result)
} else {
return {}
}
proc getinput {prompt} {
return [tk_messageBox -icon info -type input -message $prompt]
diff summerso/HHMI_tcl/getpkppm5.tcl summers/HHMI_tcl/getpkppm5.tcl
getpkppm5.tcl
When looping over all the peaks in a peak list it is better to use the builtin foreachpeak command. It will skip over gaps in peak numbers (if for example, you have peaks 0, 1, 3, 4, ...)
for {set j 0} {$j < $n} {set j [expr $j+1]} {
	set iPeak [eval nv_peak idnum $plist.$j]
foreachpeak iPeak $plist {
When using the nv_peak elem command to get or set the chemical shift use the format dimName.P (like 1H.P) rather than just dimName. The latter still works, but is more consistent with other uses of the command (to get the width 1H.W, bounds 1H.B etc.)
set ppm [nv_peak elem $dimname $plist.$iPeak]
set ppm [nv_peak elem $dimname.P $plist.$iPeak]
"nv_atom numb" command used to return the index number of an atom. We now try to avoid using atom index numbers, referring to the atom by its name instead. "nv_atom num" (note, num, not numb) returns -1 if the atom doesn't exist and 1 if it does exist so it should be used only as a check for the existance of the atom.
			if {[catch "nv_atom numb $root$idx" atmn]} {
			if {[nv_atom num $root$idx] > 0} {
			}
if {$atmn>0} {
				if {[catch "nv_atom elem ppm $atmn $avgppm" result]} {
				if {[catch "nv_atom elem ppm $root$idx $avgppm" result]} {
		if {[catch "nv_atom numb $aname" atmn]} {
			puts $atmn
			puts "$aname"
		} else {
		if {[catch "nv_atom elem ppm $atmn $avgppm" result]} {
		if {[nv_atom num $aname] > 0} {
		    puts "$aname"
		    if {[catch "nv_atom elem ppm $aname $avgppm" result]} {
			puts "$aname $atmn"
		}
			puts "$aname"
		    }
diff summerso/HHMI_tcl/getppm.tcl summers/HHMI_tcl/getppm.tcl
getppm.tcl
Optimization to make use of the "nv_peak match" command, much faster than writing out the script to do the same.
set labs [nv_peak label $list];
set npks [nv_peak n $list];

foreach lab $labs {
for {set i 0} {$i < $npks} {incr i} {
set atm [nv_peak element $lab.L $list.$i];
if {[string compare $atm $atom] == 0} {
return [nv_peak element $lab $list.$i];
}
}
set matches [nv_peak match $list $atom]
if {[llength $matches] > 0} {
set peak [lindex $matches 0]
foreach label [nv_peak labels $list] {
if {[nv_peak elem $label.L $peak] == $atom} {
return [nv_peak elem $label.P $peak]
}
}
diff summerso/HHMI_tcl/jpanel.tcl summers/HHMI_tcl/jpanel.tcl
jpanel.tcl

global PPM1 PPM2
-command {set PPM1 [nv_win cross1x]}];
-command {set PPM1 [nv_win cross1x]}]

proc jpanel_cmd {mode} {
global PPM1
set PPM1 [nv_win cross1x]
}
diff summerso/HHMI_tcl/jxy.tcl summers/HHMI_tcl/jxy.tcl
jxy.tcl
The UMBC "fold" proc was changed so that it takes the symbolic name of the window's dimension, rather than an integer dimension number. This is generally more flexible, and more likely to be correct when dataset dimensions are assigned to window dimensions out of their natural order.
set x [fold 1 $x]
set x [fold x $x]
set y [fold 2 $y]
set y [fold y $y]
diff summerso/HHMI_tcl/jxyz.tcl summers/HHMI_tcl/jxyz.tcl
jxyz.tcl
See change described above for the "fold" proc.
set x [fold 1 $x]
set x [fold x $x]
set y [fold 2 $y]
set y [fold y $y]
set z [fold 3 $z]
set z [fold z $z]
set z2 [fold 4 $z2]
set z2 [fold a $z2]
diff summerso/HHMI_tcl/jxz.tcl summers/HHMI_tcl/jxz.tcl
jxz.tcl
See change described above for the "fold" proc.
set x [fold 1 $x]
set x [fold x $x]
set z [fold 3 $z]
set z [fold z $z]
diff summerso/HHMI_tcl/jyz.tcl summers/HHMI_tcl/jyz.tcl
jyz.tcl
See change described above for the "fold" proc.
set y [fold 2 $y]
set y [fold y $y]
set z [fold 3 $z]
set z [fold z $z]
diff summerso/HHMI_tcl/movepk.tcl summers/HHMI_tcl/movepk.tcl
movepk.tcl
global curr_list curr_peak
set labs [nv_peak label];
set labs [nv_peak label $curr_list];
set curpeak [nv_peak pan];
nv_peak elem $xlab $curpeak $x;
nv_peak elem $ylab $curpeak $y;
nv_peak elem $xlab.P $curr_list.$curr_peak $x;
nv_peak elem $ylab.P $curr_list.$curr_peak $y;
diff summerso/HHMI_tcl/nw.tcl summers/HHMI_tcl/nw.tcl
nw.tcl

wm geometry $top ${width}x${height}
NvSpectrumCBar $top
set splace [frame $top.splace]
pack $splace -side top -fill both -expand y
nv_win xbor 20 20;
place $wname -in $top -relx $x1 -rely $y1 \
nv_win border x 20 20;
place $wname -in $splace -relx $x1 -rely $y1 \
#  spectrum $wname;
#  place $wname -in $top -relheight 1 -relwidth 1;
global retval NO_OVERWRITE;
global NO_OVERWRITE;
toplevel .ovrwrt;
label .ovrwrt.txt -text "File $fname exists.  Overwrite?";
frame .ovrwrt.bot;
button .ovrwrt.ok -text "OK" -command {destroy .ovrwrt; set retval 1};
button .ovrwrt.no -text "Cancel" -command {destroy .ovrwrt; set retval 0};
pack .ovrwrt.txt -in .ovrwrt -side top;
pack .ovrwrt.bot -in .ovrwrt -side bottom;
pack .ovrwrt.ok -in .ovrwrt.bot -side left;
pack .ovrwrt.no -in .ovrwrt.bot -side right;
tkwait window .ovrwrt;
set result [tk_messageBox -icon warning -type yesno -message "File $fname exists.  Overwrite?"]
set retval [expr {$result == "yes"}]
diff summerso/HHMI_tcl/pkpk.tcl summers/HHMI_tcl/pkpk.tcl
pkpk.tcl
"nv_win dispeaks" now returns an empty list, rather than the word "none" if there are no peak lists set for display in window.
if {$peaks == "none"} {
if {$peaks == ""} {
Use new style getinput that returns value, rather than setting a variable
getinput "New Peaklist Name"
if {$promptvalue(ok) == 0} {return} else {
set listname $promptvalue(result)}
set listname [getinput "New Peaklist Name"]
if {$listname == ""} {return}
Use dim name, rather than integer number, for "nv_win label" command.
set dimstring ""
for {set i 1} {$i <= $ndims} {incr i} {
append dimstring "[nv_win label $i] "
set dimstring [list]
foreach dim "x y z a" {
set dimLabel [nv_win label $dim]
if {$dimLabel == {}} {break}
lappend dimstring $dimLabel
The eval command is used here to expand dimstring into a number of arguments. The whole command should not be in quotes.
eval "nv_peak addlist $listname $dimstring"
eval nv_peak addlist $listname $dimstring
Use "nv_peak elem" not "nv_peak element"
nv_peak element $labx.P $lst.$newpk $c1x
nv_peak element $laby.P $lst.$newpk $c1y
nv_peak element $labx.B $lst.$newpk $wx
nv_peak element $laby.B $lst.$newpk $wy
nv_peak element $labx.W $lst.$newpk [expr $wx*0.75]
nv_peak element $laby.W $lst.$newpk [expr $wy*0.75]
nv_peak element $labx.L $lst.$newpk "?"
nv_peak element $laby.L $lst.$newpk "?"
nv_peak elem $labx.P $lst.$newpk $c1x
nv_peak elem $laby.P $lst.$newpk $c1y
nv_peak elem $labx.B $lst.$newpk $wx
nv_peak elem $laby.B $lst.$newpk $wy
nv_peak elem $labx.W $lst.$newpk [expr $wx*0.75]
nv_peak elem $laby.W $lst.$newpk [expr $wy*0.75]
nv_peak elem $labx.L $lst.$newpk "?"
nv_peak elem $laby.L $lst.$newpk "?"
Use "nv_peak elem" not "nv_peak element"
nv_peak element $labz.P $lst.$newpk $ppmz
nv_peak element $labz.B $lst.$newpk 0.5
nv_peak element $labz.W $lst.$newpk 0.5
nv_peak element $labz.L $lst.$newpk "?"
nv_peak elem $labz.P $lst.$newpk $ppmz
nv_peak elem $labz.B $lst.$newpk 0.5
nv_peak elem $labz.W $lst.$newpk 0.5
nv_peak elem $labz.L $lst.$newpk "?"
Use "nv_peak elem" not "nv_peak element"
nv_peak element $labz2.P $lst.$newpk $ppmz2
nv_peak element $labz2.B $lst.$newpk 1.5
nv_peak element $labz2.W $lst.$newpk 1.5
nv_peak element $labz2.L $lst.$newpk "?"
nv_peak elem $labz2.P $lst.$newpk $ppmz2
nv_peak elem $labz2.B $lst.$newpk 1.5
nv_peak elem $labz2.W $lst.$newpk 1.5
nv_peak elem $labz2.L $lst.$newpk "?"
Nv_Priv not used here
global Nv_Priv
"nv_peak label" command should now requires an argument specifying the list, it used to use a "default" list.
set label [nv_peak label]
set label [nv_peak label $lst]
"nv_peak label" command should now requires an argument specifying the list, it used to use a "default" list.
set pklabels [nv_peak label]
set pklabels [nv_peak label $lst]
Use "nv_peak elem" not "nv_peak element"
nv_peak element $labx.P $lst.$newpk $c1x
nv_peak element $laby.P $lst.$newpk $c1y
nv_peak element $labx.B $lst.$newpk $wx
nv_peak element $laby.B $lst.$newpk $wy
nv_peak element $labx.W $lst.$newpk [expr $wx*0.75]
nv_peak element $laby.W $lst.$newpk [expr $wy*0.75]
nv_peak elem $labx.P $lst.$newpk $c1x
nv_peak elem $laby.P $lst.$newpk $c1y
nv_peak elem $labx.B $lst.$newpk $wx
nv_peak elem $laby.B $lst.$newpk $wy
nv_peak elem $labx.W $lst.$newpk [expr $wx*0.75]
nv_peak elem $laby.W $lst.$newpk [expr $wy*0.75]
Use "nv_peak elem" not "nv_peak element"
set wz [nv_peak element $labz.W $lst.$lastpk]
set bz [nv_peak element $labz.B $lst.$lastpk]
nv_peak element $labz.P $lst.$newpk $ppmz
nv_peak element $labz.B $lst.$newpk $bz
nv_peak element $labz.W $lst.$newpk $wz
nv_peak element $labz.L $lst.$newpk $asnz
set wz [nv_peak elem $labz.W $lst.$lastpk]
set bz [nv_peak elem $labz.B $lst.$lastpk]
nv_peak elem $labz.P $lst.$newpk $ppmz
nv_peak elem $labz.B $lst.$newpk $bz
nv_peak elem $labz.W $lst.$newpk $wz
nv_peak elem $labz.L $lst.$newpk $asnz
Use "nv_peak elem" not "nv_peak element"
set wz2 [nv_peak element $labz2.W $lst.$lastpk]
set bz2 [nv_peak element $labz2.B $lst.$lastpk]
nv_peak element $labz2.P $lst.$newpk $ppmz2
nv_peak element $labz2.B $lst.$newpk $bz2
nv_peak element $labz2.W $lst.$newpk $wz2
nv_peak element $labz2.L $lst.$newpk $asnz2
set wz2 [nv_peak elem $labz2.W $lst.$lastpk]
set bz2 [nv_peak elem $labz2.B $lst.$lastpk]
nv_peak elem $labz2.P $lst.$newpk $ppmz2
nv_peak elem $labz2.B $lst.$newpk $bz2
nv_peak elem $labz2.W $lst.$newpk $wz2
nv_peak elem $labz2.L $lst.$newpk $asnz2
"nv_peak panel" command was not supported in NvJ, so change to using NvSetPeakAnal (but "nv_peak panel" is now supported).
nv_win draw
nv_peak panel $lst.$newpk
nv_win draw peak


NvSetPeakAnal $Nv_Priv(peakAnal) $lst.$newpk
diff summerso/HHMI_tcl/rdwin.tcl summers/HHMI_tcl/rdwin.tcl
rdwin.tcl
NvJ windows can have a control icon bar across top, add it in when loading window.
NvSpectrumCBar $parent
set splace [frame $parent.splace]
pack $splace -side top -fill both -expand y
Use "nv_win border x", rather than "nv_win xbor". Same for dim y.
nv_win xbor $xbor1 $xbor2
nv_win border x $xbor1 $xbor2
Window is placed inside a frame named splace
place $winame -in $parent -relx $xstart -rely $ystart \
place $winame -in $parent.splace -relx $xstart -rely $ystart \
Use "nv_win border x", rather than "nv_win xbor". Same for dim y.
nv_win xbor $xbor1 $xbor2
nv_win border x $xbor1 $xbor2
diff summerso/HHMI_tcl/setx.tcl summers/HHMI_tcl/setx.tcl
setx.tcl
Use "nv_win ppm x", rather than "nv_win x". Same for dim y,z,a.
set lims [nv_win x]
set lims [nv_win ppm x]
nv_win x $lolim $hilim
nv_win ppm x $lolim $hilim
diff summerso/HHMI_tcl/sety.tcl summers/HHMI_tcl/sety.tcl
sety.tcl
Use "nv_win ppm y", rather than "nv_win y". Same for dim x,z,a.
set lims [nv_win y]
set lims [nv_win ppm y]
nv_win y $lolim $hilim
nv_win ppm y $lolim $hilim
diff summerso/HHMI_tcl/shiftpks.tcl summers/HHMI_tcl/shiftpks.tcl
shiftpks.tcl
When looping over all the peaks in a peak list it is better to use the builtin foreachpeak command. It will skip over gaps in peak numbers (if for example, you have peaks 0, 1, 3, 4, ...)
proc shiftpks {dim amt {list -}} {
for {set i 0} {$i < [nv_peak n]} {incr i} {
nv_peak elem $dim $i [expr [nv_peak elem $dim $i] + $amt]
proc shiftpks {dim amt {list {}}} {
global curr_list
if {$list == {}} {
set list  $curr_list
}
foreachpeak i $list {
nv_peak elem $dim.P $list.$i [expr {[nv_peak elem $dim.P $list.$i] + $amt}]
diff summerso/HHMI_tcl/slice.tcl summers/HHMI_tcl/slice.tcl
slice.tcl
nv_win y $yp1 $yp2
nv_win x [expr $xpos+$xsw2] [expr $xpos-$xsw2]
nv_win z $zpos $zpos
nv_win ppm y $yp1 $yp2
nv_win ppm x [expr $xpos+$xsw2] [expr $xpos-$xsw2]
nv_win ppm z $zpos $zpos
nv_win x $xp1 $xp2
nv_win y [expr $ypos+$ysw2] [expr $ypos-$ysw2]
nv_win z $zpos $zpos
nv_win ppm x $xp1 $xp2
nv_win ppm y [expr $ypos+$ysw2] [expr $ypos-$ysw2]
nv_win ppm z $zpos $zpos
diff summerso/HHMI_tcl/wcopy.tcl summers/HHMI_tcl/wcopy.tcl
wcopy.tcl
Use "nv_win border x", rather than "nv_win xborder". Same for dim y,z,a.
set WINFO(xborder) [nv_win xborder]
set WINFO(xborder) [nv_win border x]
set WINFO(yborder) [nv_win border y]
diff summerso/HHMI_tcl/wpaste.tcl summers/HHMI_tcl/wpaste.tcl
wpaste.tcl
Use "nv_win border x", rather than "nv_win xborder". Same for dim y,z,a.
nv_win xborder [lindex $WINFO(xborder) 0] [lindex $WINFO(xborder) 1]
nv_win border x [lindex $WINFO(xborder) 0] [lindex $WINFO(xborder) 1]
nv_win border y [lindex $WINFO(yborder) 0] [lindex $WINFO(yborder) 1]
diff summerso/HHMI_tcl/writepksvi.tcl summers/HHMI_tcl/writepksvi.tcl
writepksvi.tcl
"nv_peak name" not used anymore.
	set lst [nv_peak name $curr_list]
	set lst $curr_list
diff summerso/HHMI_tcl/wrwin.tcl summers/HHMI_tcl/wrwin.tcl
wrwin.tcl
"nv_peak nwin" not used anymore. Check if "nv_win active" returns empty string to see if no windows are present.
set nwin [nv_win nwin]
if {$nwin < 1} {
set activeWin [nv_win active]
if {$activeWin ==  {}} {
nv_win act $winame;
if {[regexp sgrid $winame] || [regexp cbar $winame]} {
if {[winfo class $winame] != "Spectrum"} {
nv_win act $winame;
Use "nv_win border x", rather than "nv_win xborder". Same for dim y,z,a.
puts $outf "xborder [nv_win xbor]"
puts $outf "xborder [nv_win border x]"
puts $outf "yborder [nv_win border y]"