Ignore:
Timestamp:
Nov 22, 2010 5:02:57 PM (10 years ago)
Author:
toby
Message:

fix bug on replace atoms; clean up loading/creation of exp files; add revert menu command; initial draft of rigid body support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/expgui

    r1021 r1036  
    326326            file copy -force $expgui(expfile) $expnam.EXP
    327327            set expgui(expfile) $expnam.EXP
     328            wm title . "EXPGUI interface to GSAS: [file tail $expgui(expfile)]"
     329            set expgui(titleunchanged) 1
    328330        } else {
    329331            MyMessageBox -parent . -title "File not found" \
     
    333335        }
    334336    } else {
    335         SetEXPfile $expgui(expfile)
     337        set expgui(expfile) [SetEXPfile $expgui(expfile)]
    336338    }
    337339}
     
    348350    # I am not sure it is still needed.
    349351    update
    350     SetEXPfile [getExpFileName ""]
     352    set expgui(expfile) [SetEXPfile [getExpFileName ""]]
    351353    set expgui(resize) 1
    352354}
     
    360362proc loadexp {expfile} {
    361363    global expgui expmap entryvar entrycmd tcl_platform
    362     set prevexp $expgui(expfile)
    363     # is this a compressed archive file?
    364     if {[string match {*.O[0-9A-F][0-9A-F]} $expfile]} {
    365         set expnam [file rootname $expfile]
    366         set ans [MyMessageBox -parent . -title "Load Archived File" \
    367                 -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?" \
    368                 -icon question -type "{Use New Name} {Continue with current}" \
    369                 -default {Use New Name} \
    370                 -helplink "expguierr.html LoadArchived"
    371         ]
    372         # archive the current .EXP file
    373         if {$ans != "use new name" && [file exists $expfile]} {
    374             # get the last archived version
    375             set lastf [lindex [lsort [glob -nocomplain $expnam.{O\[0-9A-F\]\[0-9A-F\]}]] end]
    376             if {$lastf == ""} {
    377                 set num 01
    378             } else {
    379                 regexp {.*\.O([0-9A-F][0-9A-F])$} $lastf a num
    380                 scan $num %x num
    381                 if {$num >= 255} {
    382                     set num FF
    383                 } else {
    384                     set num [string toupper [format %.2x [incr num]]]
    385                 }
    386             }
    387             catch {
    388                 set newfile $expnam.O$num
    389                 file rename -force $expnam.EXP $newfile
    390                 set fp [open $expnam.LST a+]
    391                 puts $fp "\n----------------------------------------------"
    392                 puts $fp "     Regressing to archive file [file tail $expfile]"
    393                 puts $fp "     but first archiving [file tail $expnam.EXP] as [file tail $newfile]"
    394                 puts $fp "----------------------------------------------\n"
    395                 close $fp
    396             }
    397             file copy -force $expfile $expnam.EXP
    398             set expfile $expnam.EXP
    399         }
    400         if {$ans == "use new name"} {
    401             set newexpfile [getExpFileName new]
    402             if {$newexpfile == ""} return
    403             file copy -force $expfile $newexpfile
    404             catch {cd [string trim [file dirname $expgui(expfile)]]}
    405             set expfile [file tail $newexpfile]
    406             set expgui(needpowpref) 2
    407             set expgui(needpowpref_why) "\tA new .EXP file was created\n"
    408             SetEXPfile $newexpfile
    409         } else {
    410             SetEXPfile $expfile
    411         }
    412         if {$expgui(expfile) == ""} {
    413             set expgui(expfile) $prevexp
    414             return
    415         }
    416     }
    417 
     364    set expfile [SetEXPfile $expfile]
     365    if {$expfile == ""} {
     366        return
     367    }
    418368    # change the icon and assign an app to this .EXP file
    419369    if {$tcl_platform(os) == "Darwin" && $expgui(MacAssignApp)} {
    420370        MacSetResourceFork $expfile
    421371    }
    422 
    423     SetEXPfile $expfile
    424     if {$expgui(expfile) == ""} {
    425         set expgui(expfile) $prevexp
    426         return
    427     }
    428372    # read in the .EXP file
    429373    set fmt [expload $expfile]
     374    set expgui(expfile) $expfile
    430375    # if the file was not in the correct format, force a rewrite before use
    431376    if {$fmt < 0} {
     
    452397    set expgui(last_History) [string range [string trim [lindex [exphistory last] 1]] 0 50 ]
    453398    # set the window/icon title
    454     wm title . "EXPGUI interface to GSAS: $expfile"
     399    wm title . "EXPGUI interface to GSAS: [file tail $expgui(expfile)]"
    455400    set expgui(titleunchanged) 1
    456401    wm iconname . [file tail $expfile]
     
    462407    afterawhile
    463408}
     409
    464410
    465411# [re]load all screens with current state of EXPGUI file
     
    546492    global expgui
    547493    global tcl_platform
    548     set prevexp $expgui(expfile)
    549     set newexpfile [getExpFileName new]
    550     if {$newexpfile == ""} return
    551     SetEXPfile $newexpfile 1
    552     if {$expgui(expfile) == ""} {
    553         set expgui(expfile) $prevexp
    554         return
    555     }
     494    set $newexpfile [SetEXPfile [getExpFileName new] 1]
     495    if {$newexpfile == ""} return
    556496    expwrite $newexpfile
    557497    # change the icon and assign an app to this .EXP file
     
    573513
    574514# called to read a different .EXP file
    575 proc readnewexp {} {
     515proc readnewexp {"mode 0"} {
    576516    global expgui expmap
    577517    if $expgui(changed) {
     
    585525        }
    586526    }
    587     set prevexp $expgui(expfile)
    588     set newexpfile [getExpFileName old]
    589     if {$newexpfile == ""} return
    590     SetEXPfile $newexpfile
    591     if {$expgui(expfile) == ""} {
    592         set expgui(expfile) $prevexp
    593         return
    594     }
     527    if {$mode == 0} {
     528        set newexpfile [getExpFileName old]
     529    } else {
     530        set newexpfile [RevertExpFile]
     531    }
     532    if {$newexpfile == ""} return
    595533
    596534    # switch to the 1st page
    597535    RaisePage lsFrame
    598536    set expgui(globalmode) 0
    599     loadexp $expgui(expfile)
     537    loadexp $newexpfile
    600538
    601539    # reset the phase selection
Note: See TracChangeset for help on using the changeset viewer.