Changeset 1121 for branches/sandbox


Ignore:
Timestamp:
Mar 23, 2011 5:00:54 PM (10 years ago)
Author:
toby
Message:
 
Location:
branches/sandbox
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/addcmds.tcl

    r1109 r1121  
    379379    }
    380380}
     381set newhist(LimitMode) 1
    381382trace variable newhist(setnum) w LabelInstParm
    382383trace variable newhist(LimitMode) w ClearHistLimit
     
    415416            -column 0 -row 0 -sticky ew -columnspan 7
    416417    grid [checkbutton $np.d0 -text "Dummy Histogram" -variable newhist(dummy) \
    417             -command "PostDummyOpts $np" \
     418            -command "PostInstBankopts $np" \
    418419            ] -column 2 -row 0 -columnspan 99 -sticky e
    419420    grid [label $np.l1 -text "Data file:"] -column 0 -row 2
     
    510511    }
    511512
    512     PostDummyOpts $np
     513    PostInstBankopts $np
    513514    # set grab, etc.
    514515    putontop $np
     
    676677            incr row
    677678        }
    678         grid [radiobutton $np.bank.$i -text $i -command SetTmax \
     679        grid [radiobutton $np.bank.$i -text $i -command SetDefaultBank \
    679680                -variable newhist(banknum) -value $i] \
    680681                -column [incr col] -row $row -sticky w
    681         # only 1 choice, so set it
    682         if {[llength $newhist(banklist)] == 1} {
    683             set newhist(banknum) $i
    684             SetTmax
    685         } else {
    686             set flag 1
    687         }
     682    }
     683    # if only 1 choice, set it
     684    if {[llength $newhist(banklist)] == 1} {
     685        set newhist(banknum) $i
     686        SetDefaultBank
     687    } else {
     688        set flag 1
    688689    }
    689690    if {$flag} {
    690691        set newhist(2tLimit) {}
    691         set newhist(LimitMode) {}
    692692    }
    693693    SetMultipleAdd $np
    694694}
    695695
     696proc SetDefaultBank {} {
     697    # set the default instrument parameter set to follow the bank # when the
     698    # numbers of banks in each place agree. Do this when the data bank # is set
     699    global newhist
     700    if {[llength $newhist(banklist)] == $newhist(instbanks)} {
     701        set newhist(setnum) $newhist(banknum)
     702    }
     703    SetTmax
     704}
     705
    696706proc SetTmax {} {
     707    # set the default data range when the data or instrument parameter set is changed
    697708    global newhist
     709    # mode must be t-max or 2theta, at least for now
     710    if {$newhist(LimitMode) != 1} return
     711    # is a instrument parameter file loaded? If not, try again later
     712    if {[string trim $newhist(instfile)] == ""} return
     713    # get data bank number, test if valid
    698714    set num $newhist(banknum)
     715    if {[catch {expr $num}]} {return}
    699716    if {$newhist(insttype) == "TOF"} {
    700717        set newhist(2tLimit) [expr {$newhist(tmin$num) / 10.}]
    701         if {[llength $newhist(banklist)] == $newhist(instbanks)} {
    702             set newhist(setnum) $newhist(banknum)
    703             # at Ashfia's request, override the bank header # with the
    704             # value from the instrument parameter file.
    705             catch {
    706                 set s $newhist(setnum)
    707                 foreach {x tmin tmax x} $newhist(inst${s}ITYP) {}
    708                 if {$tmin > 0} {set newhist(2tLimit) $tmin}
    709             }
     718        # at Ashfia's request, override the bank header # with the
     719        # value from the instrument parameter file.
     720        catch {
     721            set s $newhist(setnum)
     722            foreach {x tmin tmax x} $newhist(inst${s}ITYP) {}
     723            if {$tmin > 0} {set newhist(2tLimit) $tmin}
    710724        }
    711725    } else {
    712726        set newhist(2tLimit) $newhist(tmax$num)
    713727    }
    714     set newhist(LimitMode) 1
    715 
    716728}
    717729
     
    819831        }
    820832        grid [radiobutton $np.set.$i -text $i \
    821                 -command "PostDummyOpts $np; ValidateDummyHist $np" \
     833                -command "PostInstBankopts $np; ValidateDummyHist $np" \
    822834                -variable newhist(setnum) -value $i] \
    823835                -column [incr col] -row $row -sticky w
    824836        if {$newhist(instbanks) == 1} {set newhist(setnum) $i}
    825837    }
    826     if {$newhist(dummy)} {PostDummyOpts $np; ValidateDummyHist $np}
     838    if {$newhist(dummy)} {PostInstBankopts $np; ValidateDummyHist $np}
    827839    LabelInstParm
    828840    SetMultipleAdd $np
     
    10231035    update
    10241036}
    1025 #--- Dummy histogram stuff
    1026 proc PostDummyOpts {np} {
     1037#--- Respond to the setting of the bank # for the Instrument parameter file.
     1038proc PostInstBankopts {np} {
    10271039    global newhist
    10281040    if {$newhist(dummy)} {
     
    10841096        grid $np.cb4 -column 2 -row 20 -sticky w
    10851097        grid $np.cb5 -column 2 -row 19 -sticky w
    1086      }
     1098        SetTmax
     1099    }
    10871100}
    10881101
     
    13371350    grid [radiobutton $top.vartyp.cb5 -text "Q-max\n(A-1)" -variable newhist(LimitMode) \
    13381351            -value 2] -column 2 -row 1 -sticky w
    1339     set newhist(LimitMode) 1
    13401352   
    13411353    grid [button $top.add -text Add -command "destroy $np"] -column 0 -row 3
     
    19361948                ] -row 2 -column 0 -columnspan 10
    19371949    }
     1950
     1951    # allow fixing of atom coordinates
     1952    if {[lindex $expmap(phasetype) [expr {$p - 1}]] != 4} {
     1953        grid [TitleFrame $w.10 -bd 6 -relief groove \
     1954                -text "Fix Atom$suffix Coordinates"] \
     1955                -row 9 -column 0 -columnspan 10 -sticky news
     1956        set fix [$w.10 getframe]
     1957        Fix_Initialize $numberList
     1958
     1959        label $fix.xlab -text "  x  " -width 8
     1960        label $fix.ylab -text "  y  " -width 8
     1961        label $fix.zlab -text "  z  " -width 8
     1962        grid $fix.xlab -row 2 -column 0
     1963        grid $fix.ylab -row 2 -column 1
     1964        grid $fix.zlab -row 2 -column 2
     1965
     1966
     1967        button $fix.x -text "$::fix_state_X" -width 8 \
     1968               -command "Fix_Atoms $phase [list $numberList] X $fix.x;
     1969               Fix_Write
     1970               DisplayAllAtoms $phase"
     1971
     1972        button $fix.y -text "$::fix_state_Y" -width 8 \
     1973                -command "Fix_Atoms $phase [list $numberList] Y $fix.y
     1974                Fix_Write
     1975                DisplayAllAtoms $phase"
     1976        button $fix.z -text "$::fix_state_Z" -width 8 \
     1977                -command "Fix_Atoms $phase [list $numberList] Z $fix.z
     1978                Fix_Write
     1979                DisplayAllAtoms $phase"
     1980        grid $fix.x -row 3 -column 0
     1981        grid $fix.y -row 3 -column 1
     1982        grid $fix.z -row 3 -column 2
     1983    }
     1984    #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
     1985
     1986    grid rowconfigure $w 11 -minsize 5
     1987    grid [frame $w.b] -row 12 -column 0 -columnspan 10 -sticky ew
     1988    pack [button $w.b.3 -text Close -command "destroy $w"] -side left \
     1989            -padx 5 -pady 5
     1990    pack [button $w.b.help -text Help -bg yellow \
     1991            -command "MakeWWWHelp expgui2.html xform"] -side right \
     1992            -padx 5 -pady 5
     1993    bind $w <Return> "destroy $w"
     1994
     1995    # force the window to stay on top
     1996    putontop $w
     1997    focus $w.b.3
     1998    tkwait window $w
     1999    afterputontop
     2000    # if there are selected atoms, reset their display
     2001    if {[llength $expgui(selectedatomlist)] != 0} editRecord
     2002}
     2003
    19382004#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
    19392005
     
    19562022             }
    19572023     }
    1958 
    1959              set ::fix_state_X [Fix_State 1 $numberList X]
    1960              set ::fix_state_Y [Fix_State 1 $numberList Y]
    1961              set ::fix_state_Z [Fix_State 1 $numberList Z]
    1962 
     2024    set ::fix_state_X [Fix_State 1 $numberList X]
     2025    set ::fix_state_Y [Fix_State 1 $numberList Y]
     2026    set ::fix_state_Z [Fix_State 1 $numberList Z]
    19632027}
    19642028
     
    19662030     set status_fixed "-1"
    19672031     set status_unfixed "-1"
    1968      puts "$coord before: $status_fixed $status_unfixed"
     2032     #puts "$coord before: $status_fixed $status_unfixed"
    19692033     foreach i $numberList {
    19702034             set temp [info exists ::fix_param($phase,$i,$coord)]
     
    19732037             if {$temp == 0} {set status_unfixed 1}
    19742038     }
    1975      puts "$coord after $status_fixed $status_unfixed"
     2039     #puts "$coord after $status_fixed $status_unfixed"
    19762040     if {$status_fixed == 1 && $status_unfixed != 1} {return "fixed"}
    19772041     if {$status_fixed == 1 && $status_unfixed == 1} {return "mixed"}
     
    19812045proc Fix_Write {} {
    19822046      incr ::expgui(changed)
    1983       puts "Prepare to write [array names ::fix_Param]"
     2047      #puts "Prepare to write [array names ::fix_Param]"
    19842048      foreach j [array names ::fix_param] {
    19852049             regexp {[0-9]+} $j  temp_phase
     
    19942058     foreach i $phaselist {
    19952059             catch {atom_constraint_write $i $fix_list($i)}
    1996              puts $fix_list($i)
     2060             #puts $fix_list($i)
    19972061     }
    19982062}
     
    20002064proc Fix_Atoms {phase numberList coord but} {
    20012065#     puts "before  ::fix_state_$coord [set ::fix_state_$coord]"
    2002      puts " before operationi: $::fix_list($coord,$phase)"
     2066     #puts " before operationi: $::fix_list($coord,$phase)"
    20032067     switch [set ::fix_state_$coord] {
    20042068     "unfixed" {$but config -text "fixed"
     
    20132077     }
    20142078     if {[set ::fix_state_$coord] == "fixed"} {
    2015         puts "fixing atom number $numberList"
     2079        #puts "fixing atom number $numberList"
    20162080        foreach i $numberList {
    20172081                lappend ::fix_list($coord,$phase) $i
     
    20212085     }
    20222086     if {[set ::fix_state_$coord] == "unfixed"} {
    2023         puts "unfixing atoms $numberList"
     2087        #puts "unfixing atoms $numberList"
    20242088        foreach i $numberList {
    20252089           set temp [lsearch $::fix_list($coord,$phase) $i]
     
    20302094        }
    20312095     }
    2032      puts "after operation: $::fix_list($coord,$phase)"
    2033 
    2034 
    2035 }
    2036 
    2037 #******Main Fixing Program
    2038     if {[lindex $expmap(phasetype) [expr {$p - 1}]] != 4} {
    2039         grid [TitleFrame $w.10 -bd 6 -relief groove \
    2040                 -text "Fix Atom$suffix Coordinates"] \
    2041                 -row 9 -column 0 -columnspan 10 -sticky news
    2042         set fix [$w.10 getframe]
    2043         Fix_Initialize $numberList
    2044 
    2045         label $fix.xlab -text "  x  " -width 8
    2046         label $fix.ylab -text "  y  " -width 8
    2047         label $fix.zlab -text "  z  " -width 8
    2048         grid $fix.xlab -row 2 -column 0
    2049         grid $fix.ylab -row 2 -column 1
    2050         grid $fix.zlab -row 2 -column 2
    2051 
    2052 
    2053         button $fix.x -text "$::fix_state_X" -width 8 \
    2054                -command "Fix_Atoms $phase [list $numberList] X $fix.x;
    2055                Fix_Write
    2056                DisplayAllAtoms $phase"
    2057 
    2058         button $fix.y -text "$::fix_state_Y" -width 8 \
    2059                 -command "Fix_Atoms $phase [list $numberList] Y $fix.y
    2060                 Fix_Write
    2061                 DisplayAllAtoms $phase"
    2062         button $fix.z -text "$::fix_state_Z" -width 8 \
    2063                 -command "Fix_Atoms $phase [list $numberList] Z $fix.z
    2064                 Fix_Write
    2065                 DisplayAllAtoms $phase"
    2066         grid $fix.x -row 3 -column 0
    2067         grid $fix.y -row 3 -column 1
    2068         grid $fix.z -row 3 -column 2
    2069     }
    2070 
    2071 
    2072 
    2073 
    2074 #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    2075 
    2076     grid rowconfigure $w 11 -minsize 5
    2077     grid [frame $w.b] -row 12 -column 0 -columnspan 10 -sticky ew
    2078     pack [button $w.b.3 -text Close -command "destroy $w"] -side left \
    2079             -padx 5 -pady 5
    2080     pack [button $w.b.help -text Help -bg yellow \
    2081             -command "MakeWWWHelp expgui2.html xform"] -side right \
    2082             -padx 5 -pady 5
    2083     bind $w <Return> "destroy $w"
    2084 
    2085     # force the window to stay on top
    2086     putontop $w
    2087     focus $w.b.3
    2088     tkwait window $w
    2089     afterputontop
    2090     # if there are selected atoms, reset their display
    2091     if {[llength $expgui(selectedatomlist)] != 0} editRecord
    2092 }
    2093 
     2096     #puts "after operation: $::fix_list($coord,$phase)"
     2097}
    20942098
    20952099
     
    28692873set newhist(dummy) 0
    28702874set newhist(instfiletext) {}
     2875set newhist(instbanks) {}
Note: See TracChangeset for help on using the changeset viewer.