[195] | 1 | # $Revision: 636 $ $Date: 2009-12-04 23:09:29 +0000 (Fri, 04 Dec 2009) $ |
---|
| 2 | # Pamela Whitfield & Brian Toby |
---|
[240] | 3 | # a GUI for March-Dollase preferred orientation |
---|
[195] | 4 | |
---|
| 5 | proc MakeOrientPane {} { |
---|
| 6 | global expgui expmap |
---|
[416] | 7 | pack [frame $expgui(orientFrame).hs -class HistList] \ |
---|
| 8 | -side left -expand y -fill both |
---|
[230] | 9 | MakeHistBox $expgui(orientFrame).hs |
---|
[195] | 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 | } |
---|
[230] | 21 | |
---|
[195] | 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 |
---|
| 56 | proc DisplayOrient {} { |
---|
[305] | 57 | global expgui entrycmd entryvar entrybox expmap |
---|
[195] | 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 { |
---|
[200] | 96 | foreach phase $expmap(phaselist_$hist) { |
---|
| 97 | grid [frame $pOrientf1.sp$row -bd 8 -bg white] \ |
---|
[195] | 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 | } |
---|
[200] | 105 | grid [label $pOrientf1.l1$row -text $lbl] \ |
---|
[195] | 106 | -column 0 -row [incr row] -sticky nws |
---|
| 107 | set naxis [hapinfo $hist $phase POnaxis] |
---|
| 108 | set col 0 |
---|
[636] | 109 | foreach var {h k l} lbl {u v w} { |
---|
| 110 | grid [label $pOrientf1.l${var}$row -text $lbl \ |
---|
[195] | 111 | -anchor center] \ |
---|
| 112 | -column [incr col] -row $row -sticky ews |
---|
| 113 | } |
---|
[200] | 114 | grid [label $pOrientf1.lrat$row -text "Ratio" -anchor center] \ |
---|
[195] | 115 | -column 10 -row $row -sticky ews |
---|
| 116 | if {$naxis > 1} { |
---|
[200] | 117 | grid [label $pOrientf1.lfrac$row -text "Fraction" \ |
---|
[195] | 118 | -anchor center] \ |
---|
| 119 | -column 13 -row $row -sticky ews |
---|
| 120 | } |
---|
[200] | 121 | grid [label $pOrientf1.ld$row -text "Damping"] \ |
---|
[195] | 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 |
---|
[200] | 139 | grid [label $pOrientf1.axis$row -text "axis $axis"\ |
---|
[195] | 140 | -anchor center ] \ |
---|
| 141 | -column [incr col] -row $row |
---|
| 142 | set col 0 |
---|
| 143 | # Axis |
---|
| 144 | foreach var {h k l} { |
---|
[200] | 145 | grid [entry $pOrientf1.e${var}$row \ |
---|
[195] | 146 | -textvariable entryvar(${var}$phax) -width 4] \ |
---|
| 147 | -column [incr col] -row $row |
---|
[305] | 148 | set entrybox(${var}$phax) $pOrientf1.e${var}$row |
---|
[195] | 149 | } |
---|
| 150 | # Ratio |
---|
[200] | 151 | grid [entry $pOrientf1.erat$row \ |
---|
[195] | 152 | -textvariable entryvar(ratio$phax) -width 10] \ |
---|
| 153 | -column 10 -row $row -sticky e |
---|
[305] | 154 | set entrybox(ratio$phax) $pOrientf1.erat$row |
---|
[195] | 155 | # ratio refine |
---|
[200] | 156 | grid [checkbutton $pOrientf1.ratref$row \ |
---|
[195] | 157 | -variable entryvar(ratioref$phax)] \ |
---|
| 158 | -column 11 -row $row -sticky w |
---|
| 159 | if {$naxis > 1} { |
---|
| 160 | # Fraction |
---|
[200] | 161 | grid [entry $pOrientf1.efrac$row \ |
---|
[195] | 162 | -textvariable entryvar(fraction$phax) -width 10] \ |
---|
| 163 | -column 13 -row $row -sticky e |
---|
[305] | 164 | set entrybox(fraction$phax) $pOrientf1.efrac$row |
---|
[195] | 165 | # fraction refine |
---|
[200] | 166 | grid [checkbutton $pOrientf1.fracref$row \ |
---|
[195] | 167 | -variable entryvar(fracref$phax)] \ |
---|
| 168 | -column 14 -row $row -sticky w |
---|
| 169 | } |
---|
| 170 | #damp |
---|
[200] | 171 | tk_optionMenu $pOrientf1.opd$row \ |
---|
[195] | 172 | entryvar(damp$phax) \ |
---|
| 173 | 0 1 2 3 4 5 6 7 8 9 |
---|
[200] | 174 | grid $pOrientf1.opd$row \ |
---|
[195] | 175 | -column 15 -row $row -sticky e |
---|
| 176 | } |
---|
[200] | 177 | grid [button $pOrientf1.add$row -text "Add axis" \ |
---|
[195] | 178 | -command "AddNewPOaxis $hist $phase"] \ |
---|
| 179 | -column 0 -columnspan 4 -row [incr row] -sticky nws |
---|
| 180 | |
---|
| 181 | } |
---|
| 182 | } |
---|
[200] | 183 | grid [frame $pOrientf1.sp$row -bd 8 -bg white] \ |
---|
[195] | 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 | |
---|
| 203 | proc 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 | } |
---|