source: trunk/orient.tcl @ 481

Last change on this file since 481 was 416, checked in by toby, 13 years ago

# on 2001/09/04 22:06:05, toby did:
adjustable fonts

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