Changeset 668


Ignore:
Timestamp:
Dec 4, 2009 5:10:01 PM (14 years ago)
Author:
toby
Message:

# on 2003/04/10 21:59:03, toby did:
leave filenames up for rawplot
set tmin properly for TOF
show text for bank selected
add Qmax option
add "run powpref" warning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/addcmds.tcl

    • Property rcs:date changed from 2002/09/05 18:16:00 to 2003/04/10 21:59:03
    • Property rcs:lines changed from +9 -6 to +141 -38
    • Property rcs:rev changed from 1.29 to 1.30
    r641 r668  
    215215    }
    216216    file delete exptool.in exptool.out
     217    # set the powpref warning (2 = required)
     218    set expgui(needpowpref) 2
     219    set msg "A phase was added"
     220    if {[string first $msg $expgui(needpowpref_why)] == -1} {
     221        append expgui(needpowpref_why) "\t$msg\n"
     222    }
    217223    # now select the new phase
    218224    SelectOnePhase [lindex $expmap(phaselist) end]   
     
    220226
    221227#----------- Add Histogram routines --------------------------------------
     228proc LabelInstParm {args} {
     229    global newhist
     230    switch $newhist(insttype) {
     231        TOF {
     232            set newhist(instfiletext) "Neutron Time of Flight"
     233            catch {
     234                set b $newhist(setnum)
     235                append newhist(instfiletext) ", 2theta = $newhist(inst${b}Angle)"
     236            }
     237        }
     238        ED {set newhist(instfiletext) "X-ray Energy Dispersive"}
     239        "CW X" {set newhist(instfiletext) "CW X-ray"}
     240        "CW N" {set newhist(instfiletext) "CW Neutron"}
     241    }
     242}
     243trace variable newhist(setnum) w LabelInstParm
    222244proc MakeAddHistBox {} {
    223245    global expmap newhist
     
    255277    grid [label $np.lset -text "Select set" -anchor w] -column 1 -row 6 -sticky w
    256278    grid [frame $np.set]  -column 2 -row 6 -columnspan 7 -sticky ew
    257 
    258     grid [button $np.f6a -text "Run\nRAWPLOT" -command RunRawplot] \
    259             -column 4 -row 8 -rowspan 2
    260     grid [label $np.l3 -text "Usable data limit:"] -column 0 -row 8 -rowspan 2
     279    grid [label $np.t2a -textvariable newhist(instfiletext) \
     280            -justify center -anchor center -fg blue] \
     281            -column 0 -row 8 -columnspan 99 -sticky ew
     282
     283    grid [button $np.f6a -text "Run\nRAWPLOT" -command "RunRawplot $np"] \
     284            -column 4 -row 18 -rowspan 2
     285    grid [label $np.l3 -text "Usable data limit:"] -column 0 -row 18 -rowspan 3
    261286    grid [entry $np.e3 -width 12 -textvariable newhist(2tLimit) \
    262             ] -column 1 -row 8 -rowspan 2
     287            ] -column 1 -row 18 -rowspan 3
    263288    grid [radiobutton $np.cb3 -text "D-min" -variable newhist(LimitMode) \
    264             -value 0] -column 2 -row 8 -sticky w
     289            -value 0] -column 2 -row 18 -sticky w
    265290    grid [radiobutton $np.cb4 -textvariable newhist(limitLbl)  \
    266291            -variable newhist(LimitMode) -anchor w -justify l \
    267             -value 1] -column 2 -row 9 -sticky w
     292            -value 1] -column 2 -row 20 -sticky w
     293    grid [radiobutton $np.cb5 -text "Q-max" -variable newhist(LimitMode) \
     294            -value 2] -column 2 -row 19 -sticky w
    268295    set newhist(limitLbl) "TOF-min\n2-Theta Max"
    269296    # spacers
     
    273300            -columnspan 20 -column 0 -row 4 -sticky nsew -ipady 2
    274301    grid [frame $np.sp2 -bg white] \
    275             -columnspan 20 -column 0 -row 7 -sticky nsew -ipady 2
     302            -columnspan 20 -column 0 -row 17 -sticky nsew -ipady 2
    276303    grid [frame $np.sp3 -bg white] \
    277304            -columnspan 20 -column 0 -row 98 -sticky nsew -ipady 2
     
    349376        set len [gets $in line]
    350377        if {$len > 160} {
    351             # this is a UNIX file. Hope there are no control characters
     378            # this is an old-style UNIX file. Hope there are no control characters
    352379            set i 0
    353380            set j 79
     
    490517    set num $newhist(banknum)
    491518    if {$newhist(insttype) == "TOF"} {
    492         set newhist(2tLimit) $newhist(tmin$num)
     519        set newhist(2tLimit) [expr {$newhist(tmin$num) / 10.}]
    493520        if {[llength $newhist(banklist)] == $newhist(instbanks)} {
    494521            set newhist(setnum) $newhist(banknum)
     
    557584                    [string trim [string range $line 12 end]]
    558585        }
    559         # scan for the INS   BANK line
     586        # scan for the INS   HTYPE line
    560587        if {[string first "INS   HTYPE" $line] == 0} {
    561588            if {[string index [lindex $line 2] 2] == "T"} {
     
    563590            } elseif {[string index [lindex $line 2] 2] == "E"} {
    564591                set newhist(insttype) ED
     592            } elseif {[string index [lindex $line 2] 1] == "X"} {
     593                set newhist(insttype) "CW X"
    565594            } else {
    566                 set newhist(insttype) CW
     595                set newhist(insttype) "CW N"
    567596            }
    568597        }
     
    575604            set b [string trim $b]
    576605            set newhist(inst${b}ITYP) [string trim $c]
     606        }
     607        if {[regexp {INS ([ 1-9][0-9])BNKPAR(.*)} $line a b c]} {
     608            set b [string trim $b]
     609            set newhist(inst${b}Angle) [string trim [lindex $c 1]]
    577610        }
    578611    }
     
    604637    }
    605638    if {$newhist(dummy)} {PostDummyOpts $np; ValidateDummyHist $np}
     639    LabelInstParm
    606640}
    607641
     
    634668    } elseif {[catch {expr $newhist(2tLimit)}]} {
    635669        append err "  The 2Theta/d-space limit is not valid\n"
     670    } elseif {$newhist(2tLimit) <= 0} {
     671        append err "  The 2Theta/d-space limit is not valid\n"
    636672    }
    637673    if {[string trim $newhist(LimitMode)] == ""} {
    638         append err "  Please choose between either a 2Theta or d-space limit\n"
     674        append err "  Please choose between either a 2Theta, Q or d-space limit\n"
    639675    }
    640676
     
    659695    puts $fp $newhist(banknum)
    660696    puts $fp $newhist(setnum)
    661     if {$newhist(LimitMode)} {
     697    if {$newhist(LimitMode) == 1} {
    662698        puts $fp "T"
    663     } else {
     699        puts $fp "$newhist(2tLimit)"
     700    } elseif {$newhist(LimitMode) == 2} {
    664701        puts $fp "D"
    665     }
    666     puts $fp "$newhist(2tLimit)"
     702        set Q 100
     703        catch {set Q [expr {4*acos(0)/$newhist(2tLimit)}]}
     704        puts $fp "$Q"
     705    } else {
     706        puts $fp "D"
     707        puts $fp "$newhist(2tLimit)"
     708    }
    667709    puts $fp "/"
    668710    puts $fp "X"
     
    705747    }
    706748    file delete exptool.in exptool.out
    707 }
    708 
    709 proc RunRawplot {} {
     749    # set the powpref warning (2 = required)
     750    set expgui(needpowpref) 2
     751    set msg "A histogram was added"
     752    if {[string first $msg $expgui(needpowpref_why)] == -1} {
     753        append expgui(needpowpref_why) "\t$msg\n"
     754    }
     755    # select the most recently added histogram
     756    if {!$err} {
     757        set i [llength $expmap(histlistboxcontents)]
     758        if {$i > 0} {
     759            incr i -1
     760            set expgui(curhist) $i
     761            sethistlist
     762        }
     763    }
     764}
     765
     766proc RunRawplot {parent} {
    710767    global newhist tcl_platform
     768    set f1 $newhist(rawfile)
     769    set f2 $newhist(instfile)
    711770    # for Windows put a message on top, in case file names must be shortened
    712771    if {$tcl_platform(platform) == "windows"} {
    713         set f1 {}
    714772        catch {set f1 [file nativename \
    715773                    [file attributes $newhist(rawfile) -shortname]]}
    716         set f2 {}
    717774        catch {set f2 [file nativename \
    718775                [file attributes $newhist(instfile) -shortname]]}
    719         if {$f1 != "" || $f2 != ""} {
    720             set msg "Note: input to RAWPLOT\n"
    721             if {$f1 != ""} {append msg "data file: $f1\n"}
    722             if {$f2 != ""} {append msg "instrument file: $f2"}
    723             MyMessageBox -icon info -message $msg -parent .
    724         }
     776    }
     777    if {$f1 != "" || $f2 != ""} {
     778        #set msg "Note: input to RAWPLOT\n"
     779        #if {$f1 != ""} {append msg "data file: $f1\n"}
     780        #if {$f2 != ""} {append msg "instrument file: $f2"}
     781        catch {toplevel $parent.msg}
     782        catch {eval destroy [winfo children $parent.msg]}
     783        wm title $parent.msg "File names"
     784        grid [label $parent.msg.1 \
     785                -text "File names to be input to RAWPLOT" \
     786                -justify center -anchor center] \
     787                -col 0 -row 0 -columnspan 2
     788        if {$f1 != ""} {
     789            grid [label $parent.msg.2a \
     790                    -text "Raw histogram: $f1" \
     791                    -justify center -anchor e] \
     792                    -col 0 -row 1
     793            grid [button $parent.msg.2b \
     794                    -command "clipboard clear; clipboard append $f1" \
     795                    -text "put name\nin clipboard"] \
     796                    -col 1 -row 1
     797        }           
     798        if {$f2 != ""} {
     799            grid [label $parent.msg.3a \
     800                    -text "Raw histogram: $f2" \
     801                    -justify center -anchor e] \
     802                    -col 0 -row 2
     803            grid [button $parent.msg.3b \
     804                    -command "clipboard clear; clipboard append $f2" \
     805                    -text "put name\nin clipboard"] \
     806                    -col 1 -row 2
     807        }           
     808        grid [button $parent.msg.4 \
     809                -command "destroy $parent.msg" \
     810                -text "Close"] \
     811                -col 0 -columnspan 2 -row 9
    725812    }
    726813    # start RAWPLOT
    727814    runGSASprog rawplot 1
     815    if {[winfo exists $parent.msg]} {raise $parent.msg}
     816    update
    728817}
    729818#--- Dummy histogram stuff
     
    740829        $np.d1.m2 config -text {}
    741830        $np.b1 config -state disabled
    742         grid forget $np.l3 $np.e3 $np.cb3 $np.cb4 $np.bank $np.f6a
    743         grid $np.dl1 -column 0 -row 8
    744         grid $np.d1 -column 1 -row 8 -rowspan 2 -columnspan 4 -sticky e
    745         grid $np.dl3 -column 0 -columnspan 99 -row 10 -sticky ew
     831        grid forget $np.l3 $np.e3 $np.cb3 $np.cb4 $np.cb5 $np.bank $np.f6a
     832        grid $np.dl1 -column 0 -row 18
     833        grid $np.d1 -column 1 -row 18 -rowspan 2 -columnspan 4 -sticky e
     834        grid $np.dl3 -column 0 -columnspan 99 -row 20 -sticky ew
    746835        if {$newhist(insttype) == "TOF"} {
    747836            $np.dl1 config -text "Data range:\n(TOF)"
    748837            $np.d1.lu config -text millisec
    749             grid $np.dl2 -column 0 -row 9
     838            grid $np.dl2 -column 0 -row 19
    750839            catch {
    751840                set s $newhist(setnum)
     
    754843                $np.d1.m2 config -text $tmax
    755844            }
    756         } elseif {$newhist(insttype) == "CW"} {
     845        } elseif {[lindex $newhist(insttype) 0] == "CW"} {
    757846            $np.dl1 config -text "Data range:\n(2Theta)"
    758847            $np.d1.lu config -text degrees
     
    765854            $np.d1.m1 config -text 1.
    766855            $np.d1.m2 config -text 200.
    767             grid $np.dl2 -column 0 -row 9
     856            grid $np.dl2 -column 0 -row 19
    768857        } else {
    769858            $np.dl1 config -text "No file\nselected"
     
    782871        $np.b1 config -state normal
    783872        grid $np.bank -column 2 -row 3 -columnspan 7 -sticky ew
    784         grid $np.f6a -column 4 -row 8 -rowspan 2
    785         grid $np.l3 -column 0 -row 8 -rowspan 2
    786         grid $np.e3 -column 1 -row 8 -rowspan 2
    787         grid $np.cb3 -column 2 -row 8 -sticky w
    788         grid $np.cb4 -column 2 -row 9 -sticky w
     873        grid $np.f6a -column 4 -row 18 -rowspan 3
     874        grid $np.l3 -column 0 -row 18 -rowspan 3
     875        grid $np.e3 -column 1 -row 18 -rowspan 3
     876        grid $np.cb3 -column 2 -row 18 -sticky w
     877        grid $np.cb4 -column 2 -row 20 -sticky w
     878        grid $np.cb5 -column 2 -row 19 -sticky w
    789879     }
    790880}
     
    839929                    [lindex $newhist(inst${s}ICONS) 0]}]
    840930        }
    841     } elseif {$newhist(insttype) == "CW"} {
     931    } elseif {[lindex $newhist(insttype) 0] == "CW"} {
    842932        if {$newhist(tmin) <= 0 } {
    843933            $np.d1.e1 config -fg red
     
    9681058    }
    9691059    file delete exptool.in exptool.out
     1060    # set the powpref warning (2 = required)
     1061    set expgui(needpowpref) 2
     1062    set msg "A histogram was added"
     1063    if {[string first $msg $expgui(needpowpref_why)] == -1} {
     1064        append expgui(needpowpref_why) "\t$msg\n"
     1065    }
    9701066}
    9711067
     
    19432039    }
    19442040    file delete exptool.in exptool.out
     2041    # set the powpref warning (2 = required)
     2042    set expgui(needpowpref) 2
     2043    set msg "A phase was replaced"
     2044    if {[string first $msg $expgui(needpowpref_why)] == -1} {
     2045        append expgui(needpowpref_why) "\t$msg\n"
     2046    }
    19452047    destroy $top
    19462048}
     
    19972099set newhist(insttype) {}
    19982100set newhist(dummy) 0
     2101set newhist(instfiletext) {}
Note: See TracChangeset for help on using the changeset viewer.