Changeset 30


Ignore:
Timestamp:
Dec 4, 2009 4:59:12 PM (11 years ago)
Author:
toby
Message:

# on 1999/01/20 19:29:10, toby did:
use custom file open box
allow for a new .EXP file to be opened from a dialog
add filesort option
add phase select to readnewexp
fix bug in SetupExtractHist? for empty .EXP files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expgui

    • Property rcs:date changed from 1999/01/13 05:02:47 to 1999/01/20 19:29:10
    • Property rcs:lines changed from +59 -37 to +46 -28
    • Property rcs:rev changed from 1.7 to 1.8
    r28 r30  
    44# to do:
    55#
    6 # new file menu box w/sort by that allows for new .EXP names
     6# need to change heading and button label depending on where getExpFileName
     7# is called from
     8#
     9# fixup documentation and you are done!
    710#
    811# global background editing & profile work differently: should both
     
    2831
    2932if {$argv != ""} {
    30     set expgui(expfile) [lindex $argv 0]
     33    set expgui(expfile) $argv
    3134    if {[string toupper [file extension $expgui(expfile)]] != ".EXP"} {
    3235        append expgui(expfile) ".EXP"
    3336    }
    3437} else {
    35     # windows needs this update or focus gets screwed up after tk_getOpenFile
    36     update
    37     set expgui(expfile) [tk_getOpenFile -defaultextension .EXP \
    38         -filetypes {{"GSAS Experiment" ".EXP"}} -parent .]
    39 }
    40 if {$expgui(expfile) == ""} exit
     38    set expgui(expfile) {}
     39}
    4140
    4241set expgui(debug) 0
     
    5958set liveplot(hst) 1
    6059set liveplot(legend) 1
     60set expgui(filesort) 1
    6161
    6262#=============================================================================
     
    102102set expgui(gsasdir) [file dirname $expgui(scriptdir)]
    103103set expgui(gsasexe) [file join $expgui(gsasdir) exe]
    104 catch {cd [string trim [file dirname $expgui(expfile)]]}
    105104#----------------------------------------------------------------
    106105# fetch EXP file processing routines
     
    119118}
    120119#---------------------------------------------------------------------------
     120if {$expgui(expfile) != ""} {
     121    if ![file exists $expgui(expfile)] {
     122        update
     123        set ans [tk_dialog .expFileErrorMsg "File Open Error" \
     124                "File $expgui(expfile) does not exist" error 0 "Create" "Open other"]
     125        if $ans {set expgui(expfile) {}}
     126    }
     127}
     128if {$expgui(expfile) == ""} {
     129    # windows needs this update or focus gets screwed up after tk_getOpenFile
     130    update
     131    set expgui(expfile) [getExpFileName old]
     132}
     133if {$expgui(expfile) == ""} exit
     134# you've been warned this .EXP does not exist!
    121135if ![file exists $expgui(expfile)] {
    122     set ans [tk_dialog .expFileErrorMsg "File Open Error" \
    123             "File $expgui(expfile) does not exist" error 0 "Exit" "Create"]
    124     if $ans {
    125         # create an "empty" exp file
    126         createexp $expgui(expfile) \
    127                 [getstring "title for experiment $expgui(expfile)" 60 0]
    128     } else {
    129         exit
    130     }
    131 }
     136    puts "creating $expgui(expfile)"
     137    # create an "empty" exp file
     138    createexp $expgui(expfile) \
     139            [getstring "title for experiment $expgui(expfile)" 60 0]
     140}
     141catch {cd [string trim [file dirname $expgui(expfile)]]}
    132142
    133143#
     
    235245proc SaveAsFile {} {
    236246    global expgui
    237     set newexpfile [tk_getSaveFile -defaultextension .EXP \
    238         -filetypes {{"GSAS Experiment" ".EXP"}} -parent . \
    239         -initialdir [file dirname $expgui(expfile)] \
    240         -initialfile [file tail $expgui(expfile)] ]
     247    set newexpfile [getExpFileName new]
    241248    if {$newexpfile == ""} return
    242249    set expgui(expfile) $newexpfile
     
    254261# called to read a different .EXP file
    255262proc readnewexp {} {
    256     global expgui
     263    global expgui expmap
    257264    if $expgui(changed) {
    258265        set decision [tk_dialog .instrSaveData {Save .EXP changes} \
     
    265272        }
    266273    }
    267     set newexpfile [tk_getOpenFile -defaultextension .EXP \
    268         -filetypes {{"GSAS Experiment" ".EXP"}} -parent . \
    269         -initialdir [file dirname $expgui(expfile)] ]
     274    set newexpfile [getExpFileName old]
    270275    if {$newexpfile == ""} return
    271276    set expgui(expfile) $newexpfile
    272277    catch {cd [string trim [file dirname $expgui(expfile)]]}
    273278    loadexp $expgui(expfile)
     279
     280    # select the 1st phase
     281    SelectOnePhase [lindex $expmap(phaselist) 0]
     282    # select the first histogram in the list by default (if there are any)
     283    if {[llength $expmap(histlistboxcontents)] > 0} {set expgui(curhist) 0}
     284    if !$expgui(havetix) {
     285        RaisePage lsFrame
     286    } else {
     287        .n raise lsPane
     288        set expgui(pagenow) lsFrame
     289    }
    274290}
    275291
     
    344360    puts $fp "set expgui(asorttype) $expgui(asorttype)"
    345361    puts $fp "set expgui(hsorttype) $expgui(hsorttype)"
     362    puts $fp "set expgui(filesort) $expgui(filesort)"
    346363    if {$tcl_platform(platform) != "windows"} {
    347364        puts $fp "set env(GSASBACKSPACE) $env(GSASBACKSPACE)"
     
    17471764    set histlist {}
    17481765    foreach item $expgui(curhist) {
    1749         lappend histlist [lindex $expmap(powderlist) $item]
     1766        set hist [lindex $expmap(powderlist) $item]
     1767        if {$hist != ""} {lappend histlist $hist}
    17501768    }
    17511769    set entrycmd(fobsextract) "histinfo [list $histlist] foextract"
    1752     if {[llength $histlist] == 0} {
     1770    if {[llength $histlist] == 0 || [string trim $histlist] == ""} {
    17531771        foreach phase {1 2 3 4 5 6 7 8 9} {
    17541772            $expgui(lsFrame).f1.a.l$phase config -fg grey
Note: See TracChangeset for help on using the changeset viewer.