1 | if {[llength $argv] != 1} { |
---|
2 | wm withdraw . |
---|
3 | tk_dialog .err {Wrong Args} \ |
---|
4 | "$argv0: argument should be a .EXP file name" \ |
---|
5 | error 0 Continue |
---|
6 | exit |
---|
7 | } |
---|
8 | set expgui(font) 14 |
---|
9 | set expgui(debug) 0 |
---|
10 | |
---|
11 | pack [label .l -text "Reading $argv\nPlease wait"] |
---|
12 | update |
---|
13 | wm protocol . WM_DELETE_WINDOW {puts ""; exit} |
---|
14 | #============================================================================= |
---|
15 | #---------------------------------------------------------------- |
---|
16 | # where are we? |
---|
17 | set expgui(script) [info script] |
---|
18 | # translate links -- go six levels deep |
---|
19 | foreach i {1 2 3 4 5 6} { |
---|
20 | if {[file type $expgui(script)] == "link"} { |
---|
21 | set link [file readlink $expgui(script)] |
---|
22 | if { [file pathtype $link] == "absolute" } { |
---|
23 | set expgui(script) $link |
---|
24 | } { |
---|
25 | set expgui(script) [file dirname $expgui(script)]/$link |
---|
26 | } |
---|
27 | } else { |
---|
28 | break |
---|
29 | } |
---|
30 | } |
---|
31 | # fixup relative paths |
---|
32 | if {[file pathtype $expgui(script)] == "relative"} { |
---|
33 | set expgui(script) [file join [pwd] $expgui(script)] |
---|
34 | } |
---|
35 | set expgui(scriptdir) [file dirname $expgui(script) ] |
---|
36 | #---------------------------------------------------------------- |
---|
37 | source [file join $expgui(scriptdir) opts.tcl] |
---|
38 | # fetch EXP file processing routines |
---|
39 | source [file join $expgui(scriptdir) readexp.tcl] |
---|
40 | # commands for running GSAS programs |
---|
41 | #source [file join $expgui(scriptdir) gsascmds.tcl] |
---|
42 | # override options with locally defined values |
---|
43 | if [file exists [file join $expgui(scriptdir) localconfig]] { |
---|
44 | source [file join $expgui(scriptdir) localconfig] |
---|
45 | } |
---|
46 | if [file exists [file join ~ .gsas_config]] { |
---|
47 | source [file join ~ .gsas_config] |
---|
48 | } |
---|
49 | SetTkDefaultOptions $expgui(font) |
---|
50 | |
---|
51 | if {![file exists $argv]} { |
---|
52 | # read error |
---|
53 | wm withdraw . |
---|
54 | tk_dialog .err {Bad file} \ |
---|
55 | "$argv0: error\nfile $argv not found" \ |
---|
56 | error 0 Continue |
---|
57 | exit |
---|
58 | } |
---|
59 | set fmt [expload $argv] |
---|
60 | if {$fmt < 0} { |
---|
61 | # read error |
---|
62 | wm withdraw . |
---|
63 | tk_dialog .err {Bad file} \ |
---|
64 | "$argv0: error reading $argv\nThis is not a valid GSAS .EXP file" \ |
---|
65 | error 0 Continue |
---|
66 | exit |
---|
67 | } |
---|
68 | mapexp |
---|
69 | if {[llength $expmap(phaselist)] == 0} { |
---|
70 | # read error |
---|
71 | wm withdraw . |
---|
72 | tk_dialog .err {Bad file} \ |
---|
73 | "$argv0: error reading $argv\nNo phases found" \ |
---|
74 | error 0 Continue |
---|
75 | exit |
---|
76 | } |
---|
77 | if {[llength $expmap(phaselist)] > 1} { |
---|
78 | # need to select a phase |
---|
79 | .l config -text "Select a phase" |
---|
80 | foreach p $expmap(phaselist) { |
---|
81 | set n [phaseinfo $p name] |
---|
82 | pack [radiobutton .p$p -text "Phase $p: $n" -variable phase \ |
---|
83 | -value $p] -anchor w |
---|
84 | } |
---|
85 | wm withdraw . |
---|
86 | update idletasks |
---|
87 | set x [expr {[winfo screenwidth .]/2 - [winfo reqwidth .]/2}] |
---|
88 | set y [expr {[winfo screenheight .]/2 - [winfo reqheight .]/2}] |
---|
89 | wm geom . +$x+$y |
---|
90 | wm deiconify . |
---|
91 | grab . |
---|
92 | focus . |
---|
93 | tkwait variable phase |
---|
94 | } else { |
---|
95 | set phase $expmap(phaselist) |
---|
96 | } |
---|
97 | foreach v {a b c alpha beta gamma} { |
---|
98 | lappend l [phaseinfo $phase $v] |
---|
99 | } |
---|
100 | set l1 {} |
---|
101 | foreach a $expmap(atomlist_$phase) { |
---|
102 | set l2 {} |
---|
103 | foreach p {label x y z type frac} { |
---|
104 | lappend l2 [atominfo $phase $a $p] |
---|
105 | } |
---|
106 | if {[atominfo $phase $a temptype] == "I"} { |
---|
107 | lappend l2 [atominfo $phase $a Uiso] |
---|
108 | } else { |
---|
109 | set ueq {} |
---|
110 | catch { |
---|
111 | set ueq [expr { |
---|
112 | ([atominfo $phase $a U11] + |
---|
113 | [atominfo $phase $a U22] + |
---|
114 | [atominfo $phase $a U33]) /3. |
---|
115 | }] |
---|
116 | } |
---|
117 | lappend l2 $ueq |
---|
118 | # } |
---|
119 | lappend l1 $l2 |
---|
120 | } |
---|
121 | puts [list [phaseinfo $phase spacegroup] $l $l1] |
---|
122 | exit |
---|