- Timestamp:
- Aug 26, 2012 6:51:47 PM (11 years ago)
- Location:
- branches/sandbox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sandbox/chemrest.tcl
r1215 r1220 293 293 # show a box as yellow, if an invalid number is entered 294 294 proc ChemUpdateRow {var index mode} { 295 if $::expcons(DisableChemWeightsTrace) return 295 296 set num $index 296 if $::expcons(DisableChemWeightsTrace) return297 297 set weight [string trim $::ChemWeights($num)] 298 298 set box $::expcons(ChemConstBox) … … 363 363 } 364 364 365 foreach item [trace vinfo ChemWeights] { 366 eval trace vdelete ChemWeights $item 367 } 368 trace variable ChemWeights w ChemUpdateRow 369 365 set ::ChemWeights(0) "" 366 foreach item [trace vinfo ::ChemWeights] { 367 eval trace vdelete ::ChemWeights $item 368 } 369 trace variable ::ChemWeights w ChemUpdateRow 370 371 set ::expcons(ChemSum) "" 372 set ::expcons(ChemSumESD) "" 370 373 foreach item [trace vinfo expcons(ChemSum)] { 371 374 eval trace vdelete expcons(ChemSum) $item -
branches/sandbox/expgui
r1215 r1220 767 767 # utility export routines for the export_*.tcl files: 768 768 # make a box for export 769 proc MakeExportBox {win title webref } {769 proc MakeExportBox {win title webref {bookmark ""}} { 770 770 global expmap expgui 771 771 catch {destroy $win} … … 783 783 } 784 784 # leave a place for format-specific items 785 pack [frame $win.special] -side top 786 pack [frame $win.but] -side top -fill x -expand yes785 pack [frame $win.special] -side top -fill both -expand yes 786 pack [frame $win.but] -side top -fill x -expand no 787 787 pack [button $win.but.1 -text Write -command "destroy $win"] -side left 788 788 SetExportPhase [lindex $expmap(phaselist) 0] $win … … 790 790 -command "set expgui(export_phase) 0;destroy $win"] -side left 791 791 pack [button $win.but.help -text Help -bg yellow \ 792 -command "MakeWWWHelp expgui.html ExportMSI"] \792 -command "MakeWWWHelp expgui.html $bookmark"] \ 793 793 -side right 794 794 } -
branches/sandbox/export_drawxtl.tcl
r1215 r1220 6 6 set action export_drawxtl 7 7 set ::DXTLcolorlist "White Red Green Blue Yellow Cyan Magenta Black Orange Brown Grey Silver White" 8 set ::DXTL(bonds) 0 9 set ::DXTL(coords) 1 10 set ::DXTL(blackarrow) Green 11 set ::DXTL(redarrow) Red 12 foreach a {X Y Z} { 13 set ::DXTL(${a}dispMin) 0.0 14 set ::DXTL(${a}dispMax) 1.0 15 } 16 set ::DXTL(mtype) "" 17 set ::DXTL(mfil) "" 18 set ::DXTL(FourierRange) "" 19 8 20 proc export_drawxtl {} { 9 21 global expmap expgui … … 15 27 return 16 28 } 17 foreach t [trace vinfo expgui(export_phase)] {18 eval trace vdelete expgui(export_phase) $t19 } 20 29 foreach t [trace vinfo ::expgui(export_phase)] { 30 eval trace vdelete ::expgui(export_phase) $t 31 } 32 MakeExportBox .export "Export coordinates to program DRAWXTL" "" 21 33 # "MakeWWWHelp expgui.html export" 22 34 … … 24 36 wm protocol .export WM_DELETE_WINDOW {set expgui(export_phase) 0; destroy .export } 25 37 set bx .export.special 26 global DXTL27 if {[info global DXTL] == ""} {28 set DXTL(bonds) 029 set DXTL(coords) 130 set DXTL(blackarrow) Green31 set DXTL(redarrow) Red32 }33 38 set row 1 34 39 grid [label $bx.1 -text "Title:"] -column 1 -row $row -sticky e 35 grid [entry $bx.2 -textvariable DXTL(title) -width 40] \40 grid [entry $bx.2 -textvariable ::DXTL(title) -width 40] \ 36 41 -row $row -column 2 -columnspan 5 -sticky w 37 set DXTL(title) [expinfo title]42 set ::DXTL(title) [expinfo title] 38 43 incr row 39 44 grid [checkbutton $bx.3 -text "Include coordinates in .str file" \ 40 -variable DXTL(coords)] \45 -variable ::DXTL(coords)] \ 41 46 -row $row -column 1 -columnspan 5 -sticky w 42 47 incr row 43 set DXTL(arrowbox) $bx.448 set ::DXTL(arrowbox) $bx.4 44 49 grid [checkbutton $bx.4 -text "Display arrows for magnetic atoms" \ 45 -variable DXTL(genarrows) -state disabled] \50 -variable ::DXTL(genarrows) -state disabled] \ 46 51 -row $row -column 1 -columnspan 5 -sticky w 47 52 incr row 48 set DXTL(arrowcolorbox) $bx.4a49 set DXTL(arrowcolorbox_row) $row50 grid [frame $bx.4a] -sticky ew -row $ DXTL(arrowcolorbox_row) \53 set ::DXTL(arrowcolorbox) $bx.4a 54 set ::DXTL(arrowcolorbox_row) $row 55 grid [frame $bx.4a] -sticky ew -row $::DXTL(arrowcolorbox_row) \ 51 56 -column 1 -columnspan 5 52 57 grid [label $bx.4a.h -text "Arrow colors: "] -column 0 -row 1 -sticky w 53 58 grid [label $bx.4a.bll -text " generated by Black operator "] -column 0 -row 2 54 eval tk_optionMenu $bx.4a.bl DXTL(blackarrow) $::DXTLcolorlist59 eval tk_optionMenu $bx.4a.bl ::DXTL(blackarrow) $::DXTLcolorlist 55 60 grid $bx.4a.bl -column 2 -row 2 56 61 grid [label $bx.4a.redl -text " generated by Red operator "] -column 0 -row 3 57 eval tk_optionMenu $bx.4a.red DXTL(redarrow) $::DXTLcolorlist62 eval tk_optionMenu $bx.4a.red ::DXTL(redarrow) $::DXTLcolorlist 58 63 grid $bx.4a.red -column 2 -row 3 59 64 incr row … … 72 77 if {$app != ""} { 73 78 set show normal 74 set DXTL(app) $appname75 set DXTL(launch) 179 set ::DXTL(app) $appname 80 set ::DXTL(launch) 1 76 81 } else { 77 82 set show disabled 78 set DXTL(launch) 083 set ::DXTL(launch) 0 79 84 } 80 85 grid [checkbutton $bx.l -text "Launch DRAWxtl" \ 81 -variable DXTL(launch) -state $show] \86 -variable ::DXTL(launch) -state $show] \ 82 87 -row $row -column 1 -columnspan 5 -sticky w 83 88 incr row … … 88 93 incr row 89 94 grid [label $bx.c.${v}1 -text "${V} min:"] -column 1 -row $row 90 grid [entry $bx.c.${v}2 -textvariable DXTL(${v}min) -width 4] -column 2 -row $row91 grid [scale $bx.c.${v}3 -resolution 0.1 -variable DXTL(${v}min) \95 grid [entry $bx.c.${v}2 -textvariable ::DXTL(${v}min) -width 4] -column 2 -row $row 96 grid [scale $bx.c.${v}3 -resolution 0.1 -variable ::DXTL(${v}min) \ 92 97 -showvalue 0 -orient h -from -2 -to 1] -column 3 -row $row 93 set DXTL(${v}min) -0.198 set ::DXTL(${v}min) -0.1 94 99 grid [label $bx.c.${v}4 -text " max:"] -column 4 -row $row 95 grid [entry $bx.c.${v}5 -textvariable DXTL(${v}max) -width 4] -column 5 -row $row96 grid [scale $bx.c.${v}6 -resolution 0.1 -variable DXTL(${v}max) \100 grid [entry $bx.c.${v}5 -textvariable ::DXTL(${v}max) -width 4] -column 5 -row $row 101 grid [scale $bx.c.${v}6 -resolution 0.1 -variable ::DXTL(${v}max) \ 97 102 -showvalue 0 -orient h -from 0 -to 3] -column 6 -row $row 98 set DXTL(${v}max) 1.1103 set ::DXTL(${v}max) 1.1 99 104 } 100 105 # atom type box 101 106 grid [frame $bx.s -relief groove -bd 4] -row $row -column 0 -columnspan 5 -sticky nsew 107 grid rowconfigure $bx $row -weight 1 102 108 grid [label $bx.s.0 -text "Atom representation" \ 103 109 -anchor w] -row 0 -column 0 -sticky w … … 106 112 -yscrollcommand "$bx.s.scroll set" ] \ 107 113 -column 0 -row [incr row] -sticky nsew 114 grid rowconfigure $bx.s $row -weight 1 108 115 grid columnconfig $bx.s 0 -weight 1 109 frame [set DXTL(lb) $bx.s.canvas.fr]110 $bx.s.canvas create window 0 0 -anchor nw -window $ DXTL(lb)116 frame [set ::DXTL(lb) $bx.s.canvas.fr] 117 $bx.s.canvas create window 0 0 -anchor nw -window $::DXTL(lb) 111 118 grid [scrollbar $bx.s.scroll \ 112 119 -command "$bx.s.canvas yview"] -sticky ns -row $row -column 1 … … 114 121 incr row 115 122 grid [frame $bx.b -relief groove -bd 4] -row $row -column 0 -columnspan 5 -sticky ew 123 grid rowconfigure $bx $row -weight 1 116 124 grid [frame $bx.b.0] -row 0 -column 0 -columnspan 7 -sticky ew 117 125 grid [label $bx.b.0.1 -text "Bond List" \ … … 124 132 -yscrollcommand "$bx.b.scroll set" ] \ 125 133 -column 0 -row [incr row] -sticky nsew 134 grid rowconfigure $bx.b $row -weight 1 126 135 grid columnconfig $bx.b 0 -weight 1 127 frame [set DXTL(Blst) $bx.b.canvas.fr]128 $bx.b.canvas create window 0 0 -anchor nw -window $ DXTL(Blst)136 frame [set ::DXTL(Blst) $bx.b.canvas.fr] 137 $bx.b.canvas create window 0 0 -anchor nw -window $::DXTL(Blst) 129 138 grid [scrollbar $bx.b.scroll \ 130 139 -command "$bx.b.canvas yview"] -sticky ns -row $row -column 1 … … 132 141 incr row 133 142 grid [frame $bx.f -relief groove -bd 4] -row $row -column 0 -columnspan 5 -sticky nsew 134 grid [label $bx.f.0 -text "Fourier display" \ 143 grid [frame $bx.f.0] -column 0 -columnspan 3 -row 0 -sticky news 144 grid columnconfig $bx.f.0 0 -weight 1 145 grid [label $bx.f.0.l1 -text "Fourier display" \ 135 146 -anchor w] -row 0 -column 0 -sticky w 136 grid [frame $bx.f.1] -column 0 -row 1 -sticky news 137 grid [frame $bx.f.2] -column 0 -row 2 -sticky news 147 set ::DXTL(FourierRange) "Range: unknown" 148 grid [label $bx.f.0.l2 -textvariable ::DXTL(FourierRange) \ 149 -anchor w] -row 0 -column 1 -sticky e 150 grid [frame $bx.f.1] -column 0 -columnspan 3 -row 1 -sticky news 151 grid [frame $bx.f.2] -column 0 -columnspan 3 -row 2 -sticky news 138 152 grid [canvas $bx.f.canvas -relief sunk -bd 2 \ 139 153 -scrollregion {0 0 5000 500} -width 250 -height 70 \ 140 154 -yscrollcommand "$bx.f.scroll set" ] \ 141 155 -column 0 -row 3 -sticky nsew 156 grid rowconfigure $bx $row -weight 1 157 grid rowconfigure $bx.f 3 -weight 1 142 158 grid columnconfig $bx.f 0 -weight 1 143 frame [set DXTL(fb) $bx.f.canvas.fr]144 $bx.f.canvas create window 0 0 -anchor nw -window $ DXTL(fb)159 frame [set ::DXTL(fb) $bx.f.canvas.fr] 160 $bx.f.canvas create window 0 0 -anchor nw -window $::DXTL(fb) 145 161 grid [scrollbar $bx.f.scroll \ 146 -command "$bx.f.canvas yview"] -sticky ns -row 3 -column 1162 -command "$bx.f.canvas yview"] -sticky ns -row 3 -column 2 147 163 grid [button $bx.f.1.1 -text "Setup\nFourier" \ 148 164 -command EditFourier] -column 0 -row 0 149 grid [button [set DXTL(FourCompute) $bx.f.1.2] -text "Compute\nFourier" \165 grid [button [set ::DXTL(FourCompute) $bx.f.1.2] -text "Compute\nFourier" \ 150 166 -command {DXTLwritegrd $expgui(export_phase)}] -column 1 -row 0 151 167 grid [label $bx.f.1.3 -text "Select\nMap"] -column 3 -row 0 152 set DXTL(fmenu) [tk_optionMenu $bx.f.1.4DXTL(mtype) test]168 set ::DXTL(fmenu) [tk_optionMenu $bx.f.1.4 ::DXTL(mtype) test] 153 169 grid $bx.f.1.4 -column 4 -row 0 154 grid [button [set DXTL(AddContour) $bx.f.1.5] -text "Add\nContour" \170 grid [button [set ::DXTL(AddContour) $bx.f.1.5] -text "Add\nContour" \ 155 171 -command AddContour] -column 5 -row 0 156 SetupFourierButtons 157 return 172 grid [frame $bx.f.1.f] -column 0 -columnspan 9 -row 1 173 grid [label $bx.f.1.f.0 -text "display\nlimits"] -column 0 -row 0 174 set col 0 175 foreach a {X Y Z} { 176 incr col 177 grid [label $bx.f.1.f.$col -text $a] -column $col -row 0 178 incr col 179 grid [entry $bx.f.1.f.$col -textvariable ::DXTL(${a}dispMin) \ 180 -width 6] -column $col -row 0 181 incr col 182 grid [entry $bx.f.1.f.$col -textvariable ::DXTL(${a}dispMax) \ 183 -width 6] -column $col -row 0 184 } 185 set ::DXTL(contours) 0 186 trace variable ::expgui(export_phase) w OnNewFourierPhase 187 OnNewFourierPhase 188 #SetupFourierButtons 189 #return 190 # this appears to be needed by OSX 191 ResizeWin .export 158 192 # force the window to stay on top 159 193 putontop .export 160 trace variable expgui(export_phase) w "SetDXTLatoms;SetupFourierButtons"161 194 SetDXTLatoms 162 # this appears to be needed by OSX163 ResizeWin .export164 195 165 196 # Wait for the Write or Quit button to be pressed … … 187 218 # title info from GSAS title & phase title 188 219 puts $fp "REM created by EXPGUI from $expgui(expfile) on [clock format [clock seconds]]" 189 puts $fp "title \"$ DXTL(title)\""190 puts $fp "pack $ DXTL(xmin) $DXTL(xmax) $DXTL(ymin) $DXTL(ymax) $DXTL(zmin) $DXTL(zmax)"220 puts $fp "title \"$::DXTL(title)\"" 221 puts $fp "pack $::DXTL(xmin) $::DXTL(xmax) $::DXTL(ymin) $::DXTL(ymax) $::DXTL(zmin) $::DXTL(zmax)" 191 222 puts $fp "edges 0.02 Black" 192 223 puts $fp "phong 1.0 30." 193 224 foreach type [array names typelist] { 194 if {$ DXTL(display_$type) == "sphere"} {195 puts $fp "sphere $type $ DXTL(radius_$type) $DXTL(color_$type)"196 } elseif {$ DXTL(display_$type) == "polyhedron"} {197 puts $fp "polysz $type $ DXTL(radius_$type) $DXTL(color_$type)"198 } elseif {$ DXTL(display_$type) == "ellipsoid"} {199 puts $fp "ellipcolor $type * $ DXTL(color_$type)"225 if {$::DXTL(display_$type) == "sphere"} { 226 puts $fp "sphere $type $::DXTL(radius_$type) $::DXTL(color_$type)" 227 } elseif {$::DXTL(display_$type) == "polyhedron"} { 228 puts $fp "polysz $type $::DXTL(radius_$type) $::DXTL(color_$type)" 229 } elseif {$::DXTL(display_$type) == "ellipsoid"} { 230 puts $fp "ellipcolor $type * $::DXTL(color_$type)" 200 231 } 201 232 } 202 if {$ DXTL(coords)} {233 if {$::DXTL(coords)} { 203 234 # write out cell parameters 204 235 puts -nonewline $fp "cell" … … 230 261 puts $fp "import gsas [file tail $expgui(expfile)] $phase" 231 262 } 232 for {set i 1} {$i <= $ DXTL(bonds)} {incr i} {233 puts $fp "bond $ DXTL(ba_$i) $DXTL(bb_$i) $DXTL(bw_$i) $DXTL(bmin_$i) $DXTL(bmax_$i) $DXTL(bc_$i)"263 for {set i 1} {$i <= $::DXTL(bonds)} {incr i} { 264 puts $fp "bond $::DXTL(ba_$i) $::DXTL(bb_$i) $::DXTL(bw_$i) $::DXTL(bmin_$i) $::DXTL(bmax_$i) $::DXTL(bc_$i)" 234 265 } 235 266 # list arrows, when requested 236 267 if {[lindex $expmap(phasetype) [expr {$phase - 1}]] != 1 && \ 237 $ DXTL(genarrows)} {268 $::DXTL(genarrows)} { 238 269 DXTLwriteArrows $fp $phase 239 270 } 240 DXTLwriteFourierCommands 271 DXTLwriteFourierCommands $fp 241 272 puts $fp "END" 242 273 close $fp 243 if {$ DXTL(launch)} {244 exec $ DXTL(app) $filnam &274 if {$::DXTL(launch)} { 275 exec $::DXTL(app) $filnam & 245 276 } 246 277 } errmsg] { … … 251 282 -message "File [file tail $filnam] was written" 252 283 } 253 catch {unset DXTL}284 #catch {unset DXTL} 254 285 foreach t [trace vinfo expgui(export_phase)] { 255 286 eval trace vdelete expgui(export_phase) $t … … 272 303 # add atoms to atom representation list 273 304 proc SetDXTLatoms {args} { 274 global DXTLexpgui expmap275 eval destroy [winfo children $ DXTL(lb)]276 eval destroy [winfo children $ DXTL(Blst)]277 set DXTL(bonds) 0305 global expgui expmap 306 eval destroy [winfo children $::DXTL(lb)] 307 eval destroy [winfo children $::DXTL(Blst)] 308 set ::DXTL(bonds) 0 278 309 if {$expgui(export_phase) == 0} {return} 279 310 set phase $expgui(export_phase) … … 285 316 } 286 317 if {[lindex $expmap(phasetype) [expr {$phase - 1}]] == 1} { 287 set DXTL(genarrows) 0288 $ DXTL(arrowbox) configure -state disabled289 grid forget $ DXTL(arrowcolorbox)318 set ::DXTL(genarrows) 0 319 $::DXTL(arrowbox) configure -state disabled 320 grid forget $::DXTL(arrowcolorbox) 290 321 } else { 291 set DXTL(genarrows) 1292 $ DXTL(arrowbox) configure -state normal293 grid $ DXTL(arrowcolorbox) -sticky ew -row $DXTL(arrowcolorbox_row) \322 set ::DXTL(genarrows) 1 323 $::DXTL(arrowbox) configure -state normal 324 grid $::DXTL(arrowcolorbox) -sticky ew -row $::DXTL(arrowcolorbox_row) \ 294 325 -column 1 -columnspan 5 295 326 } 296 327 catch {unset typelist} 297 set DXTL(title) [phaseinfo $phase name]328 set ::DXTL(title) [phaseinfo $phase name] 298 329 foreach atom $expmap(atomlist_$phase) { 299 330 set typelist([atominfo $phase $atom type]) 1 300 331 } 301 set DXTL(typelist) [array names typelist]332 set ::DXTL(typelist) [array names typelist] 302 333 set row 0 303 grid [label $ DXTL(lb).l$row -text "type " -bg yellow\334 grid [label $::DXTL(lb).l$row -text "type " -bg yellow\ 304 335 ] -column 0 -row $row -sticky ew 305 grid [label $ DXTL(lb).d$row -text " representation " -bg yellow336 grid [label $::DXTL(lb).d$row -text " representation " -bg yellow 306 337 ] -column 1 -row $row -sticky ew 307 grid [label $ DXTL(lb).e$row -text " radius " -bg yellow\338 grid [label $::DXTL(lb).e$row -text " radius " -bg yellow\ 308 339 ] -column 2 -row $row -sticky ew 309 grid [label $ DXTL(lb).c$row -text " color " -bg yellow\340 grid [label $::DXTL(lb).c$row -text " color " -bg yellow\ 310 341 ] -column 3 -row $row -sticky ew 311 342 foreach type [array names typelist] { 312 343 incr row 313 grid [label $ DXTL(lb).l$row -text $type] -column 0 -row $row314 tk_optionMenu $ DXTL(lb).d$rowDXTL(display_$type) sphere polyhedron ellipsoid none315 grid $ DXTL(lb).d$row -column 1 -row $row316 grid [entry $ DXTL(lb).e$row -textvariableDXTL(radius_$type) \344 grid [label $::DXTL(lb).l$row -text $type] -column 0 -row $row 345 tk_optionMenu $::DXTL(lb).d$row ::DXTL(display_$type) sphere polyhedron ellipsoid none 346 grid $::DXTL(lb).d$row -column 1 -row $row 347 grid [entry $::DXTL(lb).e$row -textvariable ::DXTL(radius_$type) \ 317 348 -width 5] -column 2 -row $row 318 eval tk_optionMenu $DXTL(lb).c$row DXTL(color_$type) $::DXTLcolorlist 319 grid $DXTL(lb).c$row -column 3 -row $row 320 set DXTL(display_$type) sphere 321 set DXTL(radius_$type) 0.2 322 set DXTL(color_$type) [lindex $::DXTLcolorlist $row] 323 } 349 eval tk_optionMenu $::DXTL(lb).c$row ::DXTL(color_$type) $::DXTLcolorlist 350 grid $::DXTL(lb).c$row -column 3 -row $row 351 set ::DXTL(display_$type) sphere 352 set ::DXTL(radius_$type) 0.2 353 set ::DXTL(color_$type) [lindex $::DXTLcolorlist $row] 354 } 355 # Resize the list 356 update idletasks 357 foreach i {lb Blst fb} { 358 set sizes [grid bbox $::DXTL($i)] 359 [winfo parent $::DXTL($i)] config -scrollregion $sizes \ 360 -width [lindex $sizes 2] 361 } 362 wm geom [winfo toplevel $::DXTL(Blst)] {} 363 } 364 365 # add bonds to bond list 366 proc DXTLaddBond {} { 367 if {$::DXTL(bonds) == 0} { 368 # insert header 369 set row 0 370 grid [label $::DXTL(Blst).a$row -text "from " -bg yellow\ 371 ] -column 1 -row $row -sticky ew 372 grid [label $::DXTL(Blst).b$row -text " to " -bg yellow\ 373 ] -column 2 -row $row -sticky ew 374 grid [label $::DXTL(Blst).c$row -text " width " -bg yellow\ 375 ] -column 3 -row $row -sticky ew 376 grid [label $::DXTL(Blst).d$row -text " min " -bg yellow\ 377 ] -column 4 -row $row -sticky ew 378 grid [label $::DXTL(Blst).e$row -text " max " -bg yellow\ 379 ] -column 5 -row $row -sticky ew 380 grid [label $::DXTL(Blst).f$row -text " color " -bg yellow\ 381 ] -column 6 -row $row -sticky ew 382 } 383 set row [incr ::DXTL(bonds)] 384 eval tk_optionMenu $::DXTL(Blst).ta$row ::DXTL(ba_$row) $::DXTL(typelist) 385 grid $::DXTL(Blst).ta$row -column 1 -row $row 386 eval tk_optionMenu $::DXTL(Blst).tb$row ::DXTL(bb_$row) $::DXTL(typelist) 387 grid $::DXTL(Blst).tb$row -column 2 -row $row 388 grid [entry $::DXTL(Blst).w$row -textvariable ::DXTL(bw_$row) \ 389 -width 5] -column 3 -row $row 390 grid [entry $::DXTL(Blst).mi$row -textvariable ::DXTL(bmin_$row) \ 391 -width 5] -column 4 -row $row 392 grid [entry $::DXTL(Blst).mx$row -textvariable ::DXTL(bmax_$row) \ 393 -width 5] -column 5 -row $row 394 eval tk_optionMenu $::DXTL(Blst).c$row ::DXTL(bc_$row) $::DXTLcolorlist 395 grid $::DXTL(Blst).c$row -column 6 -row $row 396 set ::DXTL(bw_$row) 0.02 397 set ::DXTL(bmin_$row) 1.0 398 set ::DXTL(bmax_$row) 2.0 399 set ::DXTL(bc_$row) [lindex $::DXTLcolorlist $row] 324 400 # Resize the list 325 401 update 326 set sizes [grid bbox $ DXTL(lb)]327 [winfo parent $ DXTL(lb)] config -scrollregion $sizes \402 set sizes [grid bbox $::DXTL(Blst)] 403 [winfo parent $::DXTL(Blst)] config -scrollregion $sizes \ 328 404 -width [lindex $sizes 2] 329 set sizes [grid bbox $DXTL(Blst)] 330 [winfo parent $DXTL(Blst)] config -scrollregion $sizes \ 331 -width [lindex $sizes 2] 332 wm geom [winfo toplevel $DXTL(Blst)] {} 333 } 334 335 # add bonds to bond list 336 proc DXTLaddBond {} { 337 global DXTL 338 if {$DXTL(bonds) == 0} { 339 # insert header 340 set row 0 341 grid [label $DXTL(Blst).a$row -text "from " -bg yellow\ 342 ] -column 1 -row $row -sticky ew 343 grid [label $DXTL(Blst).b$row -text " to " -bg yellow\ 344 ] -column 2 -row $row -sticky ew 345 grid [label $DXTL(Blst).c$row -text " width " -bg yellow\ 346 ] -column 3 -row $row -sticky ew 347 grid [label $DXTL(Blst).d$row -text " min " -bg yellow\ 348 ] -column 4 -row $row -sticky ew 349 grid [label $DXTL(Blst).e$row -text " max " -bg yellow\ 350 ] -column 5 -row $row -sticky ew 351 grid [label $DXTL(Blst).f$row -text " color " -bg yellow\ 352 ] -column 6 -row $row -sticky ew 353 } 354 set row [incr DXTL(bonds)] 355 eval tk_optionMenu $DXTL(Blst).ta$row DXTL(ba_$row) $DXTL(typelist) 356 grid $DXTL(Blst).ta$row -column 1 -row $row 357 eval tk_optionMenu $DXTL(Blst).tb$row DXTL(bb_$row) $DXTL(typelist) 358 grid $DXTL(Blst).tb$row -column 2 -row $row 359 grid [entry $DXTL(Blst).w$row -textvariable DXTL(bw_$row) \ 360 -width 5] -column 3 -row $row 361 grid [entry $DXTL(Blst).mi$row -textvariable DXTL(bmin_$row) \ 362 -width 5] -column 4 -row $row 363 grid [entry $DXTL(Blst).mx$row -textvariable DXTL(bmax_$row) \ 364 -width 5] -column 5 -row $row 365 eval tk_optionMenu $DXTL(Blst).c$row DXTL(bc_$row) $::DXTLcolorlist 366 grid $DXTL(Blst).c$row -column 6 -row $row 367 set DXTL(bw_$row) 0.02 368 set DXTL(bmin_$row) 1.0 369 set DXTL(bmax_$row) 2.0 370 set DXTL(bc_$row) [lindex $::DXTLcolorlist $row] 371 # Resize the list 372 update 373 set sizes [grid bbox $DXTL(Blst)] 374 [winfo parent $DXTL(Blst)] config -scrollregion $sizes \ 375 -width [lindex $sizes 2] 405 #set can [winfo parent $::DXTL($i)] 406 #set scroll [winfo parent $can].scroll 407 #[winfo parent $::DXTL($i)] config -scrollregion $sizes 376 408 } 377 409 378 410 proc DXTLwriteArrows {out phase} { 379 global expgui expmap DXTL411 global expgui expmap 380 412 set fp [open geom.in w] 381 413 puts $fp "N" … … 423 455 puts $out "rem spin for atom $name # $k ($spin)" 424 456 if {$spin == "Red"} { 425 puts $out "arrow $pos $vec 1. 0.15 $ DXTL(redarrow)"457 puts $out "arrow $pos $vec 1. 0.15 $::DXTL(redarrow)" 426 458 } else { 427 puts $out "arrow $pos $vec 1. 0.15 $ DXTL(blackarrow)"459 puts $out "arrow $pos $vec 1. 0.15 $::DXTL(blackarrow)" 428 460 } 429 461 } elseif {$i == 6} { … … 440 472 # returns a list of Fourier map types 441 473 proc DXTLwritegrd {phase} { 442 global expgui expmap DXTL474 global expgui expmap 443 475 set lst [listFourier] 444 if { $lst< 1} {476 if {[llength $lst] < 1} { 445 477 MyMessageBox -parent . -title "No Fourier" \ 446 478 -message "You have not set up to compute a Fourier map." \ … … 481 513 } 482 514 set fp [open f.in w] 483 if {[ llength $typelist] > 1} {515 if {[OutputFourierType]} { 484 516 puts $fp [lindex $typelist 0] 485 517 } … … 502 534 set deleteerror 1 503 535 } 536 # Save the current exp file 537 savearchiveexp 538 # disable the file changed monitor 539 set expgui(expModifiedLast) 0 504 540 catch { 505 541 exec $fourier [file root $expgui(expfile)] >& f.out 506 542 exec $map [file root $expgui(expfile)] < f.in >>& f.out 507 543 } 544 # reset the file changed monitor 545 #loadexp $expgui(expfile) 546 set expgui(expModifiedLast) [file mtime $expgui(expfile)] 547 508 548 if {[llength [glob -nocomplain "[file root $expgui(expfile)]*.grd"]] == 0} { 509 549 set fp [open f.out r] … … 520 560 catch {close $fp} 521 561 catch {file delete -force f.in f.out} 562 SetupFourierButtons 522 563 return $typelist 523 564 } 524 565 } 525 566 567 # called when the phase # is set or changed 568 # clean up old Fourier maps 569 proc OnNewFourierPhase {args} { 570 SetDXTLatoms 571 if {[llength $::expmap(phaselist)] > 1} { 572 # there is more than one phase; delete any .grd files to make sure 573 # generate ones for the current phase 574 foreach f [glob -nocomplain "[file root $::expgui(expfile)]*.grd"] { 575 catch {file delete -force $f} 576 } 577 } 578 SetupFourierButtons 579 eval destroy [winfo children $::DXTL(fb)] 580 set ::DXTL(contours) 0 581 } 582 583 # this enables/disables Fourier buttons based on the Fourier setup 584 # and the files that are present 526 585 proc SetupFourierButtons {} { 527 586 set phase $::expgui(export_phase) … … 531 590 set ::DXTL(mtype) "" 532 591 set ::DXTL(mfil) "" 592 set ::DXTL(FourierRange) "" 533 593 # if the Fourier is not set up; return here 534 if {[listFourier] < 1} return 594 if {[llength [set nF [listFourier]]] < 1} return 595 # check that all phases are set to current phase 596 foreach i $nF { 597 set ph [Fourierinfo $i phase] 598 if {$ph != $phase} return 599 } 535 600 if {[llength [FourierHists $phase]] < 1} return 536 601 # make sure we have default limits 537 602 getFourierLimits $phase 538 603 $::DXTL(FourCompute) config -state normal 539 # if there are no maps, return here604 # if there are no maps, return now 540 605 set maps [glob -nocomplain "[file root $::expgui(expfile)]*.grd"] 541 606 if {[llength $maps] < 1} return … … 544 609 lappend types [lindex [split [file root [file tail $fil]] "_"] end] 545 610 } 546 $::DXTL(AddContour) config -state normal547 611 set i 0 548 612 foreach fil $maps lbl $types { 549 if {$i == 1} {$::DXTL(fmenu) invoke 0} 613 $::DXTL(fmenu) add command -label $lbl \ 614 -command "set DXTL(mtype) $lbl; set DXTL(mfil) $fil; GetFourierRange" 615 if {$i == 0} { 616 $::DXTL(fmenu) invoke 0 617 $::DXTL(AddContour) config -state normal 618 } 550 619 incr i 551 $::DXTL(fmenu) add command -label $lbl \552 -command "set DXTL(mtype) $lbl; set DXTL(mfil) $fil"553 620 } 554 621 } 555 622 556 623 proc EditFourier {} { 557 error 624 set phase $::expgui(export_phase) 625 # check that all Fourier records are set to the current phase 626 foreach i [listFourier] { 627 set ph [Fourierinfo $i phase] 628 if {$ph != $phase} {Fourierinfo $i phase set $phase} 629 } 630 # for now we will not offer access to section, (dmin, dmax not supported) 631 set typelist {} 632 foreach i [listFourier] { 633 lappend typelist [Fourierinfo $i type] 634 } 635 set histlist [FourierHists $phase] 636 set limits [getFourierLimits $phase] 637 set box .export.fourier 638 catch {destroy $box} 639 toplevel $box 640 grid [frame $box.1] -row 1 -column 1 -rowspan 10 641 grid [frame $box.2] -row 1 -column 2 -rowspan 10 642 grid [frame $box.b] -sticky news -row 11 -column 1 -columnspan 2 643 grid columnconfigure $box.b 0 -weight 1 644 grid columnconfigure $box.b 3 -weight 1 645 grid [button $box.b.1 -text Continue \ 646 -command "set ::DXTL(quit) 0; destroy $box" \ 647 ] -row 1 -column 1 648 grid [button $box.b.2 -text Quit \ 649 -command "set ::DXTL(quit) 1; destroy $box" \ 650 ] -row 1 -column 2 651 652 # map type selection 653 set row 0 654 grid [label $box.1.$row -text "Select map type(s)"] -column 1 -row $row 655 foreach typ {DELF FCLC FOBS 2FDF 3FDF 4FDF PTSN DPTS} lbl { 656 "Difference Fourier" "Fcalc Fourier" "Fobs Fourier" 657 "2*Fo-Fc Fourier" "3*Fo-2*Fc Fourier" "4*Fo-3*Fc Fourier" "Patterson map" "Delta-F Patterson"\ 658 } { 659 incr row 660 grid [ \ 661 checkbutton $box.1.$row -variable ::DXTL($typ) \ 662 -text "$lbl ($typ)" \ 663 ] -column 1 -row $row -sticky w 664 if {[lsearch $typelist $typ] == -1} { 665 set ::DXTL($typ) 0 666 } else { 667 set ::DXTL($typ) 1 668 } 669 } 670 grid [label $box.2.a1 -text "Histogram(s) to be used\n(last superceeds)"] -column 1 -row 1 671 grid [entry $box.2.a2 -textvariable ::DXTL(histlist) -width 20] -column 2 -row 1 -columnspan 3 672 set ::DXTL(histlist) $histlist 673 grid [label $box.2.m1 -text min] -column 2 -row 2 674 grid [label $box.2.m2 -text max] -column 3 -row 2 675 grid [label $box.2.m3 -text "map step\n(A)"] -column 4 -row 2 676 set row 3 677 foreach axis {X Y Z} lim [lrange $limits 1 end] step [lindex $limits 0] { 678 incr row 679 grid [label $box.2.0$axis -text "$axis limits"] -column 1 -row $row -sticky e 680 grid [entry $box.2.min$axis -width 10 -textvariable ::DXTL(min$axis)] -column 2 -row $row 681 grid [entry $box.2.max$axis -width 10 -textvariable ::DXTL(max$axis)] -column 3 -row $row 682 grid [entry $box.2.step$axis -width 10 -textvariable ::DXTL(step$axis)] -column 4 -row $row 683 set ::DXTL(min$axis) [lindex $lim 0] 684 set ::DXTL(max$axis) [lindex $lim 1] 685 set ::DXTL(step$axis) [format "%.4f" [expr {$step + 0.0001}]] 686 } 687 putontop $box 688 tkwait window $box 689 afterputontop 690 if $::DXTL(quit) return 691 delFourier 692 foreach typ {DELF FCLC FOBS 2FDF 3FDF 4FDF PTSN DPTS} { 693 if {$::DXTL($typ)} { 694 addFourier $phase $typ 695 } 696 } 697 FourierHists $phase set $::DXTL(histlist) 698 setFourierLimits $phase \ 699 [list $::DXTL(stepX) $::DXTL(stepY) $::DXTL(stepZ)] \ 700 [list $::DXTL(minX) $::DXTL(maxX)] \ 701 [list $::DXTL(minY) $::DXTL(maxY)] \ 702 [list $::DXTL(minZ) $::DXTL(maxZ)] 703 SetupFourierButtons 704 incr ::expgui(changed) 558 705 } 559 706 560 707 proc AddContour {} { 561 global DXTL 562 # if {$DXTL(bonds) == 0} { 563 # # insert header 564 # set row 0 565 # grid [label $DXTL(Blst).a$row -text "from " -bg yellow\ 566 # ] -column 1 -row $row -sticky ew 567 # grid [label $DXTL(Blst).b$row -text " to " -bg yellow\ 568 # ] -column 2 -row $row -sticky ew 569 # grid [label $DXTL(Blst).c$row -text " width " -bg yellow\ 570 # ] -column 3 -row $row -sticky ew 571 # grid [label $DXTL(Blst).d$row -text " min " -bg yellow\ 572 # ] -column 4 -row $row -sticky ew 573 # grid [label $DXTL(Blst).e$row -text " max " -bg yellow\ 574 # ] -column 5 -row $row -sticky ew 575 # grid [label $DXTL(Blst).f$row -text " color " -bg yellow\ 576 # ] -column 6 -row $row -sticky ew 577 # } 578 # set row [incr DXTL(bonds)] 579 # eval tk_optionMenu $DXTL(Blst).ta$row DXTL(ba_$row) $DXTL(typelist) 580 # grid $DXTL(Blst).ta$row -column 1 -row $row 581 # eval tk_optionMenu $DXTL(Blst).tb$row DXTL(bb_$row) $DXTL(typelist) 582 # grid $DXTL(Blst).tb$row -column 2 -row $row 583 # grid [entry $DXTL(Blst).w$row -textvariable DXTL(bw_$row) \ 584 # -width 5] -column 3 -row $row 585 # grid [entry $DXTL(Blst).mi$row -textvariable DXTL(bmin_$row) \ 586 # -width 5] -column 4 -row $row 587 # grid [entry $DXTL(Blst).mx$row -textvariable DXTL(bmax_$row) \ 588 # -width 5] -column 5 -row $row 589 # eval tk_optionMenu $DXTL(Blst).c$row DXTL(bc_$row) $::DXTLcolorlist 590 # grid $DXTL(Blst).c$row -column 6 -row $row 591 # set DXTL(bw_$row) 0.02 592 # set DXTL(bmin_$row) 1.0 593 # set DXTL(bmax_$row) 2.0 594 # set DXTL(bc_$row) [lindex $::DXTLcolorlist $row] 595 # # Resize the list 596 # update 597 # set sizes [grid bbox $DXTL(Blst)] 598 # [winfo parent $DXTL(Blst)] config -scrollregion $sizes \ 599 # -width [lindex $sizes 2] 600 error 601 } 602 603 proc DXTLwriteFourierCommands {} { 604 error 605 #mapread grd 10CO_DELF.grd 4 606 #mapcontour 2.000 mesh Green 607 #mapcontour 2.500 solid Blue 608 } 708 # set a header 709 if {$::DXTL(contours) == 0} { 710 set row 0 711 grid [label $::DXTL(fb).a$row -text "Type" -bg yellow \ 712 ] -column 1 -row $row -sticky ew 713 grid [label $::DXTL(fb).b$row -text "Contour Level" -bg yellow \ 714 ] -column 2 -row $row -sticky ew 715 grid [label $::DXTL(fb).c$row -text "Color" -bg yellow \ 716 -anchor center] -column 3 -row $row -sticky ew 717 } 718 set row [incr ::DXTL(contours)] 719 eval tk_optionMenu $::DXTL(fb).ta$row ::DXTL(fb_type_$row) {mesh solid} 720 grid $::DXTL(fb).ta$row -column 1 -row $row 721 grid [entry $::DXTL(fb).w$row -width 10 -textvariable ::DXTL(fb_val_$row) \ 722 ] -column 2 -row $row 723 set menu [eval tk_optionMenu $::DXTL(fb).tb$row \ 724 ::DXTL(fb_color_$row) $::DXTLcolorlist] 725 $menu invoke $row 726 grid $::DXTL(fb).tb$row -column 3 -row $row 727 grid [button $::DXTL(fb).del$row -text "Delete"\ 728 -command "DeleteFourierContour $row"] -column 4 -row $row 729 update idletasks 730 set sizes [grid bbox $::DXTL(fb)] 731 [winfo parent $::DXTL(fb)] config -scrollregion $sizes \ 732 -width [lindex $sizes 2] 733 } 734 735 proc DeleteFourierContour {row} { 736 foreach i "$::DXTL(fb).ta$row $::DXTL(fb).w$row $::DXTL(fb).tb$row \ 737 $::DXTL(fb).tb$row $::DXTL(fb).del$row" { 738 catch {destroy $i} 739 } 740 set ::DXTL(fb_val_$i) "" 741 if {$::DXTL(contours) == $row} {incr ::DXTL(contours) -1} 742 } 743 744 proc GetFourierRange {} { 745 set fp [open f.in w] 746 set lst [listFourier] 747 if {[llength $lst] < 1} { 748 MyMessageBox -parent . -title "No Fourier" \ 749 -message "You have not set up to compute a Fourier map." \ 750 -icon warning 751 return 752 } 753 set typelist {} 754 foreach l $lst { 755 lappend typelist [Fourierinfo $l type] 756 } 757 if {[OutputFourierType]} { 758 puts $fp $::DXTL(mtype) 759 } 760 close $fp 761 if {$::tcl_platform(platform) == "windows"} { 762 set map [file join $::expgui(gsasexe) forsrh.exe] 763 } else { 764 set map [file join $::expgui(gsasexe) forsrh] 765 } 766 catch { 767 exec $map [file root $::expgui(expfile)] < f.in >& f.out 768 } 769 foreach {min max} {{} {}} {} 770 catch { 771 set fp [open "f.out" r] 772 while {[gets $fp line] >= 0} { 773 if {[string first "range of map values" $line] != -1} { 774 set off [expr 4 + [string first " is " $line]] 775 foreach {min to max} [string trim [string range $line $off end]] {} 776 break 777 } 778 } 779 } 780 catch { 781 close $fp 782 } 783 if {$min != ""} {set ::DXTL(FourierRange) "Range: $min to $max"} 784 } 785 786 # is output of the current Fourier map type required as input to a program? 787 # answer is yes when more than one map file is present 788 proc OutputFourierType {} { 789 set i 0 790 foreach ext {DEL FCL FOB PTS DPT} { 791 if {[file exists [file root $::expgui(expfile)].$ext]} { 792 incr i 793 } 794 for {set i 2} {$i <= 9} {incr i} { 795 if {[file exists [file root $::expgui(expfile)].${i}FD]} { 796 incr i 797 } 798 } 799 } 800 if {$i > 1} { 801 return 1 802 } 803 return 0 804 } 805 806 proc DXTLwriteFourierCommands {fp} { 807 if {$::DXTL(mfil) == ""} return 808 if {![file exists $::DXTL(mfil)]} { 809 puts "file not found $::DXTL(mfil)" 810 return 811 } 812 set cntlist {} 813 for {set i 1} {$i <= $::DXTL(contours)} {incr i} { 814 set val "" 815 catch {set val $::DXTL(fb_val_$i)} 816 if {[catch {set val [expr 1.*$val]}]} continue 817 lappend cntlist [list $val $::DXTL(fb_type_$i) $::DXTL(fb_color_$i)] } 818 if {[llength $cntlist] <= 0} return 819 puts $fp "mapread grd [file tail $::DXTL(mfil)] 4" 820 foreach item $cntlist { 821 puts $fp "mapcontour $item" 822 } 823 set s {} 824 foreach a {X Y Z} { 825 lappend s $::DXTL(${a}dispMin) 826 lappend s $::DXTL(${a}dispMax) 827 } 828 puts $fp "mapregion $s" 829 } -
branches/sandbox/readexp.tcl
r1215 r1220 4750 4750 # read a Fourier map entry 4751 4751 # returns five values: 4752 # 0: type of map (DELF,FCLC,FOBS, NFDF,PTSN,DPTS)4752 # 0: type of map (DELF,FCLC,FOBS,*FDF,PTSN,DPTS) 4753 4753 # 1: section (X,Y or Z) 4754 4754 # 2: phase (1-9) … … 4761 4761 } 4762 4762 set vals {} 4763 # 0: type of map (DELF,FCLC,FOBS, NFDF,PTSN,DPTS)4763 # 0: type of map (DELF,FCLC,FOBS,[2-9]FDF,PTSN,DPTS) 4764 4764 lappend vals [string trim [string range [readexp $key] 2 6]] 4765 4765 # 1: section (X,Y or Z) … … 4777 4777 # arguments: 4778 4778 # phase: (1-9) 4779 # type: type of map (DELF,FCLC,FOBS, NFDF,PTSN,DPTS) - default DELF4779 # type: type of map (DELF,FCLC,FOBS,*FDF,PTSN,DPTS) - default DELF 4780 4780 # section: (X,Y or Z) - default Z 4781 4781 # returns the number of the map that is added … … 4800 4800 } 4801 4801 4802 # delete all Fourier map computations 4803 proc delFourier {} { 4804 foreach i {1 2 3 4 5 6 7 8 9} { 4805 set key " FOUR CDAT$i" 4806 delexp $key 4807 } 4808 } 4809 4802 4810 # read/set a Fourier computation value 4803 4811 # use: Fourierinfo num parm … … 4806 4814 # num is the Fourier entry 4807 4815 # parm is one of the following 4808 # type -- type of map (DELF,FCLC,FOBS, NFDF,PTSN,DPTS)4816 # type -- type of map (DELF,FCLC,FOBS,*FDF,PTSN,DPTS) 4809 4817 # section -- last running map direction (X,Y or Z) 4810 4818 # phase -- phase (1-9) … … 4819 4827 switch -glob ${parm}-$action { 4820 4828 type-get { 4821 # type of map (DELF,FCLC,FOBS, NFDF,PTSN,DPTS)4829 # type of map (DELF,FCLC,FOBS,*FDF,PTSN,DPTS) 4822 4830 return [string trim [string range [readexp $key] 2 6]] 4823 4831 } 4824 4832 type-set { 4825 4833 set found 0 4826 foreach val {DELF FCLC FOBS NFDF PTSN DPTS} {4834 foreach val {DELF FCLC FOBS 2FDF 3FDF 4FDF 5FDF 6FDF 7FDF 8FDF 9FDF PTSN DPTS} { 4827 4835 if {$val == $value} { 4828 4836 set found 1 … … 4935 4943 } 4936 4944 set steps {} 4937 foreach v {x y z} { 4938 set range_$v {} 4939 lappend steps [expr {[set cell_$v] / [set step_$v]}] 4940 lappend range_$v [expr {[set min_$v] * 1. / [set step_$v] }] 4941 lappend range_$v [expr {[set max_$v] * 1. / [set step_$v] }] 4942 } 4943 return [list $steps $range_x $range_y $range_z] 4945 if {[catch { 4946 foreach v {x y z} { 4947 set range_$v {} 4948 lappend steps [expr {[set cell_$v] / [set step_$v]}] 4949 lappend range_$v [expr {[set min_$v] * 1. / [set step_$v] }] 4950 lappend range_$v [expr {[set max_$v] * 1. / [set step_$v] }] 4951 } 4952 }]} { 4953 return [list {.2 .2 .2} {0 1} {0 1} {0 1}] 4954 } else { 4955 return [list $steps $range_x $range_y $range_z] 4956 } 4944 4957 } 4945 4958
Note: See TracChangeset
for help on using the changeset viewer.