source: trunk/orient.tcl

Last change on this file was 1251, checked in by toby, 9 years ago

use svn ps svn:eol-style "native" * to change line ends

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Revision Id
File size: 7.1 KB
Line 
1# $Revision: 1251 $ $Date: 2014-03-10 22:17:29 +0000 (Mon, 10 Mar 2014) $
2# Pamela Whitfield & Brian Toby
3# a GUI for March-Dollase preferred orientation
4# revised labeling as per egbert.keller@krist.uni-freiburg.de (msg of 12/13/02)
5
6proc MakeOrientPane {} {
7    global expgui expmap
8    pack [frame $expgui(orientFrame).hs -class HistList] \
9            -side left -expand y -fill both
10    MakeHistBox $expgui(orientFrame).hs
11    bind $expgui(orientFrame).hs.lbox <ButtonRelease-1> {
12        set expgui(curhist) [$expgui(orientFrame).hs.lbox curselection]
13        DisplayOrient
14    }
15    bind $expgui(orientFrame).hs.lbox <Button-3>  {
16        if $expgui(globalmode) {
17            $expgui(orientFrame).hs.lbox selection set 0 end
18            set expgui(curhist) [$expgui(orientFrame).hs.lbox curselection]
19            DisplayOrient
20        }
21    }
22
23    # Create a frame on the right side
24    pack [TitleFrame $expgui(orientFrame).f1 -bd 4 \
25              -text "March-Dollase Preferential Orientation" \
26              -relief groove] -fill both -expand true
27    set PrefOrientBox [$expgui(orientFrame).f1 getframe]
28
29    grid columnconfigure $PrefOrientBox 0 -weight 1
30    grid rowconfigure $PrefOrientBox 1 -weight 1
31    # Create canvas with a frame inside for scrolling
32    grid [set expgui(OrientBox) [canvas $PrefOrientBox.orientBox \
33            -scrollregion {0 0 5000 500} \
34            -yscrollcommand "$PrefOrientBox.yscroll set" \
35            -width 500 -height 350 -bg lightgrey]] \
36            -sticky news -row 1 -column 0
37    set expgui(OrientScroll) [scrollbar $PrefOrientBox.yscroll \
38            -command "$expgui(OrientBox) yview" \
39            -orient vertical]
40    # control the griding of the scrollbar in DisplayOrient
41    #grid $PrefOrientBox.yscroll -sticky ns -row 1 -column 1
42    frame $expgui(OrientBox).f -bd 0   
43    $expgui(OrientBox) create window 0 0 -anchor nw \
44            -window $expgui(OrientBox).f
45
46    # insert the histograms & resize in case the pane needs more space
47    sethistlist
48#    ResizeNotebook
49}
50
51# this is used to update the contents of the PO page when histogram(s)
52# are selected
53proc DisplayOrient {} {
54    global expgui entrycmd entryvar entrybox expmap
55       
56    # identify the frame and kill the old contents
57    set pOrientf1 $expgui(OrientBox).f
58    eval destroy [winfo children $pOrientf1]
59    grid columnconfig $pOrientf1 0 -weight 1
60    grid columnconfig $pOrientf1 15 -weight 1
61    grid columnconfig $pOrientf1 9 -min 10
62    grid columnconfig $pOrientf1 12 -min 10
63    # trap if more than one histogram is selected unless global mode
64    if {$expgui(globalmode) == 0 && [llength $expgui(curhist)] > 1} {
65        set expgui(curhist) [lindex $expgui(curhist) 0]
66    }
67
68    # display the selected histograms
69    $expgui(orientFrame).hs.lbox selection clear 0 end
70    foreach h $expgui(curhist) {
71        $expgui(orientFrame).hs.lbox selection set $h
72    }
73
74    #disable traces on entryvar
75    set entrycmd(trace) 0
76    trace vdelete entryvar w entvartrace
77   
78    #display selected histograms
79    $expgui(orientFrame).hs.lbox selection clear 0 end
80    foreach hist $expgui(curhist) {
81        $expgui(orientFrame).hs.lbox selection set $hist
82    }
83
84    #get histogram list by histogram number
85    set histlist {}
86    foreach item $expgui(curhist) {
87        lappend histlist [lindex $expmap(powderlist) $item]
88    }
89
90    # loop over histograms and phases
91    set row -1
92    foreach hist $histlist {
93        foreach phase $expmap(phaselist_$hist) {
94            grid [frame $pOrientf1.sp$row -bd 8 -bg white] \
95                -columnspan 20 -column 0 -row [incr row] -sticky nsew
96            # add extra label here when more than one histogram is selected
97            if {[llength $histlist] > 1} {
98                set lbl "Histogram $hist\nPhase $phase"
99            } else {
100                set lbl "Phase $phase"
101            }
102            grid [label $pOrientf1.l1$row -text $lbl] \
103                    -column 0 -row [incr row] -sticky nws
104            set naxis [hapinfo $hist $phase POnaxis]
105            set col 0
106            foreach var {h k l} lbl {h k l} {
107                grid [label $pOrientf1.l${var}$row -text $lbl \
108                        -anchor center] \
109                        -column [incr col] -row $row -sticky ews
110            }
111            grid [label $pOrientf1.lrat$row -text "Ratio" -anchor center] \
112                    -column 10 -row $row -sticky ews
113            if {$naxis > 1} {
114                grid [label $pOrientf1.lfrac$row -text "Fraction" \
115                        -anchor center] \
116                        -column 13 -row $row -sticky ews
117            }
118            grid [label $pOrientf1.ld$row -text "Damping"] \
119                    -column 15 -row $row -sticky es
120            for {set axis 1} {$axis <= $naxis} {incr axis} {
121                set phax ${phase}_$axis
122                # define variables needed
123                foreach var {ratio fraction ratioref fracref damp type} {
124                    set entrycmd(${var}$phax) \
125                            "MDprefinfo $hist $phase $axis $var"
126                    set entryvar(${var}$phax) [eval $entrycmd(${var}$phax)]
127                }
128                foreach var {h k l} {
129                    set entrycmd(${var}$phax) \
130                            "MDprefinfo $hist $phase $axis $var"
131                    set entryvar(${var}$phax) \
132                            [format %.2f [eval $entrycmd(${var}$phax)]]
133                }
134                incr row
135                set col -1
136                grid [label $pOrientf1.axis$row -text "Plane $axis"\
137                        -anchor center ] \
138                        -column [incr col] -row $row
139                set col 0
140                # Axis
141                foreach var {h k l} {
142                    grid [entry $pOrientf1.e${var}$row \
143                            -textvariable entryvar(${var}$phax) -width 4] \
144                            -column [incr col] -row $row
145                    set entrybox(${var}$phax) $pOrientf1.e${var}$row
146                }
147                # Ratio
148                grid [entry $pOrientf1.erat$row \
149                        -textvariable entryvar(ratio$phax) -width 10] \
150                        -column 10 -row $row -sticky e
151                set entrybox(ratio$phax) $pOrientf1.erat$row
152                # ratio refine
153                grid [checkbutton $pOrientf1.ratref$row \
154                        -variable entryvar(ratioref$phax)] \
155                        -column 11 -row $row -sticky w
156                if {$naxis > 1} {
157                    # Fraction
158                    grid [entry $pOrientf1.efrac$row \
159                            -textvariable entryvar(fraction$phax) -width 10] \
160                            -column 13 -row $row -sticky e
161                    set entrybox(fraction$phax) $pOrientf1.efrac$row
162                    # fraction refine
163                    grid [checkbutton $pOrientf1.fracref$row \
164                            -variable entryvar(fracref$phax)] \
165                            -column 14 -row $row -sticky w
166                }
167                #damp
168                tk_optionMenu $pOrientf1.opd$row \
169                        entryvar(damp$phax) \
170                        0 1 2 3 4 5 6 7 8 9
171                grid $pOrientf1.opd$row \
172                        -column 15 -row $row -sticky e
173            }
174            grid [button $pOrientf1.add$row -text "Add plane" \
175                    -command "AddNewPOaxis $hist $phase"] \
176                    -column 0 -columnspan 4 -row [incr row] -sticky nws
177
178        }
179    }
180    grid [frame $pOrientf1.sp$row -bd 8 -bg white] \
181            -columnspan 20 -column 0 -row [incr row] -sticky nsew
182
183    # resize the scroll area
184    update
185    set sizes [grid bbox $pOrientf1]
186    $expgui(OrientBox) config -scrollregion $sizes -width [lindex $sizes 2]
187    # use the scroll for BIG lists
188    if {[lindex $sizes 3] > [winfo height $expgui(OrientBox)]} {
189        grid $expgui(OrientScroll) -sticky ns -column 1 -row 1
190    } else {
191        grid forget $expgui(OrientScroll)
192    }
193    update
194    #enable traces on entryvar now
195    set entrycmd(trace) 1
196    trace variable entryvar w entvartrace
197    ResizeNotebook
198}
199
200proc AddNewPOaxis {hist phase} {
201    global expgui
202    set nextaxis [hapinfo $hist $phase POnaxis]
203    incr nextaxis
204    if {$nextaxis > 9} return
205    MDprefinfo $hist $phase $nextaxis new set
206    RecordMacroEntry "MDprefinfo $hist $phase $nextaxis new set" 0
207    hapinfo $hist $phase POnaxis set $nextaxis
208    RecordMacroEntry "hapinfo $hist $phase POnaxis set $nextaxis" 0
209    incr expgui(changed)
210    RecordMacroEntry "incr expgui(changed)" 0
211    DisplayOrient
212}
Note: See TracBrowser for help on using the repository browser.