Changeset 1116 for trunk


Ignore:
Timestamp:
Mar 2, 2011 9:29:09 AM (10 years ago)
Author:
toby
Message:

fix Ashfia's tmin problem again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/addcmds.tcl

    r1025 r1116  
    197197    # validate the input
    198198    set err {}
     199    set warn {}
    199200    set title [$np.t1 get]
    200201    if {[string trim $title] == ""} {
     
    231232            append spg " R"
    232233            if {$err == ""} {
    233                 # no need to warn on error
    234                 MyMessageBox -parent $np -title "Space Group Fix" \
    235                 -message "Adding a final 'R' to the space group for rhombohedral space group set in rhombohedral cell, as required in GSAS" \
    236                 -icon warning
     234                append warn "Note that a rhombohedral setting was used, the space group symbol ($spg) as been flagged accordingly\n"
    237235            }
    238236        }
     
    315313    }
    316314    # now select the new phase
    317     SelectOnePhase [lindex $expmap(phaselist) end]   
     315    set phase [lindex $expmap(phaselist) end]
     316    SelectOnePhase $phase
     317    SpaceGroupWarnings $warn $phase $spg
    318318}
    319319
     
    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
     
    25192531        incr expgui(changed)
    25202532    }
     2533    set expmap(atomlist_$phase) {}
    25212534    RecordMacroEntry "incr expgui(changed)" 0
    25222535    # write new atoms from table as input to exptool
    25232536    set errmsg [runAddAtoms $phase $atomlist]
    25242537    RecordMacroEntry "runAddAtoms $phase [list $atomlist]" 0
     2538    SpaceGroupWarnings "" $phase $spg
    25252539    return $errmsg
     2540}
     2541
     2542proc SpaceGroupWarnings {warn phase spg} {
     2543    # warning on possible origin 1 setting
     2544    set shift [GetOrigin1Shift $phase]
     2545    if {$shift != ""} {
     2546        append warn "Note that this space group ($spg) has both Origin 1 and Origin 2 settings. Origin 2 must be used in GSAS. Please check atom multiplicities (or use the Results/composition command) to verify you have the correct origin setting. Note that the Xform Atoms/Xform Origin 1 to Origin 2 button can be used to correct this.\n"
     2547    }
     2548    if {$warn != ""} {
     2549        MyMessageBox -parent . -title "Space Group Note" \
     2550            -message $warn -icon warning
     2551    }
    25262552}
    25272553
     
    27162742set newhist(dummy) 0
    27172743set newhist(instfiletext) {}
     2744set newhist(instbanks) {}
Note: See TracChangeset for help on using the changeset viewer.