source: trunk/orient.tcl @ 824

Last change on this file since 824 was 824, checked in by toby, 14 years ago

# on 2004/10/04 16:21:09, toby did:
remove non-BWidget code

  • Property rcs:author set to toby
  • Property rcs:date set to 2004/10/04 16:21:09
  • Property rcs:lines set to +6 -10
  • Property rcs:rev set to 1.8
  • Property rcs:state set to Exp
  • Property svn:keywords set to Author Date Revision Id
File size: 6.8 KB
Line 
1# $Revision: 824 $ $Date: 2009-12-04 23:12:40 +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    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
28    grid columnconfigure $PrefOrientBox 0 -weight 1
29    grid rowconfigure $PrefOrientBox 1 -weight 1
30    # Create canvas with a frame inside for scrolling
31    grid [set expgui(OrientBox) [canvas $PrefOrientBox.orientBox \
32            -scrollregion {0 0 5000 500} \
33            -yscrollcommand "$PrefOrientBox.yscroll set" \
34            -width 500 -height 350 -bg lightgrey]] \
35            -sticky news -row 1 -column 0
36    set expgui(OrientScroll) [scrollbar $PrefOrientBox.yscroll \
37            -command "$expgui(OrientBox) yview" \
38            -orient vertical]
39    # control the griding of the scrollbar in DisplayOrient
40    #grid $PrefOrientBox.yscroll -sticky ns -row 1 -column 1
41    frame $expgui(OrientBox).f -bd 0   
42    $expgui(OrientBox) create window 0 0 -anchor nw \
43            -window $expgui(OrientBox).f
44
45    # insert the histograms & resize in case the pane needs more space
46    sethistlist
47#    ResizeNotebook
48}
49
50# this is used to update the contents of the PO page when histogram(s)
51# are selected
52proc DisplayOrient {} {
53    global expgui entrycmd entryvar entrybox expmap
54       
55    # identify the frame and kill the old contents
56    set pOrientf1 $expgui(OrientBox).f
57    eval destroy [winfo children $pOrientf1]
58    grid columnconfig $pOrientf1 0 -weight 1
59    grid columnconfig $pOrientf1 15 -weight 1
60    grid columnconfig $pOrientf1 9 -min 10
61    grid columnconfig $pOrientf1 12 -min 10
62    # trap if more than one histogram is selected unless global mode
63    if {$expgui(globalmode) == 0 && [llength $expgui(curhist)] > 1} {
64        set expgui(curhist) [lindex $expgui(curhist) 0]
65    }
66
67    # display the selected histograms
68    $expgui(orientFrame).hs.lbox selection clear 0 end
69    foreach h $expgui(curhist) {
70        $expgui(orientFrame).hs.lbox selection set $h
71    }
72
73    #disable traces on entryvar
74    set entrycmd(trace) 0
75    trace vdelete entryvar w entvartrace
76   
77    #display selected histograms
78    $expgui(orientFrame).hs.lbox selection clear 0 end
79    foreach hist $expgui(curhist) {
80        $expgui(orientFrame).hs.lbox selection set $hist
81    }
82
83    #get histogram list by histogram number
84    set histlist {}
85    foreach item $expgui(curhist) {
86        lappend histlist [lindex $expmap(powderlist) $item]
87    }
88
89    # loop over histograms and phases
90    set row -1
91    foreach hist $histlist {
92        foreach phase $expmap(phaselist_$hist) {
93            grid [frame $pOrientf1.sp$row -bd 8 -bg white] \
94                -columnspan 20 -column 0 -row [incr row] -sticky nsew
95            # add extra label here when more than one histogram is selected
96            if {[llength $histlist] > 1} {
97                set lbl "Histogram $hist\nPhase $phase"
98            } else {
99                set lbl "Phase $phase"
100            }
101            grid [label $pOrientf1.l1$row -text $lbl] \
102                    -column 0 -row [incr row] -sticky nws
103            set naxis [hapinfo $hist $phase POnaxis]
104            set col 0
105            foreach var {h k l} lbl {u v w} {
106                grid [label $pOrientf1.l${var}$row -text $lbl \
107                        -anchor center] \
108                        -column [incr col] -row $row -sticky ews
109            }
110            grid [label $pOrientf1.lrat$row -text "Ratio" -anchor center] \
111                    -column 10 -row $row -sticky ews
112            if {$naxis > 1} {
113                grid [label $pOrientf1.lfrac$row -text "Fraction" \
114                        -anchor center] \
115                        -column 13 -row $row -sticky ews
116            }
117            grid [label $pOrientf1.ld$row -text "Damping"] \
118                    -column 15 -row $row -sticky es
119            for {set axis 1} {$axis <= $naxis} {incr axis} {
120                set phax ${phase}_$axis
121                # define variables needed
122                foreach var {ratio fraction ratioref fracref damp type} {
123                    set entrycmd(${var}$phax) \
124                            "MDprefinfo $hist $phase $axis $var"
125                    set entryvar(${var}$phax) [eval $entrycmd(${var}$phax)]
126                }
127                foreach var {h k l} {
128                    set entrycmd(${var}$phax) \
129                            "MDprefinfo $hist $phase $axis $var"
130                    set entryvar(${var}$phax) \
131                            [format %.2f [eval $entrycmd(${var}$phax)]]
132                }
133                incr row
134                set col -1
135                grid [label $pOrientf1.axis$row -text "axis $axis"\
136                        -anchor center ] \
137                        -column [incr col] -row $row
138                set col 0
139                # Axis
140                foreach var {h k l} {
141                    grid [entry $pOrientf1.e${var}$row \
142                            -textvariable entryvar(${var}$phax) -width 4] \
143                            -column [incr col] -row $row
144                    set entrybox(${var}$phax) $pOrientf1.e${var}$row
145                }
146                # Ratio
147                grid [entry $pOrientf1.erat$row \
148                        -textvariable entryvar(ratio$phax) -width 10] \
149                        -column 10 -row $row -sticky e
150                set entrybox(ratio$phax) $pOrientf1.erat$row
151                # ratio refine
152                grid [checkbutton $pOrientf1.ratref$row \
153                        -variable entryvar(ratioref$phax)] \
154                        -column 11 -row $row -sticky w
155                if {$naxis > 1} {
156                    # Fraction
157                    grid [entry $pOrientf1.efrac$row \
158                            -textvariable entryvar(fraction$phax) -width 10] \
159                            -column 13 -row $row -sticky e
160                    set entrybox(fraction$phax) $pOrientf1.efrac$row
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.