Changeset 1166 for trunk/expgui


Ignore:
Timestamp:
Aug 17, 2011 6:17:04 PM (9 years ago)
Author:
toby
Message:

bring sandbox changes over to main release

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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#}
Note: See TracChangeset for help on using the changeset viewer.