source: trunk/orient.tcl @ 282

Last change on this file since 282 was 240, checked in by toby, 13 years ago

# on 2000/07/20 22:13:40, toby did:
move MDprefinfo into readexp.tcl

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