Changeset 1166


Ignore:
Timestamp:
08/17/11 18:17:04 (8 years ago)
Author:
toby
Message:

bring sandbox changes over to main release

Location:
trunk
Files:
26 added
2 deleted
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/Geo_Viewer.tcl

    r1025 r1166  
    4747     array set ::geo_bonds "" 
    4848     set ::geo_alist "" 
     49     set ::geo_filterval 5.00 
    4950} 
    5051 
     
    6061   set angle_total -1 
    6162 
     63   set ::geo_phase_list {} 
     64   catch {unset ::geo_angles} 
     65   catch {unset ::geo_bonds} 
    6266   array set ::geo_bonds "" 
    6367   array set ::geo_angles "" 
    6468   array set ::geo_angle_keys "" 
     69 
    6570 
    6671   while {[gets $fh line] >= 0} { 
     
    143148    Geo_Read $root.disagl 
    144149    donewait 
     150    if {[llength  $::geo_phase_list] == 0} { 
     151        MyMessageBox -parent . -title "DISAGL Problem" \ 
     152            -message "No output found in DISAGL output. Is something wrong with DISAGL settings or this .EXP file?" \ 
     153            -icon error 
     154        return 
     155    } 
    145156     set mcb .maincontrolbox 
    146157     catch {toplevel $mcb} 
     
    175186     eval tk_optionMenu $sc.phase ::geo_entryvar(phase) $::geo_phase_list 
    176187     label $sc.atom1 -text "Atom Type" 
     188     label $sc.filterlab -text "Dmax Filter" 
     189     entry $sc.filterval -textvariable ::geo_filterval 
     190          $sc.filterval config -width 6 
    177191     #button $sc.engage -text "Print Info" -command Geo_Fill_Display 
    178192     grid $sc.phlabel -row 0 -column 0 
    179      grid $sc.phase  -row 0 -column 1 
    180      grid $sc.atom1 -column 0 -row 1 
     193     grid $sc.phase   -row 0 -column 1 
     194     grid $sc.atom1   -row 1 -column 0 
     195     grid $sc.filterlab   -row 2 -column 0 
     196     grid $sc.filterval -row 2 -column 1 
    181197 
    182198     label $as.atom -text "Choose Atom(s)" 
     
    270286     label $top.toplabel1 -text "Atom 2" -width 8 
    271287     label $top.toplabel2 -text "symm" -width 8 
    272      label $top.toplabel3 -text "Distance" -width 8 
     288     label $top.toplabel3 -text "Distance" -width 10 
    273289     label $top.toplabel4 -text "Angle" 
    274290#     grid $top.toplabel0 -column 0 -row 0 
     
    293309             set symlist {} 
    294310             incr rownum 
     311             if {[string trim $::geo_filterval] == ""} {set ::geo_filterval 5.00} 
    295312             foreach j $slist { 
    296                  lappend keylist [lindex $j 10] 
    297                  lappend atmlist [lindex $j 6] 
    298                  lappend symlist [lindex $j 9] 
    299                  label $::geo_side.atom1${bondnum} -text [lindex $j 5] -width 8 
    300                  label $::geo_main.atom2${bondnum} -text [lindex $j 6] -width 8 
    301                  label $::geo_main.atom2symm${bondnum} -text [lindex $j 9] -width 8 
    302                  label $::geo_main.bonddist${bondnum} -text [lindex $j 7] -width 8 
    303  
    304                  grid $::geo_side.atom1${bondnum} -row $rownum -column 0 
    305                  grid $::geo_main.atom2${bondnum} -row $rownum -column 0 
    306                  grid $::geo_main.atom2symm${bondnum} -row $rownum -column 1 
    307                  grid $::geo_main.bonddist${bondnum} -row $rownum -column 2 
    308  
    309                  set key [lindex $j 10] 
    310                  set atom [lindex $j 1] 
    311                  set phase [lindex $j 0] 
    312  
    313  
    314                  foreach k $keylist { 
    315  
    316                  if {$key != $k} { 
    317                     if {[array name ::geo_angles "$phase,$key,$atom,$k"] != ""} { 
    318                     label $::geo_main.$counter -text [lindex $::geo_angles($phase,$key,$atom,$k) 7] 
    319                     grid $::geo_main.$counter -row $rownum -column $colnum -padx 5 
    320                     incr colnum 
    321                     incr counter 
    322                     } elseif {[array name ::geo_angles "$phase,$k,$atom,$key"] != ""} { 
    323                     label $::geo_main.$counter -text [lindex $::geo_angles($phase,$k,$atom,$key) 7] 
    324                     grid $::geo_main.$counter -row $rownum -column $colnum -padx 5 
    325  
    326                     incr colnum 
    327                     incr counter 
     313                 if {[lindex $j 7] <= $::geo_filterval} { 
     314                    lappend keylist [lindex $j 10] 
     315                    lappend atmlist [lindex $j 6] 
     316                    lappend symlist [lindex $j 9] 
     317                    label $::geo_side.atom1${bondnum} -text [lindex $j 5] -width 8 
     318                    label $::geo_main.atom2${bondnum} -text [lindex $j 6] -width 8 
     319                    label $::geo_main.atom2symm${bondnum} -text [lindex $j 9] -width 8 
     320                    set bonddist [lindex $j 7] 
     321                    set bondesd  [lindex $j 8] 
     322                    set bondentry [formatSU $bonddist $bondesd] 
     323                    label $::geo_main.bonddist${bondnum} -text $bondentry -width 10 
     324 
     325                    grid $::geo_side.atom1${bondnum} -row $rownum -column 0 
     326                    grid $::geo_main.atom2${bondnum} -row $rownum -column 0 
     327                    grid $::geo_main.atom2symm${bondnum} -row $rownum -column 1 
     328                    grid $::geo_main.bonddist${bondnum} -row $rownum -column 2 
     329 
     330                    set key [lindex $j 10] 
     331                    set atom [lindex $j 1] 
     332                    set phase [lindex $j 0] 
     333 
     334 
     335                    foreach k $keylist { 
     336 
     337                            if {$key != $k} { 
     338                            # search for atom 1 - central atom - atom 2 angle. 
     339                            if {[array name ::geo_angles "$phase,$key,$atom,$k"] != ""} { 
     340                               set ang  [lindex $::geo_angles($phase,$key,$atom,$k) 7] 
     341                               set angesd [lindex $::geo_angles($phase,$key,$atom,$k) 8] 
     342                               set angentry [formatSU $ang $angesd] 
     343                               label $::geo_main.$counter -text $angentry 
     344#                               label $::geo_main.$counter -text [lindex $::geo_angles($phase,$key,$atom,$k) 7] 
     345                               grid $::geo_main.$counter -row $rownum -column $colnum -padx 5 
     346                               incr colnum 
     347                               incr counter 
     348                               # search for atom 2 - central atom - atom 1 angle. 
     349                            } elseif {[array name ::geo_angles "$phase,$k,$atom,$key"] != ""} { 
     350                               set ang  [lindex $::geo_angles($phase,$k,$atom,$key) 7] 
     351                               set angesd [lindex $::geo_angles($phase,$k,$atom,$key) 8] 
     352                               set angentry [formatSU $ang $angesd] 
     353                               label $::geo_main.$counter -text $angentry 
     354#                              label $::geo_main.$counter -text [lindex $::geo_angles($phase,$k,$atom,$key) 7] 
     355                              grid $::geo_main.$counter -row $rownum -column $colnum -padx 5 
     356 
     357                              incr colnum 
     358                              incr counter 
     359                            } 
     360                            } 
    328361                    } 
    329  
    330                  } 
    331                  } 
    332362                 incr bondnum 
    333                 incr rownum 
     363                 incr rownum 
    334364                 set colnum 3 
    335  
     365             } 
    336366             } 
    337367                  set colnum 3 
  • trunk/addcmds.tcl

    r1116 r1166  
    709709    # mode must be t-max or 2theta, at least for now 
    710710    if {$newhist(LimitMode) != 1} return 
    711     # is a instrument parameter file loaded? If not, try again later 
    712     if {[string trim $newhist(instfile)] == ""} return 
    713711    # get data bank number, test if valid 
    714712    set num $newhist(banknum) 
    715713    if {[catch {expr $num}]} {return} 
    716714    if {$newhist(insttype) == "TOF"} { 
     715        # is a instrument parameter file loaded? If not, try again later 
     716        if {[string trim $newhist(instfile)] == ""} return 
    717717        set newhist(2tLimit) [expr {$newhist(tmin$num) / 10.}] 
    718718        # at Ashfia's request, override the bank header # with the  
     
    740740        set inp [ 
    741741        tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes { 
    742             {"Inst files" .INS*} {"Inst files" .ins*}  
     742            {"Inst files" .INS*} {"Inst files" .ins*} 
    743743            {"Inst files" .PRM}  {"Inst files" .prm}  
    744744            {"All files" *} 
     
    937937    puts $fp "H" 
    938938    if {$tcl_platform(platform) == "windows"} { 
    939         puts $fp [file attributes $rawfile -shortname] 
    940         puts $fp [file attributes $instfile -shortname] 
     939        if {[string length $rawfile] > 50} { 
     940            puts $fp [file attributes $rawfile -shortname] 
     941        } else { 
     942            puts $fp $rawfile 
     943        } 
     944        if {[string length $instfile] > 50} {             
     945            puts $fp [file attributes $instfile -shortname] 
     946        } else { 
     947            puts $fp $instfile 
     948        } 
    941949    } else { 
    942950        puts $fp $rawfile 
     
    16371645        grid $top.scroll -sticky ns -column 4 -row 2 
    16381646    } else { 
    1639         grid forget $top.scroll  
     1647        grid forget $top.scroll 
    16401648    } 
    16411649    update 
     
    19491957    } 
    19501958 
     1959    # allow fixing of atom coordinates 
     1960    if {[lindex $expmap(phasetype) [expr {$p - 1}]] != 4} { 
     1961        grid [TitleFrame $w.10 -bd 6 -relief groove \ 
     1962                -text "Fix Atom$suffix Coordinates"] \ 
     1963                -row 9 -column 0 -columnspan 10 -sticky news 
     1964        set fix [$w.10 getframe] 
     1965        Fix_Initialize $numberList 
     1966 
     1967        label $fix.xlab -text "  x  " -width 8 
     1968        label $fix.ylab -text "  y  " -width 8 
     1969        label $fix.zlab -text "  z  " -width 8 
     1970        grid $fix.xlab -row 2 -column 0 
     1971        grid $fix.ylab -row 2 -column 1 
     1972        grid $fix.zlab -row 2 -column 2 
     1973 
     1974 
     1975        button $fix.x -text "$::fix_state_X" -width 8 \ 
     1976               -command "Fix_Atoms $phase [list $numberList] X $fix.x; 
     1977               Fix_Write 
     1978               DisplayAllAtoms $phase" 
     1979 
     1980        button $fix.y -text "$::fix_state_Y" -width 8 \ 
     1981                -command "Fix_Atoms $phase [list $numberList] Y $fix.y 
     1982                Fix_Write 
     1983                DisplayAllAtoms $phase" 
     1984        button $fix.z -text "$::fix_state_Z" -width 8 \ 
     1985                -command "Fix_Atoms $phase [list $numberList] Z $fix.z 
     1986                Fix_Write 
     1987                DisplayAllAtoms $phase" 
     1988        grid $fix.x -row 3 -column 0 
     1989        grid $fix.y -row 3 -column 1 
     1990        grid $fix.z -row 3 -column 2 
     1991    } 
     1992    #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     1993 
    19511994    grid rowconfigure $w 11 -minsize 5 
    19521995    grid [frame $w.b] -row 12 -column 0 -columnspan 10 -sticky ew 
     
    19662009    if {[llength $expgui(selectedatomlist)] != 0} editRecord 
    19672010} 
     2011 
     2012#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x 
     2013 
     2014proc Fix_Initialize {numberList} { 
     2015     set phaselist $::expmap(phaselist) 
     2016     catch {unset ::fix_param} 
     2017     foreach i $phaselist { 
     2018             set ::fix_list(X,$i) "" 
     2019             set ::fix_list(Y,$i) "" 
     2020             set ::fix_list(Z,$i) "" 
     2021 
     2022             set temp [atom_constraint_read $i] 
     2023             foreach j $temp { 
     2024                     set atomnum [string trim [string range $j 2 3]] 
     2025                     set param [string trim [string range $j 4 6]] 
     2026                     set ::fix_param($i,$atomnum,$param) 1 
     2027                     if {$param == "X"} {lappend ::fix_list(X,$i) $atomnum} 
     2028                     if {$param == "Y"} {lappend ::fix_list(Y,$i) $atomnum} 
     2029                     if {$param == "Z"} {lappend ::fix_list(Z,$i) $atomnum} 
     2030             } 
     2031     } 
     2032    set ::fix_state_X [Fix_State $i $numberList X] 
     2033    set ::fix_state_Y [Fix_State $i $numberList Y] 
     2034    set ::fix_state_Z [Fix_State $i $numberList Z] 
     2035} 
     2036 
     2037proc Fix_State {phase numberList coord} { 
     2038     set status_fixed "-1" 
     2039     set status_unfixed "-1" 
     2040     #puts "$coord before: $status_fixed $status_unfixed" 
     2041     foreach i $numberList { 
     2042         set temp [info exists ::fix_param($phase,$i,$coord)] 
     2043         #puts "::fix_param($phase,$i,$coord) is variable present?: $temp" 
     2044         if {$temp != 0} {set status_fixed 1} 
     2045         if {$temp == 0} {set status_unfixed 1} 
     2046     } 
     2047     #puts "$coord after $status_fixed $status_unfixed" 
     2048     if {$status_fixed == 1 && $status_unfixed != 1} {return "fixed"} 
     2049     if {$status_fixed == 1 && $status_unfixed == 1} {return "mixed"} 
     2050     if {$status_fixed != 1 && $status_unfixed == 1} {return "unfixed"} 
     2051} 
     2052 
     2053proc Fix_Write {} { 
     2054      incr ::expgui(changed) 
     2055      #puts "Prepare to write [array names ::fix_Param]" 
     2056      foreach j [array names ::fix_param] { 
     2057             regexp {[0-9]+} $j  temp_phase 
     2058             regexp {,[0-9]+} $j ans 
     2059             set temp_atom [string range $ans 1 end] 
     2060             regexp {[a-zA-Z]+} $j temp_param 
     2061             if {$temp_param == "U"} {regexp {[a-zA-Z]+[0-9]+} $j temp_param} 
     2062             set temp_entry [format "%1s %+2s%-4s" $temp_phase $temp_atom $temp_param] 
     2063             lappend fix_list($temp_phase) $temp_entry 
     2064     } 
     2065     set phaselist $::expmap(phaselist) 
     2066     foreach i $phaselist { 
     2067             catch {atom_constraint_write $i $fix_list($i)} 
     2068             catch  {RecordMacroEntry "catch {atom_constraint_write $i $fix_list($i)}" 0} 
     2069             #puts $fix_list($i) 
     2070     } 
     2071} 
     2072 
     2073proc Fix_Atoms {phase numberList coord but} { 
     2074#     puts "before  ::fix_state_$coord [set ::fix_state_$coord]" 
     2075     #puts " before operationi: $::fix_list($coord,$phase)" 
     2076     switch [set ::fix_state_$coord] { 
     2077     "unfixed" {$but config -text "fixed" 
     2078               set ::fix_state_$coord "fixed" 
     2079               } 
     2080     "fixed"   {$but config -text "unfixed" 
     2081               set ::fix_state_$coord "unfixed" 
     2082               } 
     2083     "mixed"   {$but config -text "unfixed" 
     2084               set ::fix_state_$coord "unfixed" 
     2085               } 
     2086     } 
     2087     if {[set ::fix_state_$coord] == "fixed"} { 
     2088        #puts "fixing atom number $numberList" 
     2089        foreach i $numberList { 
     2090                lappend ::fix_list($coord,$phase) $i 
     2091                set ::fix_list($coord,$phase) [lsort -uniq -integer $::fix_list($coord,$phase)] 
     2092                set ::fix_param($phase,$i,$coord) 1 
     2093        } 
     2094     } 
     2095     if {[set ::fix_state_$coord] == "unfixed"} { 
     2096        #puts "unfixing atoms $numberList" 
     2097        foreach i $numberList { 
     2098           set temp [lsearch $::fix_list($coord,$phase) $i] 
     2099           if {$temp != -1} { 
     2100              set ::fix_list($coord,$phase) [lreplace $::fix_list($coord,$phase) $temp $temp] 
     2101              catch {unset ::fix_param($phase,$i,$coord)} 
     2102           } 
     2103        } 
     2104     } 
     2105     #puts "after operation: $::fix_list($coord,$phase)" 
     2106} 
     2107 
    19682108 
    19692109# transform the coordinates 
  • trunk/disagledit.tcl

    r1025 r1166  
    11proc DA_Initialize {} { 
    2 catch {unset ::da_ddrad} 
    3 catch {unset ::da_darad} 
    4 catch {unset ::da_drad} 
    5 catch {unset ::da_arad} 
    6 catch {unset ::da_acon} 
    7 catch {unset ::da_dcon} 
     2    catch {unset ::da_ddrad} 
     3    catch {unset ::da_darad} 
     4    catch {unset ::da_drad} 
     5    catch {unset ::da_arad} 
     6    catch {unset ::da_acon} 
     7    catch {unset ::da_dcon} 
    88    set ::da_quit 1 
    9 set ::da_phase $::expmap(phaselist) 
    10 foreach j $::da_phase { 
     9    set ::da_phase $::expmap(phaselist) 
     10    foreach j $::da_phase { 
    1111        set ::da_dcon($j) [phaseinfo $j DistCalc] 
    1212        set b [regexp -all {[0-9]} $::da_dcon($j)] 
    1313        if {$b > 0} { 
    14            set ::da_dval($j) $::da_dcon($j)] 
    15            } else { 
    16              set ::da_dval$j "" 
     14            set ::da_dval($j) $::da_dcon($j)] 
     15    } else { 
     16        set ::da_dval$j "" 
     17    } 
     18 
     19    set ::da_acon($j) [phaseinfo $j AngCalc] 
     20    set c [regexp -all {[0-9]} $::da_acon($j)] 
     21    if {$c > 0} {set ::da_aval$j $::da_acon($j) 
     22    } else { 
     23        set ::da_aval$j ""} 
     24 
     25} 
     26 
     27} 
     28 
     29proc DA_Read {} { 
     30 
     31    set ::da_list [AtmTypList] 
     32    set da_angrad [DefAtmTypInfo angrad] 
     33    set da_distrad [DefAtmTypInfo distrad] 
     34 
     35    #Build search arrays 
     36    #::da_darad array contains default angle search radii 
     37    #::da_ddrad array contains default distance search radii 
     38    #::da_arad array contains current angle search radii 
     39    #::da_drad array contains current distance search radii 
     40 
     41    foreach j $da_angrad { 
     42        set ::da_darad([lindex $j 0]) [lindex $j 1] 
     43    } 
     44    foreach k $da_distrad { 
     45        set ::da_ddrad([lindex $k 0]) [lindex $k 1] 
     46    } 
     47    foreach i $::da_list { 
     48        set ::da_drad($i) [AtmTypInfo distrad $i] 
     49        set ::da_arad($i) [AtmTypInfo angrad $i] 
     50    } 
     51} 
     52 
     53#**************** Build Disagl Control Panel **************************** 
     54 
     55proc DA_Control_Panel {"launchdisagl 0"} { 
     56    DA_Initialize 
     57    DA_Read 
     58    destroy .disaglcon 
     59    set dcb .disaglcon 
     60    catch {toplevel $dcb} 
     61    eval destroy [winfo children $dcb] 
     62 
     63    #construct phase control box in phasecon frame 
     64    set phasecon $dcb.phasecon 
     65    frame $phasecon -bd 2 -relief groove 
     66    grid $phasecon -column 0 -row 0 
     67 
     68    label $phasecon.lbl1 -text "Bond Search \n Method" 
     69    label $phasecon.lbl2 -text "Angle Search \n Method" 
     70    grid  $phasecon.lbl1 -column 1 -row 0 
     71    grid  $phasecon.lbl2 -column 2 -row 0 
     72 
     73 
     74    foreach i $::da_phase { 
     75        label  $phasecon.phase$i -text "Phase $i" -width 8 
     76        set tacon [regexp {[0-9]+.[0-9]+} $::da_acon($i)] 
     77        set tdcon [regexp {[0-9]+.[0-9]+} $::da_dcon($i)] 
     78        if {$tacon} {set alist {none radii $::da_acon($i)} 
     79        } else {set alist {none radii {fixed search range}}} 
     80        if {$tdcon} {set dlist {none radii $::da_dcon($i)} 
     81        } else {set dlist {none radii {fixed search range}}} 
     82 
     83        #            set list  {none radii {fixed search range}} 
     84        #if {[set ::da_dval$i] != ""} {lappend list [set ::da_dval$i]} 
     85        eval tk_optionMenu $phasecon.dist$i ::da_dcon($i) $dlist 
     86        $phasecon.dist$i config -width 10 
     87        eval tk_optionMenu $phasecon.ang$i  ::da_acon($i) $alist 
     88        $phasecon.ang$i config -width 10 
     89        grid   $phasecon.phase$i -row $i -column 0 -padx 10 
     90        grid   $phasecon.dist$i  -row $i -column 1 -padx 10 
     91        grid   $phasecon.ang$i   -row $i -column 2 -padx 10 
     92    } 
     93 
     94    trace var ::da_dcon w DA_Controls 
     95    trace var ::da_acon w DA_Controls 
     96 
     97 
     98    #save box 
     99    set dasave $dcb.dasave 
     100    frame $dasave -bd 2 -relief groove 
     101    grid $dasave -column 0 -row 2 
     102 
     103    if {$launchdisagl} { 
     104        wm title $dcb "DISAGL Control Panel" 
     105        grab release $dcb 
     106        checkbutton $dasave.option -text "DISAGL output in separate window" \ 
     107            -variable ::expgui(disaglSeparateBox) 
     108        grid $dasave.option -row 0 -column 0 
     109        button $dasave.sexit -text "Save and run DISAGL" -command DA_Save -bg LightGreen 
     110        grid $dasave.sexit -row 1 -column 0 
     111    } else { 
     112        wm title $dcb "Distance Search Parameters" 
     113        grab release $dcb 
     114        button $dasave.sexit -text "Save and Exit" -command DA_Save -bg LightGreen 
     115        grid $dasave.sexit -row 0 -column 0 
     116    } 
     117    button $dasave.quit -text "Cancel" -command "destroy $dcb" 
     118    grid $dasave.quit -row 2 -column 0 
     119 
     120 
     121    #construct control box 
     122 
     123 
     124    set dacon $dcb.dacon 
     125    frame $dacon -bd 2 -relief groove 
     126    grid $dacon -column 1 -row 2 
     127 
     128    button $dacon.default -text "Restore to Default Radii" -command { 
     129        foreach i $::da_list { 
     130            set ::da_drad($i) $::da_ddrad([lindex [split $i {+-}] 0]) 
     131            set ::da_arad($i) $::da_darad([lindex [split $i {+-}] 0]) 
     132        } 
     133    } 
     134    grid $dacon.default -row 3 -column 0 -columnspan 3 
     135 
     136    label $dacon.dradcon -text "Increment All Bond Search Radii (0.10 A)" 
     137    label $dacon.aradcon -text "Increment All Angle Search Radii (0.10 A)" 
     138    button $dacon.dradup -text "\u2191" -command DA_Inc_Drad 
     139    button $dacon.draddn -text "\u2193" -command DA_Dec_Drad 
     140    button $dacon.aradup -text "\u2191" -command DA_Inc_Arad 
     141    button $dacon.araddn -text "\u2193" -command DA_Dec_Arad 
     142    grid $dacon.dradcon -column 0 -row 0 -pady 5 
     143    grid $dacon.dradup  -column 1 -row 0 -padx 5 
     144    grid $dacon.draddn  -column 2 -row 0 -padx 5 
     145    grid $dacon.aradcon -column 0 -row 1 -pady 5 
     146    grid $dacon.aradup  -column 1 -row 1 -padx 5 
     147    grid $dacon.araddn  -column 2 -row 1 -padx 5 
     148 
     149    #     button $dacon.radcon -text "Radii Editor" -command {DA_Radii_Box .disaglcon} 
     150    #     grid $dacon.radcon -row 1 -column 0 
     151 
     152    DA_Radii_Box .disaglcon 
     153    putontop  .disaglcon 
     154    tkwait window .disaglcon 
     155    afterputontop 
     156    return $::da_quit 
     157 
     158} 
     159 
     160proc DA_Controls {var phase junk } { 
     161    if {[set ${var}($phase)] == "none"} { 
     162        if {$var == "::da_acon"} { 
     163            set ::da_dcon($phase) "none" 
     164            #puts 1 
     165        } else { 
     166            set ::da_acon($phase) "none" 
     167            #puts 2 
    17168        } 
    18  
    19         set ::da_acon($j) [phaseinfo $j AngCalc] 
    20         set c [regexp -all {[0-9]} $::da_acon($j)] 
    21         if {$c > 0} {set ::da_aval$j $::da_acon($j) 
     169    } 
     170    if {[set ${var}($phase)] != "none" && ($::da_dcon($phase) == "none" || $::da_acon($phase) == "none")} { 
     171        if {$var == "::da_acon"} { 
     172            set ::da_dcon($phase) "radii" 
    22173        } else { 
    23           set ::da_aval$j ""} 
    24  
    25 } 
    26  
    27 } 
    28  
    29 proc DA_Read {} { 
    30  
    31    set ::da_list [AtmTypList] 
    32    set da_angrad [DefAtmTypInfo angrad] 
    33    set da_distrad [DefAtmTypInfo distrad] 
    34  
    35    #Build search arrays 
    36    #::da_darad array contains default angle search radii 
    37    #::da_ddrad array contains default distance search radii 
    38    #::da_arad array contains current angle search radii 
    39    #::da_drad array contains current distance search radii 
    40  
    41    foreach j $da_angrad { 
    42        set ::da_darad([lindex $j 0]) [lindex $j 1] 
    43    } 
    44    foreach k $da_distrad { 
    45        set ::da_ddrad([lindex $k 0]) [lindex $k 1] 
    46    } 
    47    foreach i $::da_list { 
    48            set ::da_drad($i) [AtmTypInfo distrad $i] 
    49            set ::da_arad($i) [AtmTypInfo angrad $i] 
    50    } 
    51 } 
    52  
    53 #**************** Build Disagl Control Panel **************************** 
    54  
    55 proc DA_Control_Panel {"launchdisagl 0"} { 
    56      DA_Initialize 
    57      DA_Read 
    58      destroy .disaglcon 
    59      set dcb .disaglcon 
    60      catch {toplevel $dcb} 
    61      eval destroy [winfo children $dcb] 
    62  
    63      #construct phase control box in phasecon frame 
    64      set phasecon $dcb.phasecon 
    65      frame $phasecon -bd 2 -relief groove 
    66      grid $phasecon -column 0 -row 0 
    67  
    68      label $phasecon.lbl1 -text "Bond Search \n Method" 
    69      label $phasecon.lbl2 -text "Angle Search \n Method" 
    70      grid  $phasecon.lbl1 -column 1 -row 0 
    71      grid  $phasecon.lbl2 -column 2 -row 0 
    72  
    73  
    74      foreach i $::da_phase { 
    75              label  $phasecon.phase$i -text "Phase $i" -width 8 
    76              set tacon [regexp {[0-9]+.[0-9]+} $::da_acon($i)] 
    77              set tdcon [regexp {[0-9]+.[0-9]+} $::da_dcon($i)] 
    78              if {$tacon} {set alist {none radii $::da_acon($i)} 
    79                 } else {set alist {none radii {fixed search range}}} 
    80              if {$tdcon} {set dlist {none radii $::da_dcon($i)} 
    81                 } else {set dlist {none radii {fixed search range}}} 
    82  
    83 #            set list  {none radii {fixed search range}} 
    84              #if {[set ::da_dval$i] != ""} {lappend list [set ::da_dval$i]} 
    85              eval tk_optionMenu $phasecon.dist$i ::da_dcon($i) $dlist 
    86                   $phasecon.dist$i config -width 10 
    87              eval tk_optionMenu $phasecon.ang$i  ::da_acon($i) $alist 
    88                   $phasecon.ang$i config -width 10 
    89              grid   $phasecon.phase$i -row $i -column 0 -padx 10 
    90              grid   $phasecon.dist$i  -row $i -column 1 -padx 10 
    91              grid   $phasecon.ang$i   -row $i -column 2 -padx 10 
    92      } 
    93  
    94      trace var ::da_dcon w DA_Controls 
    95      trace var ::da_acon w DA_Controls 
    96  
    97  
    98      #save box 
    99      set dasave $dcb.dasave 
    100      frame $dasave -bd 2 -relief groove 
    101      grid $dasave -column 0 -row 2 
    102  
    103      if {$launchdisagl} { 
    104        wm title $dcb "DISAGL Control Panel" 
    105        grab release $dcb 
    106        checkbutton $dasave.option -text "DISAGL output in separate window" \ 
    107                    -variable ::expgui(disaglSeparateBox) 
    108        grid $dasave.option -row 0 -column 0 
    109        button $dasave.sexit -text "Save and run DISAGL" -command DA_Save -bg LightGreen 
    110        grid $dasave.sexit -row 1 -column 0 
    111      } else { 
    112        wm title $dcb "Distance Search Parameters" 
    113        grab release $dcb 
    114        button $dasave.sexit -text "Save and Exit" -command DA_Save -bg LightGreen 
    115        grid $dasave.sexit -row 0 -column 0 
    116      } 
    117      button $dasave.quit -text "Cancel" -command "destroy $dcb" 
    118      grid $dasave.quit -row 2 -column 0 
    119  
    120  
    121      #construct control box 
    122  
    123  
    124      set dacon $dcb.dacon 
    125      frame $dacon -bd 2 -relief groove 
    126      grid $dacon -column 1 -row 2 
    127  
    128      button $dacon.default -text "Restore to Default Radii" -command { 
    129             foreach i $::da_list { 
    130                     set ::da_drad($i) $::da_ddrad([lindex [split $i {+-}] 0]) 
    131                     set ::da_arad($i) $::da_darad([lindex [split $i {+-}] 0]) 
    132             } 
    133      } 
    134      grid $dacon.default -row 3 -column 0 -columnspan 3 
    135  
    136      label $dacon.dradcon -text "Increment All Bond Search Radii (0.10 A)" 
    137      label $dacon.aradcon -text "Increment All Angle Search Radii (0.10 A)" 
    138      button $dacon.dradup -text "\u2191" -command DA_Inc_Drad 
    139      button $dacon.draddn -text "\u2193" -command DA_Dec_Drad 
    140      button $dacon.aradup -text "\u2191" -command DA_Inc_Arad 
    141      button $dacon.araddn -text "\u2193" -command DA_Dec_Arad 
    142      grid $dacon.dradcon -column 0 -row 0 -pady 5 
    143      grid $dacon.dradup  -column 1 -row 0 -padx 5 
    144      grid $dacon.draddn  -column 2 -row 0 -padx 5 
    145      grid $dacon.aradcon -column 0 -row 1 -pady 5 
    146      grid $dacon.aradup  -column 1 -row 1 -padx 5 
    147      grid $dacon.araddn  -column 2 -row 1 -padx 5 
    148  
    149 #     button $dacon.radcon -text "Radii Editor" -command {DA_Radii_Box .disaglcon} 
    150 #     grid $dacon.radcon -row 1 -column 0 
    151  
    152 DA_Radii_Box .disaglcon 
    153              putontop  .disaglcon 
    154              tkwait window .disaglcon 
    155              afterputontop 
    156              return $::da_quit 
    157  
    158 } 
    159  
    160 proc DA_Controls {var phase junk } { 
    161      if {[set ${var}($phase)] == "none"} { 
    162         if {$var == "::da_acon"} { 
    163            set ::da_dcon($phase) "none" 
    164            puts 1 
    165         } else { 
    166            set ::da_acon($phase) "none" 
    167            puts 2 
     174            set ::da_acon($phase) "radii" 
    168175        } 
    169      } 
    170      if {[set ${var}($phase)] != "none" && ($::da_dcon($phase) == "none" || $::da_acon($phase) == "none")} { 
    171         if {$var == "::da_acon"} { 
    172            set ::da_dcon($phase) "radii" 
    173         } else { 
    174            set ::da_acon($phase) "radii" 
    175         } 
    176      } 
    177  
    178  
    179 #     if {[set ${var}($phase)] == "fixed search range"} {} 
    180       if {[set ${var}($phase)] != "none" && [set ${var}($phase)] != "radii" } { 
    181            catch {destroy .disaglcon.top} 
    182            set dedit .disaglcon.top 
    183            toplevel $dedit 
    184            bind $dedit <Return> "destroy $dedit" 
    185 #           frame $dedit -bd 2 -relief groove 
    186 #           pack $dedit -side top 
    187            set temp [regexp {[0-9]+.[0-9]+} [set ${var}($phase)]] 
    188            if {$temp == 0} {set ${var}($phase) 0.00} 
    189            if {$var == "::da_acon"} { 
    190               label $dedit.lbl1    -text "set angle fixed search range \n for phase $phase in angstroms" 
    191 #              set ::da_acon($phase) 0 
    192               entry  $dedit.entry1 -textvariable ::da_acon($phase) -takefocus 1  
    193                      $dedit.entry1 selection range 0 end 
    194               grid $dedit.lbl1 -column 0 -row 0 
    195               grid $dedit.entry1 -column 0 -row 1 
    196               focus $dedit.entry1 
    197            } 
    198            if {$var == "::da_dcon"} { 
    199  #             set ::da_dcon($phase) 0 
    200               label $dedit.lbl1    -text "set bond fixed search range \n for phase $phase in angstroms" 
    201               entry  $dedit.entry1 -textvariable ::da_dcon($phase) -takefocus 1 
    202                      $dedit.entry1 selection range 0 end 
    203               grid $dedit.lbl1 -column 0 -row 0 
    204               grid $dedit.entry1 -column 0 -row 1 
    205               focus $dedit.entry1 
    206            } 
    207            button $dedit.quit -text "Set" -command "destroy $dedit" 
    208            grid $dedit.quit -column 0 -row 2 
    209            putontop $dedit 
    210            tkwait window $dedit 
    211            afterputontop 
    212      } 
    213  
    214  
    215  
    216  
    217 #     puts "phase = $phase" 
    218 #     puts "var = $var" 
    219 #     puts "new value = [set ${var}($phase)]" 
     176    } 
     177 
     178 
     179    #     if {[set ${var}($phase)] == "fixed search range"} {} 
     180    if {[set ${var}($phase)] != "none" && [set ${var}($phase)] != "radii" } { 
     181        catch {destroy .disaglcon.top} 
     182        set dedit .disaglcon.top 
     183        toplevel $dedit 
     184        bind $dedit <Return> "destroy $dedit" 
     185        #           frame $dedit -bd 2 -relief groove 
     186        #           pack $dedit -side top 
     187        set temp [regexp {[0-9]+.[0-9]+} [set ${var}($phase)]] 
     188        if {$temp == 0} {set ${var}($phase) 0.00} 
     189        if {$var == "::da_acon"} { 
     190            label $dedit.lbl1    -text "set angle fixed search range \n for phase $phase in angstroms" 
     191            #              set ::da_acon($phase) 0 
     192            entry  $dedit.entry1 -textvariable ::da_acon($phase) -takefocus 1  
     193            $dedit.entry1 selection range 0 end 
     194            grid $dedit.lbl1 -column 0 -row 0 
     195            grid $dedit.entry1 -column 0 -row 1 
     196            focus $dedit.entry1 
     197        } 
     198        if {$var == "::da_dcon"} { 
     199            #             set ::da_dcon($phase) 0 
     200            label $dedit.lbl1    -text "set bond fixed search range \n for phase $phase in angstroms" 
     201            entry  $dedit.entry1 -textvariable ::da_dcon($phase) -takefocus 1 
     202            $dedit.entry1 selection range 0 end 
     203            grid $dedit.lbl1 -column 0 -row 0 
     204            grid $dedit.entry1 -column 0 -row 1 
     205            focus $dedit.entry1 
     206        } 
     207        button $dedit.quit -text "Set" -command "destroy $dedit" 
     208        grid $dedit.quit -column 0 -row 2 
     209        putontop $dedit 
     210        tkwait window $dedit 
     211        afterputontop 
     212    } 
     213 
     214 
     215 
     216 
     217    #     puts "phase = $phase" 
     218    #     puts "var = $var" 
     219    #     puts "new value = [set ${var}($phase)]" 
    220220} 
    221221 
    222222proc DA_Radii_Box {dcb args} { 
    223      #construct radii control box 
    224      catch {destory $dcb.radcon} 
    225      catch {destory $dcb.discon} 
    226      set radcon $dcb.radcon 
    227      frame $radcon -bd 2 -relief groove 
    228      grid $radcon -column 1 -row 0 -rowspan 2 
    229  
    230      label $radcon.lbl1 -text "Atom/Ion" 
    231      label $radcon.lbl2 -text "Bond \n Search Radii" 
    232      label $radcon.lbl3 -text "Angle \n Search Radii" 
    233      grid $radcon.lbl1 -row 0 -column 0 
    234      grid $radcon.lbl2 -row 0 -column 1 
    235      grid $radcon.lbl3 -row 0 -column 2 
    236      set count 1 
    237      foreach j [array names ::da_drad] { 
    238              label $radcon.atom$j -text "$j" -width 5 
    239              entry $radcon.drad$j -textvariable ::da_drad($j) -width 6 -takefocus 1 
    240              entry $radcon.arad$j -textvariable ::da_arad($j) -width 6 -takefocus 1 
    241              grid  $radcon.atom$j -row $count -column 0 
    242              grid  $radcon.drad$j -row $count -column 1 
    243              grid  $radcon.arad$j -row $count -column 2 
    244              incr count 
    245      } 
     223    #construct radii control box 
     224    catch {destory $dcb.radcon} 
     225    catch {destory $dcb.discon} 
     226    set radcon $dcb.radcon 
     227    frame $radcon -bd 2 -relief groove 
     228    grid $radcon -column 1 -row 0 -rowspan 2 
     229 
     230    label $radcon.lbl1 -text "Atom/Ion" 
     231    label $radcon.lbl2 -text "Bond \n Search Radii" 
     232    label $radcon.lbl3 -text "Angle \n Search Radii" 
     233    grid $radcon.lbl1 -row 0 -column 0 
     234    grid $radcon.lbl2 -row 0 -column 1 
     235    grid $radcon.lbl3 -row 0 -column 2 
     236    set count 1 
     237    foreach j [array names ::da_drad] { 
     238        label $radcon.atom$j -text "$j" -width 5 
     239        entry $radcon.drad$j -textvariable ::da_drad($j) -width 6 -takefocus 1 
     240        entry $radcon.arad$j -textvariable ::da_arad($j) -width 6 -takefocus 1 
     241        grid  $radcon.atom$j -row $count -column 0 
     242        grid  $radcon.drad$j -row $count -column 1 
     243        grid  $radcon.arad$j -row $count -column 2 
     244        incr count 
     245    } 
    246246} 
    247247 
    248248 
    249249proc DA_Inc_Drad {args} { 
    250         foreach j [array names ::da_drad] { 
    251                 set ::da_drad($j) [format %.1f [expr $::da_drad($j) + 0.1]] 
    252         } 
     250    foreach j [array names ::da_drad] { 
     251        set ::da_drad($j) [format %.1f [expr $::da_drad($j) + 0.1]] 
     252    } 
    253253} 
    254254 
    255255proc DA_Dec_Drad {args} { 
    256         foreach j [array names ::da_drad] { 
    257                 set ::da_drad($j) [format %.1f [expr $::da_drad($j) - 0.1]] 
    258         } 
     256    foreach j [array names ::da_drad] { 
     257        set ::da_drad($j) [format %.1f [expr $::da_drad($j) - 0.1]] 
     258    } 
    259259} 
    260260proc DA_Inc_Arad {args} { 
    261         foreach j [array names ::da_arad] { 
    262                 set ::da_arad($j) [format %.1f [expr $::da_arad($j) + 0.1]] 
    263         } 
     261    foreach j [array names ::da_arad] { 
     262        set ::da_arad($j) [format %.1f [expr $::da_arad($j) + 0.1]] 
     263    } 
    264264} 
    265265proc DA_Dec_Arad {args} { 
    266         foreach j [array names ::da_drad] { 
    267                 set ::da_arad($j) [format %.1f [expr $::da_arad($j) - 0.1]] 
    268         } 
     266    foreach j [array names ::da_drad] { 
     267        set ::da_arad($j) [format %.1f [expr $::da_arad($j) - 0.1]] 
     268    } 
    269269} 
    270270 
    271271proc DA_Save {args} { 
    272      foreach i $::da_list { 
    273            if {$::da_drad($i) >= 0 && $::da_drad($i) <= 10000} { 
    274               AtmTypInfo distrad $i set $::da_drad($i) 
    275            } 
    276            puts 1 
    277            if {$::da_arad($i) >= 0 && $::da_arad($i) <= 10000} { 
    278               AtmTypInfo angrad $i set $::da_arad($i) 
    279            } 
    280  
    281      } 
    282      foreach j $::da_phase { 
     272    foreach i $::da_list { 
     273        if {$::da_drad($i) >= 0 && $::da_drad($i) <= 10000} { 
     274            AtmTypInfo distrad $i set $::da_drad($i) 
     275        } 
     276        puts 1 
     277        if {$::da_arad($i) >= 0 && $::da_arad($i) <= 10000} { 
     278            AtmTypInfo angrad $i set $::da_arad($i) 
     279        } 
     280 
     281    } 
     282    foreach j $::da_phase { 
    283283        phaseinfo $j DistCalc set $::da_dcon($j) 
    284284        phaseinfo $j AngCalc set $::da_acon($j) 
    285      } 
    286      # indicate a change to the .EXP file 
    287      incr ::expgui(changed) 
    288      set ::da_quit 0 
    289      destroy .disaglcon 
    290 } 
     285    } 
     286    # indicate a change to the .EXP file 
     287    incr ::expgui(changed) 
     288    set ::da_quit 0 
     289    destroy .disaglcon 
     290} 
  • trunk/distrest.tcl

    r1025 r1166  
    3737 
    3838proc DisplayDistanceRestraints {args} { 
     39    #puts DisplayDistanceRestraints 
    3940    global expcons 
    4041    eval destroy [winfo children $expcons(distmaster)] 
     
    5152        -sticky nsew 
    5253    grid [frame $phasebox -bd 2 -relief groove] -column 0 -row 0 \ 
    53          -sticky new -columnspan 2 
     54        -sticky new -columnspan 2 
    5455 
    5556 
    5657    grid [frame $editorbox -bd 2 -relief groove] -column 0 -row 2 \ 
    57          -sticky sew -columnspan 2 
     58        -sticky sew -columnspan 2 
    5859 
    5960 
     
    6465    # Pick Phase to be Evaluated ********************************************** 
    6566    label $phasebox.phlabel -text Phase 
    66 #    set ::sr_phaselist $::expmap(phaselist) 
     67    #    set ::sr_phaselist $::expmap(phaselist) 
    6768 
    6869    eval tk_optionMenu $phasebox.phase ::sr_entryvar(softphase) $::expmap(phaselist) 
    69 #    eval tk_optionMenu $phasebox.phase ::sr_entryvar(softphase) $::sr_phaselist 
    70 #   trace variable ::sr_entryvar(softphase) w DisplayDistanceRestraints 
    71 #   bind $phasebox.phase <ButtonRelease> {DisplayDistanceRestraints} 
     70    #    eval tk_optionMenu $phasebox.phase ::sr_entryvar(softphase) $::sr_phaselist 
     71    #   trace variable ::sr_entryvar(softphase) w DisplayDistanceRestraints 
     72    #   bind $phasebox.phase <ButtonRelease> {DisplayDistanceRestraints} 
    7273 
    7374    grid $phasebox.phlabel -column 0 -row 0 
     
    7879    grid [label $leftfr.lweight -text "Restraint Weight"] -column 0 -row 1 -sticky sw -pady 10 
    7980    grid [entry $leftfr.weight -width 8 -textvariable entryvar(distrestweight)] -column 1 -row 1 -sticky sw \ 
    80          -padx 5 -pady 10 
     81        -padx 5 -pady 10 
    8182    set ::entrycmd(distrestweight) "SoftConst weight" 
    8283    set ::entrycmd(trace) 0 
    8384    set ::entryvar(distrestweight) [SoftConst weight] 
     85    RecordMacroEntry "set ::entryvar(distrestweight) [SoftConst weight]" 0 
    8486    set ::entrycmd(trace) 1 
    85  
     87    incr ::expgui(changed) 
    8688 
    8789    #Run Disagl Commands ***************************************************** 
     
    9597    grid [button $editorbox.edit -text "Activate Restraint \n Editor" -command SR_TEST] -column 0 -row 4 \ 
    9698        -columnspan 2 -pady 5 
    97         $editorbox.edit config -bg LightGreen -bd 6 
     99    $editorbox.edit config -bg LightGreen -bd 6 
    98100 
    99101    grid [button $editorbox.search -text "Edit Search Distance \n Parameters" -command DA_Control_Panel] -column 0 -row 3 \ 
    100102        -columnspan 2 
    101         $editorbox.edit config -bd 4 
     103    $editorbox.edit config -bd 4 
    102104 
    103105 
     
    114116 
    115117    label  $top.rlabel1 -text "Restraint" -width 9 -anchor center 
    116     label  $top.rlabel2 -text "esd"      -width 9 -anchor center 
     118    label  $top.rlabel2 -text "Tolerance" -width 9 -anchor center 
    117119 
    118120    grid $top.alabel1 -column 1 -row 2 -padx 3 
     
    139141    SR_Show_RestraintsOnly $main $rightfr 
    140142    foreach item [trace vinfo ::sr_entryvar(softphase)] { 
    141     eval trace vdelete ::sr_entryvar(softphase) $item 
     143        eval trace vdelete ::sr_entryvar(softphase) $item 
    142144    } 
    143145 
     
    148150    SR_Fill_Display  $main 
    149151    ResizeScrollTable $rightfr 
     152    #puts $rightfr 
    150153} 
    151154 
     
    336339 
    337340    label  $sr_top.rlabel1 -text "Restraint" 
    338     label  $sr_top.rlabel2 -text "esd" 
     341    label  $sr_top.rlabel2 -text "Tolerance" 
    339342    grid $sr_top.rlabel1 -column 4 -row 2 -padx 20 
    340343    grid $sr_top.rlabel2 -column 5 -row 2 -padx 20 
    341344 
    342345 
    343     button $sr_top.rcon1   -text "Check All" -width 10 -command " 
     346    button $sr_top.rcon1   -text "Check\nAll" -width 4 -command " 
    344347        set ::sr_checkall 1; 
    345348        SR_Set_All_Check_Buttons; 
     
    348351    " 
    349352 
    350     button $sr_top.rcon2   -text "Clear All" -width 10 -command " 
     353    button $sr_top.rcon2   -text "Clear\nAll" -width 4 -command " 
    351354        set ::sr_checkall 0; 
    352355        SR_Set_All_Check_Buttons; 
     
    396399                                label $main.rdistance$i -text [lindex $rprint 8] -justify center -anchor center 
    397400                                entry $main.restraint$i -width 8 -textvariable ::sr_restraintdist([lindex $rprint 13]) -takefocus 1 
    398                                       $main.restraint$i selection range 0 end 
     401                                $main.restraint$i selection range 0 end 
    399402                                bind  $main.restraint$i <KeyRelease> {SR_Validate_Soft %W distance} 
    400403                                entry $main.restesd$i -width 8 -textvariable ::sr_restraintesd([lindex $rprint 13]) -takefocus 1 
    401                                       $main.restesd$i selection range 0 end 
     404                                $main.restesd$i selection range 0 end 
    402405                                bind  $main.restesd$i <KeyRelease> {SR_Validate_Soft %W esd} 
    403406                                checkbutton $main.sr_crestraint$i -variable ::sr_crestraint([lindex $rprint 13]) 
     
    458461        # valid value 
    459462        $win config -fg black 
    460         $::srcb3.rbutton3 config -bg LightGreen -text "Save Restraints to EXP File" 
     463        $::srcb3.rbutton3 config -bg LightGreen -text "Save Changes" 
    461464        set ::sr_error 0 
    462465    } 
     
    515518        set sr_write "" 
    516519        set new_list "" 
    517 #       set len [llength $::sr_bond_list] 
     520        #       set len [llength $::sr_bond_list] 
    518521        set ::sr_key_list "" 
    519522        foreach temp $::sr_bond_list  { 
    520 puts $temp 
    521 #       for {set i 0} {$i <= [expr $len-1]} {incr i} {} 
    522 #           set temp [lindex $::sr_bond_list $i] 
    523  
    524            catch { 
    525             if {[string trim $::sr_restraintdist([lindex $temp 13])] != ""} { 
    526                 set softrest "[lindex $temp 0] [lindex $temp 1] \ 
     523            #   for {set i 0} {$i <= [expr $len-1]} {incr i} {} 
     524            #       set temp [lindex $::sr_bond_list $i] 
     525 
     526            if {[catch { 
     527                if {[string trim $::sr_restraintdist([lindex $temp 13])] != ""} { 
     528                    set softrest "[lindex $temp 0] [lindex $temp 1] \ 
    527529                                [lindex $temp 2] [lindex $temp 3] [lindex $temp 4] \ 
    528530                                [lindex $temp 5] [lindex $temp 6] [lindex $temp 7]\ 
    529531                                $::sr_restraintdist([lindex $temp 13])\ 
    530532                                $::sr_restraintesd([lindex $temp 13])" 
    531                 lappend sr_write $softrest 
    532 puts $softrest 
    533                 lappend new_list $temp 
    534             } 
    535             } 
     533                    lappend sr_write $softrest 
     534                    #lappend new_list $temp 
     535                } 
     536            } errmsg]} {puts "error: $errmsg"} 
    536537        } 
    537 # 
     538        # 
    538539        #puts $sr_write 
    539540        # put the entire restraint list back into the .EXP file 
     541        #puts "SoftConst restraintlist set $sr_write" 
    540542        SoftConst restraintlist set $sr_write 
    541         set ::sr_bond_list $new_list 
     543        RecordMacroEntry "SoftConst restraintlist set $sr_write" 0 
     544        #set ::sr_bond_list $new_list 
    542545        # indicate a change to the .EXP file 
    543546        incr ::expgui(changed) 
     
    623626    label $srcb1.dmaxlabel    -text "Dmax" 
    624627    label $srcb2.restlabel    -text "Restraint Value" -width 16 -anchor w 
    625     label $srcb2.restlabelesd -text "esd" 
     628    label $srcb2.restlabelesd -text "Tolerance" 
    626629 
    627630    eval tk_optionMenu $srcb1.atom1 ::sr_entryvar(softatom1) "[lsort [array names ::sr_lookuplist1${::sr_entryvar(softphase)}]] all" 
     
    630633 
    631634    entry  $srcb1.sr_dminvalue -width 8 -textvariable ::sr_dminvalue        -takefocus 1 
    632            $srcb1.sr_dminvalue selection range 0 end 
     635    $srcb1.sr_dminvalue selection range 0 end 
    633636    entry  $srcb1.sr_dmaxvalue -width 8 -textvariable ::sr_dmaxvalue        -takefocus 1 
    634            $srcb1.sr_dmaxvalue selection range 0 end 
     637    $srcb1.sr_dmaxvalue selection range 0 end 
    635638    entry  $srcb2.sr_rvalue    -width 8 -textvariable ::sr_rvalue           -takefocus 1 
    636            $srcb2.sr_rvalue selection range 0 end 
     639    $srcb2.sr_rvalue selection range 0 end 
    637640    entry  $srcb2.sr_resd      -width 8 -textvariable ::sr_resd             -takefocus 1 
    638            $srcb2.sr_resd selection range 0 end 
     641    $srcb2.sr_resd selection range 0 end 
    639642 
    640643    bind  $srcb1.sr_dminvalue <KeyRelease> {SR_Validate_Soft %W dmin} 
     
    644647 
    645648    button $srcb1.recalc   -text "Filter" -bd 6 -command {SR_Display} 
    646     button $srcb2.rbutton1 -text "check update" -command {SR_Update_Restraints} 
    647     button $srcb2.rbutton2 -text "check delete" -command {SR_Delete_Restraints} 
    648     button $::srcb3.rbutton3 -text "Save Restraints to EXP File" -bd 6 -bg LightGreen -command {SR_Write_Restraints} 
    649     button $::srcb3.rbutton4 -text "Cancel" -command {destroy .mainrestraintbox 
     649    button $srcb2.rbutton1 -text "Set checked" -command {SR_Update_Restraints} 
     650    button $srcb2.rbutton2 -text "Delete checked" -command {SR_Delete_Restraints} 
     651    button $::srcb3.rbutton3 -text "Save changes" -bd 6 -bg LightGreen -command {SR_Write_Restraints} 
     652    button $::srcb3.rbutton4 -text "Cancel" -command { 
     653        destroy .mainrestraintbox 
    650654        afterputontop 
    651655        SR_Rest_Only 
    652         DisplayDistanceRestraints} 
    653     wm protocol .mainrestraintbox WM_DELETE_WINDOW {destroy .mainrestraintbox 
     656        DisplayDistanceRestraints 
     657    } 
     658    wm protocol .mainrestraintbox WM_DELETE_WINDOW { 
     659        destroy .mainrestraintbox 
    654660        afterputontop 
    655661        SR_Rest_Only 
    656         DisplayDistanceRestraints} 
     662        DisplayDistanceRestraints 
     663    } 
    657664 
    658665    grid $srcb1.atomlabel1   -column 1 -row 0 
     
    725732    set ::sr_distance_button 1 
    726733    set ::sr_entryvar(choicenum) 0 
    727 #    set ::sr_entryvar(softphase) "1" 
    728 #    set ::sr_phaselist $::expmap(phaselist) 
     734    #    set ::sr_entryvar(softphase) "1" 
     735    #    set ::sr_phaselist $::expmap(phaselist) 
    729736    set ::sr_entryvar(softatom1) "all" 
    730737    set ::sr_entryvar(softatom2) "all" 
  • trunk/doc/excledt.html

    r971 r1166  
    283283</TH></TR></TABLE> 
    284284 
    285 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    286 <font size=-1><? lastmod(); ?> </font> 
    287 <br>$Revision$ $Date$ 
    288285</blockquote> 
    289286</body> 
  • trunk/doc/expgui.html

    r973 r1166  
    1616EXPGUI<BR> 
    1717A Graphical User Interface for  
    18 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/gsas.html"> 
     18<A Href="https://subversion.xor.aps.anl.gov/trac/EXPGUI/wiki/GSASIntro"> 
    1919GSAS</A> 
    2020<HR noshade width="75%" size="2" align="center"> 
     
    3434<P><P> 
    3535EXPGUI is a graphical interface for the  
    36 Los Alamos 
    37 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/gsas.html"> 
    38 GSAS</A> package.  
     36<A Href="https://subversion.xor.aps.anl.gov/trac/EXPGUI/wiki/GSASIntro">GSAS</A> 
     37package, developed at Los Alamos and maintained now at Argonne.  
    3938EXPGUI does two things:  
    4039it can be used to directly modify the GSAS  
     
    6059<TH><A Href="expgui4.html">Scaling info</A></TH> 
    6160<TH><A Href="expgui5.html">Profile terms</A></TH> 
    62 <TH><A Href="expgui6.html">Constraints</A></TH> 
     61<TH><A Href="expgui6.html">Constraints & Restraints</A></TH> 
    6362</TR> 
    6463<TR> 
     64<TH><A Href="expgui6A.html">Rigid Bodies</A></TH> 
    6565<TH><A Href="expgui7.html">Preferred Orientation</A></TH> 
    6666<TH><A Href="expguic.html">Menus</A></TH> 
     
    117117A.C. Larson and R.B. Von Dreele, "General Structure Analysis System (GSAS)",  
    118118Los Alamos National Laboratory Report LAUR 86-748 (2000). 
    119 <A HREF="http://www.ccp14.ac.uk/ccp/ccp14/ftp-mirror/gsas/public/gsas/manual/GSASManual.pdf"> 
     119<A 
     120  HREF="https://subversion.xor.aps.anl.gov/EXPGUI/gsas/all/GSAS%20Manual.pdf"> 
    120121[link to PDF copy of manual] 
    121122</A> 
     
    154155are used. The File/Save operation is done automatically before any GSAS 
    155156programs, such as GENLES or EXPEDT, are run. 
     157<P> 
     158<A name="badexp"> 
     159The GSAS refinement program, GENLES, will sometimes "blow up", where the 
     160  program changes varied parameters to values very far from their 
     161  correct values. This occurs when parameters are highly correlated, 
     162  are refining to values that are not allowed, or some of the refined parameters have 
     163  very little impact on the quality of the fit. When this happens, 
     164  invalid values are written to the GSAS experiment file that contain 
     165  either asterisks (****) or the string "NAN" (not a number). Such 
     166  files cannot be used for additional GENLES runs. 
     167  <P> 
     168  When EXPGUI reads a .EXP file it scans it for evidence of a previous 
     169  failure of a GENLES refinement and warns if a problem is 
     170  noted. Please note that this scan is not perfect and occasionally 
     171  you may be warned in cases where the file is fine (if possible, 
     172  please send such .EXP file to Brian Toby so this scan can be improved.) 
     173  When such a "bad" .EXP file is located, one can "revert" to an 
     174  archived copy of a previous experiment file (with suffix .Oxx). This 
     175  can be done with the Revert menu item in the File menu. Note that 
     176clicking on a file in the file selection window causes it to be 
     177scanned and shows the status of that refinement. Also note that 
     178usually the last good archived file has settings that will produce the same bad 
     179refinement, so it is necessary to either revert further back, or to 
     180change the refinement options before running GENLES.  
    156181<P> 
    157182 
     
    475500 
    476501The INSTEDIT utility is used to edit or create an instrument parameter file. 
    477 At this time it can only be used to edit files for  
    478 constant-wavelength data. The utility can be started from the "Edit File" 
    479 button in the  
     502The utility can be started from the "Edit File" button in the  
    480503<A HREF="expgui3.html#AddHist">"Add New Histogram"</A> dialog, or from the  
    481 the "instedit" option in the Powder menu. In the latter case, the user 
    482 is given the chance to select an input file. If no file is selected, 
    483 a new, empty, file is created. An example INSTEDIT window appears below. 
     504the "instedit" option in the Powder menu. Alternately, to create a new 
     505  instrument parameter file, choose Powder menu option "New InstParm 
     506  file". (It is also possible  
     507  to create a new file using the standard instedit by selecting 
     508  "Cancel" when asked for an input file.) 
     509An example INSTEDIT window appears below. 
    484510<P> 
    485511<img SRC="instedit1.gif" align=RIGHT alt="EXPGUI Screen snapshot"> 
     
    593619records can slow the GSAS programs  
    594620(this is less of a problem on faster computers). For these reasons, it may be  
    595 a good idea to prune the older history records from the file. If more than 100 
    596 history records are found in an experiment file, EXPGUI suggests that the 
    597 older history entries be deleted. Alternately the File/EraseHistory command 
    598 can be used to invoke the this option. 
     621a good idea to prune the older history records from the file. 
     622The File/EraseHistory command can be used to invoke the this option. 
    599623<P> 
    600624On the dialog the number of history records to be retained is specified.  
     
    681705<A name=tcltk> 
    682706<H2> 
    683 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/tclpkgs.html"> 
     707<A Href="http://www.tcl.tk"> 
    684708Tcl/Tk</A></H2> 
    685709The  
    686 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/tclpkgs.html"> 
     710<A Href="http://www.tcl.tk"> 
    687711Tcl/Tk program</A> is a platform-independent scripting language that is 
    688712used to implement most of EXPGUI. This software is available for free 
    689 and must be loaded in order to use EXPGUI. See the  
    690 installation notes for  
    691 <A HREF="expgui_Win_readme.html">Windows</A>, 
    692 and for 
    693 <A HREF="expgui_Unix_readme.html">UNIX</A> for information on how to do this. 
     713and must be loaded in order to use EXPGUI. A somewhat out of date 
     714version of Tcl/Tk (8.4) is distributed with EXPGUI (ncnrpack.exe, etc.) but 
     715more recent versions can be used, but note that the BLT package (see 
     716below) is needed for all features of EXPGUI. 
    694717While learning Tcl/Tk is a great thing to do, it is not a requirement 
    695718for using or installing EXPGUI. 
    696  
    697 <A name=winexec> 
    698 <H3> 
    699 WINEXEC</H3> 
    700 <UL> 
    701 The WINEXEC package is needed under Windows-95 and its offspring  
    702 (-98 and -ME). See the <A HREF="expgui_Win_readme.html">Windows installation  
    703 notes</A> for more details. 
    704 </UL> 
    705719 
    706720<A name=blt> 
     
    715729If this is the case, a message,  
    716730"BLT Setup Error: could not access a Blt_ routine...", will be displayed. 
    717 This is most common in UNIX and is discussed further in the  
    718 <A HREF="expgui_Unix_readme.html">UNIX installation notes</A>. Also see  
    719 <A HREF="http://www.ncnr.nist.gov/programs/crystallography/software/tclpkgs.html"> 
    720 http://www.ncnr.nist.gov/programs/crystallography/software/tclpkgs.html 
    721 </A> for more information on installation of BLT. 
     731Use of the ncnrpack file distributed with EXPGUI usually avoids this problem. 
    722732</UL> 
    723733 
     
    727737<UL> 
    728738The 
    729 <A HREF="www.hume.com">Hume  
     739<A HREF="http://www.hume.com">Hume  
    730740</A> 
    731741Linear Algebra Tcl Package,  
    732 <A HREF="www.hume.com"> 
     742<A HREF="http://www.hume.com/la/la.html"> 
    733743La</A>,  
    734744is used by the BKGEDIT 
     
    739749should not happen, since the package is included with the EXPGUI files. 
    740750So if get this error you probably have an incomplete installation. 
    741 Note that the La package requires Tcl/Tk version 8.1 or higher, so that if  
    742 you are using an older version of Tcl/Tk, you will need to upgrade. 
    743 See the installation instructions for 
    744 <A HREF="expgui_Win_readme.html">Windows</A>, 
    745 and for 
    746 <A HREF="expgui_Unix_readme.html">UNIX</A> for more information on Tcl/Tk. 
     751</UL> 
     752 
     753<A name=winexec> 
     754<H3> 
     755WINEXEC</H3> 
     756<UL> 
     757The WINEXEC package was needed under Windows-95 and its offspring  
     758(-98 and -ME). It was found in older versions of EXPGUI, but is no 
     759  longer included. 
    747760</UL> 
    748761 
     
    750763Acknowledgments</H2> 
    751764Praise to Larson and  
    752 Von Dreele for GSAS, <A HREF="http://www.scriptics.com/">Ousterhout</A> 
     765Von Dreele for GSAS, <A HREF="http://home.pacbell.net/ouster/">John Ousterhout</A> 
    753766for Tcl/Tk,  
    754 Przemek Klosowski</A> 
     767Przemek Klosowski 
    755768for convincing me to learn Tcl/Tk  
    756 and Jonathan Wasserman for helping get this project started. 
    757 Thanks also to  
     769and Jonathan Wasserman for helping me get this project started. 
     770Thanks also to 
     771Charles Lake of Indiana University of PA for working on many recent additions to EXPGUI, including the 
     772bond-distance restraints module and the (soon to come) rigid body editor; 
    758773Pamela Whitfield of the NRC (Canada) for writing large  
    759774sections of the  
     
    763778code and to John Cowgill for the "Export to GRACE" code. 
    764779<P> 
    765 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/gsas.html"> 
     780<A Href="https://subversion.xor.aps.anl.gov/trac/EXPGUI/wiki/GSASIntro"> 
    766781GSAS</A> 
    767782is written by Allen C. Larson and Robert B. Von Dreele while at  
     
    770785<A HREF="MAILTO:vondreele@anl.gov">vondreele@anl.gov</A> 
    771786EXPGUI was written by Brian H. Toby while at the NIST Center for Neutron Research, 
    772 <A HREF="MAILTO:Brian.Toby@ANL.GOV">Brian.Toby@ANL.GOV</A>  
    773 with help from Jonathan Wasserman. 
     787<A HREF="MAILTO:Brian.Toby@ANL.GOV">Brian.Toby@ANL.GOV</A>. 
    774788 
    775789<P><hr><blockquote> 
     
    786800software. 
    787801 
    788 <P>The author of EXPGUI is a U.S. Government employee which means that 
     802<P>EXPGUI was written by a U.S. Government employee, which means that 
    789803EXPGUI is not subject to copyright. Have fun with it. Modify it. Please write  
    790804new sections and make them available to the rest of the world.  
     
    793807expressed or implied, or assumes any liability or responsibility  
    794808for the use of this information or the software described 
    795 here. Brand names cited herein are used for 
    796 identification purposes and do not constitute an endorsement by NIST. 
     809here. 
    797810</blockquote> 
    798811 
  • trunk/doc/expgui0.html

    r971 r1166  
    4444</TH></TR></TABLE> 
    4545 
    46 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    47 <font size=-1><? lastmod(); ?> </font> 
    48 <br>$Revision$ $Date$ 
    49 </blockquote> 
     46/blockquote> 
    5047</body> 
    5148</html> 
  • trunk/doc/expgui1.html

    r971 r1166  
    186186</TH></TR></TABLE> 
    187187 
    188 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    189 <font size=-1><? lastmod(); ?> </font> 
    190 <br>$Revision$ $Date$ 
    191188</blockquote> 
    192189</body> 
  • trunk/doc/expgui2.html

    r971 r1166  
    8080<P> 
    8181<a name="xform"></a> 
    82 <h4>A.2.2 Transform Coordinates</h4>  
    83 <DL><DL> 
    84 <img SRC="2a.gif" align=RIGHT alt="EXPGUI Screen snapshot"> 
    85 If one or more atoms have been selected 
    86 <A href="expgui.html#mouseactions">(see Mouse Actions)</A>, it is possible 
    87 to make changes to those atoms by pressing the "Xform atom(s)" button.  
    88 This raises the window shown to the right. 
    89 Note that no changes are actually made, until the  
    90 "Transform Coordinates", "Set Occupancies",... buttons are pressed. 
    91 <P> 
    92 This window can be used  
    93 to transform the coordinates coordinates of the selected atoms,  
    94 globally set occupancy or Uiso (Uequiv)  
    95 values for the selected atoms, or erase the selected atoms. by pressing the  
    96 It is also possible to transform the selected atoms 
    97 from isotropic to anisotropic, or the reverse.  
    98 <P> 
    99 <IMG SRC="new.gif" alt="New!"> 
    100 The "Xform Origin 1 to Origin 2" button is only available for those  
     82<h4>A.2.2 Modify Atom</h4>  
     83<DL><DL> 
     84<img SRC="2a.jpg" align=RIGHT alt="EXPGUI Screen snapshot"> 
     85The "Modify Atom" button ("Modify Atoms" when multiple atoms are 
     86  selected) provides access to additional options that can 
     87  transform or modify the selected atom(s) from the phase panel   
     88<A href="expgui.html#mouseactions">(see Mouse Actions</A> for 
     89  information on selecting atoms); this opens the menu window shown to 
     90  the right. 
     91Note that changes are made to the coordinates when the buttons on this 
     92  window (such as  
     93"Transform Coordinates", "Set Occupancies",...) are pressed. 
     94<P><B>Modify Coordinates:</B> 
     95  This is used  
     96to transform the coordinates coordinates of the selected atoms using a 
     97set of  transformation relationships. 
     98   
     99<P><B>Reset Multiplicities:</B> 
     100 When atom positions are edited in EXPGUI, they may be moved off from 
     101  or onto special positions in the cell, changing the site 
     102  multiplicity -- but this will not be reflected in the phase 
     103  display. When atoms are subsequently refined, GENLES will update the 
     104  multiplcities. Pressing the  "Reset Multiplicities" button cases 
     105  this to be done right away (I think this may not work if there are no 
     106  histograms present).  
     107 
     108<P><B>Xform Origin 1 to Origin 2:</B> This button is only available for those  
    101109orthorhombic, tetragonal and cubic space groups that are listed in the 
    102110International Tables with two origin settings. (These space groups have  
     
    106114of symmetry. GSAS only uses the origin 2 settings.) 
    107115If coordinates have been entered in the origin 1 setting, they may be  
    108 transformed to the origin 2 setting using this button. 
     116transformed to the origin 2 setting using this button. It is important 
     117  to select all atoms in the asymmetric unit before using this button. 
     118 
     119  <P><B>Modify Occupancies:</B> 
     120 This allows the occupancy to be set for one or more atoms. It is 
     121  most convenient for when many atoms will have their occupancy 
     122  changed at one time. 
     123 
     124<P><B>Modify Displacement Parameters:</B> 
     125  This allows one to set Uiso (or Uequiv) values for the selected 
     126  atoms (<B>Set U</B>). To change the flag that determines if the 
     127  selected atom(s) are represented as Isotropic or Anisotropic, press 
     128  the <B>Set Isotropic</B> or <B>Set Anisotropic</B> buttons. 
     129 
     130<P><B>Erase Atoms:</B> 
     131  The "Erase Atoms" removes the selected atoms from the phase. I 
     132  usually set the occupancy to 0. instead.  
     133   
     134<P><B>Fix Atom Coordinates:</B> 
     135When an atom is refined in GSAS, only the coordinates that are not 
     136defined by site symmetry are refined. However, in some space groups, 
     137it is necessary to not refine additional coordinates. The most common 
     138example are polar space groups (P1, P2, P2<sub>1</sub>, C2,  P4, P4<sub>1</sub>, P 
     1394<sub>2</sub>, P4<sub>3</sub>, I4, I4<sub>1</sub>, P3, P3<sub>1</sub>, P3<sub>2</sub>, R3, P6, P6<sub>1</sub>, P6<sub>5</sub>, P6<sub>2</sub>, P6<sub>4</sub> and 
     140P6<sub>3</sub> - from 
     141<a href="http://www.ruppweb.org/Xray/comp/space_instr.htm"> Bernard Rupp's 
     142web site, http://www.ruppweb.org/Xray/comp/space_instr.htm</A>) where 
     143one or more coordinates of the origin are not defined by symmetry. In 
     144these space groups an appropriate number of coordinates must be fixed 
     145to define the origin. As an example, in P1, one x, one y and one z 
     146coordinate must not be refined; in space group P2<sub>1</sub>, the 
     1472<sub>1</sub> screw axis defines the origin at (0,0,z) so one z 
     148coordinate cannot be varied. 
     149 
     150Occasionally, while symmetry may allow 
     151atom coordinates to be varied, a crystallographer may choose to 
     152simplify or constrain the representation to fix the atom in a 
     153particular location and not refine with all allowed degrees of freedom. 
     154 
     155<IMG SRC="new.gif" alt="New!"> 
     156 The "Fix Atom Coordinates" buttons allows a flag to be set (or 
     157cleared) for an atom 
     158to prevent refinement of selected coordinates, even when the X 
     159refinement flag is set. Note the addition of an "F" for the x and z 
     160coordinates of the first atom as shown in the phase panel, above. This 
     161indicates that x & z have been fixed. When the atom position is 
     162varied, only y will be optimized.  
    109163 
    110164<br clear=all> 
     
    248302</TH></TR></TABLE> 
    249303 
    250 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    251 <font size=-1><? lastmod(); ?> </font> 
    252 <br>$Revision$ $Date$ 
    253304</blockquote> 
    254305</body> 
  • trunk/doc/expgui3.html

    r971 r1166  
    3131<HR noshade width="75%" size="2" align="center"> 
    3232</h1></center> 
    33 <h3>A.3 Histogram panel</h3>  
    34 <DL><DL> 
    35 The histogram panel is used to edit background 
    36 and diffractometer constants for a histogram, as well as  
     33<h3>A.3 Powder panel</h3>  
     34<DL><DL> 
     35The Powder (was histogram) panel is used to edit background 
     36and diffractometer constants for powder histogram(s), as well as  
    3737set damping and refinement flags for these parameters. 
    3838<P> 
     
    288288</TH></TR></TABLE> 
    289289 
    290 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    291 <font size=-1><? lastmod(); ?> </font> 
    292 <br>$Revision$ $Date$ 
    293290</blockquote> 
    294291</body> 
  • trunk/doc/expgui4.html

    r971 r1166  
    6060</TH></TR></TABLE> 
    6161 
    62 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    63 <font size=-1><? lastmod(); ?> </font> 
    64 <br>$Revision$ $Date$ 
    6562</blockquote> 
    6663</body> 
  • trunk/doc/expgui5.html

    r971 r1166  
    118118</TH></TR></TABLE> 
    119119 
    120 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    121 <font size=-1><? lastmod(); ?> </font> 
    122 <br>$Revision$ $Date$ 
    123120</blockquote> 
    124121</body> 
  • trunk/doc/expgui6.html

    r971 r1166  
    2222<TABLE BORDER BGCOLOR="#FFFF40" ALIGN=RIGHT> 
    2323<TR><TH><A  Href="expgui.html">EXPGUI top</A>  
    24 </TH><TH><A Href="expgui7.html">Next page</A> 
     24</TH><TH><A Href="expgui6A.html">Next page</A> 
    2525</TH><TH><A Href="expgui5.html">Previous page</A> 
    2626</TH></TR></TABLE><BR CLEAR=ALL> 
     
    3232</h1></center> 
    3333 
    34 <h3>A.6 Constraints panel</h3> 
     34<h3>A.6 Re/Constraints panel</h3> 
    3535<DL><DL> 
    3636GSAS offers two types of restraints that can be included in a model.  
     
    4141by grouping parameters so that a single shift (possibly scaled) is  
    4242applied to each parameter in the group. 
    43 The constraints panel is used to set these "hard constraints." 
     43The Re/Constraints panel is used to set these "hard constraints" or in 
     44  the case of bond distances, "restraints". 
    4445At this time the only constraints that can be set in EXPGUI are on atomic 
    45 and profile profile (others can be set in EXPEDT). 
     46and profile profile (others can be set in EXPEDT). EXPEDT offers many 
     47  other types of restraints as well. 
    4648<P> 
    4749Note that these constraints are only applied to shifts, but not to the 
     
    212214usually make sense and EXPGUI does not allow it. 
    213215</DL></DL> 
     216<a name="DistanceRestraints"></a> 
     217<H4>Distance Restraints</H4> 
     218<DL><DL> 
     219  When the distance restraints tab is first selected, the active 
     220  distance restraints for the selected phase are shown. The <B>Atom 1</B> and 
     221  <B>Atom 2</B> buttons can be used to sort this list. 
     222  <P> 
     223  The <B>Restraint Weight</B> parameter is very important. As this 
     224  determines how strongly the distance restraints will be used in the 
     225  refinement relative to the diffraction data. This value is sometimes 
     226  set as high as 500,000 in the initial stages of a fit, but should be 
     227  lowered as much as is possible in the final stages of the fit, as 
     228  needed to obtain chemically plausible interatomic distances. For 
     229  some refinements, a value of 0.0 is possible for the Restraint 
     230  Weight in the final stages. This removes any restraint effect. 
     231 
     232  To see how restraints are affecting the refinement, one can look at 
     233  the ratio of the "Sum(w*d**2)" (shown in the .LST file) for the 
     234  diffraction histograms vs. the restraint histogram. 
     235<P> 
     236  The <B>Active Restraints Editor</B> can be used to select distances 
     237  to be restrained or edit the restraints. If there are too many 
     238  distances shown, the options at the top of the window can be used to 
     239  select a distance range, or specific atoms to include. Likewise, 
     240  only restrained or unrestrained distances can be selected. The 
     241  changes are applied when the <B>Filter</B> button is pressed. 
     242<P> 
     243  The bottom section of the window shows individual interatomic 
     244  distances. A <B>Restraint</B> and <B>Tolerance</B> value is needed to restrain 
     245  that distance. The quantity minimized is 
     246<blockquote> 
     247<blockquote> 
     248 "Restraint Weight" * SUM{  [ (Distance - Restraint) / Tolerance ]**2 }  
     249</blockquote> 
     250</blockquote> 
     251thus the "Tolerance" provides individual weighting for each 
     252  restraint. 
     253<P> 
     254  To set a large number of restraints at the same time, select the 
     255  check button next to the distance(s), or use the <B>Check 
     256  All</B>. Then use the section above to enter a global 
     257  <B>Restraint</B> and <B>Tolerance</B> value. These values are set 
     258  when the <B>Set Checked</B> button is used.  The <B>Delete 
     259  Checked</B> button removes restraints from all selected distances. 
     260<P> 
     261The entered restraint information will be used onlt when the <B>Save 
     262  Changes</B> button is pressed. The <B>Cancel</B> button will reverse 
     263  any changes made while the window is open. Closing the window has 
     264  the same effect as "Cancel." 
     265  <P> 
     266  Note that the interatomic distances that are shown are determined by 
     267  the parameters to program DISAGL. These are controlled with the 
     268  <B>Edit Search Distance Parameters</B> button.  
     269 
     270</DL></DL> 
    214271<hr> 
    215272<TABLE BORDER BGCOLOR="#FFFF40" ALIGN=RIGHT> 
    216273<TR><TH><A  Href="expgui.html">EXPGUI top</A>  
    217 </TH><TH><A Href="expgui7.html">Next page</A> 
     274</TH><TH><A Href="expgui6A.html">Next page</A> 
    218275</TH><TH><A Href="expgui5.html">Previous page</A> 
    219276</TH></TR></TABLE> 
    220277 
    221 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    222 <font size=-1><? lastmod(); ?> </font> 
    223 <br>$Revision$ $Date$ 
    224278</blockquote> 
    225279</body> 
  • trunk/doc/expgui7.html

    r971 r1166  
    2323<TR><TH><A  Href="expgui.html">EXPGUI top</A>  
    2424</TH><TH><A Href="expguic.html">Next page (Menus)</A> 
    25 </TH><TH><A Href="expgui6.html">Previous page</A> 
     25</TH><TH><A Href="expgui6A.html">Previous page</A> 
    2626</TH></TR></TABLE><BR CLEAR=ALL> 
    2727 
    2828<center><h1> 
    2929<HR noshade width="75%" size="2" align="center"> 
    30 EXPGUI, part 7 
     30EXPGUI, part 8 
    3131<HR noshade width="75%" size="2" align="center"> 
    3232</h1></center> 
    3333 
    34 <h3>A.7 Preferential Orientation Panel</h3></a> 
     34<h3>A.8 Preferential Orientation Panel</h3></a> 
    3535<DL><DL> 
    3636The Preferential Orientation Panel is used to control parameters related 
     
    4343</DL></DL> 
    4444<a name="MD"></a> 
    45 <h4>A.7.a March-Dollase</H4> 
     45<h4>A.8.a March-Dollase</H4> 
    4646<DL><DL> 
    4747In this model one or more axes are designated 
     
    6767</DL></DL> 
    6868<a name="ODF"></a> 
    69 <H4>A.7.b Spherical harmonic</H4> 
     69<H4>A.8.b Spherical harmonic</H4> 
    7070<DL><DL> 
    7171The spherical harmonic formulation, also referred to as an "orientation 
     
    9898<TR><TH><A  Href="expgui.html">EXPGUI top</A>  
    9999</TH><TH><A Href="expguic.html">Next page (Menus)</A> 
    100 </TH><TH><A Href="expgui6.html">Previous page</A> 
     100</TH><TH><A Href="expgui6A.html">Previous page</A> 
    101101</TH></TR></TABLE> 
    102102 
    103 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    104 <font size=-1><? lastmod(); ?> </font> 
    105 <br>$Revision$ $Date$ 
    106103</blockquote> 
    107104</body> 
  • trunk/doc/expgui_intro.html

    r971 r1166  
    7070Customization notes</A> 
    7171<LI> 
    72 <A HREF="tutorial3/index.html"> 
     72<A HREF="https://subversion.xor.aps.anl.gov/EXPGUI/tutorials/tutorial3/index.html"> 
    7373A well-annotated CW neutron tutorial (Alumina).</A> 
    7474<B><I>A very good place to start!</I></B> 
    7575<LI> 
    76 <A HREF="tutorial1/index.html"> 
     76<A HREF="https://subversion.xor.aps.anl.gov/EXPGUI/tutorials/tutorial1/index.html"> 
    7777A TOF Tutorial Example (Nickel)</A> 
    7878<LI> 
    79 <A HREF="tutorial2/index.html"> 
     79<A HREF="https://subversion.xor.aps.anl.gov/EXPGUI/tutorials/tutorial2/index.html"> 
    8080A CW Neutron Tutorial Example (Garnet)</A> 
    8181</UL> 
     
    164164<p><br><B>Who is to blame for EXPGUI?</B> 
    165165<blockquote>The initial version of the GUI part of EXPGUI was created by 
    166 Jonathan Wasserman (thanks Jon!) <a href="http://www.ncnr.nist.gov/staff/toby/">Brian 
     166Jonathan Wasserman (thanks Jon!) Brian 
    167167Toby</a> is irresponsible for the rest.</blockquote> 
    168168 
     
    170170<blockquote>Gee, you want to add some features... Great! You have all the 
    171171EXPGUI sources and 
    172 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/tclpkgs.html">Tcl/Tk</A> 
    173 is free. Oh, you want me to do it. Well, please  
     172Tcl/Tk is free. Oh, you want me to do it. Well, please  
    174173ask and I will try. In particular, I am looking for good ideas on  
    175174how to design GUI's for different aspects of experiment editing,  
     
    177176 
    178177<p><br><B>Mailing List</B> 
    179 <blockquote>If you would like to get news about EXPGUI, please send  
    180 <a href="mailto:brian.toby@anl.gov?subject=EXPGUI Mailing List">Brian.Toby@ANL.GOV</a> e-mail. The mailing list is not active at present, but  
    181 I hope to use it again to provide  
     178<blockquote>If you would like to get news about EXPGUI, please  
     179<a href="http://www.aps.anl.gov/mailman/listinfo/expgui">see this 
     180link</a>. 
     181The mailing list is used only to provide  
    182182information about updates and bug fixes.  
    183183</blockquote> 
  • trunk/doc/expguic.html

    r971 r1166  
    4949        experiment file from scratch. 
    5050<DT>expnam<DD> 
    51 Equivalent to Open, included since this is the command used in other  
    52 GSAS shells to select GSAS experiments. 
     51Equivalent to Open (included for historical reasons.) 
     52 
    5353<DT>Save<DD>Saves modifications to the current experiment file to disk (shortcut Alt-S). 
    5454<DT>Save As<DD>Saves modifications to the current experiment file to disk 
     
    6060  offers the program user the option to update these files. The update 
    6161  will fail if the user does not have permission to change the EXPGUI 
    62   or GSAS files. In this case, a system administrator may be needed.  
     62  or GSAS files. In this case, a system administrator may be needed. 
     63  <DT>revert<DD>Used to load an <a href="#archive">archived</A> 
     64    (backup) version of the current .EXP file.  
    6365<DT>EraseHistory<DD>Deletes old history records to speed reading of the .EXP file. 
    64 <DT>convert<DD>Convert a standard ASCII file to the direct access format used by GSAS (and for UNIX, the reverse) 
     66<DT>convert<DD>Convert a standard ASCII file to the direct access 
     67  format used by GSAS (and for UNIX, the reverse) -- this is not 
     68  likely to be needed, as GSAS now does most conversions automatically. 
    6569<DT>exit<DD>Exit EXPGUI (shortcut Alt-X or ^C) 
    6670</DL> 
     
    99103revised .EXP file, which means that you reject the last set of changes. 
    100104This is useful if  
    101 GENLES blows up or you have done something wrong. The advantage  
    102 of turning "autoload EXP" on is 
     105GENLES blows up or you have done something wrong. The reason to  
     106turning "autoload EXP" on is 
    103107that there is one less thing to do when running GSAS programs. 
    104108Note that it is still possible to reverse changes, if  
    105 <a href="#archive">archive files</A>, but this may require more effort. 
    106  
     109<a href="#archive">archive files</A>, but this may require more 
     110  effort. See the File/revert menu entry. 
    107111<a name="execprompt"></a> 
    108112<DT>Prompt after GSAS run<DD> 
     
    121125screen cluttered with EXPGUI when it can't be used,  
    122126but this is an option so that the mode can be turned off by those people 
    123 who find this behavior annoying. 
     127who find this behavior annoying. It appears this option causes 
     128  problems on Windows 7.  
    124129 
    125130<a name="AutostartGRWND"></a> 
     
    225230<DT>rawplot<DD>Plot powder data 
    226231<DT>fitspec<DD>Fit a TOF vanadium scattering spectrum 
    227 <DT>tofnorm<DD>Normalize a TOF spectrum 
    228232<DT><a HREF="liveplot.html#bkgedit">bkgedit</a> 
    229233<DD>Invokes the <a HREF="liveplot.html#bkgedit">BKGEDIT</a> program 
     
    233237to set the upper and lower limits for a histogram, as well as 
    234238edit excluded regions. 
     239<DT>seqgsas<DD>Invokes the sequential GSAS refinement program to run 
     240  GENLES on a set of very similar data files. 
     241<DT>mustrplot<DD>Plot microstrain results 
     242<DT><a HREF="expgui.html#INSTEDIT">instedit</A><DD>Invokes the <a HREF="expgui.html#INSTEDIT">instedit</A> 
     243  to edit an instrument parameter file. 
     244<DT>New InstParm file<DD>Creates a new instrument parameter file using 
     245  <a HREF="expgui.html#INSTEDIT">instedit</A>. 
     246 
     247 
    235248</DL> 
    236249<img SRC="m3.gif"  BORDER=3 alt="EXPGUI Screen snapshot"> 
     
    238251 
    239252<a name="4"></a> 
    240 <h3>C.4 Single Crystal Menu</h3> 
     253<h3>C.4 Xtal (Single Crystal) Menu</h3> 
    241254<BLOCKQUOTE> 
    242255This menu contains links to GSAS programs used for  
     
    268281<DT>fourier<DD>Generate Fourier map 
    269282<DT>forsrh<DD>Search Fourier map for peaks 
     283<DT>gsas2map<DD>Exports a Fourier map in formats used by other 
     284  programs (for example Fox and DRAWxtl). 
    270285<DT><a HREF="liveplot.html#liveplot">liveplot</a> 
    271286<DD>Invokes the <a HREF="liveplot.html#liveplot">LIVEPLOT</a> program 
     
    274289<DT>vrstplot<DD>Create a VRML 3-D file for viewing with 3rd party software 
    275290<DT>widplt<DD>Displays the FWHM as a function of Q, 2Theta,... for UVWXY values input or read from an EXP file 
     291<DT><a HREF="expgui.html#ABSPLT">absplt</A> 
     292<DD>The <a HREF="expgui.html#ABSPLT">absplt</A> program displays the 
     293  absorption/reflectivity correction curve for values used in a histogram. 
     294<DT>mustrplot<DD>Plot microstrain results 
     295<DT>seqplot<DD>Plot results from seqgsas 
    276296</DL> 
    277297<img SRC="m5.gif"  BORDER=3 alt="EXPGUI Screen snapshot"> 
     
    287307<DT>bijcalc<DD>Thermal parameter analysis 
    288308<DT>disagl<DD>Distance/angle calculations 
     309<DT>disaglviewer<DD>Display results from distance/angle calculations 
     310  in a graphical browser. 
    289311<DT>reflist<DD>List reflection data 
    290312<DT>geometry<DD>Molecular geometry calculations 
     
    297319<DT>ramafit<DD>Fits torsion angle distributions, particularly in peptide 
    298320chains, for use in restraints. 
     321<DT>seqplot<DD>Plot results from seqgsas 
    299322</DL> 
    300323<img SRC="m6.gif"  BORDER=3 alt="EXPGUI Screen snapshot"> 
     
    307330<DL> 
    308331<DT>cllchg<DD>Transform unit cell 
    309 <DT>fprime<DD>Compute f, f', f'' and mu/rho for an element for a range of x-ray wavelengths 
     332<DT>composition<DD>Computes the chemical composition of a unit cell 
     333accounting for site multiplicies and occupancies 
    310334<DT>rducll<DD>Unit cell reduction 
    311335<DT>spcgroup<DD>Space group symbol interpreter 
     336<DT>seqgsas<DD>Invokes the sequential GSAS refinement program to run 
     337  GENLES on a set of very similar data files. 
     338<DT>seqplot<DD>Plot results from seqgsas 
    312339<DT>unimol<DD>Unique molecule assembler 
    313340</DL> 
     
    315342</BLOCKQUOTE> 
    316343 
    317 <a name="8"></a> 
    318 <h3>C.8 Import/Export Menu</h3> 
    319 <BLOCKQUOTE> 
    320 This menu contains utilities for importing information into GSAS and 
    321 exporting. 
    322 <DL> 
    323 <DT>exp2xtl<DD>Prepare a .XTL format file of atomic positions. This 
    324 file is used in MSI software such as Cerius and InsightII. 
    325 <DT>gsas2cif<DD>Prepare IUCr crystallographic information (CIF) file 
    326 <DT>hklsort<DD>Prepare HKL tables 
    327 <DT>pubtable<DD>Prepare atom parameter tables 
    328 <DT>convert<DD>Convert a standard ASCII file to the direct access format used by GSAS (and for UNIX, the reverse) 
    329 <DT>cad4rd<DD>Prepare CAD4 single crystal data 
    330 <DT>dbwscnv<DD>Convert a powder diffraction data file from DBWS format 
    331 <DT>x17bcnv<DD>Convert an energy dispersive diffractogram data file from NSLS X17b 
    332 <DT>p3r3data<DD>Prepare Siemens/Brucker P3R3 single crystal data 
    333 <DT>sxtldata<DD>Prepare generic single crystal data 
    334 <DT>gsas2pdb<DD> 
    335 Import (using GSAS2PDB & EXPEDT) and export coordinates (for  
    336 macromolecular phases) to/from Protein Data Base files 
    337 <DT>ref2asc<DD> 
    338 Exports a GSAS reflection file to ASCII for use in non-GSAS programs 
    339 <DT>ref2bin<DD> 
    340 Imports an ASCII reflection file to the GSAS binary format 
    341 </DL> 
    342 <img SRC="m8.gif"  BORDER=3 alt="EXPGUI Screen snapshot"> 
    343 </BLOCKQUOTE> 
    344  
    345344<a name="9"></a> 
    346 <h3>C.9 Macro Menu 
     345<h3>C.8 Macro Menu 
    347346<IMG SRC="new.gif" HEIGHT=13 WIDTH=36 alt="New!"> 
    348347</h3> 
     
    402401</DL> 
    403402</BLOCKQUOTE> 
     403 
     404<a name="8"></a> 
     405<h3>C.9 Import/Export Menu</h3> 
     406<BLOCKQUOTE> 
     407This menu contains utilities for importing information into GSAS and 
     408exporting it to other programs. 
     409<DL> 
     410<DT>Coord Export<DD>This provides a series of routines that are used 
     411to write coordinates and possibly other information to files:<P> 
     412<DL> 
     413<DT>gsas2cif<DD>Prepares IUCr crystallographic information (CIF) file 
     414that documents the current refinement. The CIF contains the 
     415coordinates for all phases as well as the observed and computed 
     416diffraction patterns. The templates used by GSAS2CIF can be customized 
     417to provide a detailed description of the experimental measurements and 
     418results for use in documenting analysis for publication or 
     419deposition.  
     420<DT>coords-only CIF<DD>For export of intermediate results to another 
     421program, CIF can be a useful exchange format. This routine provides a 
     422CIF with the current coordinates from one phase and not much else. 
     423<DT>export to DRAWxtl<DD>This writes a .STR file used in the DRAWxtl 
     424program and optionally launches DRAWxtl.  
     425<DT>export to SHELX<DD>This writes coordinates for a selected phase in 
     426the .INS format used by SHELX and several other programs. 
     427<DT>export to PLATON<DD>This writes coordinates for a selected phase in 
     428the .SPF format used by PLATON 
     429<DT>export test format<DD>This demonstrates how a coordinate export 
     430routine can be added to EXPGUI. See the <A 
     431HREF="expgui_cfg.html#export">documentation on this</A> for further 
     432information.  
     433<DT>export to FOX<DD>This prepares a XML file with coordinates for use 
     434in the FOX program 
     435<DT>MSI .xtl<DD>Prepare a .XTL format file of atomic positions. This 
     436file is used in older Accelrys software such as Cerius and 
     437Insight-II. It may no longer be of value. 
     438</DL> 
     439 
     440<DT>CIF Export<DD>This provides a series of routines that are used 
     441to prepare CIF files:<P> 
     442<DL> 
     443<DT>gsas2cif<DD>Prepares IUCr crystallographic information (CIF) file 
     444that documents the current refinement. The CIF contains the 
     445coordinates for all phases as well as the observed and computed 
     446diffraction patterns. The templates used by GSAS2CIF can be customized 
     447to provide a detailed description of the experimental measurements and 
     448results for use in documenting analysis for publication or 
     449deposition. 
     450<DT>FillTemplate<DD>Used to edit the CIF template files used in GSAS2CIF 
     451<DT>CIFselect<DD>Used to select interatomic distances and angles to be 
     452included in the CIF created by GSAS2CIF. 
     453</DL> 
     454 
     455<DT>hklsort<DD>Prepare HKL tables 
     456<DT>pubtable<DD>Prepare atom parameter tables 
     457<DT>convert<DD>Convert a standard ASCII file to the direct access format used by GSAS (and for UNIX, the reverse) 
     458<DT>cad4rd<DD>Prepare CAD4 single crystal data 
     459<DT>dbwscnv<DD>Convert a powder diffraction data file from DBWS format 
     460<DT>x17bcnv<DD>Convert an energy dispersive diffractogram data file from NSLS X17b 
     461<DT>p3r3data<DD>Prepare Siemens/Brucker P3R3 single crystal data 
     462<DT>sxtldata<DD>Prepare generic single crystal data 
     463<DT>gsas2pdb<DD> 
     464Import (using GSAS2PDB & EXPEDT) and export coordinates (for  
     465macromolecular phases) to/from Protein Data Base files 
     466<DT>ref2asc<DD> 
     467Exports a GSAS reflection file to ASCII for use in non-GSAS programs 
     468<DT>ref2bin<DD> 
     469Imports an ASCII reflection file to the GSAS binary format 
     470<DT>gsas2map<DD>Exports a Fourier map in formats used by other 
     471  programs (for example Fox and DRAWxtl). 
     472</DL> 
     473<img SRC="m8.gif"  BORDER=3 alt="EXPGUI Screen snapshot"> 
     474</BLOCKQUOTE> 
     475 
    404476<hr> 
    405477<TABLE BORDER BGCOLOR="#FFFF40" ALIGN=RIGHT> 
  • trunk/doc/gsas2cif.html

    r971 r1166  
    3333<BR> 
    3434to export 
    35 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/gsas.html"> 
    36 GSAS</A> 
     35<A Href="https://subversion.xor.aps.anl.gov/trac/EXPGUI/wiki/GSASIntro">GSAS</A> 
    3736results 
    3837<HR noshade width="75%" size="2" align="center"> 
     
    575574</BLOCKQUOTE> 
    576575 
    577 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    578 <font size=-1><? lastmod(); ?></font> 
    579 $Revision$ $Date$ 
    580576</font> 
    581577</BLOCKQUOTE> 
  • trunk/doc/liveplot.html

    r971 r1166  
    4040<P> 
    4141Both LIVEPLOT and BKGEDIT get the current diffraction information  
    42 by running the GSAS TCLDUMP program, if installed, or 
    43 the GSAS HSTDUMP otherwise. The TCLDUMP program has been optimized for use  
    44 with LIVEPLOT and allows LIVEPLOT to offer a number of extra  
    45 options that are not available when HSTDUMP is used. Since TCLDUMP has been  
    46 included in GSAS since April of 2000, the following documentation assumes  
    47 that TCLDUMP is installed. 
     42by running the GSAS TCLDUMP program. (In GSAS/EXPGUI before 2001, the 
     43GSAS HSTDUMP program was used, which was less powerful. This code has 
     44not been removed, but will not be used if TCLDUMP is present.) 
    4845 
    4946<a name="liveplot"></a> 
     
    5451Some of the features available in LIVEPLOT are: 
    5552<UL> 
    56 <LI>The plot is updated automatically after each refinement run 
     53<LI><IMG SRC="new.gif" alt="New!">  
     54Regions of the plot can be magnified to show more detail, for example 
     55  in regions at high Q.  
     56<LI><IMG SRC="new.gif" alt="New!">  
     57Plots can be <a href="#export">exported to obtain publication-quality 
     58graphics </a> -- <B><I>now on all platforms</I></B>. 
     59<LI><IMG SRC="new.gif" alt="New!"> Intensity can be displayed as I/sigma(I) 
     60 <LI>The plot is updated automatically after each refinement run 
    5761<LI>The plot can be "zoomed-in", by clicking on the corners of the  
    5862area to be magnified and "zoomed-out" using the  
     
    6165The units used for plotting histograms can be selected. Choices are:  
    6266native units (2Theta/TOF/KeV); d-space (A) or Q (A<sup>-1</sup>) 
    63 <LI> 
    64 The background (fixed plus fitted) can be plotted or can be subtracted.  
     67 <LI> 
     68  The background (fixed plus fitted) can be plotted or can be subtracted.  
    6569<LI> 
    6670Reflection tickmarks can be displayed in a variety of formats  
     
    7377<LI> 
    7478The cumulative chi<sup>2</sup> function or  
    75 <IMG SRC="new.gif" alt="New!"> (obs-calc)/sigma can be plotted. 
     79 (obs-calc)/sigma can be plotted. 
    7680<LI> 
    7781The cursor position can be displayed 
    78 <LI> 
    79 Plots can be <a href="#export">exported to obtain publication-quality 
    80 graphics.</a> 
    8182</UL> 
    8283 
     
    285286<P> 
    286287<a name="zoomshift"></a> 
    287 <IMG SRC="new.gif" alt="New!"> 
    288288To shift the zoom region around,  
    289289the right and left arrow keys can be used to shift the  
     
    363363<br clear=all> 
    364364<P> 
     365<a name="magnification"></a> 
     366<B>Plot Magnification</B> 
     367Sections of the plot can be magnified through use of options in the 
     368Magnification menu or by using control-1 through control-9.  
     369<img SRC="magreg.png" align=RIGHT alt="LIVEPLOT Screen snapshot"> 
     370<UL> 
     371<LI>The Magnification/Add region menu item requests a location in the 
     372  pattern (2Theta/TOF/KeV/d-space/Q) and a multiplier. Data where the 
     373  scan variable (2Theta...) is of that value or higher, up to the 
     374  next region or end of the pattern are multiplied by that factor. The 
     375  factor, must be >0. 
     376<LI>Magnification/Edit regions brings up a menu (see below) where the previously 
     377 defined regions can be changed. The region boundaries can be moved 
     378  and the multiplier values can be changed. If a multiplier is set to 
     379  zero (or negative) that region is removed. 
     380<LI>Magnification/Clear deletes all previously defined regions 
     381<LI>Pressing control plus a positive digit (1,2,3,...9) also adds a 
     382  magnification region. The digit determines the magnification 
     383  multiplier. Data where the 
     384  scan variable (2Theta...) from the mouse position up to the 
     385  next region or end of the pattern are multiplied by that factor. 
     386<img SRC="editreg.png" align=RIGHT alt="LIVEPLOT menu"> 
     387</UL> 
     388 <br clear=all> 
     389<P> 
    365390<a name="export"></a> 
    366391<B>Export plot options</B> 
    367392<UL><LI> 
    368 The plot can be exported to  
     393<IMG SRC="new.gif" alt="New!">  
     394The LIVEPLOT program can export plots to to a <I>high quality</I> PDF 
     395  file for presentations or publications using <A 
     396  HREF="http://www.gnuplot.info/">gnuplot</A>. 
     397  The PDF will match what is is shown on fairly 
     398  closely with respect to colors, <A href="#plotfont">font sizes</a> 
     399  and <a href="#zoom">zoom</a>. The new <A href="#magnification">plot magnification</a> to show detail in 
     400  the fit and for publication increase the  
     401  <A href="#plotfont">plot font</a> so that the figure size can be 
     402  reduced to the standard Rietveld postage stamp, required by so many 
     403  Journals -- allowing the text to be discerned, even if the problems in the 
     404  fit cannot. 
     405  <P>Starting August 
     406  2011, windows and Mac versions of gnuplot are included with the GSAS 
     407  binaries; gnuplot is easily 
     408  installed on Linux with standard tools such as yum (Redhat), 
     409  apt-get (ubuntu) or zypper (openSuse).  
     410 
     411<P><LI>  The plot can be exported to  
    369412<A HREF="http://plasma-gate.weizmann.ac.il/Grace/">Grace</A>, WYSIWYG 2D plotting tool for X-Windows 
    370 that produces publication-quality graphics. Many UNIX users know  
    371 this program under a previous name, xmgr. 
    372 The export is implemented  
    373 by producing an ASCII file with instructions that  
    374 creates a plot with similar formatting to what appears on the  
    375 screen in LIVEPLOT/BKGEDIT. However, the output quality from  
    376 Grace is much higher quality. Further, Grace 
    377 can be used to enhanced and annotate the plot further. 
    378 <LI> 
     413that produces publication-quality graphics that appear very similar to 
     414  what is seen in LIVEPLOT/BKGEDIT. Further, Grace 
     415  can be used to enhance the plot, for example by editing captions, 
     416  figure display options and even annotate the plot. 
     417  Grace runs well on Linux and Mac computers; Many UNIX users know  
     418  this program under a previous name, xmgr. 
     419  For Windows, 
     420  installation of <A HREF="http://cygwin.com/">Cygwin</A> is required. 
     421  <P><LI> 
    379422For use in many other graphics programs, LIVEPLOT will produce a  
    380423"comma separated variable" data file with the data displayed on the screen.  
     
    382425set line styles and scaling, etc., but this does provide an option for  
    383426generating high-quality graphics for presentations and publications. 
    384 <LI>LIVEPLOT will produce PostScript versions of the plot on the screen, 
     427<P><LI>LIVEPLOT will produce PostScript versions of the plot on the screen, 
    385428but the quality is rather low (this is a limitation of the BLT graphics 
    386429package). 
     430  <P><LI>LIVEPLOT/BKGFIT can also be used to prepare input for FOX (Free 
     431  Objects for Xtallography).  
     432   
    387433</UL> 
    388434 
     
    408454<DT><a href="#zoomshift">arrow keys</A> 
    409455<DD>Moves zoom region around in plot 
     456<DT><a href="#mag">Control+1, 2,...</a> 
     457<DD>Defines a <a href="#magnification">magnification region</A> at the 
     458  cursor location. 
    410459</DL> 
    411460 
     
    438487<DT>Export Plot 
    439488<DD>This offers options for exporting the plot in multiple formats. 
    440 I am hoping to add more export formats eventually. 
    441 <DL><DL> 
     489<DL><DL> 
     490<DT>to PDF 
     491 <IMG SRC="new.gif" alt="New!">  
     492<DD>Creates a <I>high quality</I> PDF file that may be useful for 
     493  presentations or publications. Note that you may wish to use 
     494  <A href="#magnification">plot magnification</a> to show detail in 
     495  the fit and for publication increase the  
     496  <A href="#plotfont">plot font</a> so that the figure size can be 
     497  reduced. 
     498 
    442499<DT>to PostScript 
    443500<DD>Creates a <I>low quality</I> PostScript file containing the LIVEPLOT  
     
    446503On Windows, a program such ghostview may be needed to translate the  
    447504PostScript to a format that can be viewed or printed. 
    448 <A name="grace"> 
     505 
     506  <A name="grace"> 
    449507<DT>to Grace 
    450508<IMG SRC="note.gif" alt="Note!"> 
     
    454512After the plot is exported, it can be further  
    455513enhanced and annotated in grace. 
     514 
     515<DT>to .csv file 
     516  <DD>Creates a "comma separated variable" file. This contains all the 
     517  diffraction data shown in the plot. It can be used to produce a plot 
     518  in some other graphics program.  
     519  <DT>Fox XML 
     520  <DD>The Fox program provides structure solution capabilities. This 
     521  option can be used to write data in the XML format that Fox uses.  
    456522</DL></DL> 
    457523<DT>Quit 
     
    505571<DT>Y units 
    506572<DD>The intensity values can be normalized by the incident spectrum 
    507 (for energy dispersive methods). 
     573(for energy dispersive methods) or 
     574  <IMG SRC="new.gif" alt="New!"> can be displayed as a ratio with the 
     575  experimental uncertainty [I<sub>obs</sub>/sigma(I<sub>obs</sub>), 
     576  I<sub>calc</sub>/sigma(I<sub>obs</sub>) and their difference]. 
    508577</DL></DL> 
    509578<br clear=all> 
     
    535604<DT>Set screen font 
    536605<DD>This option is used to control the font used for menus, graphics and  
    537 other aspects of windows.  
     606other aspects of windows. This value can be saved as a default value.  
     607<A name="plotfont"> 
     608  <DT>Set plot font 
     609<DD>This option is used to change the font used in the plot 
     610  window. This has a similar effect to changing the screen font, but 
     611  can be changed over a wider range and only affects the 
     612  graph. Changing the font size either way will change the font used 
     613  in the exported .PDF. 
    538614<DT>Raise on update 
    539615<DD>This causes the plot to be placed on top of other windows, if partially 
     
    650726<P> 
    651727<hr><H2>Interfacing External Programs</H2> 
    652 <IMG SRC="new.gif" alt="New!"> 
    653728<B>Combining LIVEPLOT with CMPR & LOGIC</B> 
    654729If you have the  
    655 <A HREF="http://www.ncnr.nist.gov/programs/crystallography/software/cmpr"> 
    656 CMPR/LOGIC</A> 
    657 programs installed on your computer, you can use superimpose on the  
     730<A HREF="https://subversion.xor.aps.anl.gov/trac/CMPR">CMPR</A> 
     731program installed on your computer, you can use superimpose on the  
    658732GSAS results the peaks for an arbitrary unit cell. 
    659 If you have an old version of the  
    660 <A HREF="http://www.icdd.com/products/overview.htm"> 
    661 ICDD-JCPDS PDF-2 powder diffraction database</a>,  
    662 (when distributed as an AIDS*83 format flat file) 
    663 you can also superimpose entries from this database on the  
    664 GSAS results displayed in LIVEPLOT.  
    665 <P> 
    666 When the CMPR/LOGIC program is installed in the same location 
     733<P> 
     734When the CMPR program is installed in the same location 
    667735as the GSAS package (<i>e.g.</i>  
    668736<font face="courier">/home/gsas</font> &  
     
    692760software is located. The 
    693761"Display a cell" option produces a window similar to the 
    694 <A href="http://www.ncnr.nist.gov/xtal/software/cmpr/doc/cmprdoc.html#editcell"> 
     762<A href="https://subversion.xor.aps.anl.gov/CMPR/trunk/doc/cmprdoc.html#editcell"> 
    695763Edit Cell feature in CMPR</A> 
    696764where allowed reflection positions are displayed for a set of unit cell  
    697765parameters and optionally a space group or extinction conditions. 
    698 The "Plot ICDD Entry" provides a window similar to the  
    699 <A href="http://www.ncnr.nist.gov/xtal/software/cmpr/doc/cmprdoc.html#editcell"> 
    700 LOGIC interface in CMPR</A> 
    701 where ICDD searches may be conducted. From the resulting list of matches, 
    702 selected entries may be displayed. 
    703766<P> 
    704767Note that these routines display peak positions in units of 2Theta, Q or 
     
    718781</TH></TR></TABLE> 
    719782 
    720 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    721 <font size=-1><? lastmod(); ?> </font> 
    722 <br> 
    723 $Revision$ $Date$ 
    724783</blockquote> 
    725784</body> 
  • trunk/doc/revlog.html

    r971 r1166  
    3232    </h1></center> 
    3333    <P> 
    34     This page describes all revisions logged for changes to the EXPGUI source 
     34    This page has been superceeded by the Trac registry, see 
     35    <A HREF="https://subversion.xor.aps.anl.gov/trac/EXPGUI/timeline"> 
     36    https://subversion.xor.aps.anl.gov/trac/EXPGUI/timeline</A>. 
     37    <HR><HR> 
     38    Below is information on older revisions logged for changes to the EXPGUI source 
    3539    files, sorted by date.  
    36     See the <A HREF="wishlist.html">EXPGUI Wish List</A> for a more  
    37     descriptive listing. 
    38  
     40    See the 
     41    <A HREF="https://subversion.xor.aps.anl.gov/trac/EXPGUI/report"> 
     42    View Tickets</A> section of the Trac site for active and closed 
     43    projects. There is some older information on the  
     44    <A HREF="wishlist.html">EXPGUI Wish List</A>. 
     45     
    3946<h2>since 1-Jun-2009</h2><DL><DL> 
    4047</DL></DL> 
     
    16331640    </TH><TH><A Href="wishlist.html">Past and Planned<BR>Updates</A>   
    16341641    </TH></TR></TABLE> 
    1635     <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    1636     <font size=-1><? lastmod(); ?> </font> 
    1637     <br> 
    1638     </blockquote> 
     1642   </blockquote> 
    16391643 
    16401644Created Fri Jul 03 20:35:34 CDT 2009 
  • trunk/doc/win_old_notes.html

    r971 r1166  
    4343Nonetheless, please report problems, including improvements on  
    4444these instructions to 
    45 <A HREF="mailto:brian.toby@nist.gov">Brian Toby</A>. 
     45<A HREF="mailto:brian.toby@anl.gov">Brian Toby</A>. 
    4646Otherwise, Windows-specific issues are unlikely to be addressed or repaired. 
    4747</EM> 
     
    5757<P> 
    5858<LI>Get  
    59 <A Href="http://www.ncnr.nist.gov/programs/crystallography/software/gsas.html"> 
    60 GSAS</A> from one of the following sites: 
     59<A Href="https://subversion.xor.aps.anl.gov/trac/EXPGUI/wiki/GSASIntro">GSAS</A> 
     60from one of the following sites: 
    6161<DL><P> 
    6262<DT>UK<DD> 
     
    296296<A HREF="MAILTO:vondreele@anl.gov">vondreele@anl.gov</A> 
    297297<P>EXPGUI is written by Brian H. Toby of the NIST Center for Neutron Research, 
    298 <A HREF="MAILTO:Brian.Toby@NIST.GOV">Brian.Toby@NIST.GOV</A>  
     298<A HREF="MAILTO:Brian.Toby@ANL.GOV">Brian.Toby@ANL.GOV</A>  
    299299with help from Jonathan Wasserman. 
    300300 
     
    325325</TH></TR></TABLE> 
    326326 
    327 <P><font size=-1><A HREF="MAILTO:crystal@NIST.gov?subject=WWW page <?=$PHP_SELF?>">Comments, corrections or questions: crystal@NIST.gov</A></font><BR> 
    328 <font size=-1><? lastmod(); ?> </font> 
    329 <br> 
    330 $Revision$ $Date$ 
    331327</blockquote> 
    332328</body> 
  • trunk/doc/wishlist.html

    r971 r1166  
    3131<HR noshade width="75%" size="2" align="center"> 
    3232</h1></center> 
     33<I><blockquote><blockquote> 
     34Information on desired (and completed) development tasks for EXPGUI 
     35are now captured as "Tickets" in the 
     36    <A HREF="https://subversion.xor.aps.anl.gov/trac/EXPGUI/"> 
     37EXPGUI Trac system</A>. In particular, see the 
     38    <A HREF="https://subversion.xor.aps.anl.gov/trac/EXPGUI/timeline"> 
     39    timeline of changes</A> and the  
     40   <A HREF="https://subversion.xor.aps.anl.gov/trac/EXPGUI/report"> 
     41    reports on Tickets</A>. Any other information on this page is no 
     42longer being updated -- though there are still some good ideas for 
     43development here. 
     44</blockquote></blockquote></I> 
     45<P> 
     46<hr><hr> 
     47 
     48 
    3349<P> 
    3450This page describes recent features added to EXPGUI or that are being  
  • trunk/expgui

    r1161 r1166  
    327327            file copy -force $expgui(expfile) $expnam.EXP 
    328328            set expgui(expfile) $expnam.EXP 
     329            wm title . "EXPGUI interface to GSAS: [file tail $expgui(expfile)]" 
     330            set expgui(titleunchanged) 1 
    329331        } else { 
    330332            MyMessageBox -parent . -title "File not found" \ 
     
    334336        } 
    335337    } else { 
    336         SetEXPfile $expgui(expfile) 
     338        set expgui(expfile) [SetEXPfile $expgui(expfile)] 
    337339    } 
    338340} 
     
    349351    # I am not sure it is still needed. 
    350352    update 
    351     SetEXPfile [getExpFileName ""] 
     353    set expgui(expfile) [SetEXPfile [getExpFileName ""]] 
    352354    set expgui(resize) 1 
    353355} 
     
    361363proc loadexp {expfile} { 
    362364    global expgui expmap entryvar entrycmd tcl_platform 
    363     set prevexp $expgui(expfile) 
    364     # is this a compressed archive file?  
    365     if {[string match {*.O[0-9A-F][0-9A-F]} $expfile]} { 
    366         set expnam [file rootname $expfile] 
    367         set ans [MyMessageBox -parent . -title "Load Archived File" \ 
    368                 -message "Loading archived version of $expnam. Do you want to continue using the same experiment name or work with the archived version under a new name?" \ 
    369                 -icon question -type "{Use New Name} {Continue with current}" \ 
    370                 -default {Use New Name} \ 
    371                 -helplink "expguierr.html LoadArchived" 
    372         ] 
    373         # archive the current .EXP file 
    374         if {$ans != "use new name" && [file exists $expfile]} { 
    375             # get the last archived version 
    376             set lastf [lindex [lsort [glob -nocomplain $expnam.{O\[0-9A-F\]\[0-9A-F\]}]] end] 
    377             if {$lastf == ""} { 
    378                 set num 01 
    379             } else { 
    380                 regexp {.*\.O([0-9A-F][0-9A-F])$} $lastf a num 
    381                 scan $num %x num 
    382                 if {$num >= 255} { 
    383                     set num FF 
    384                 } else { 
    385                     set num [string toupper [format %.2x [incr num]]] 
    386                 } 
    387             } 
    388             catch { 
    389                 set newfile $expnam.O$num 
    390                 file rename -force $expnam.EXP $newfile 
    391                 set fp [open $expnam.LST a+] 
    392                 puts $fp "\n----------------------------------------------" 
    393                 puts $fp "     Regressing to archive file [file tail $expfile]" 
    394                 puts $fp "     but first archiving [file tail $expnam.EXP] as [file tail $newfile]" 
    395                 puts $fp "----------------------------------------------\n" 
    396                 close $fp 
    397             } 
    398             file copy -force $expfile $expnam.EXP 
    399             set expfile $expnam.EXP 
    400         } 
    401         if {$ans == "use new name"} { 
    402             set newexpfile [getExpFileName new] 
    403             if {$newexpfile == ""} return  
    404             file copy -force $expfile $newexpfile 
    405             catch {cd [string trim [file dirname $expgui(expfile)]]} 
    406             set expfile [file tail $newexpfile] 
    407             set expgui(needpowpref) 2 
    408             set expgui(needpowpref_why) "\tA new .EXP file was created\n"  
    409             SetEXPfile $newexpfile 
    410         } else { 
    411             SetEXPfile $expfile 
    412         } 
    413         if {$expgui(expfile) == ""} { 
    414             set expgui(expfile) $prevexp 
    415             return 
    416         } 
    417     } 
    418  
     365    set expfile [SetEXPfile $expfile] 
     366    if {$expfile == ""} { 
     367        return 
     368    } 
    419369    # change the icon and assign an app to this .EXP file 
    420370    if {$tcl_platform(os) == "Darwin" && $expgui(MacAssignApp)} { 
    421371        MacSetResourceFork $expfile 
    422372    } 
    423  
    424     SetEXPfile $expfile 
    425     if {$expgui(expfile) == ""} { 
    426         set expgui(expfile) $prevexp 
    427         return 
    428     } 
    429373    # read in the .EXP file 
    430374    set fmt [expload $expfile] 
     375    set expgui(expfile) $expfile 
    431376    # if the file was not in the correct format, force a rewrite before use 
    432377    if {$fmt < 0} { 
     
    453398    set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ] 
    454399    # set the window/icon title 
    455     wm title . "EXPGUI interface to GSAS: $expfile" 
     400    wm title . "EXPGUI interface to GSAS: [file tail $expgui(expfile)]" 
    456401    set expgui(titleunchanged) 1 
    457402    wm iconname . [file tail $expfile] 
     
    462407    # start checking for external changes 
    463408    afterawhile 
     409    # check if the file seems corrupt 
     410    set warnings [ScanEXPforError] 
     411    if {$warnings != ""} { 
     412        ExplainEXPerror . $warnings $expfile 
     413    } 
    464414} 
    465415 
     
    547497    global expgui 
    548498    global tcl_platform 
    549     set prevexp $expgui(expfile)  
    550     set newexpfile [getExpFileName new] 
    551     if {$newexpfile == ""} return  
    552     SetEXPfile $newexpfile 1 
    553     if {$expgui(expfile) == ""} { 
    554         set expgui(expfile) $prevexp 
    555         return 
    556     } 
     499    set newexpfile [SetEXPfile [getExpFileName new] 1] 
     500    if {$newexpfile == ""} return 
    557501    expwrite $newexpfile 
     502    set expgui(expfile) $newexpfile 
    558503    # change the icon and assign an app to this .EXP file 
    559504    if {$tcl_platform(os) == "Darwin" && $expgui(MacAssignApp)} { 
     
    574519 
    575520# called to read a different .EXP file 
    576 proc readnewexp {} { 
     521proc readnewexp {"mode 0"} { 
    577522    global expgui expmap 
    578523    if $expgui(changed) { 
     
    586531        } 
    587532    } 
    588     set prevexp $expgui(expfile)  
    589     set newexpfile [getExpFileName old] 
    590     if {$newexpfile == ""} return  
    591     SetEXPfile $newexpfile 
    592     if {$expgui(expfile) == ""} { 
    593         set expgui(expfile) $prevexp 
    594         return 
    595     } 
    596  
    597     # switch to the 1st page 
    598     RaisePage lsFrame 
     533    if {$mode == 0} { 
     534        set newexpfile [getExpFileName old] 
     535    } else { 
     536        set newexpfile [RevertExpFile] 
     537    } 
     538    if {$newexpfile == ""} return 
     539 
    599540    set expgui(globalmode) 0 
    600     loadexp $expgui(expfile) 
     541    loadexp $newexpfile 
     542 
     543    # switch to the appropriate 1st page 
     544    #StageTabUse 
     545    SetStartPanel 
    601546 
    602547    # reset the phase selection 
     
    609554        set expgui(curhist) {} 
    610555    } 
    611     if {[CountHistory] > 100} { 
    612         DeleteHistoryRecords "This .EXP file has [CountHistory] history records\nErasing most will speed EXPGUI" 
    613     } 
     556#    if {[CountHistory] > 100} { 
     557#       DeleteHistoryRecords "This .EXP file has [CountHistory] history records\nErasing most will speed EXPGUI" 
     558#    } 
    614559} 
    615560 
     
    10581003 
    10591004    set crsPhase {} 
    1060     $expgui(atomxform) config -text "Xform Atoms" -state disabled 
     1005    $expgui(atomxform) config -text "Modify Atoms" -state disabled 
    10611006    foreach n $expmap(phaselist) type $expmap(phasetype) { 
    10621007        if {$n == $num} { 
     
    10991044        DisplayRefFlags 0 0 
    11001045        $expgui(atomlistbox) delete 0 end 
     1046        $expgui(AddAtomBut)  config -state disabled 
    11011047        return 
    11021048    } 
    11031049 
    11041050    # don't reload the last displayed phase 
    1105     if {$expgui(curPhase) == $crsPhase} return 
     1051    if {$expgui(curPhase) == $crsPhase} { 
     1052       DisplayAllAtoms $crsPhase 
     1053       return 
     1054    } 
    11061055 
    11071056    ########################################################## 
     
    11271076    DisplayRefFlags 0 0 
    11281077    $expgui(EditingAtoms) config -text "" 
     1078    $expgui(AddAtomBut)  config -state normal 
    11291079 
    11301080    DisplayAllAtoms $crsPhase 
     
    13081258            } else { 
    13091259                append refflag " [mmatominfo $phase $atom ${type}damp] " 
    1310             }    
     1260            } 
    13111261        } 
    13121262        set line [format \ 
     
    13231273                [mmatominfo $phase $atom z] \ 
    13241274                [mmatominfo $phase $atom frac] \ 
    1325                 [mmatominfo $phase $atom Uiso]  
     1275                [mmatominfo $phase $atom Uiso] 
    13261276        ] 
    13271277    } elseif {[atominfo $phase $atom temptype] == "A"} { 
     
    13371287        set maxline A 
    13381288        # aniso 
    1339         set line [format "%3d %-6s %-6s %8s %10.6f%10.6f%10.6f%4d%9.4f" \ 
     1289        set fmt "%3d %-6s %-6s %8s %s%s%s%4d%9.4f" 
     1290        set line [format $fmt \ 
    13401291                $atom \ 
    13411292                [atominfo $phase $atom label] \ 
    13421293                [atominfo $phase $atom type] \ 
    13431294                $refflag \ 
    1344                 [atominfo $phase $atom x] \ 
    1345                 [atominfo $phase $atom y] \ 
    1346                 [atominfo $phase $atom z] \ 
     1295                [ShowFixAtom $phase $atom x] \ 
     1296                [ShowFixAtom $phase $atom y] \ 
     1297                [ShowFixAtom $phase $atom z] \ 
    13471298                [atominfo $phase $atom mult] \ 
    1348                 [atominfo $phase $atom frac]  
     1299                [atominfo $phase $atom frac] 
    13491300        ] 
    13501301        append line [format "  %9.5f%9.5f%9.5f%9.5f%9.5f%9.5f" \ 
     
    13541305                [atominfo $phase $atom U12] \ 
    13551306                [atominfo $phase $atom U23] \ 
    1356                 [atominfo $phase $atom U13]  
     1307                [atominfo $phase $atom U13] 
    13571308        ] 
    13581309    } else { 
     
    13621313            } else { 
    13631314                append refflag " [atominfo $phase $atom ${type}damp] " 
    1364             }    
    1365         } 
    1366         set line [format \ 
    1367                 "%3d %-6s %-6s %8s %10.6f%10.6f%10.6f%4d%9.4f  %9.5f" \ 
     1315            } 
     1316        } 
     1317        #set fmt "%3d %-6s %-6s %8s %10.6f%10.6f%10.6f%4d%9.4f  %9.5f" 
     1318        set fmt "%3d %-6s %-6s %8s %s%s%s%4d%9.4f  %9.5f" 
     1319        set line [format $fmt \ 
    13681320                $atom \ 
    13691321                [atominfo $phase $atom label] \ 
    13701322                [atominfo $phase $atom type] \ 
    13711323                $refflag \ 
    1372                 [atominfo $phase $atom x] \ 
    1373                 [atominfo $phase $atom y] \ 
    1374                 [atominfo $phase $atom z] \ 
     1324                [ShowFixAtom $phase $atom x] \ 
     1325                [ShowFixAtom $phase $atom y] \ 
     1326                [ShowFixAtom $phase $atom z] \ 
    13751327                [atominfo $phase $atom mult] \ 
    13761328                [atominfo $phase $atom frac] \ 
    1377                 [atominfo $phase $atom Uiso]  
     1329                [atominfo $phase $atom Uiso] 
    13781330        ] 
    13791331    } 
    13801332    return $line 
     1333} 
     1334 
     1335# format a coordinate from a non-mm phase as 10 chars; mark fixed coordinates differently 
     1336proc ShowFixAtom {phase atom var} { 
     1337  # is this fixed? 
     1338  set param [string toupper $var] 
     1339  if {[array name ::fix_param "$phase,$atom,$param"] != ""} { 
     1340    return [format "%9.5fF" [atominfo $phase $atom $var]] 
     1341  } else { 
     1342    return [format "%10.6f" [atominfo $phase $atom $var]] 
     1343  } 
    13811344} 
    13821345 
     
    14421405    DisplayRefFlags $atomnum $p 
    14431406    $expgui(EditingAtoms) config -text "Editing atom #$atomnum -- [atominfo $p $atomnum label]" 
    1444     $expgui(atomxform) config -text "Xform Atom" -state normal 
     1407    $expgui(atomxform) config -text "Modify Atom" -state normal 
    14451408} 
    14461409 
     
    14671430    # this needs to track by phase 
    14681431    DisplayRefFlags $numberList $p 
    1469     $expgui(atomxform) config -text "Xform Atoms" -state normal 
     1432    $expgui(atomxform) config -text "Modify Atoms" -state normal 
    14701433} 
    14711434 
     
    18491812        set expgui(backtermlbl) "" 
    18501813        set expgui(backtypelbl) "" 
     1814        set expgui(abstypelbl) ""  
    18511815        foreach var {bref bdamp absref absdamp} { 
    18521816            set entrycmd($var) "" 
     
    18651829        set expgui(backtermlbl) "" 
    18661830        set expgui(backtypelbl) "" 
    1867         set expgui(abstypelbl) "" 
     1831        set expgui(abstypelbl) ""  
    18681832        foreach var {bref bdamp absref absdamp} { 
    18691833            set entrycmd($var) "histinfo [list $histlist] $var" 
     
    33493313            {SelectOnePhase $expgui(curPhase)} \ 
    33503314            0  expgui2.html ""} 
    3351     {histFrame    Histogram \ 
     3315    {histFrame    Powder \ 
    33523316            MakeHistPane \ 
    33533317            DisplayHistogram \ 
     
    33653329            DisplayConstraintsPane \ 
    33663330            0  expgui6.html ""} 
     3331    {rbFrame   "Rigid Body" \ 
     3332            "source  [file join $expgui(scriptdir) rigid.tcl]; MakeRBPane" \ 
     3333            DisplayRB \ 
     3334            1  expguiRB.html ""} 
    33673335    {orientFrame  "MD Pref Orient" \ 
    33683336            MakeOrientPane \ 
     
    33743342            0  expgui7.html ODF} 
    33753343} 
     3344 
     3345# future expansion: single crystal panel goes here -- if present 
     3346catch { 
     3347   source  [file join $expgui(scriptdir) single.tcl] 
     3348   set expgui(notebookpagelist) [linsert $expgui(notebookpagelist) 3 \ 
     3349       {singFrame   Single \ 
     3350       "MakeSinglePane" \ 
     3351       DisplaySingle \ 
     3352       1  expguiSing.html ""}] 
     3353} err 
     3354 
    33763355 
    33773356pack [NoteBook .n -bd 2] -expand yes -fill both 
     
    33963375    } 
    33973376} 
     3377 
     3378set expgui(startpanel) 2 
    33983379# procedure to disable tabs when phases or histograms are not defined 
    33993380proc StageTabUse {args} { 
    34003381    global expgui 
     3382    set expgui(startpanel) 2 
    34013383    # reset everything 
    34023384    foreach item [lrange $::expgui(notebookpagelist) 0 end] { 
     
    34233405            .n itemconfigure $frm -state disabled 
    34243406        } 
     3407        set expgui(startpanel) 0 
    34253408        return 
    34263409    } 
     
    34413424            .n itemconfigure $frm -state disabled 
    34423425        } 
     3426        set expgui(startpanel) 0 
    34433427        return 
    34443428    } 
     
    34503434            .n itemconfigure $frm -state disabled 
    34513435        } 
     3436        set expgui(startpanel) 1 
    34523437        return 
    34533438    } 
     
    34633448    .n see $nextpage 
    34643449    .n raise $nextpage 
     3450} 
     3451 
     3452proc SetStartPanel {} { 
     3453    global expgui 
     3454    if {$expgui(startpanel) == 0} { 
     3455        RaisePage phaseFrame 
     3456    } elseif {$expgui(startpanel) == 1} { 
     3457        RaisePage histFrame 
     3458    } else { 
     3459        RaisePage lsFrame 
     3460    } 
    34653461} 
    34663462 
     
    43074303    $expgui(fm).option.menu  add checkbutton -label "Prompt after GSAS run" \ 
    43084304            -variable expgui(execprompt) 
    4309     $expgui(fm).option.menu  add checkbutton -label "Iconify during GSAS" \ 
     4305    if {$tcl_platform(platform) == "windows" && \ 
     4306            $tcl_platform(osVersion) == 6.1} { 
     4307        set expgui(autoiconify) 0 
     4308        $expgui(fm).option.menu  add checkbutton -label "Iconify during GSAS" \ 
     4309            -variable expgui(autoiconify) -state disabled 
     4310    } else { 
     4311        $expgui(fm).option.menu  add checkbutton -label "Iconify during GSAS" \ 
    43104312            -variable expgui(autoiconify) 
     4313    } 
    43114314    if {$tcl_platform(platform) == "windows" && \ 
    43124315            $tcl_platform(os) == "Windows 95"} { 
     
    44534456    } 
    44544457} 
     4458$expgui(fm).powder.menu add command -label "New InstParm file" -command {EditInstFile (new)} 
    44554459 
    44564460# Macro menu 
     
    45554559LocateWindow "." $xpos $ypos $poscntr 
    45564560update 
    4557 RaisePage lsFrame 
    4558 if {[CountHistory] > 200} { 
    4559     DeleteHistoryRecords "This .EXP file has [CountHistory] history records\nErasing most will speed EXPGUI" 
    4560 } 
     4561SetStartPanel 
     4562#if {[CountHistory] > 200} { 
     4563#    DeleteHistoryRecords "This .EXP file has [CountHistory] history records\nErasing most will speed EXPGUI" 
     4564#} 
  • trunk/graceexport.tcl

    r930 r1166  
    241241                set center 10 
    242242            } elseif {[string range $just 0 0] == "e"} { 
    243                 # is this correct? 
     243                # is this correct?  
     244                set center 1 
     245            } else { 
    244246                set center 0 
    245             } else { 
    246                 set center 1 
    247247            } 
    248248            set color_data 1 
  • trunk/gsascmds.tcl

    r1034 r1166  
    464464    afterputontop 
    465465    return $makenew(result) 
     466} 
     467 
     468# format numbers & errors in crystallographic notation 
     469proc formatSU {num err} { 
     470    # errors less or equal to t are expressed as 2 digits 
     471    set T 19 
     472    set lnT [expr { log10($T) }]   
     473    # error is zero 
     474    if {$err == 0} { 
     475        # is this an integer? 
     476        if {int($num) == $num} { 
     477            return [format %d [expr int($num)]] 
     478        } 
     479        # allow six sig figs with a zero error (except for 0.0) 
     480        set dec [expr int(5.999999-log10( abs($num) ))] 
     481        if {$dec < -2 || $dec > 9} { 
     482            return [format %.5E $num] 
     483        } elseif {$dec <= 0} { 
     484            return [format %d [expr int($num)]] 
     485        } else { 
     486            return [format %.${dec}f $num] 
     487        } 
     488    } else { 
     489        #set sigfigs [expr log10( abs(10) / abs(.012/$T) ) + 1] 
     490        # should the number be expressed in scientific notation? 
     491        if {$err > $T || abs($num) < 0.0001} { 
     492            # get the exponent 
     493            set exp [lindex [split [format %E $num] E] end] 
     494            # strip leading zeros 
     495            regsub {([-\+])0+} $exp {\1} exp 
     496            # number of decimals in exponetial notation 
     497            set dec [expr int($lnT - log10( abs($err) ) + $exp)] 
     498            # should the error be displayed? 
     499            if {$err < 0} { 
     500                return [format "%.${dec}E" $num] 
     501            } else { 
     502                # scale the error into a decimal number 
     503                set serr [expr int(0.5 + $err * pow(10,$dec-$exp))] 
     504                return [format "%.${dec}E(%d)" $num $serr] 
     505            } 
     506        } else { 
     507            # number of digits 
     508            set dec [expr int($lnT - log10( abs($err) ))] 
     509            # should the error be displayed? 
     510            if {$err < 0} { 
     511                return [format "%.${dec}f" $num] 
     512            } else { 
     513                set serr [expr int(0.5 + $err * pow(10,$dec))] 
     514                return [format "%.${dec}f(%d)" $num $serr] 
     515            } 
     516        } 
     517    } 
    466518} 
    467519 
     
    9741026            } 
    9751027        } 
    976         # so sorry, have to use Internet Explorer 
     1028        # so sorry, have to use Safari, even if not default 
    9771029        set url [file nativename $url]; # replace ~/ if present 
    9781030        if {[file pathtype $url] == "relative"} { 
    9791031            set url [file join [pwd] $url] 
    9801032        } 
    981         exec osascript -e "tell application \"Internet Explorer\"\rGetURL \"file://$url\"\rend tell" 
     1033        exec osascript -e "tell application \"Safari\" to open location \"file://$url\"" 
    9821034    } elseif {$tcl_platform(platform) == "unix"} { 
    9831035        set browserlist {} 
     
    19592011proc SetEXPfile {expfile "newOK 0"} { 
    19602012    global expgui tcl_platform 
    1961     set expgui(expfile) {} 
    19622013    if {[string trim $expfile] == ""} return 
    19632014 
     
    20152066    # force exp files to be upper case, set to force save if name changes 
    20162067    set origexp $expname 
    2017     if {$expname != [string toupper $expfile]} { 
    2018         set expname [string toupper [file tail $expfile]] 
    2019         if {$tcl_platform(platform) != "windows"} {set expgui(changed) 1} 
    2020     } 
    2021     if {[file extension $expname] != ".EXP"} { 
     2068    if {$expname != [file tail $expfile] && $tcl_platform(platform) != "windows"} { 
     2069        set expgui(changed) 1 
     2070    } 
     2071    #puts $expgui(expfile) 
     2072    if {[string match {.O[0-9A-F][0-9A-F]} [file extension $expname]]} { 
     2073        set expname [ArchiveChoice $expname] 
     2074        set dirname "" 
     2075        if {$expname == ""} return 
     2076    } elseif {[file extension $expname] != ".EXP"} { 
    20222077        append expname ".EXP" 
    20232078    } 
    2024     if {$dirname == "."} { 
     2079    if {$dirname == "." || $dirname == ""} { 
    20252080        set newexpfile $expname 
    20262081    } else { 
     
    20812136        if {[string tolower $ans] == "create"} { 
    20822137            # you've been warned this .EXP does not exist! 
    2083             # create an "empty" exp file 
    2084             createexp $newexpfile \ 
    2085                 [getstring "title for experiment $expname" 60 0] 
    2086             if {! [file exists [file join $dirname $expname]]} { 
    2087                 update 
    2088                 MyMessageBox -parent . -title "File Creation Error" \ 
    2089                     -message "Experiment file name \"$expname\" was not created -- This is unexpected, please try a different name" \ 
    2090                     -icon warning -type Continue -default continue 
    2091                 set expgui(resize) 1 
    2092                 return 
    2093             } 
     2138            if [CreateMTexpfile $newexpfile] return 
    20942139        } else { 
    20952140            return 
    20962141        } 
    20972142    } 
    2098     set expgui(expfile) $newexpfile 
    2099     catch {cd [string trim [file dirname $expgui(expfile)]]} 
     2143    catch {cd [string trim [file dirname $newexpfile]]} 
     2144    return $newexpfile 
     2145} 
     2146 
     2147proc ArchiveChoice {expfile} { 
     2148    set expnam [file rootname $expfile] 
     2149    set ans [MyMessageBox -parent . -title "Load Archived File" \ 
     2150        -message "Loading archived version of $expnam. Do you want to continue using the same experiment name or work with the archived version under a new name?" \ 
     2151        -icon question -type "{Use New Name} {Continue with current}" \ 
     2152        -default {Use New Name} \ 
     2153        -helplink "expguierr.html LoadArchived" 
     2154    ] 
     2155    # archive the current .EXP file 
     2156    if {$ans != "use new name" && [file exists $expfile]} { 
     2157        # get the last archived version 
     2158        set lastf [lindex [lsort [glob -nocomplain $expnam.{O\[0-9A-F\]\[0-9A-F\]}]] end] 
     2159        if {$lastf == ""} { 
     2160            set num 01 
     2161        } else { 
     2162            regexp {.*\.O([0-9A-F][0-9A-F])$} $lastf a num 
     2163            scan $num %x num 
     2164            if {$num >= 255} { 
     2165                set num FF 
     2166            } else { 
     2167                set num [string toupper [format %.2x [incr num]]] 
     2168            } 
     2169        } 
     2170        catch { 
     2171            set newfile $expnam.O$num 
     2172            file rename -force $expnam.EXP $newfile 
     2173            set fp [open $expnam.LST a+] 
     2174            puts $fp "\n----------------------------------------------" 
     2175            puts $fp "     Regressing to archive file [file tail $expfile]" 
     2176            puts $fp "     but first archiving [file tail $expnam.EXP] as [file tail $newfile]" 
     2177            puts $fp "----------------------------------------------\n" 
     2178            close $fp 
     2179        } 
     2180        file copy -force $expfile $expnam.EXP 
     2181        set expfile $expnam.EXP 
     2182    } 
     2183    if {$ans == "use new name"} { 
     2184        set newexpfile [getExpFileName new] 
     2185        if {$newexpfile == ""} { 
     2186            set expgui(FileMenuEXPNAM) "" 
     2187            return  
     2188        } 
     2189        file copy -force $expfile $newexpfile 
     2190        set expgui(needpowpref) 2 
     2191        set expgui(needpowpref_why) "\tA new .EXP file was created\n"  
     2192        return $newexpfile 
     2193    } else { 
     2194        return $expfile 
     2195    } 
     2196} 
     2197 
     2198# create an "empty" exp file 
     2199proc CreateMTexpfile {newexpfile} { 
     2200    set expname [file tail $newexpfile] 
     2201    createexp $newexpfile \ 
     2202        [getstring "title for experiment $expname" 60 0] 
     2203    if {! [file exists $newexpfile]} { 
     2204        update 
     2205        MyMessageBox -parent . -title "File Creation Error" \ 
     2206            -message "Experiment file name \"$expname\" was not created -- This is unexpected, please try a different name" \ 
     2207            -icon warning -type Continue -default continue 
     2208        set ::expgui(resize) 1 
     2209        return 1 
     2210    } 
     2211    return 0 
    21002212} 
    21012213 
     
    21292241                -side top -fill both -expand yes -pady 5 
    21302242    } elseif {$mode != "new"} { 
    2131         # for initial read, don't access archived files 
     2243        # for initial read, don't offer access to archived files 
    21322244        pack [frame $expgui(FileInfoBox) -bd 4 -relief groove \ 
    21332245                -class SmallFont] \ 
     
    21582270    afterputontop 
    21592271    if {$expgui(FileMenuEXPNAM) == ""} return 
    2160     # is there a space in the EXP name? 
    2161 #    if {[string first " " [file tail $expgui(FileMenuEXPNAM)]] != -1} { 
    2162 #       update 
    2163 #       MyMessageBox -parent . -title "File Name Error" \ 
    2164 #           -message "File name \"$expgui(FileMenuEXPNAM)\" is invalid -- EXPGUI can#not process experiment files with spaces in the name" \ 
    2165 #           -icon warning -type Continue -default continue 
    2166 #               -helplink "expguierr.html OpenErr" 
    2167 #       return 
    2168 #    } 
    2169 #    if {[string first " " $expgui(FileMenuDir)] != -1} { 
    2170 #       set warn 1 
    2171 #       catch {set warn $expgui(warnonexpdirspace)} 
    2172 #       if $warn { 
    2173 #           update 
    2174 #           MyMessageBox -parent . -title "Good luck..." \ 
    2175 #               -message "You are using a directory with a space in the name ($expgui(FileMenuDir)) -- You may encounter bugs in EXPGUI. Please e-mail them to Brian.Toby@ANL.gov so they can be fixed." \ 
    2176 #               -icon warning -type Continue -default continue 
    2177 #           #           -helplink "expguierr.html OpenErr" 
    2178 #           set expgui(warnonexpdirspace) 0 
    2179 #       } 
    2180 #    } 
     2272    #puts "end getexp $expgui(expfile)" 
    21812273    return [file join $expgui(FileMenuDir) $expgui(FileMenuEXPNAM)] 
    21822274} 
    21832275 
    21842276# validation routine 
     2277# called from getExpFileName, either from Read button or from SelectExpFil (see expfilebox) 
    21852278proc valid_exp_file {frm mode} { 
    21862279    global expgui tcl_platform 
     
    22082301        return 
    22092302    } 
    2210     # append a .EXP if not present 
    2211     if {[file extension $expgui(FileMenuEXPNAM)] == ""} { 
     2303    set ext [string toupper [file extension $expgui(FileMenuEXPNAM)]] 
     2304    if {$ext == ""} { 
     2305        # append a .EXP if not present 
    22122306        append expgui(FileMenuEXPNAM) ".EXP" 
    2213     } 
    2214     # is there a space in the name? 
    2215 #    if {[string first " " $expgui(FileMenuEXPNAM)] != -1} { 
    2216 #       MyMessageBox -parent . -title "File Name Error" \ 
    2217 #               -message "File name $expgui(FileMenuEXPNAM) is invalid -- EXPGUI cannot process experiment files with spaces in the name" \ 
    2218 #               -icon warning -type Continue -default continue 
    2219 #               -helplink "expguierr.html OpenErr" 
    2220 #       return 
    2221 #    } 
    2222     # check for archive files 
    2223     if {[string match {*.O[0-9A-F][0-9A-F]} $expgui(FileMenuEXPNAM)] && \ 
     2307    } elseif {[string match {*.O[0-9A-F][0-9A-F]} $ext] && \ 
    22242308            $mode == "old" && [file exists $expgui(FileMenuEXPNAM)]} { 
     2309        # check for archive files 
    22252310        destroy .file 
    22262311        return 
    2227     } elseif {[string toupper [file extension $expgui(FileMenuEXPNAM)]] != ".EXP"} { 
     2312    } elseif {$ext != ".EXP"} { 
    22282313        # check for files that end in something other than .EXP .exp or .Exp... 
    22292314        MyMessageBox -parent . -title "File Open Error" \ 
     
    22582343                -helplink "expguierr.html OpenErr" 
    22592344        ] 
    2260         if {[string tolower $ans] == "create"} {destroy .file} 
     2345        if {[string tolower $ans] == "create"} { 
     2346            if [CreateMTexpfile $file] return 
     2347            destroy .file 
     2348        } 
    22612349        return 
    22622350    } 
     
    24172505            - [winfo height $box.top] - [winfo height $box.scroll]-25] 
    24182506} 
    2419  
     2507proc RevertExpFile {} { 
     2508    global expgui tcl_platform 
     2509    set frm .file 
     2510    catch {destroy $frm} 
     2511    toplevel $frm 
     2512    wm title $frm "Experiment file" 
     2513    bind $frm <Key-F1> "MakeWWWHelp expguierr.html open" 
     2514    pack [frame [set frmA $frm.1] -bd 2 -relief groove] -padx 3 -pady 3 -side left 
     2515    pack [frame [set frmC $frm.3] ] -padx 3 -pady 3 -side left \ 
     2516            -fill y -expand yes 
     2517    pack [button $frmC.help -text Help -bg yellow \ 
     2518            -command "MakeWWWHelp expguierr.html open"] \ 
     2519            -side top -anchor e 
     2520    set expgui(filesort) 0 
     2521    set expgui(includearchived) 1 
     2522    set expgui(FileInfoBox) $frmC.info 
     2523    pack [label $frmC.ar -text "(Showing Archived Files Only)"] -side top -pady 10 
     2524    pack [frame $expgui(FileInfoBox) -bd 4 -relief groove \ 
     2525              -class SmallFont] \ 
     2526        -side top -fill both -expand yes -pady 5 
     2527 
     2528    pack [button $frmC.b -text Read \ 
     2529            -command "valid_exp_file $frmA old"] -side bottom 
     2530    pack [button $frmC.q -text Cancel \ 
     2531            -command "set expgui(FileMenuEXPNAM) {}; destroy $frm"] -side bottom 
     2532    bind $frm <Return> "$frmC.b invoke" 
     2533 
     2534    pack [label $frmA.0 -text "Select an archived experiment file to read"] \ 
     2535                -side top -anchor center 
     2536    set bx $frmA  
     2537    pack [frame $bx.top] -side top  
     2538    #pack [label $bx.top.a -text "Directory" ] -side left  
     2539    set expgui(FileDirButtonMenu) [tk_optionMenu $bx.top.d expgui(FileMenuDir) [pwd] ] 
     2540    #pack $bx.top.d -side left 
     2541    #set expgui(FileMenuDir) [pwd] 
     2542    # the icon below is from tk8.0/tkfbox.tcl 
     2543    pack [frame $bx.a -width 200 -height 75] -side top -expand yes -fill both 
     2544    listbox $bx.a.files -relief raised -bd 2 \ 
     2545            -yscrollcommand "sync2boxesY $bx.a.files $bx.a.dates $bx.a.scroll" \ 
     2546            -height 15 -width 0 -exportselection 0  
     2547    listbox $bx.a.dates -relief raised -bd 2 \ 
     2548            -yscrollcommand "sync2boxesY $bx.a.dates $bx.a.files $bx.a.scroll" \ 
     2549            -height 15 -width 0 -takefocus 0 -exportselection 0  
     2550    scrollbar $bx.a.scroll -command "move2boxesY \" $bx.a.files $bx.a.dates \" " 
     2551    ChooseExpFil $bx 1 
     2552    if {[llength [$bx.a.files get 0 end]] == 0} { 
     2553        destroy $frm 
     2554        MyMessageBox -parent . -title "No Archives" \ 
     2555            -message "Sorry no archived versions of $::expgui(expfile) are present" \ 
     2556                    -icon warning -type ok -default ok 
     2557        return 
     2558    } 
     2559    bind $bx.a.files <ButtonRelease-1> "ReleaseExpFil $bx" 
     2560    bind $bx.a.dates <ButtonRelease-1> "ReleaseExpFil $bx" 
     2561    bind $bx.a.files <Double-1> "SelectExpFil $bx old" 
     2562    bind $bx.a.dates <Double-1> "SelectExpFil $bx old" 
     2563    pack $bx.a.scroll -side left -fill y  
     2564    pack $bx.a.files $bx.a.dates -side left -fill both -expand yes 
     2565    pack [entry $bx.c -textvariable expgui(FileMenuEXPNAM)] -side top 
     2566    # force the window to stay on top 
     2567    putontop $frm 
     2568    focus $frmC.b 
     2569    tkwait window $frm 
     2570    afterputontop 
     2571    if {$expgui(FileMenuEXPNAM) == ""} return 
     2572    return [file join $expgui(FileMenuDir) $expgui(FileMenuEXPNAM)] 
     2573} 
    24202574 
    24212575# support routine for SetHistUseFlags 
     
    25422696    return 
    25432697} 
     2698 
     2699proc ScanEXPforError {"ns {}"} { 
     2700    # record types to ignore 
     2701    set ignorelist {DESCR HSTRY PNAM HNAM "REFN STATS"} 
     2702    set warn {} 
     2703    set badkeylist {} 
     2704    # scan file for warnings 
     2705    foreach key [array names ${ns}::exparray] { 
     2706        if {[string first "***" [set ${ns}::exparray($key)]] != -1 ||  
     2707            [string first "#IN" [set ${ns}::exparray($key)]] != -1 || 
     2708            [string first "nan" [set ${ns}::exparray($key)]] != -1 || 
     2709            [string first "NAN" [set ${ns}::exparray($key)]] != -1  
     2710        } { 
     2711            #puts [set ${ns}::exparray($key)] 
     2712            set OK 0 
     2713            foreach i $ignorelist { 
     2714                if {[string first $i $key] != -1} { 
     2715                    set OK 1 
     2716                    break 
     2717                } 
     2718            } 
     2719            # ignore atom name section of Atom records 
     2720            if {(! $OK) && [string match  "CRS*AT*A" $key]} { 
     2721                foreach str [list [string range [set ${ns}::exparray($key)] 0 49]  
     2722                             [string range [set ${ns}::exparray($key)] 58 end]] { 
     2723                    if {[string first "***" $str] ||  
     2724                        [string first "#INF" $str] ||  
     2725                        [string first "nan" $str] ||  
     2726                        [string first "NAN" $str]} { 
     2727                        append warn "  Record \"$key\": [set ${ns}::exparray($key)]\n" 
     2728                        lappend badkeylist $key 
     2729                        break 
     2730                    } 
     2731                } 
     2732                continue 
     2733            } 
     2734            if {! $OK} { 
     2735                append warn "  Record \"$key\": [set ${ns}::exparray($key)]\n" 
     2736                lappend badkeylist $key 
     2737            } 
     2738        } 
     2739    } 
     2740    if {$warn == ""} return 
     2741    set hint "" 
     2742    set unknown "" 
     2743    foreach key $badkeylist { 
     2744        if {[string match  "CRS*AT*" $key]} { 
     2745            if {[string first "atomic parameter" $hint] == -1} { 
     2746                append hint "\t* An atomic parameter (coordinate, occupancy or U) appears out of range\n" 
     2747            } 
     2748        } elseif {[string match  "CRS*ABC*" $key] ||  
     2749                  [string match  "CRS*ANGLES*" $key] ||  
     2750                  [string match  "CRS*CELVOL*" $key]} { 
     2751            if {[string first "cell parameter" $hint] == -1} { 
     2752                append hint "\t* A unit cell parameter appears out of range\n" 
     2753            } 
     2754        } elseif {[string match  "CRS*ODF*" $key]} { 
     2755            if {[string first "spherical harmonic" $hint] == -1} { 
     2756                append hint "\t* A spherical harmonic (ODF) parameter appears out of range\n" 
     2757            } 
     2758        } elseif {[string match  "HST*ICONS" $key]} { 
     2759            if {[string first "diffractometer constant" $hint] == -1} { 
     2760                append hint "\t* A diffractometer constant (wave, DIFC,...) appears out of range\n" 
     2761            } 
     2762        } elseif {[string match  "HST*TRNGE" $key]} { 
     2763            if {[string first "histogram data range" $hint] == -1} { 
     2764                append hint "\t* A histogram data range value appears out of range\n" 
     2765            } 
     2766        } elseif {[string match "*GNLS  RUN*" $key] ||  
     2767                  [string match "*GNLS SHFTS" $key] || 
     2768                  [string match "HST*RPOWD" $key] || 
     2769                  [string match " REFN RPOWD " $key] || 
     2770                  [string match " REFN GDNFT " $key] 
     2771              } { 
     2772            if {[string first "refinement statistics" $hint] == -1} { 
     2773                append hint "\t* The refinement statistics imply the last refinement diverged\n" 
     2774            } 
     2775        } else { 
     2776            lappend unknown $key 
     2777        } 
     2778    } 
     2779    if {$unknown != ""} { 
     2780        append hint "\t* The following less common problem record(s) appear out of range:\n\t\t" 
     2781        foreach key $unknown { 
     2782            append hint "\"" [string trim $key] "\" " 
     2783        } 
     2784    } 
     2785    return "Likely error(s) noted:\n$hint\nDetails of problem(s):\n$warn" 
     2786} 
     2787 
     2788proc ExplainEXPerror {parent message file} { 
     2789    if {$parent == "."} { 
     2790        set w .experr 
     2791    } else { 
     2792        set w $parent.experr 
     2793    } 
     2794    catch {destroy $w} 
     2795    toplevel $w -class Dialog 
     2796    wm title $w "Corrupt .EXP file" 
     2797    wm iconname $w Dialog 
     2798    wm protocol $w WM_DELETE_WINDOW { } 
     2799    # Make the message box transient if the parent is viewable. 
     2800    if {[winfo viewable [winfo toplevel $parent]] } { 
     2801        wm transient $w $parent 
     2802    }  
     2803    frame $w.bot 
     2804    pack $w.bot -side bottom -fill both 
     2805    frame $w.top 
     2806    pack $w.top -side top -fill both -expand 1 
     2807    frame $w.msg 
     2808    pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m 
     2809    set txt {Likely errors were noted when reading this file} 
     2810    append txt " ([file tail $file]). " 
     2811    append txt "These problems probably\narose from the last refinement, " 
     2812    append txt "based on settings applied in the previous saved file.\n" 
     2813    append txt "It is probably not possible to continue with this file.\n" 
     2814    append txt "You likely need to revert at least two archived versions back." 
     2815    grid [label $w.msg.s -text $txt -justify left] -row 0 -column 0 -sticky nws 
     2816    grid [button $w.msg.1 -text Help -bg yellow \ 
     2817              -command "MakeWWWHelp expgui.html badexp"] -row 0 -column 1 -columnspan 2 -sticky ne 
     2818    bind $w <Key-F1> "MakeWWWHelp expgui.html badexp" 
     2819    set filelist [lsort -dictionary -decreasing \ 
     2820                      [glob -nocomplain \ 
     2821                           [file root $file.O* ]]] 
     2822    grid [text  $w.msg.t -font {Times 12} \ 
     2823              -height 10 -width 90 -relief flat -wrap word \ 
     2824              -yscrollcommand "$w.msg.rscr set" \ 
     2825             ] -row 1 -column 0  -columnspan 2 -sticky news 
     2826    grid [scrollbar $w.msg.rscr  -command "$w.msg.t yview" \ 
     2827             ] -row 1 -column 2 -sticky ns 
     2828    # give extra space to the text box 
     2829    grid columnconfigure $w.msg 0 -weight 1 
     2830    grid rowconfigure $w.msg 1 -weight 1 
     2831    $w.msg.t insert end $message 
     2832    button $w.ok -command [list destroy $w] -text OK -default active 
     2833    pack $w.ok -in $w.bot -side left -expand 1 -padx 3m -pady 2m 
     2834    putontop $w 
     2835    tkwait window $w 
     2836    afterputontop 
     2837} 
     2838 
    25442839proc UpdateInfoBox {} { 
    25452840    global expgui 
     
    25482843    set file [file join [set expgui(FileMenuDir)] $expgui(FileMenuEXPNAM)] 
    25492844    if [file isdirectory $file] return 
    2550     if [file exists $file] { 
     2845    if [file exists $file] {     
    25512846        pack [label $expgui(FileInfoBox).1 -text $expgui(FileMenuEXPNAM)] \ 
    25522847                -side top 
    25532848        catch { 
     2849            # load the EXP file into a namespace & scan for errors 
     2850            expload $file scan 
     2851            set warnings [ScanEXPforError scan] 
     2852            if {$warnings != ""} { 
     2853                pack [frame $expgui(FileInfoBox).1a -bg yellow -padx 4 -pady 4] -side top 
     2854                pack [label $expgui(FileInfoBox).1a.err -justify left \ 
     2855                          -text "WARNING: Likely corrupt" -bg yellow] \ 
     2856                    -side left -anchor w -fill both 
     2857                pack [button $expgui(FileInfoBox).1a.show \ 
     2858                          -text "More..." -padx 0 \ 
     2859                          -command "ExplainEXPerror $expgui(FileInfoBox) [list $warnings] $file"\ 
     2860                         ] -side right -anchor w 
     2861            } 
    25542862            set fp [open $file r] 
    25552863            global testline 
     
    25622870                    -text "last GENLES run:\n  $last\n  total cycles: $cycles"] \ 
    25632871                -side top -anchor w 
     2872            set chi2 ? 
     2873            set vars ? 
    25642874            regexp {REFN GDNFT.*= *([0-9]*\.[0-9]*) +for *([0-9]+) variables} \ 
    25652875                    $testline a chi2 vars 
     
    26002910                    -text $lbl] \ 
    26012911                    -side top -anchor w      
    2602         } 
     2912        } err 
    26032913    } 
    26042914} 
     
    26342944# fill the files & dates & Directory selection box with current directory, 
    26352945# also called when box is created to fill it 
    2636 proc ChooseExpFil {frm} { 
     2946proc ChooseExpFil {frm "archiveonly 0"} { 
    26372947    global expgui 
    26382948    set files $frm.a.files 
     
    26412951    $files delete 0 end 
    26422952    $dates delete 0 end 
    2643     $files insert end {<Parent>} 
    2644     $dates insert end {(Directory)} 
    2645     set filelist [glob -nocomplain \ 
    2646             [file join [set expgui(FileMenuDir)] *] ] 
    2647     foreach file [lsort -dictionary $filelist] { 
    2648         if {[file isdirectory $file]} { 
    2649             $files insert end [file tail $file] 
    2650             $dates insert end {(Directory)} 
    2651         } 
     2953    if {$archiveonly == 0} { 
     2954        $files insert end {<Parent>} 
     2955        $dates insert end {(Directory)} 
     2956        set filelist [glob -nocomplain \ 
     2957                          [file join [set expgui(FileMenuDir)] *] ] 
     2958        foreach file [lsort -dictionary $filelist] { 
     2959            if {[file isdirectory $file]} { 
     2960                $files insert end [file tail $file] 
     2961                $dates insert end {(Directory)} 
     2962            } 
     2963        } 
     2964    } else {     
     2965        set filelist [glob -nocomplain \ 
     2966                          [file root $expgui(expfile)].O* ] 
    26522967    } 
    26532968    set pairlist {} 
    26542969    foreach file [lsort -dictionary $filelist] { 
    26552970        if {![file isdirectory $file]  && \ 
    2656                 [string toupper [file extension $file]] == ".EXP"} { 
     2971                [string toupper [file extension $file]] == ".EXP" \ 
     2972                && $archiveonly == 0} { 
    26572973            set modified [file mtime $file] 
    26582974            lappend pairlist [list $file $modified] 
     
    27043020        if {$expgui(expfile) == [file join $expgui(FileMenuDir) $file]} { 
    27053021            $files selection set $i 
     3022            set expgui(FileMenuEXPNAM) $file 
     3023            UpdateInfoBox 
    27063024        } 
    27073025    } 
     
    33983716    global expgui 
    33993717    if {$expgui(MacroChanged)} { 
     3718 
    34003719        set ans [MyMessageBox -parent $txt -title "Save macro file?" \ 
    34013720                     -message "Macro file has been changed, do you want to save it?" \ 
  • trunk/gsasmenu.tcl

    r1025 r1166  
    99array set expgui_menulist { 
    1010    file { 
     11        revert 
    1112        EraseHistory 
    1213        convert 
     
    2526        bkgedit 
    2627        excledt 
    27         instedit 
    2828        seqgsas 
    2929        mustrplot 
     30        instedit 
    3031    } 
    3132    xtal { 
     
    5758        cllchg 
    5859        composition 
    59         fprime 
    6060        hklgen 
    6161        rducll 
     
    158158    } 
    159159 
     160    revert {{readnewexp archive} { 
     161        Select an old version of the current GSAS file} 
     162    } 
     163 
    160164    {archive EXP} {- { 
    161165        Toggles archiving of .EXP files. When on, files are  
     
    304308    fitspec     {{runGSASprog $cmd} { 
    305309        Fit a TOF vanadium scattering spectrum} 
    306     } 
    307  
    308     fprime      {{runGSASprog $cmd} { 
    309         Compute f, f', f'' and mu/rho for an element for a range of x-ray wavelengths} 
    310310    } 
    311311 
     
    363363    instedit    {{EditInstFile} { 
    364364        Edit an instrument parameter file} 
     365    } 
     366    {New InstParm file} {- { 
     367        Create a new instrument parameter file} 
    365368    } 
    366369 
  • trunk/instedit.tcl

    r991 r1166  
    7878    # loop over banks 
    7979    set msg {} 
    80     for {set i 1} {$i <= $instdat(lastbank)} {incr i} { 
    81         instbankinfo rad $i set $instdat(rad$i)  
    82         instbankinfo head $i set $instdat(head$i)  
    83         if {[string trim $instdat(name$i)] == ""} { 
    84             append msg "\n  The instrument name may not be blank" 
    85         } 
    86         instbankinfo name $i set $instdat(name$i) 
    87         set l {} 
    88         foreach var {difc difa zero pola ipola kratio} { 
    89             lappend l $instdat(${var}$i) 
    90         } 
    91         if {[instbankinfo icons $i set $l] != 1} { 
    92             append msg "\n  There is an error in values for:\n    the wavelength, zero or polarization" 
    93         } 
    94         # loop over the profile terms 
    95  
    96         for {set j 1} {$j <= $instparms(proftypes${i})} {incr j} { 
    97             set l {} 
    98             for {set k 1} {$k <= $instparms(profterms${i}_$j)} {incr k} { 
    99                 lappend l $instdat(prof${i}_${j}_$k) 
    100             } 
    101             if {[instprofinfo $i $j set [list \ 
    102                     $instdat(proftype${i}_$j) $instdat(profcut${i}_$j) $l]\ 
    103                     ] != 1} { 
    104                 append msg "\n  There is an error in the values for profile set $j." 
    105             } 
    106         } 
    107         if {$msg != ""} { 
    108             MyMessageBox -parent . -title "No save" \ 
     80    if {[catch { 
     81        for {set i 1} {$i <= $instdat(lastbank)} {incr i} { 
     82            instbankinfo rad $i set $instdat(rad$i)  
     83            instbankinfo head $i set $instdat(head$i)  
     84            if {[string trim $instdat(name$i)] == ""} { 
     85                append msg "\n  The instrument name may not be blank" 
     86            } 
     87            instbankinfo name $i set $instdat(name$i) 
     88            set l {} 
     89            foreach var {difc difa zero pola ipola kratio} { 
     90                lappend l $instdat(${var}$i) 
     91            } 
     92            if {[instbankinfo icons $i set $l] != 1} { 
     93                append msg "\n  There is an error in values for:\n    the wavelength, zero or polarization" 
     94            } 
     95            # loop over the profile terms 
     96             
     97            for {set j 1} {$j <= $instparms(proftypes${i})} {incr j} { 
     98                set l {} 
     99                for {set k 1} {$k <= $instparms(profterms${i}_$j)} {incr k} { 
     100                    lappend l $instdat(prof${i}_${j}_$k) 
     101                } 
     102                if {[instprofinfo $i $j set [list \ 
     103                                                 $instdat(proftype${i}_$j) $instdat(profcut${i}_$j) $l]\ 
     104                        ] != 1} { 
     105                    append msg "\n  There is an error in the values for profile set $j." 
     106                } 
     107            } 
     108            if {$msg != ""} { 
     109                MyMessageBox -parent . -title "No save" \ 
    109110                    -message "Error in input for bank $i:$msg" -icon warning \ 
    110111                    -type Sorry -default sorry 
    111             return 
    112         } 
     112                return 
     113            } 
     114        } 
     115    } errmsg]} { 
     116        if {$errmsg == ""} return 
     117        MyMessageBox -parent . -title "No save" \ 
     118            -message "Error in input (did you define data type, profile type, etc?):\n$errmsg" -icon warning \ 
     119            -type Sorry -default sorry 
     120        return 
    113121    } 
    114122    if {$filename == ""} { 
     
    150158proc instShowBank {box} { 
    151159    global instdat instparms 
     160    set instparms(profileframe) {} 
     161 
    152162    set topfr $box.a 
    153163    if {$instparms(bank) == 0} return 
     
    159169    } 
    160170    if {$instparms(banklabel) == ""} { 
    161         puts starting 
    162171        return 
    163172    } 
     
    562571proc AddInstProfile {box b} { 
    563572    global instparms instdat 
    564     set frame $instparms(profileframe) 
    565573    incr instparms(proftypes${b}) 
    566574    instShowBank $box 
     
    759767                -parent $instparms(top) -defaultextension .ins \ 
    760768                -filetypes {{"Instrument parameters file" ".ins .inst .prm"} {All *.*}}] 
     769    } elseif {$filename == "(new)"} { 
     770        set instparms(filename) "" 
    761771    } else { 
    762772        set instparms(filename) $filename 
  • trunk/liveplot

    r993 r1166  
    1414# process command line arguments 
    1515set exitstat 0 
    16 set expnam [lindex $argv 0] 
     16set expnam [file root [lindex $argv 0]] 
    1717if {$expnam == ""} {catch {puts "error -- no experiment name"}; set exitstat 1} 
    1818if $exitstat { 
     
    2020    exit 
    2121} 
    22  
     22# work in .EXP directory (in case files will be exported). 
     23catch { 
     24    cd [file dirname $expnam] 
     25} 
    2326# get name of script 
    2427set expgui(script) [info script] 
     
    4245    set graph(legend) [lindex $argv 2] 
    4346} 
     47set plot_title "(None)" 
    4448 
    4549set graph(backsub) 0 
     
    7983set expgui(fadetime) 10 
    8084set expgui(hklbox) 1 
    81 set expgui(autotick) 0 
     85set expgui(autotick) 1 
    8286set expgui(phaselabel) 0 
    8387set expgui(pixelregion) 5 
     
    174178source [file join $expgui(scriptdir) readexp.tcl] 
    175179source [file join $expgui(scriptdir) opts.tcl] 
     180#---------------------------------------------------------------- 
     181# use EXPGUI directory for packages 
     182lappend auto_path $expgui(scriptdir) 
    176183 
    177184if {$program == "bkgedit"}  { 
     
    357364        catch {$vec variable $vec} 
    358365    } 
    359     set maxdiff  [set diffvec(max)] 
    360     set cmin [set calcvec(min)] 
    361     set omin [set obsvec(min)] 
    362     set cmax [set calcvec(max)] 
    363     set omax [set obsvec(max)] 
    364     set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}] 
    365     set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}] 
    366     set ymin1 [expr {$cmin - 1.1*$maxdiff}] 
    367     set ymin2 [expr {$omin - 1.1*$maxdiff}] 
    368     if {$ymin1 < $ymin2} { 
    369         diffvec set [diffvec + $ymin1] 
    370     } { 
    371         diffvec set [diffvec + $ymin2] 
    372     } 
     366    ApplyMag 
    373367    plotdata 
    374368} 
     
    441435        wifdvec set $sumlist 
    442436        wifdvec set [wifdvec / [wifdvec length]] 
    443     } 
    444     if {$graph(OmCoS)} { 
     437    } elseif {$graph(OmCoS)} { 
    445438        wifdvec set $WGT 
    446439        wifdvec expr sqrt(wifdvec) 
    447440        wifdvec set [wifdvec * diffvec] 
     441    } else { 
     442        wifdvec length 0 
    448443    } 
    449444    if $graph(backsub) { 
     
    451446        calcvec set [calcvec - bckvec] 
    452447    } 
    453     global obsvec calcvec diffvec  
    454     set maxdiff  [set diffvec(max)] 
    455     set cmin [set calcvec(min)] 
    456     set omin [set obsvec(min)] 
    457     set cmax [set calcvec(max)] 
    458     set omax [set obsvec(max)] 
    459     set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}] 
    460     set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}] 
    461     set ymin1 [expr {$cmin - 1.1*$maxdiff}] 
    462     set ymin2 [expr {$omin - 1.1*$maxdiff}] 
    463     if {$ymin1 < $ymin2} { 
    464         diffvec set [diffvec + $ymin1] 
    465     } { 
    466         diffvec set [diffvec + $ymin2] 
    467     } 
    468      
     448    ApplyMag 
     449    plotdata 
     450} 
     451 
     452proc SetTitle {} { 
     453    set bx .title 
     454    toplevel $bx 
     455    wm title $bx "Edit plot title" 
     456    wm iconname $bx "Edit plot title" 
     457    grid [label $bx.txt -text "Enter plot title below"] -row 1 -column 1 
     458    grid [entry $bx.title -width 70] -row 2 -column 1 
     459    grid [frame $bx.a] -row 3 -column 1 
     460    grid [button $bx.a.save -text "Save" \ 
     461              -command "set plot_title \"\[$bx.title get\]\"; destroy $bx" \ 
     462             ] -row 1 -column 1 
     463    grid [button $bx.a.quit -text "Quit" \ 
     464              -command "destroy $bx" \ 
     465             ] -row 1 -column 2 
     466    putontop $bx 
     467    tkwait window $bx 
     468    afterputontop 
    469469    plotdata 
    470470} 
     
    572572    global expnam hst peakinfo xunits yunits cycle reflns modtime 
    573573    global lasthst graph expgui box 
     574    global obsvec calcvec diffvec  
     575 
     576    if {$graph(yunits) == 2} { 
     577        set yunits {Intensity/sigma(I)} 
     578        wifdvec set $::weightlist 
     579        wifdvec expr sqrt(wifdvec) 
     580        obsvec set [obsvec * wifdvec] 
     581        calcvec set [calcvec * wifdvec] 
     582        bckvec set {} 
     583        diffvec set [obsvec - calcvec] 
     584        wifdvec set {} 
     585        $box element config 1 -label {} -line 0 -hide 1 
     586    } else { 
     587        $box element config 1 -label bckgr -line 1 -hide 0 
     588    } 
     589 
     590    set cmin [set calcvec(min)] 
     591    set omin [set obsvec(min)] 
     592    set cmax [set calcvec(max)] 
     593    set omax [set obsvec(max)] 
     594    set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}] 
     595    set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}] 
    574596 
    575597    foreach p $::expmap(phaselist) { 
     
    592614        return 
    593615    } 
    594     $box config -title "$expnam cycle $cycle Hist $hst" 
     616    if {$::plot_title == "(None)"} { 
     617        $box config -title "$expnam cycle $cycle Hist $hst" 
     618    } else { 
     619        $box config -title $::plot_title 
     620    } 
    595621    $box xaxis config -title $xunits 
    596622    $box yaxis config -title $yunits 
     
    622648    calcvec notify now 
    623649    bckvec notify now 
    624     diffvec notify now 
    625650    wifdvec notify now 
    626651    # now deal with peaks 
    627     for {set i 1} {$i < 10} {incr i} { 
    628         if {$expgui(autotick)} { 
    629             set div [expr {( $expgui(max) - $expgui(min) )/40.}] 
    630             set ymin [expr {$expgui(min) - ($i+1) * $div}] 
    631             set ymax [expr {$expgui(min) - $i * $div}] 
    632         } else { 
    633             set ymin $peakinfo(min$i) 
    634             set ymax $peakinfo(max$i) 
    635         } 
    636         set j 0 
    637         if [set peakinfo(flag$i)] { 
    638             foreach X $reflns($i) { 
    639                 incr j 
    640                 catch { 
    641                     $box marker create line -name peaks${i}_$j  
    642                 } 
    643                 $box marker config peaks${i}_$j  -under 1 \ 
    644                         -coords "$X $ymin $X $ymax"  
    645                 catch { 
    646                     $box marker config peaks${i}_$j \ 
    647                             $graph(MarkerColorOpt) [list $peakinfo(color$i)] 
    648                     if {$peakinfo(dashes$i) && ! $expgui(autotick)} { 
    649                         $box marker config peaks${i}_$j -dashes "5 5" 
    650                     } 
    651                 } 
     652    #for {set i 1} {$i < 10} {incr i}  
     653    set k 0 
     654    set cmin $expgui(min) 
     655    foreach i $::expmap(phaselist) { 
     656        if {[set peakinfo(flag$i)]} { 
     657            incr k 
     658            if {$expgui(autotick)} { 
     659                set div [expr {( $expgui(max) - $expgui(min) )/40.}] 
     660                set ymin [expr {$expgui(min) - ($k+1) * $div}] 
     661                set ymax [expr {$expgui(min) - $k * $div}] 
     662                if {$cmin > $ymin} {set cmin $ymin} 
     663            } else { 
     664                set ymin $peakinfo(min$i) 
     665                set ymax $peakinfo(max$i) 
     666            } 
     667            set j 0 
     668            foreach X $reflns($i) { 
     669                incr j 
     670                catch { 
     671                    $box marker create line -name peaks${i}_$j  
     672                } 
     673                $box marker config peaks${i}_$j  -under 1 \ 
     674                    -coords "$X $ymin $X $ymax"  
     675                catch { 
     676                    $box marker config peaks${i}_$j \ 
     677                        $graph(MarkerColorOpt) [list $peakinfo(color$i)] 
     678                    if {$peakinfo(dashes$i) && ! $expgui(autotick)} { 
     679                        $box marker config peaks${i}_$j -dashes "5 5" 
     680                    } 
     681                } 
    652682            } 
    653683            catch {$box element create phase$i} 
    654684            catch { 
    655685                $box element config phase$i -color $peakinfo(color$i) \ 
    656                         -label $graph(label$i) 
     686                    -label $graph(label$i) 
    657687            } 
    658688        } else { 
     
    661691        } 
    662692    } 
     693    # offset the difference pattern 
     694    set maxdiff  [set diffvec(max)] 
     695    if {$expgui(autotick)} { 
     696        diffvec set [diffvec + [expr {$cmin - $maxdiff}]] 
     697    } else { 
     698        diffvec set [diffvec + [expr {$cmin - 1.1*$maxdiff}]] 
     699    } 
     700    diffvec notify now 
     701 
    663702    # force an update of the plot as BLT may not 
    664703    $box config -title [$box cget -title] 
     
    11221161        eval $box y2axis config $graph(ElementHideOption)  
    11231162        $box element config 0 -label "" 
     1163        # clear the vector 
     1164        wifdvec set {} 
     1165        wifdvec notify now 
    11241166    } 
    11251167} 
     
    20462088setlegend $box $graph(legend) 
    20472089 
     2090set ps2pdfcmd {} 
     2091set gnuplotpath {} 
     2092# find gnuplot 
     2093if {$::tcl_platform(platform) == "windows"} { 
     2094    set gnuplotpath [file join $::expgui(gsasexe) "gnuplot/gnuplot.exe"] 
     2095    if {![file exists $gnuplotpath]} { 
     2096        set gnuplotpath [auto_execok gnuplot.exe] 
     2097    } 
     2098} else { 
     2099    set ::env(PATH) "${::expgui(gsasexe)}:${::env(PATH)}" 
     2100    auto_reset 
     2101    set gnuplotpath [auto_execok gnuplot] 
     2102} 
     2103# find postscript conversion routine 
     2104if {$::tcl_platform(platform) == "windows"} { 
     2105    set gspath [file join $::expgui(gsasexe) "gs/bin/gswin32c.exe"] 
     2106    if {![file exists $gspath]} { 
     2107        set gspath [auto_execok gswin32c.exe] 
     2108    } 
     2109    if {[file exists $gspath]} { 
     2110        set ps2pdfcmd "$gspath -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\$pdfoutname -c save pop -f \$psoutname" 
     2111    } 
     2112} else { 
     2113    # look for ghostscript 
     2114    set gspath [auto_execok gs] 
     2115    if {[file exists $gspath]} { 
     2116        set ps2pdfcmd "$gspath -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\$pdfoutname -c save pop -f \$psoutname" 
     2117    } else { 
     2118        set gspath [auto_execok pstopdf]; # this is on Mac only 
     2119        if {[file exists $gspath]} { 
     2120            set ps2pdfcmd "$gspath \$psoutname -o \$pdfoutname" 
     2121        } 
     2122    } 
     2123} 
     2124set gnuplotexport {} 
     2125catch { 
     2126    source [file join $expgui(scriptdir) gnuplot.tcl] 
     2127} 
     2128 
     2129#====================================================================== 
     2130# make menus 
    20482131frame .a -bd 3 -relief groove 
    20492132pack [menubutton .a.file -text File -underline 0 -menu .a.file.menu] -side left 
     
    20542137.a.file.menu add command -label "Update Plot" \ 
    20552138        -command {set cycle [getcycle];readdata .g} 
     2139.a.file.menu add command -label "Set Plot Title" \ 
     2140        -command SetTitle 
    20562141.a.file.menu add cascade -label "Export plot" -menu .a.file.menu.export 
    20572142menu .a.file.menu.export 
     
    20622147    .a.file.menu.export add command -label "to Grace" -command exportgrace 
    20632148} 
     2149if {$gnuplotpath == {}} { 
     2150    .a.file.menu.export add cascade -label "gnuplot program not found" 
     2151} elseif {$gnuplotexport == ""} { 
     2152    .a.file.menu.export add cascade -label "file gnuplot.tcl not found" 
     2153} elseif {$ps2pdfcmd == ""} { 
     2154    .a.file.menu.export add cascade -label "gs or pstopdf program not found" 
     2155} else { 
     2156    .a.file.menu.export add command -label "to PDF" -command ExportPDF 
     2157} 
     2158 
    20642159.a.file.menu add command -label Quit -command "destroy ." 
    20652160.a.file.menu.export add command -label "as .csv file" \ 
     
    20892184.a.options.menu.tick add separator 
    20902185 
     2186pack [menubutton .a.mag -text Magnification -underline 0 -menu .a.mag.menu] \ 
     2187        -side left 
     2188menu .a.mag.menu 
     2189set maglist {} 
     2190set mag0 1.0 
     2191# display magnification routines 
     2192proc ShowMag {} { 
     2193    global blt_version tcl_platform peakinfo expgui 
     2194    set bx .opt 
     2195    catch {destroy $bx} 
     2196    toplevel $bx 
     2197    putontop $bx 
     2198    wm iconname $bx "Mag Regs" 
     2199    wm title $bx "Plot Magnification Regions" 
     2200    pack [label $bx.0 -text "Magnification Regions:"] -side top 
     2201    if {[llength $::maglist] == 0} { 
     2202        set lbl "None" 
     2203    } else { 
     2204        set lbl "" 
     2205        set xm $::xvec(min) 
     2206        set ym $::mag0 
     2207        set ::maglist [lsort -real -index 0 $::maglist] 
     2208        foreach pair $::maglist { 
     2209            foreach {xh ymh} $pair {} 
     2210            append lbl "\tfrom $xm to $xh: times $ym\n" 
     2211            set xm $xh 
     2212            set ym $ymh 
     2213        } 
     2214        set xh $::xvec(max) 
     2215        append lbl "\tfrom $xm to $xh: times $ym" 
     2216    } 
     2217    pack [label $bx.1 -text $lbl -justify left] -side top 
     2218    pack [button $bx.2 -text "Close" -command "destroy $bx"] -side top 
     2219    tkwait window $bx 
     2220    afterputontop 
     2221} 
     2222 
     2223# edit magnification regions 
     2224proc EditMag {} { 
     2225    set ::multrow 1 
     2226    set bx .opt 
     2227    catch {destroy $bx} 
     2228    toplevel $bx 
     2229    putontop $bx 
     2230    wm iconname $bx "Mag Regs" 
     2231    wm title $bx "Edit Magnification Regions" 
     2232    pack [label $bx.0 -text "Vertical Magnification Regions:"] -side top 
     2233    if {[llength $::maglist] == 0} { 
     2234        set lbl "None" 
     2235        pack [label $bx.1 -text $lbl -justify left] -side top 
     2236        pack [button $bx.2 -text "Close" -command "destroy $bx"] -side top 
     2237        tkwait window $bx 
     2238        afterputontop 
     2239        return 
     2240    } else { 
     2241        pack [frame $bx.1] -side top 
     2242        set ::maglist [lsort -real -index 0 $::maglist] 
     2243        set row 0 
     2244        foreach pair $::maglist { 
     2245            foreach {xh ymh} $pair {} 
     2246            set row1 [expr {$row + 1}] 
     2247            set ::xmag($row1) $xh 
     2248            set ::mag($row1) $ymh 
     2249            if {$row == 0} { 
     2250                grid [label $bx.1.a$row -text "From "] -column 1 -row $row 
     2251                grid [label $bx.1.b$row -text $::xvec(min)] -column 2 -row $row 
     2252                grid [label $bx.1.c$row -text " to "] -column 3 -row $row 
     2253                grid [entry $bx.1.d$row -textvariable xmag(1) -width 6] -column 4 -row $row 
     2254                grid [label $bx.1.e$row -text " times "] -column 5 -row $row 
     2255                grid [entry $bx.1.f$row -textvariable mag0 -width 4] -column 6 -row $row 
     2256            } else { 
     2257                grid [label $bx.1.a$row -text "From "] -column 1 -row $row 
     2258                grid [entry $bx.1.b$row -textvariable xmag($row) -width 6] -column 2 -row $row 
     2259                grid [label $bx.1.c$row -text " to "] -column 3 -row $row 
     2260                grid [entry $bx.1.d$row -textvariable xmag($row1) -width 6] -column 4 -row $row 
     2261                grid [label $bx.1.e$row -text " times "] -column 5 -row $row 
     2262                grid [entry $bx.1.f$row -textvariable mag($row) -width 4] -column 6 -row $row 
     2263            } 
     2264            incr row 
     2265        } 
     2266        grid [label $bx.1.a$row -text "From "] -column 1 -row $row 
     2267        grid [entry $bx.1.b$row -textvariable xmag($row) -width 6] -column 2 -row $row 
     2268        grid [label $bx.1.c$row -text " to "] -column 3 -row $row 
     2269        grid [label $bx.1.d$row -text $::xvec(max)] -column 4 -row $row 
     2270        grid [label $bx.1.e$row -text " times "] -column 5 -row $row 
     2271        grid [entry $bx.1.f$row -textvariable mag($row) -width 4] -column 6 -row $row 
     2272        set ::multrow $row 
     2273    } 
     2274    pack [label $bx.l -text "\nSet the multiplier to zero to delete a region"] -side top 
     2275    pack [frame $bx.2] -side top 
     2276    pack [button $bx.2.a -text "Edit" -command "destroy $bx"] -side left 
     2277    pack [button $bx.2.b -text "Cancel" -command "set multrow 0; destroy $bx"] -side left 
     2278    tkwait window $bx 
     2279    afterputontop 
     2280    if {$::multrow == 0} return 
     2281    set newmaglist {} 
     2282    set xp $::xvec(min) 
     2283    for {set i 1} {$i <= $::multrow} {incr i} { 
     2284        if {$::mag($i) > 0} { 
     2285            lappend newmaglist [list $::xmag($i) $::mag($i)] 
     2286        } 
     2287        set xp $::xmag($i) 
     2288    } 
     2289    set ::maglist $newmaglist 
     2290    readdata .g 
     2291} 
     2292 
     2293# show a menu to add a magnification region 
     2294proc AddMag {} { 
     2295    set bx .opt 
     2296    catch {destroy $bx} 
     2297    toplevel $bx 
     2298    putontop $bx 
     2299    wm iconname $bx "Add Regs" 
     2300    wm title $bx "Add Plot Magnification Region" 
     2301    pack [frame $bx.0] -side top 
     2302    pack [label $bx.0.a -text "Magnify from "] -side left 
     2303    pack [entry $bx.0.b -textvariable xmin -width 6] -side left 
     2304    pack [label $bx.0.c -text " to next region. Multiply by "] -side left 
     2305    pack [entry $bx.0.d -textvariable mult -width 4] -side left 
     2306    pack [frame $bx.2] -side top 
     2307    pack [button $bx.2.a -text "Add" -command "destroy $bx"] -side left 
     2308    pack [button $bx.2.b -text "Cancel" -command "set mult {}; destroy $bx"] -side left 
     2309    if {[catch {expr $::mult}]} {set ::mult 1.0} 
     2310    if {$::mult <= 0} {set ::mult 1.0} 
     2311    tkwait window $bx 
     2312    afterputontop 
     2313    catch { 
     2314        if {$::xmin < $::xvec(min)} {set ::xmin $::xvec(min)}  
     2315        if {$::xmin > $::xvec(max)} {set ::xmin $::xvec(max)}  
     2316        if {$::mult > 0} { 
     2317            lappend ::maglist [list $::xmin $::mult] 
     2318            readdata .g 
     2319        } else { 
     2320            MyMessageBox -parent . -title "Invalid" \ 
     2321                -message "Invalid input, try again" \ 
     2322                -icon error -type Continue -default continue 
     2323        } 
     2324    } 
     2325} 
     2326proc AddCursorMag {p m} { 
     2327    set x [.g xaxis invtransform $p] 
     2328    if {$x < $::xvec(min) || $x > $::xvec(max) } { 
     2329        bell 
     2330        return 
     2331    } 
     2332    lappend ::maglist [list $x $m] 
     2333    readdata .g 
     2334} 
     2335 
     2336# scale the data with magnification regions 
     2337proc ApplyMag {} { 
     2338    foreach mrk [.g marker names mag*] { 
     2339        .g marker delete $mrk 
     2340    } 
     2341    if {[llength $::maglist] == 0} return 
     2342    global xvec 
     2343    vector create ymult([xvec length]) 
     2344    set xl $xvec(min) 
     2345    set ym $::mag0 
     2346    set i 0 
     2347    set ::maglist [lsort -real -index 0 $::maglist] 
     2348    foreach pair $::maglist { 
     2349        foreach {xh ymh} $pair {} 
     2350        set xr [xvec search $xl $xh] 
     2351        #puts "$xl $xh [lindex $xr 0]:[lindex $xr end] $ym" 
     2352        if {[lindex $xr 0] != [lindex $xr end]} { 
     2353            set ymult([lindex $xr 0]:[lindex $xr end]) $ym 
     2354            if {$xl != $xvec(min)} { 
     2355                .g marker create line -coords "$xl -Inf $xl Inf" -name mag[incr i] 
     2356            } 
     2357            .g marker create text -coords "$xl Inf" -name mag[incr i] -text "x$ym" -anchor w 
     2358        } 
     2359        set xl $xh 
     2360        set ym $ymh 
     2361    } 
     2362    set xh $xvec(max) 
     2363    set xr [xvec search $xl $xh] 
     2364    set ymult([lindex $xr 0]:[lindex $xr end]) $ym 
     2365    #puts "$xl $xh [lindex $xr 0]:[lindex $xr end] $ym" 
     2366    .g marker create line -coords "$xl -Inf $xl Inf" -name mag[incr i] 
     2367    .g marker create text -coords "$xl Inf" -name mag[incr i] -text "x$ym" -anchor w 
     2368    foreach vec {obsvec calcvec bckvec diffvec} { 
     2369        global $vec 
     2370        $vec expr {$vec * ymult} 
     2371    } 
     2372} 
     2373 
     2374# create a PDF using GNUPLOT & GhostScript 
     2375proc ExportPDF {} { 
     2376    set msg {} 
     2377    if {$::gnuplotpath == {}} { 
     2378        append msg "\n\tThe gnuplot program was not found" 
     2379    }  
     2380    if {$::gnuplotexport == ""} { 
     2381        append msg "\n\tfile gnuplot.tcl not found in $::expgui(scriptdir)" 
     2382    }  
     2383    if {$::ps2pdfcmd == ""} { 
     2384        append msg "\n\tNo PDF conversion routine (ghostscript or pstopdf on Mac was found" 
     2385    } 
     2386    if {$msg != ""} { 
     2387        MyMessageBox -parent . -title "Gnuplot/GS Error" \ 
     2388                -message $msg \ 
     2389                -icon error -type OK -default OK 
     2390        return 0 
     2391    } 
     2392 
     2393    set pdfoutname [tk_getSaveFile -title "Select output file" -parent . \ 
     2394                        -defaultextension ".pdf" \ 
     2395                        -initialdir [pwd] \ 
     2396                        -initialfile "[file rootname $::expnam].pdf"] 
     2397    if { $pdfoutname == "" } { return } 
     2398    cd [file dirname $pdfoutname] 
     2399    set pdfoutname [regsub -all " " [file tail $pdfoutname] "_"] 
     2400    set rootname [file root $pdfoutname] 
     2401    set csvoutname "$rootname.csv" 
     2402    set gplotname "$rootname.gplot" 
     2403    set psoutname "$rootname.ps" 
     2404    foreach filename [list $pdfoutname $csvoutname $gplotname $psoutname] { 
     2405        catch {file -force delete $filename} 
     2406    } 
     2407    waitmsg "running gnuplot, Please wait" 
     2408    Graph2Gnuplot .g $gplotname $psoutname $csvoutname 
     2409    if {![file exists $gplotname]} { 
     2410        set msg "\n  Output file for gnuplot not created! ($gplotname)" 
     2411    } 
     2412    if {![file exists $csvoutname]} { 
     2413        append msg "\n   Output file for gnuplot not created! ($csvoutname)" 
     2414    } 
     2415    if {$msg == ""} { 
     2416        if {[catch { exec $::gnuplotpath $gplotname } err]} { 
     2417            if {[string first "Warning" $err] == -1} { 
     2418                append msg "Error in running gnuplot: $err" 
     2419            } 
     2420        } 
     2421        if {![file exists $psoutname]} { 
     2422            append msg "\n   Output file from gnuplot not created! ($psoutname)" 
     2423        } 
     2424    } 
     2425    if {$msg == ""} { 
     2426        if {[catch { eval exec [subst $::ps2pdfcmd]} err]} { 
     2427            append msg "Error in PDF conversion: $err" 
     2428        } 
     2429        if {![file exists $pdfoutname]} { 
     2430            append msg "\n   PDF file not created! ($pdfoutname)" 
     2431        } 
     2432    } 
     2433    donewaitmsg 
     2434    if {$msg == ""} { 
     2435        # clean up 
     2436        foreach filename [list $csvoutname $gplotname $psoutname] { 
     2437            catch {file -force delete $filename} 
     2438        } 
     2439        MyMessageBox -parent . -title "PDF created" \ 
     2440            -message "Success: PDF file created ($pdfoutname)" \ 
     2441            -type OK -default OK 
     2442        return 1 
     2443    } else { 
     2444        # something failed 
     2445        MyMessageBox -parent . -title "Gnuplot/GS Error" \ 
     2446                -message "Error: $msg" \ 
     2447                -icon error -type OK -default OK 
     2448        return 0 
     2449    } 
     2450} 
     2451 
     2452# resize graph font only 
     2453proc ResizeGraphFont {graph font} { 
     2454    foreach w {legend xaxis yaxis xaxis yaxis \ 
     2455                   x2axis y2axis x2axis y2axis} \ 
     2456        o {-font -tickfont -tickfont -titlefont -titlefont \ 
     2457               -tickfont -tickfont -titlefont -titlefont} { 
     2458                   catch { 
     2459                       $graph $w configure $o $font 
     2460                   } 
     2461               } 
     2462    catch { 
     2463        set curfont [$graph cget -font] 
     2464        if {[string tolower [lindex $curfont 0]] == "symbol"} { 
     2465            $graph configure -font "Symbol [lrange $font 1 end]" 
     2466        } else { 
     2467            $graph configure -font $font 
     2468        } 
     2469    } 
     2470} 
     2471 
    20912472if {$program == "liveplot"} { 
     2473    .a.mag.menu add command -label "Add region" -command "AddMag" 
     2474    .a.mag.menu add command -label "Edit Regions" -command "EditMag" 
     2475    .a.mag.menu add separator 
     2476    .a.mag.menu add command -label "Clear" \ 
     2477        -command "set maglist {}; readdata .g" 
    20922478    .a.options.menu add command -label "Obs symbol" -command getsymopts 
     2479    foreach i {1 2 3 4 5 6 7 8 9} { 
     2480        bind . <Control-Key-$i> "AddCursorMag %x $i" 
     2481    } 
    20932482} else { 
    20942483    .a.options.menu add cascade -label "Symbol Type" -menu .a.options.menu.sym 
     
    21312520            -variable graph(yunits) -value 1 \ 
    21322521            -command {set cycle [getcycle];readdata .g} 
     2522    .a.options.menu.yunits add radiobutton -label "I/Sigma(I)" \ 
     2523            -variable graph(yunits) -value 2 \ 
     2524            -command {set cycle [getcycle];readdata .g} 
    21332525    .a.options.menu add command -label "HKL labeling" -command setlblopts 
    21342526    .a.options.menu add checkbutton -label "Subtract background" \ 
     
    21552547} 
    21562548if {$program == "liveplot"} { 
     2549    .a.options.menu add cascade -menu  .a.options.menu.gfont \ 
     2550        -label "Graph font" 
     2551    menu .a.options.menu.gfont 
     2552    foreach f {12 14 16 18 20 22 24 26 28 32 36 40} { 
     2553        .a.options.menu.gfont add radiobutton \ 
     2554            -command "ResizeGraphFont .g \[list Helvetica -$f\]" \ 
     2555            -label $f -font "Helvetica -$f" 
     2556    } 
    21572557    .a.options.menu add checkbutton -label "Raise on update" \ 
    21582558            -variable graph(autoraise) 
     
    23142714expload $expnam.EXP 
    23152715mapexp 
    2316  
     2716if {$expgui(autotick)} { 
     2717    foreach i $::expmap(phaselist) { 
     2718        set peakinfo(flag$i) 1 
     2719    } 
     2720} 
     2721         
    23172722# fill the histogram menu 
    23182723if {[llength $expmap(powderlist)] > 15} { 
  • trunk/readexp.tcl

    r1033 r1166  
    99# returns 1 if the file is 80 char/line + cr/lf 
    1010# returns 2 if the file is sequential but not fixed-record length 
    11 proc expload {expfile} { 
    12     global exparray tcl_platform 
    13     # $expfile is the path to the data file.  
    14  
     11proc expload {expfile "ns {}"} { 
     12    # expfile is the path to the data file.  
     13    # ns is the namespace to place the output array (default is global) 
     14    if {$ns != ""} { 
     15        namespace eval $ns {} 
     16    } 
    1517    if [catch {set fil [open "$expfile" r]}] { 
    1618        tk_dialog .expFileErrorMsg "File Open Error" \ 
     
    2729    } 
    2830    catch { 
    29         unset exparray 
     31        unset ${ns}::exparray 
    3032    } 
    3133    if {$len > 160} { 
     
    3941            incr i2 80 
    4042            set key [string range $nline 0 11] 
    41             set exparray($key) [string range $nline 12 end] 
     43            set ${ns}::exparray($key) [string range $nline 12 end] 
    4244        } 
    4345    } else { 
     
    4547        while {$len > 0} { 
    4648            set key [string range $line 0 11] 
    47             set exparray($key) [string range $line 12 79] 
     49            set ${ns}::exparray($key) [string range $line 12 79] 
    4850            if {$len != 81 || [string range $line end end] != "\r"} {set fmt 2} 
    4951            set len [gets $fil line] 
     
    187189        } 
    188190    } 
     191    # load the constrained parameters 
     192    atom_constraint_load 
    189193    set expgui(mapstat) 1 
    190194} 
     
    294298            set digits 1 
    295299        } 
     300        if {$digits <= 0} {set digits 1} 
    296301        if {$digits + $sign >= $length} { 
    297302            # the number is much too big -- use exponential notation 
     
    307312            set decimal [expr {$length - $digits - $sign - 1}] 
    308313            set tmp [format "%#.${decimal}f" $value] 
    309         } elseif {abs($value) < pow(10,2-$decimal) && $length > 6} { 
     314        } elseif {abs($value) < pow(10,2-$decimal) && $length > 6 && $value != 0} { 
    310315            # for small values, switch to exponential notation (2-$decimal -> three sig figs.) 
    311316            set decimal [expr {$length - 6 - $sign}] 
     
    13881393#     absdamp -- damping for absorption refinement (*) 
    13891394#     absref -- refinement damping for absorption refinement (*) 
    1390 #     proftbl -- returns number of profile table termns 
     1395#     proftbl -- returns number of profile table terms 
     1396#     anomff -- returns a list of elements, f' and f" 
    13911397#   parameters transferred from the instrument parameter file: 
    13921398#     ITYP    -- returns the contents of the ITYP record 
     
    19771983                return $val 
    19781984            } 
     1985            anomff-get { 
     1986                set l {} 
     1987                foreach i {1 2 3 4 5 6 7 8 9} { 
     1988                    if {![existsexp "${key}FFANS$i"]} continue 
     1989                    set line [readexp "${key}FFANS$i"] 
     1990                    set elem [string trim [string range $line 2 9]] 
     1991                    set fp [string trim [string range $line 10 19]] 
     1992                    set fpp [string trim [string range $line 20 29]] 
     1993                    lappend l [list $elem $fp $fpp] 
     1994                } 
     1995                return $l 
     1996            } 
     1997            anomff-set { 
     1998                # match up input against elements in list.  
     1999                # change elements included, return any elements that are  
     2000                # not found. 
     2001                set errorlist {} 
     2002                foreach triplet $value { 
     2003                    foreach {e fp fpp} $triplet {}                 
     2004                    foreach i {1 2 3 4 5 6 7 8 9} { 
     2005                        if {![existsexp "${key}FFANS$i"]} continue 
     2006                        # note that the element name is not used or validated 
     2007                        set elem [string trim [string range \ 
     2008                                                   [readexp "${key}FFANS$i"] 2 9]] 
     2009                        if {[string match -nocase $e $elem]} {  
     2010                            if ![validreal fp 10 3] {return 0} 
     2011                            setexp "${key}FFANS$i" $fp 11 10 
     2012                            if ![validreal fpp 10 3] {return 0} 
     2013                            setexp "${key}FFANS$i" $fpp 21 10 
     2014                            set e {} 
     2015                            break 
     2016                        } 
     2017                    } 
     2018                    if {$e != ""} { 
     2019                        # oops, no match 
     2020                        lappend errorlist $e 
     2021                    } 
     2022                } 
     2023                if {$errorlist != ""} {return [list 0 $errorlist]} 
     2024            } 
    19792025            default { 
    19802026                set msg "Unsupported histinfo access: parm=$parm action=$action" 
     
    21732219    return 1 
    21742220} 
     2221 
     2222#  read fixed constraints 
     2223 
     2224proc atom_constraint_read {phase} { 
     2225    set fix_list "" 
     2226    foreach k {1 2 3 4 5 6 7 8 9} { 
     2227        set key [format "LEQV HOLD%1d%2d" $phase $k] 
     2228        set line [readexp $key] 
     2229        foreach j {2 10 18 26 34 42 50 58} { 
     2230            set fix_param [string range $line $j [expr $j+7]] 
     2231            if {[string trim $fix_param] == ""} {return $fix_list} 
     2232            lappend fix_list $fix_param 
     2233        } 
     2234    } 
     2235} 
     2236 
     2237# load all atom constraints into global array fix_param 
     2238proc atom_constraint_load { } { 
     2239    catch {unset ::fix_param} 
     2240    foreach i $::expmap(phaselist) { 
     2241        set temp [atom_constraint_read $i] 
     2242        foreach j $temp { 
     2243            set atomnum [string trim [string range $j 2 3]] 
     2244            set param [string trim [string range $j 4 6]] 
     2245            set ::fix_param($i,$atomnum,$param) 1     
     2246        } 
     2247    } 
     2248} 
     2249 
     2250proc atom_constraint_write {phase fix_list} { 
     2251    foreach key [array names ::exparray "LEQV HOLD$phase*"] { 
     2252        delexp $key 
     2253    } 
     2254    set k 0 
     2255    set j 1 
     2256    set line "" 
     2257    foreach fix $fix_list { 
     2258        incr k 
     2259        append line $fix 
     2260        if {$k == 8} { 
     2261            set key [format "LEQV HOLD%1d%2d" $phase $j] 
     2262            makeexprec $key 
     2263            setexp $key $line 3 [expr ($k * 8) + 2] 
     2264            set k 0 
     2265            incr j 
     2266            set line "" 
     2267        } 
     2268    } 
     2269    if {$line != ""} { 
     2270        set key [format "LEQV HOLD%1d%2d" $phase $j] 
     2271        makeexprec $key 
     2272        setexp $key $line 3 [expr ($k * 8) + 2] 
     2273    }    
     2274} 
     2275 
    21752276 
    21762277#  get a logical constraint 
     
    30993200        } 
    31003201    } 
    3101     if {$HST == ""} {return "1"} 
    31023202    if {$HST <=9} { 
    31033203        set key "HST  $HST" 
     
    31193219            makeexprec $key 
    31203220        } 
    3121         setexp $key "RSN" [expr 3 + 5*(($HST-1) % 12)] 5 
     3221        setexp $key "RSN " [expr 3 + 5*(($HST-1) % 12)] 5 
    31223222        # create other HST  xx recs 
    31233223        if {$HST <=9} { 
     
    31303230        makeexprec "$key FACTR" 
    31313231        makeexprec "$key NBNDS" 
     3232        mapexp 
     3233    } elseif {$HST == ""} { 
     3234        if $::expgui(debug) {puts "no restraints"} 
     3235        return "1" 
    31323236    } 
    31333237 
     
    34493553    } 
    34503554} 
     3555#============================================================================ 
     3556# rigid body EXP editing routines (to move into readexp.tcl) 
     3557# RigidBodyList -- returns a list of the defined rigid body types 
     3558# SetRigidBodyVar -- set variables and damping for rigid body type multipliers 
     3559# ReadRigidBody  -- # of times a body is mapped, scaling factors, var #s & coordinates 
     3560# RigidBodyMappingList - return a list instances where a RB is mapped in phase 
     3561# RigidBodyEnableTLS -- Enable or Disable TLS use for a rigid body mapping 
     3562# RigidBodySetTLS  -- change the TLS values for a rigid body mapping 
     3563# RigidBodySetDamp -- change the damping values for a rigid body mapping 
     3564# RigidBodyVary    -- set refinement variable numbers for a rigid body mapping 
     3565# RigidBodyTLSVary -- set TLS refinement variable nums for a rigid body mapping 
     3566# AddRigidBody -- defines a new rigid body type 
     3567# DeleteRigidBody -- remove a rigid body definition 
     3568# ReplaceRigidBody -- replaces a previous rigid body type 
     3569# ReadRigidBodyMapping  -- get parameters for a rigid body mapping 
     3570# MapRigidBody -- map a rigid body type into a phase 
     3571# EditRigidBodyMapping -- change the parameters in a rigid body mapping 
     3572# UnMapRigidBody --remove a rigid body constraint by removing a RB "instance" 
     3573#----- note that these older routines should not be used ------ 
     3574# RigidBodyCount -- returns the number of defined rigid bodies (body types) 
     3575#    use RigidBodyList instead 
     3576# RigidBodyMappingCount -- # of times a rigid body is mapped in phase 
     3577#    use RigidBodyMappingList instead 
     3578#============================================================================ 
     3579# returns the number of defined rigid bodies  
     3580proc RigidBodyCount {} { 
     3581    set n [string trim [readexp "RGBD  NRBDS"]] 
     3582    if {$n == ""} { 
     3583        set n 0 
     3584    } 
     3585    return $n 
     3586} 
     3587 
     3588# returns a list of the defined rigid body types  
     3589proc RigidBodyList {} { 
     3590    set n [string trim [readexp "RGBD  NRBDS"]] 
     3591    if {$n == ""} { 
     3592        set n 0 
     3593    } 
     3594    set rblist {} 
     3595    foreach rbnum {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15} { 
     3596        set value $rbnum 
     3597        validint value 2 
     3598        set key "RGBD${value}" 
     3599        if {[existsexp "$key NATR "]} { 
     3600            lappend rblist $rbnum 
     3601        } 
     3602        if {[llength $rblist] == $n} break 
     3603    } 
     3604    return $rblist 
     3605} 
     3606 
     3607# ReadRigidBody provides all information associated with a rigid body type 
     3608#  rbnum is the rigid body type number 
     3609# it returns two items:  
     3610#   the number of times the rigid body is mapped 
     3611#   a list containing an element for each scaling factor in rigid body #rbnum. 
     3612# in each element there are four items:  
     3613#    a multiplier value for the rigid body coordinates 
     3614#    a damping value (0-9) for the refinement of the multiplier 
     3615#    a variable number if the multiplier will be refined 
     3616#    a list of cartesian coordinates coordinates  
     3617# each cartesian coordinate contains 4 items: x,y,z and a label 
     3618#  note that the label is present only when the RB is created in EXPGUI and is 
     3619#  not used in GSAS. 
     3620proc ReadRigidBody {rbnum} { 
     3621    if {[lsearch [RigidBodyList] $rbnum] == -1} { 
     3622        return "" 
     3623    } 
     3624    set value $rbnum 
     3625    validint value 2 
     3626    set key "RGBD${value}" 
     3627    set n [string trim [string range [readexp "$key NATR"] 0 4]] 
     3628    set used [string trim [string range [readexp "$key NBDS"] 0 4]] 
     3629    set nmult [string trim [string range [readexp "$key NSMP"] 0 4]] 
     3630    set out {} 
     3631    for {set i 1} {$i <= $nmult} {incr i} { 
     3632        set line [readexp "${key}${i}PARM"] 
     3633        set mult [string trim [string range $line 0 9]] 
     3634        set var [string trim [string range $line 10 14]] 
     3635        set damp [string trim [string range $line 15 19]] 
     3636        set coordlist {} 
     3637        for {set j 1} {$j <= $n} {incr j} { 
     3638            set value $j 
     3639            validint value 3 
     3640            set line [readexp "${key}${i}SC$value"] 
     3641            set x [string trim [string range $line 0 9]] 
     3642            set y [string trim [string range $line 10 19]] 
     3643            set z [string trim [string range $line 20 29]] 
     3644            set lbl [string trim [string range $line 30 39]] 
     3645            lappend coordlist [list $x $y $z $lbl] 
     3646        } 
     3647        lappend out [list $mult $damp $var $coordlist] 
     3648    } 
     3649    return [list $used $out] 
     3650} 
     3651 
     3652# SetRigidBodyVar 
     3653#   rbnum is the rigid body type number 
     3654#   varnumlist is a list of variable numbers 
     3655#      note that if this list is shorter than the number of actual multipliers 
     3656#      for the body, the unspecified variable will not be changed 
     3657#   damplist   is a list of damping values (0-9) 
     3658#      note that if the damplist is shorter than the number of actual multipliers 
     3659#      the unspecified values are not changed 
     3660#  SetRigidBodVar 2 {1 2 3} {} 
     3661#       will vary the (first 3) translations in body #3 and will not change the 
     3662#       damping values 
     3663#  SetRigidBodVar 3 {} {0 0 0} 
     3664#       will not change variable settings but will change the (first 3) damping values 
     3665#  SetRigidBodVar 4 {11 11} {8 8} 
     3666#      changes both variable numbers and damping at the same time 
     3667# Nothing is returned 
     3668proc SetRigidBodyVar {rbnum varnumlist damplist} { 
     3669    if {[lsearch [RigidBodyList] $rbnum] == -1} { 
     3670        return "" 
     3671    } 
     3672    set value $rbnum 
     3673    validint value 2 
     3674    set key "RGBD${value}" 
     3675    set nmult [string trim [string range [readexp "$key NSMP"] 0 4]] 
     3676    for {set i 1} {$i <= $nmult} {incr i} { 
     3677        set j $i 
     3678        incr j -1 
     3679        set var [lindex $varnumlist $j] 
     3680        if {$var != ""} { 
     3681            validint var 5 
     3682            setexp "${key}${i}PARM" $var 11 15 
     3683        } 
     3684        set damp [lindex $damplist $j] 
     3685        if {$damp != ""} { 
     3686            if {$damp > 9} {set damp 9} 
     3687            if {$damp < 0} {set damp 0} 
     3688            validint damp 5 
     3689        } 
     3690        setexp "${key}${i}PARM" $damp 16 20 
     3691    } 
     3692} 
     3693 
     3694 
     3695# return the number of times rigid body $bodytyp is mapped in phase $phase 
     3696proc RigidBodyMappingCount {phase bodytyp} { 
     3697    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1]" 
     3698    if {! [existsexp "$key  NBDS"]} {return 0} 
     3699    set n [string trim [readexp "$key  NBDS"]] 
     3700    if {$n == ""} { 
     3701        set n 0 
     3702    } 
     3703    return $n 
     3704} 
     3705# return a list of the instances where rigid body $bodytyp is mapped in phase $phase 
     3706proc RigidBodyMappingList {phase bodytyp} { 
     3707    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1]" 
     3708    if {! [existsexp "$key  NBDS"]} {return {}} 
     3709    set n [string trim [readexp "$key  NBDS"]] 
     3710    if {$n == ""} { 
     3711        set n 0 
     3712    } 
     3713    set rblist {} 
     3714    foreach rbnum {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15} { 
     3715        set value $rbnum 
     3716        validint value 2 
     3717        set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $rbnum 1]" 
     3718        if {[existsexp "$key  NDA"]} { 
     3719            lappend rblist $rbnum 
     3720        } 
     3721        if {[llength $rblist] == $n} break 
     3722    } 
     3723    return $rblist 
     3724} 
     3725 
     3726 
     3727 
     3728# reads rigid body mapping parameters for phase ($phase), body type # ($bodytyp) and instance # ($num) 
     3729# returns a list of items (most lists) as follows: 
     3730#   1) sequence # of first atom in body 
     3731#   2) origin of body in fractional coordinates (3 elements) 
     3732#   3) Euler angles as 6 pairs of numbers (see below) 
     3733#   4) variable numbers for the 9 position variables (origin followed by rotations) 
     3734#   5) damping vals for the 9 position variables (origin followed by rotations) 
     3735#   6) the TLS values, in order below (empty list if TLS is not in use) 
     3736#   7) the variable numbers for each TLS values, in order below (or empty) 
     3737#   8) three damping values for the T, L and S terms. 
     3738# returns an empty list if no such body exists. 
     3739# 
     3740# Euler angles are a list of axes and angles to rotate:  
     3741#   { {axis1 angle1} {axis2 angle2} ...}  
     3742# where axis1,... can be 1, 2 or 3 corresponding to the cartesian X, Y or Z axes 
     3743# 
     3744# The 20 TLS terms are ordered: 
     3745#    T11, T22, T33, T12, T13, T23 
     3746#    L11, L22, L33, L12, L13, L23 
     3747#    S12, S13, S21, S23, S31, S32, SAA, SBB 
     3748# 
     3749proc ReadRigidBodyMapping {phase bodytyp num} { 
     3750    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $num] == -1} { 
     3751        return "" 
     3752    } 
     3753    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $num 1]" 
     3754    set first [string trim [string range [readexp "$key  NDA"] 0 4]] 
     3755    set line [readexp "$key BDFL"] 
     3756    set varlist {} 
     3757    set damplist {} 
     3758    foreach i {0 1 2 3 4 5 6 7 8} { 
     3759        lappend varlist [string trim [string range $line [expr {5*$i}] [expr {4 + 5*$i}] ]] 
     3760        lappend damplist [string trim [string range $line [expr {45 + $i}] [expr {45 + $i}] ]] 
     3761    } 
     3762    set TLSdamplist {} 
     3763    foreach i {54 55 56} { 
     3764        lappend TLSdamplist [string trim [string range $line $i $i ]] 
     3765    } 
     3766    set line [readexp "${key} BDLC"] 
     3767    set x [string trim [string range $line 0 9]] 
     3768    set y [string trim [string range $line 10 19]] 
     3769    set z [string trim [string range $line 20 29]] 
     3770    set origin [list $x $y $z] 
     3771    set line [readexp "${key} BDOR"] 
     3772    set rotations {} 
     3773    foreach i {0 10 20 30 40 50} { 
     3774        set angle [string trim [string range $line $i [expr {$i+7}]]] 
     3775        set axis [string trim [string range $line [expr {$i+8}] [expr {$i+9}]]] 
     3776        lappend rotations [list $angle $axis] 
     3777    } 
     3778    set TLS [string trim [string range [readexp "${key} LSTF"] 0 4]] 
     3779    set tlsvars {} 
     3780    set tlsvals {} 
     3781    if {$TLS != 0} { 
     3782        set line [readexp "${key}TLSF1"] 
     3783        for {set j 0} {$j < 20} {incr j} { 
     3784            set var [string trim [string range $line [expr {3*$j}] [expr {3*$j+2}]]] 
     3785            if {$var == ""} {set var 0} 
     3786            lappend tlsvars $var 
     3787        } 
     3788        for {set j 0} {$j < 20} {incr j} { 
     3789            set i 0 
     3790            if {$j == 0} { 
     3791                set i 1 
     3792            } elseif {$j == 8} { 
     3793                set i 2 
     3794            } elseif {$j == 16} { 
     3795                set i 3 
     3796            } 
     3797            if {$i != 0} { 
     3798                set line [readexp "${key}TLSP$i"] 
     3799                set i 0 
     3800                set j1 0 
     3801                set j2 7 
     3802            } else { 
     3803                incr j1 8 
     3804                incr j2 8 
     3805            } 
     3806            set val [string trim [string range $line $j1 $j2]] 
     3807            if {$val == ""} {set val 0} 
     3808            lappend tlsvals $val 
     3809        } 
     3810    } 
     3811    return [list $first $origin $rotations $varlist $damplist $tlsvals $tlsvars $TLSdamplist] 
     3812} 
     3813 
     3814# Control TLS representation for phase, body # and instance number of a Rigid body mapping  
     3815#   for mapping with phase ($phase), body type # ($bodytyp) and instance # ($num) 
     3816# Enable TLS use if TLS is non-zero (true). Disable if zero 
     3817proc RigidBodyEnableTLS {phase bodytyp num TLS} { 
     3818    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $num] == -1} { 
     3819        return "" 
     3820    } 
     3821    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $num 1]" 
     3822    if {$TLS} { 
     3823        setexp "${key} LSTF" [format "%5d" 1] 1 5 
     3824        if {![existsexp "${key}TLSF1"]} {makeexprec "${key}TLSF1"} 
     3825        if {![existsexp "${key}TLSP1"]} { 
     3826            makeexprec "${key}TLSP1" 
     3827            set str {} 
     3828            foreach v {.01 .01 .01 0 0 0 0 0} d {4 4 4 4 4 4 2 2} { 
     3829                validreal v 8 $d 
     3830                append str $v 
     3831            } 
     3832            setexp "${key}TLSP1" $str 1 64 
     3833        } 
     3834        if {![existsexp "${key}TLSP2"]} { 
     3835            makeexprec "${key}TLSP2" 
     3836            set str {} 
     3837            set v 0 
     3838            foreach d {2 2 2 2 4 4 4 4} { 
     3839                validreal v 8 $d 
     3840                append str $v 
     3841            } 
     3842            setexp "${key}TLSP2" $str 1 64 
     3843        } 
     3844        if {![existsexp "${key}TLSP3"]} { 
     3845            makeexprec "${key}TLSP3" 
     3846            set str {} 
     3847            set v 0 
     3848            foreach d {4 4 4 4} { 
     3849                validreal v 8 $d 
     3850                append str $v 
     3851            } 
     3852            setexp "${key}TLSP3" $str 1 64 
     3853        } 
     3854    } else { 
     3855        setexp "${key} LSTF" [format "%5d" 0] 1 5 
     3856    } 
     3857    return 1 
     3858} 
     3859 
     3860# Control the TLS values for Rigid body mapping for mapping with 
     3861#    phase ($phase), body type # ($bodytyp) and instance # ($num) 
     3862# set the 20 TLS values to the values in TLSvals 
     3863# There must be exactly 20 TLS terms, which are ordered: 
     3864#    T11, T22, T33, T12, T13, T23 
     3865#    L11, L22, L33, L12, L13, L23 
     3866#    S12, S13, S21, S23, S31, S32, SAA, SBB 
     3867proc RigidBodySetTLS {phase bodytyp num TLSvals} { 
     3868    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $num] == -1} { 
     3869        return "" 
     3870    } 
     3871    if {[llength $TLSvals] != 20} {return ""} 
     3872    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $num 1]" 
     3873    set TLS [string trim [string range [readexp "${key} LSTF"] 0 4]] 
     3874    if {$TLS == 0} {return ""} 
     3875    if {![existsexp "${key}TLSF1"]} {makeexprec "${key}TLSF1"} 
     3876    foreach n {1 2 3} { 
     3877        if {![existsexp "${key}TLSP$n"]} {makeexprec "${key}TLSP$n"} 
     3878    } 
     3879    set str {} 
     3880    set n 1 
     3881    set i 0 
     3882    foreach v $TLSvals d {4 4 4 4 4 4 2 2 2 2 2 2 4 4 4 4 4 4 4 4} { 
     3883        incr i 
     3884        validreal v 8 $d 
     3885        append str $v 
     3886        if {$i == 8} { 
     3887            set i 0 
     3888            setexp "${key}TLSP$n" $str 1 64 
     3889            incr n 
     3890            set str {} 
     3891        } 
     3892    } 
     3893    setexp "${key}TLSP$n" $str 1 64 
     3894    return 1 
     3895} 
     3896 
     3897# set damping values for a Rigid body mapping 
     3898#   for mapping with phase ($phase), body type # ($bodytyp) and instance # ($num) 
     3899# there must be 9 damping values in RBdamp for the 9 position variables (origin followed by rotations) 
     3900# Use of TLSdamp is optional, but to be used, TLS representation must be enabled and there must be 
     3901# three damping terms (for all T terms; for all L terms and for all S terms) 
     3902proc RigidBodySetDamp {phase bodytyp num RBdamp "TLSdamp {}"} { 
     3903    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $num] == -1} { 
     3904        return "" 
     3905    } 
     3906    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $num 1]" 
     3907    if {[llength $RBdamp] != 9} {return ""} 
     3908    set str {} 
     3909    foreach v $RBdamp { 
     3910        if {[validint v 1] != 1} {set v " "} 
     3911        append str $v 
     3912    } 
     3913    setexp "$key BDFL" $str 46 9 
     3914    set TLS [string trim [string range [readexp "${key} LSTF"] 0 4]] 
     3915    if {$TLS != 0 &&  [llength $TLSdamp] == 3} { 
     3916        set str {} 
     3917        foreach v $TLSdamp { 
     3918        if {[validint v 1] != 1} {set v " "} 
     3919            append str $v 
     3920        } 
     3921        setexp "$key BDFL" $str 55 3 
     3922    } 
     3923    return 1 
     3924} 
     3925 
     3926# set refinement variable numbers for a Rigid body mapping 
     3927#   for mapping with phase ($phase), body type # ($bodytyp) and instance # ($num) 
     3928# there must be 9 variable values in RBvar for the 9 position variables (origin followed by rotations) 
     3929# note that the variable values should be unique integers  
     3930proc RigidBodyVary {phase bodytyp num RBvar} { 
     3931    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $num] == -1} { 
     3932        return "" 
     3933    } 
     3934    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $num 1]" 
     3935    if {[llength $RBvar] != 9} {return ""} 
     3936    set str {} 
     3937    foreach v $RBvar { 
     3938        if {[validint v 5] != 1} {set v " "} 
     3939        append str $v 
     3940    } 
     3941    setexp "$key BDFL" $str 1 45     
     3942} 
     3943 
     3944# set TLS refinement variable numbers for a Rigid body mapping 
     3945#   for mapping with phase ($phase), body type # ($bodytyp) and instance # ($num) 
     3946# there must be 20 variable values in TLSvar for the 20 parameters: 
     3947#    T11, T22, T33, T12, T13, T23 
     3948#    L11, L22, L33, L12, L13, L23 
     3949#    S12, S13, S21, S23, S31, S32, SAA, SBB 
     3950# note that the variable values should be unique integers  
     3951proc RigidBodyTLSVary {phase bodytyp num TLSvar} { 
     3952    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $num] == -1} { 
     3953        return "" 
     3954    } 
     3955    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $num 1]" 
     3956    if {[llength $TLSvar] != 20} {return ""} 
     3957    set TLS [string trim [string range [readexp "${key} LSTF"] 0 4]] 
     3958    if {$TLS == 0} {return ""} 
     3959    set str {} 
     3960    foreach v $TLSvar { 
     3961        if {[validint v 3] != 1} {set v " "} 
     3962        append str $v 
     3963    } 
     3964    setexp "${key}TLSF1" $str 1 60 
     3965 
     3966# AddRigidBody: add a new rigid body definition into the .EXP file 
     3967# arguments are: 
     3968#   multlist: defines a list of multipliers for each set of coordinates. In the 
     3969#             simplest case this will be {1} 
     3970#   coordlist: a nested list of coordinates such as { { {0 0 0} {.1 .1 .1} {.2 .2 .2} } } 
     3971# note that when the length of multlist > 1 then coordlist must have the same length. 
     3972# for input where 
     3973#     multlist = {s1 s2} and 
     3974#     coordlist = { { {0 0 0} {1 1 0} {.0 .0 .0} ...} 
     3975#                     {0 0 0} {1 1 0} {2 1 2} ...} 
     3976#                 } 
     3977# the cartesian coordinates are defined from the input as 
     3978#    atom 1 = s1 * (0,0,0) + s2*(0,0,0) [ = (0,0,0)] 
     3979#    atom 2 = s1 * (1,1,0) + s2*(1,1,0) [ = (s1+s2) * (1,1,0)] 
     3980#    atom 3 = s1 * (0,0,0) + s2*(2,1,2) [ = s2 * (2,1,2)] 
     3981#    ... 
     3982# Returns the number of the rigid body that has been created 
     3983proc AddRigidBody {multlist coordlist} { 
     3984    # find the first unused body # 
     3985    foreach rbnum {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} { 
     3986        set value $rbnum 
     3987        validint value 2 
     3988        set key "RGBD${value}" 
     3989        if {! [existsexp "$key NATR "]} {break} 
     3990    } 
     3991    # did we go too far? 
     3992    if {$rbnum == 16} {return ""} 
     3993    # increment the RB counter 
     3994    set n [string trim [readexp "RGBD  NRBDS"]] 
     3995    if {$n == ""} { 
     3996        makeexprec "RGBD  NRBDS" 
     3997        set n 0 
     3998    } 
     3999    incr n 
     4000    validint n 5 
     4001    setexp "RGBD  NRBDS" $n 1 5 
     4002    SetRigidBody $rbnum $multlist $coordlist 
     4003    return $rbnum 
     4004} 
     4005 
     4006# DeleteRigidBody: remove a rigid body definition from the .EXP file 
     4007# The body may not be mapped. I am not sure if GSAS allows more than 9 bodies, 
     4008# but if it does, the simplifed approach used here will fail, so this 
     4009# is not allowed. 
     4010# Input: 
     4011#   Rigid body number 
     4012# Returns: 
     4013#   1 on success 
     4014#   -1 if the body number is 11 or greater 
     4015#   -2 if the body is mapped 
     4016#   -3 if the body is not defined 
     4017proc DeleteRigidBody {rbnum} { 
     4018    # can't delete bodies with numbers higher than 10, since the key prefix 
     4019    # (RGBD11... will overlap with rigid body instance records, which would be 
     4020    # deleted below 
     4021    if {$rbnum > 10} { 
     4022        return -1 
     4023    } 
     4024    set value $rbnum 
     4025    validint value 2 
     4026    set key "RGBD${value}" 
     4027    if {![existsexp "$key NATR "]} { 
     4028        return -2 
     4029    } 
     4030    # make sure the body is not mapped 
     4031    if {[string trim [string range [readexp "$key NBDS"] 0 4]] != 0} { 
     4032        return -3 
     4033    } 
     4034    # delete the records starting with "RGBD x" or "RGBD10" 
     4035    foreach key [array names ::exparray "${key}*"] { 
     4036        #puts $key 
     4037        delexp $key 
     4038    } 
     4039    # decrement the RB counter 
     4040    set n [string trim [readexp "RGBD  NRBDS"]] 
     4041    if {$n == ""} { 
     4042        set n 0 
     4043    } 
     4044    incr n -1 
     4045    validint n 5 
     4046    if {$n > 0} { 
     4047        setexp "RGBD  NRBDS" $n 1 5 
     4048    } else { 
     4049        delexp "RGBD  NRBDS" 
     4050    } 
     4051    return 1 
     4052} 
     4053 
     4054# ReplaceRigidBody: replace all the information for rigid body #rbnum 
     4055# Works the sames as AddRigidBody (see above) except that the rigid body is replaced rather 
     4056# than added. 
     4057# Note that count of the # of times the body is used is preserved 
     4058proc ReplaceRigidBody {rbnum multlist coordlist {varlist ""} {damplist ""}} { 
     4059    set value $rbnum 
     4060    validint value 2 
     4061    set key "RGBD${value}" 
     4062    set line [readexp "$key NBDS"] 
     4063    foreach key [array names ::exparray "${key}*"] { 
     4064        #puts $key 
     4065        delexp $key 
     4066    } 
     4067    SetRigidBody $rbnum $multlist $coordlist $varlist $damplist 
     4068    setexp "$key NBDS" $line 1 68 
     4069} 
     4070 
     4071# Edit the parameters for rigid body #rbnum 
     4072# (normally called from ReplaceRigidBody or AddRigidBody) 
     4073proc SetRigidBody {rbnum multlist coordlist {varlist ""} {damplist ""}} { 
     4074    set value $rbnum 
     4075    validint value 2 
     4076    set key "RGBD${value}" 
     4077    # number of atoms 
     4078    set value [llength [lindex $coordlist 0]] 
     4079    validint value 5 
     4080    makeexprec "$key NATR" 
     4081    setexp "$key NATR" $value 1 5 
     4082    # number of times used 
     4083    set value 0 
     4084    validint value 5 
     4085    makeexprec "$key NBDS" 
     4086    setexp "$key NBDS" $value 1 5 
     4087    # number of coordinate matrices 
     4088    set value [llength $multlist] 
     4089    validint value 5 
     4090    makeexprec "$key NSMP" 
     4091    setexp "$key NSMP" $value 1 5 
     4092    set i 0 
     4093    foreach mult $multlist coords $coordlist { 
     4094        set var [lindex $varlist $i] 
     4095        if {$var == ""} {set var 0} 
     4096        set damp [lindex $damplist $i] 
     4097        if {$damp == ""} {set damp 0} 
     4098        incr i 
     4099        makeexprec "${key}${i}PARM" 
     4100        setexp "${key}${i}PARM" [format "%10.5f%5d%5d" $mult $var $damp] 1 20 
     4101        set j 0 
     4102        foreach item $coords { 
     4103            #puts $item 
     4104            incr j 
     4105            set value $j 
     4106            validint value 3 
     4107            makeexprec "${key}${i}SC$value" 
     4108            if {[llength $item] == 4} { 
     4109                setexp "${key}${i}SC$value" [eval format "%10.6f%10.6f%10.6f%10s" $item] 1 40 
     4110            } elseif {[llength $item] == 3} { 
     4111                setexp "${key}${i}SC$value" [eval format "%10.6f%10.6f%10.6f" $item] 1 30 
     4112            } else { 
     4113                return -code 3 "Invalid number of coordinates" 
     4114            } 
     4115        } 
     4116    } 
     4117} 
     4118 
     4119# convert a decimal to the GSAS hex encoding with a field $digits long. 
     4120proc ToHex {num digits} { 
     4121    return [string toupper [format "%${digits}x" $num]] 
     4122} 
     4123 
     4124# convert a GSAS hex encoding to a decimal integer 
     4125proc FromHex {hex} { 
     4126    return [scan $hex "%x"] 
     4127} 
     4128 
     4129# MapRigidBody: define an "instance" of a rigid body: meaning that the coordinates  
     4130# (and optionally U values) for a set of atoms will be generated from the rigid body 
     4131# arguments: 
     4132#   phase: phase number (1-9) 
     4133#   bodytyp: number of rigid body (1-15) as returned from AddRigidBody 
     4134#   firstatom: sequence number of the first atom in phase (note that atoms may  
     4135#              not be numbered sequentially) 
     4136#   position: list of three fractional coordinates for the origin of the rigid body coordinates 
     4137#   angles: list of 3 angles to rotate the rigid body coordinates around x, y, z of the  
     4138#           cartesian system before the body is translated to position.  
     4139# returns the instance # (number of times body $bodytyp has been used in phase $phase) 
     4140proc MapRigidBody {phase bodytyp firstatom position angles} { 
     4141    # find the first unused body # for this phase & type 
     4142    foreach rbnum {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} { 
     4143        set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $rbnum 1]" 
     4144        if {! [existsexp "$key  NDA"]} {break} 
     4145    } 
     4146    # did we go too far? 
     4147    if {$rbnum == 16} {return ""} 
     4148    # increment number of mapped bodies of this type overall 
     4149    set value $bodytyp 
     4150    validint value 2 
     4151    set key "RGBD${value}" 
     4152    set used [string trim [string range [readexp "$key NBDS"] 0 4]] 
     4153    incr used 
     4154    set value $used 
     4155    validint value 5 
     4156    setexp "$key NBDS" $value 1 5 
     4157    # increment number of mapped bodies of this type in this phase 
     4158    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1]" 
     4159    if {[existsexp "$key  NBDS"]} { 
     4160        set used [string trim [string range [readexp "$key  NBDS"] 0 4]] 
     4161    } else { 
     4162        makeexprec "$key  NBDS" 
     4163        set used 0 
     4164    } 
     4165    incr used 
     4166    set value $used 
     4167    validint value 5 
     4168    setexp "$key  NBDS" $value 1 5 
     4169    # now write the mapping parameters 
     4170    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $rbnum 1]" 
     4171    set value $firstatom 
     4172    validint value 5 
     4173    makeexprec "$key  NDA" 
     4174    setexp "$key  NDA" $value 1 5 
     4175    set l1 {} 
     4176    set l2 {} 
     4177    for {set i 0} {$i < 9} {incr i} { 
     4178        append l1 [format %5d 0] 
     4179        append l2 [format %1d 0] 
     4180    } 
     4181    makeexprec "$key BDFL" 
     4182    setexp "$key BDFL" $l1$l2 1 54 
     4183    makeexprec "${key} BDLC" 
     4184    setexp "${key} BDLC" [eval format "%10.6f%10.6f%10.6f" $position] 1 30 
     4185    makeexprec "${key} BDOR" 
     4186    set l1 {} 
     4187    foreach val "$angles 0 0 0" dir "1 2 3 1 1 1" { 
     4188        append l1 [format "%8.2f%2d" $val $dir] 
     4189    } 
     4190    setexp "${key} BDOR" $l1 1 60 
     4191    makeexprec "${key} LSTF" 
     4192    setexp "${key} LSTF" [format "%5d" 0] 1 5 
     4193    return $rbnum 
     4194} 
     4195 
     4196# EditRigidBodyMapping: edit parameters that define an "instance" of a rigid body (see MapRigidBody) 
     4197# arguments: 
     4198#   phase: phase number (1-9) 
     4199#   bodytyp: number of rigid body (1-15) as returned from AddRigidBody 
     4200#   bodynum: instance number, as returned by MapRigidBody 
     4201#   position: list of three fractional coordinates for the origin of the rigid body coordinates 
     4202#   angles: list of 3 angles to rotate the rigid body coordinates around x, y, z of the  
     4203#           cartesian system before the body is translated to position.  
     4204#  
     4205proc EditRigidBodyMapping {phase bodytyp bodynum position angles} { 
     4206    # number of bodies of this type in this phase 
     4207    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $bodynum 1]" 
     4208    setexp "${key} BDLC" [eval format "%10.6f%10.6f%10.6f" $position] 1 30 
     4209    set l1 {} 
     4210    foreach val "$angles 0 0 0" dir "1 2 3 1 1 1" { 
     4211        append l1 [format "%8.2f%2d" $val $dir] 
     4212    } 
     4213    setexp "${key} BDOR" $l1 1 60 
     4214} 
     4215 
     4216# UnMapRigidBody: remove a rigid body constraint by removing a RB "instance" 
     4217# (undoes MapRigidBody) 
     4218# arguments: 
     4219#   phase: phase number (1-9) 
     4220#   bodytyp: number of rigid body (1-15) as returned from AddRigidBody 
     4221#   bodynum: instance number, as returned by MapRigidBody 
     4222proc UnMapRigidBody {phase bodytyp mapnum} { 
     4223    if {[lsearch [RigidBodyMappingList $phase $bodytyp] $mapnum] == -1} { 
     4224        return "" 
     4225    } 
     4226    # decrement number of mapped bodies of this type overall 
     4227    set value $bodytyp 
     4228    validint value 2 
     4229    set key "RGBD${value}" 
     4230    set used [string trim [string range [readexp "$key NBDS"] 0 4]] 
     4231    incr used -1 
     4232    set value $used 
     4233    validint value 5 
     4234    setexp "$key NBDS" $value 1 5 
     4235    # decrement number of mapped bodies of this type in this phase 
     4236    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1]" 
     4237    if {[existsexp "$key  NBDS"]} { 
     4238        set used [string trim [string range [readexp "$key  NBDS"] 0 4]] 
     4239    } else { 
     4240        set used 0 
     4241    } 
     4242    incr used -1 
     4243    set value $used 
     4244    validint value 5 
     4245    if {$used > 0} { 
     4246        setexp "$key  NBDS" $value 1 5 
     4247    } else { 
     4248        delexp "$key  NBDS" 
     4249    } 
     4250    # now delete the mapping parameter records 
     4251    set key "RGBD[ToHex $phase 1][ToHex $bodytyp 1][ToHex $mapnum 1]" 
     4252    foreach key [array names ::exparray "${key}*"] { 
     4253        delexp $key 
     4254    } 
     4255    return $used 
     4256} 
     4257 
  • trunk/widplt

    r1028 r1166  
    1111package require Tk 
    1212bind all <Control-KeyPress-c> {destroy .} 
     13 
    1314set expnam [lindex $argv 0] 
    1415if {$expnam != ""} { 
     
    442443    global UVWP XY wave lblarr WidSetList WidDisplay ttrange  
    443444    global ABS absSetList AbsDisplay 
     445    if {$program == "absplt"} { 
     446        $top yaxis config -title {Abs. Corr.}  
     447    } else { 
     448        $top yaxis config -title {FWHM}  
     449    } 
    444450    if {$graph(plotunits) == "d"} { 
    445451        $top xaxis configure -title "d (A)" 
     452    } elseif {$graph(plotunits) == "deltad"} { 
     453        $top xaxis configure -title "d (A)" 
     454        $top yaxis configure -title "delta-d/d" 
    446455    } elseif {$graph(plotunits) == "q"} { 
    447456        $top xaxis configure -title "Q (A-1)" 
     
    450459    } else { 
    451460        $top xaxis configure -title "2Theta @ $graph(equivwave)" 
    452     } 
    453     if {$program == "absplt"} { 
    454         $top yaxis config -title {Abs. Corr.}  
    455     } else { 
    456         $top yaxis config -title {FWHM}  
    457461    } 
    458462    $top yaxis configure -min 0  
     
    492496                if {$graph(plotunits) == "d"} { 
    493497                    set ttlist [tod $ttlist $item] 
     498                } elseif {$graph(plotunits) == "deltad"} { 
     499                    set ttlist [tod $ttlist $item] 
    494500                } elseif {$graph(plotunits) == "q"} { 
    495501                    set ttlist [toQ $ttlist $item] 
     
    530536                                        [eval LFWHM $tt $XY($item)]] 
    531537                                lappend lfwhmlist $lfwhm 
     538                            } 
     539                        } elseif {$graph(plotunits) == "deltad"} { 
     540                            set d [tt2d $wave($item) $tt ] 
     541                            lappend ttlist $d 
     542                            set gfwhm [deltad $wave($item) $tt \ 
     543                                    [eval FWHM $tt $UVWP($item)]] 
     544                            lappend fwhmlist [expr {$gfwhm/$d}] 
     545                            if $lflag { 
     546                                set lfwhm [deltad $wave($item) $tt \ 
     547                                        [eval LFWHM $tt $XY($item)]] 
     548                                lappend lfwhmlist [expr {$lfwhm/$d}] 
    532549                            } 
    533550                        } elseif {$graph(plotunits) == "q"} { 
     
    982999} 
    9831000 
     1001proc BLTmanualZoom {} { 
     1002    global graph box 
     1003    catch {toplevel .zoom} 
     1004    eval destroy [grid slaves .zoom] 
     1005    raise .zoom 
     1006    wm title .zoom {Manual Scaling} 
     1007    grid [label .zoom.l1 -text minimum] -row 1 -column 2  
     1008    grid [label .zoom.l2 -text maximum] -row 1 -column 3  
     1009    grid [label .zoom.l3 -text x] -row 2 -column 1  
     1010    grid [label .zoom.l4 -text y] -row 3 -column 1  
     1011    grid [entry .zoom.xmin -textvariable graph(xmin) -width 10] -row 2 -column 2  
     1012    grid [entry .zoom.xmax -textvariable graph(xmax) -width 10] -row 2 -column 3  
     1013    grid [entry .zoom.ymin -textvariable graph(ymin) -width 10] -row 3 -column 2  
     1014    grid [entry .zoom.ymax -textvariable graph(ymax) -width 10] -row 3 -column 3  
     1015    grid [frame .zoom.b] -row 4 -column 1 -columnspan 3 
     1016    grid [button .zoom.b.1 -text "Set Scaling" \ 
     1017             -command "SetManualZoom set"]  -row 4 -column 1 -columnspan 2 
     1018    grid [button .zoom.b.2 -text Reset \ 
     1019            -command "SetManualZoom clear"] -row 4 -column 3 
     1020    grid [button .zoom.b.3 -text Close -command "destroy .zoom"] -row 4 -column 4  
     1021    grid rowconfigure .zoom 1 -weight 1 -pad 5 
     1022    grid rowconfigure .zoom 2 -weight 1 -pad 5 
     1023    grid rowconfigure .zoom 3 -weight 1 -pad 5 
     1024    grid rowconfigure .zoom 4 -weight 0 -pad 5 
     1025    grid columnconfigure .zoom 1 -weight 1 -pad 20 
     1026    grid columnconfigure .zoom 1 -weight 1  
     1027    grid columnconfigure .zoom 3 -weight 1 -pad 10 
     1028    foreach item {min min max max} \ 
     1029            format {3   2   3   2} \ 
     1030            axis   {x   y   x   y} { 
     1031        set val [$box ${axis}axis cget -${item}] 
     1032        set graph(${axis}${item}) {(auto)} 
     1033        catch {set graph(${axis}${item}) [format %.${format}f $val]} 
     1034    } 
     1035    bind .zoom <Return> "SetManualZoom set" 
     1036} 
     1037 
     1038proc SetManualZoom {mode} { 
     1039    global graph box 
     1040    if {$mode == "clear"} { 
     1041        foreach item {xmin ymin xmax ymax} { 
     1042            set graph($item) {(auto)} 
     1043        } 
     1044    } 
     1045    foreach item {xmin ymin xmax ymax} { 
     1046        if {[catch {expr $graph($item)}]} { 
     1047            set $item "" 
     1048        } else { 
     1049            set $item $graph($item) 
     1050        } 
     1051    } 
     1052    # reset the zoomstack 
     1053    catch {Blt_ZoomStack $box} 
     1054    catch {$box xaxis config -min $xmin -max $xmax} 
     1055    catch {$box yaxis config -min $ymin -max $ymax} 
     1056    #global program 
     1057    #if {$program == "bkgedit"} {bkgEditMode ""} 
     1058} 
     1059 
    9841060#------------------------------------------------------------------------- 
    9851061# export current plot to Grace 
     
    12421318        -variable graph(plotunits) \ 
    12431319        -command "plotdata $box" 
     1320.a.options.menu add radiobutton -label "delta-d/d" -value deltad \ 
     1321        -variable graph(plotunits) \ 
     1322        -command "plotdata $box" 
    12441323.a.options.menu add checkbutton -label "Include legend" \ 
    12451324        -variable graph(legend) \ 
     
    12741353#---------------------------------------------------------------- 
    12751354 
    1276     trace variable newmenu(opt) w setoptmsg 
     1355trace variable newmenu(opt) w setoptmsg 
     1356 
     1357bind . <Key-z> {BLTmanualZoom} 
     1358bind . <Key-Z> {BLTmanualZoom} 
    12771359 
    12781360proc setoptmsg {args} { 
Note: See TracChangeset for help on using the changeset viewer.