[195] | 1 | # $Revision: 930 $ $Date: 2009-12-04 23:14:35 +0000 (Fri, 04 Dec 2009) $ |
---|
| 2 | # Pamela Whitfield & Brian Toby |
---|
[240] | 3 | # a GUI for March-Dollase preferred orientation |
---|
[840] | 4 | # revised labeling as per egbert.keller@krist.uni-freiburg.de (msg of 12/13/02) |
---|
[195] | 5 | |
---|
| 6 | proc MakeOrientPane {} { |
---|
| 7 | global expgui expmap |
---|
[416] | 8 | pack [frame $expgui(orientFrame).hs -class HistList] \ |
---|
| 9 | -side left -expand y -fill both |
---|
[230] | 10 | MakeHistBox $expgui(orientFrame).hs |
---|
[195] | 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 | } |
---|
[230] | 22 | |
---|
[195] | 23 | # Create a frame on the right side |
---|
[824] | 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 | |
---|
[195] | 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 |
---|
| 53 | proc DisplayOrient {} { |
---|
[305] | 54 | global expgui entrycmd entryvar entrybox expmap |
---|
[195] | 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 { |
---|
[200] | 93 | foreach phase $expmap(phaselist_$hist) { |
---|
| 94 | grid [frame $pOrientf1.sp$row -bd 8 -bg white] \ |
---|
[195] | 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 | } |
---|
[200] | 102 | grid [label $pOrientf1.l1$row -text $lbl] \ |
---|
[195] | 103 | -column 0 -row [incr row] -sticky nws |
---|
| 104 | set naxis [hapinfo $hist $phase POnaxis] |
---|
| 105 | set col 0 |
---|
[840] | 106 | foreach var {h k l} lbl {h k l} { |
---|
[636] | 107 | grid [label $pOrientf1.l${var}$row -text $lbl \ |
---|
[195] | 108 | -anchor center] \ |
---|
| 109 | -column [incr col] -row $row -sticky ews |
---|
| 110 | } |
---|
[200] | 111 | grid [label $pOrientf1.lrat$row -text "Ratio" -anchor center] \ |
---|
[195] | 112 | -column 10 -row $row -sticky ews |
---|
| 113 | if {$naxis > 1} { |
---|
[200] | 114 | grid [label $pOrientf1.lfrac$row -text "Fraction" \ |
---|
[195] | 115 | -anchor center] \ |
---|
| 116 | -column 13 -row $row -sticky ews |
---|
| 117 | } |
---|
[200] | 118 | grid [label $pOrientf1.ld$row -text "Damping"] \ |
---|
[195] | 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 |
---|
[840] | 136 | grid [label $pOrientf1.axis$row -text "Plane $axis"\ |
---|
[195] | 137 | -anchor center ] \ |
---|
| 138 | -column [incr col] -row $row |
---|
| 139 | set col 0 |
---|
| 140 | # Axis |
---|
| 141 | foreach var {h k l} { |
---|
[200] | 142 | grid [entry $pOrientf1.e${var}$row \ |
---|
[195] | 143 | -textvariable entryvar(${var}$phax) -width 4] \ |
---|
| 144 | -column [incr col] -row $row |
---|
[305] | 145 | set entrybox(${var}$phax) $pOrientf1.e${var}$row |
---|
[195] | 146 | } |
---|
| 147 | # Ratio |
---|
[200] | 148 | grid [entry $pOrientf1.erat$row \ |
---|
[195] | 149 | -textvariable entryvar(ratio$phax) -width 10] \ |
---|
| 150 | -column 10 -row $row -sticky e |
---|
[305] | 151 | set entrybox(ratio$phax) $pOrientf1.erat$row |
---|
[195] | 152 | # ratio refine |
---|
[200] | 153 | grid [checkbutton $pOrientf1.ratref$row \ |
---|
[195] | 154 | -variable entryvar(ratioref$phax)] \ |
---|
| 155 | -column 11 -row $row -sticky w |
---|
| 156 | if {$naxis > 1} { |
---|
| 157 | # Fraction |
---|
[200] | 158 | grid [entry $pOrientf1.efrac$row \ |
---|
[195] | 159 | -textvariable entryvar(fraction$phax) -width 10] \ |
---|
| 160 | -column 13 -row $row -sticky e |
---|
[305] | 161 | set entrybox(fraction$phax) $pOrientf1.efrac$row |
---|
[195] | 162 | # fraction refine |
---|
[200] | 163 | grid [checkbutton $pOrientf1.fracref$row \ |
---|
[195] | 164 | -variable entryvar(fracref$phax)] \ |
---|
| 165 | -column 14 -row $row -sticky w |
---|
| 166 | } |
---|
| 167 | #damp |
---|
[200] | 168 | tk_optionMenu $pOrientf1.opd$row \ |
---|
[195] | 169 | entryvar(damp$phax) \ |
---|
| 170 | 0 1 2 3 4 5 6 7 8 9 |
---|
[200] | 171 | grid $pOrientf1.opd$row \ |
---|
[195] | 172 | -column 15 -row $row -sticky e |
---|
| 173 | } |
---|
[840] | 174 | grid [button $pOrientf1.add$row -text "Add plane" \ |
---|
[195] | 175 | -command "AddNewPOaxis $hist $phase"] \ |
---|
| 176 | -column 0 -columnspan 4 -row [incr row] -sticky nws |
---|
| 177 | |
---|
| 178 | } |
---|
| 179 | } |
---|
[200] | 180 | grid [frame $pOrientf1.sp$row -bd 8 -bg white] \ |
---|
[195] | 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 | |
---|
| 200 | proc 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 |
---|
[916] | 206 | RecordMacroEntry "MDprefinfo $hist $phase $nextaxis new set" 0 |
---|
[195] | 207 | hapinfo $hist $phase POnaxis set $nextaxis |
---|
[916] | 208 | RecordMacroEntry "hapinfo $hist $phase POnaxis set $nextaxis" 0 |
---|
[195] | 209 | incr expgui(changed) |
---|
[916] | 210 | RecordMacroEntry "incr expgui(changed)" 0 |
---|
[195] | 211 | DisplayOrient |
---|
| 212 | } |
---|