Changeset 254 for trunk/addcmds.tcl


Ignore:
Timestamp:
Dec 4, 2009 5:02:59 PM (14 years ago)
Author:
toby
Message:

# on 2000/08/04 18:26:37, toby did:
new procs: MakeXformAtomsBox?, XformAtomsCoord?, XformAtomsOcc?, XformAtomsU

EraseAtoms?

above used for global atom changes on phase pane

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/addcmds.tcl

    • Property rcs:date changed from 2000/07/20 22:12:18 to 2000/08/04 18:26:37
    • Property rcs:lines changed from +4 -2 to +216 -1
    • Property rcs:rev changed from 1.9 to 1.10
    r237 r254  
    853853    file delete exptool.in exptool.out
    854854}
     855
     856#----------------------------------------------
     857# commands to modify a group of selected atoms |
     858#----------------------------------------------
     859
     860# make the dialog to choose an action
     861proc MakeXformAtomsBox {phase} {
     862    global expgui expmap
     863    set numberList {}
     864    set p $expgui(curPhase)
     865    foreach AtomIndex $expgui(selectedatomlist) {
     866        # get atom number & phase
     867        set tuple [lindex $expmap(atomlistboxcontents) $AtomIndex]
     868        lappend numberList [lindex $tuple 0]
     869    }
     870    if {$numberList == ""} return
     871    if {[llength $numberList] > 1} {
     872        set suffix s
     873        set suffixy "ies"
     874    } else {
     875        set suffix ""
     876        set suffixy "y"
     877    }
     878    set w .global
     879    catch {destroy $w}
     880    toplevel $w
     881    wm title $w "Edit Atomic Parameter -- phase #$phase"
     882    # this needs to track by phase
     883    grid [label $w.0 \
     884            -text "Modifying atom${suffix} [CompressList $numberList] Phase $phase" \
     885            -bg yellow -anchor center] -row 0 -column 0 -columnspan 10 \
     886            -sticky nsew
     887    grid rowconfigure $w 0 -pad 5
     888    grid rowconfigure $w 1 -minsize 2
     889
     890    grid [TitleFrame $w.1 -bd 6 -relief groove -text "Modify coordinates"] \
     891            -row 2 -column 0 -columnspan 10 -sticky news
     892    set w1 [$w.1 getframe]
     893    set row 0
     894    foreach v {x y z} {
     895        incr row
     896        set col -1
     897        grid [label $w1.l$v -text "new $v   =   "] -column [incr col] -row $row
     898        foreach o {x y z} {
     899            grid [entry $w1.e${v}${o} -width 6] -column [incr col] -row $row
     900            $w1.e${v}${o} delete 0 end
     901            if {$v == $o} {
     902                $w1.e${v}${o} insert end "1.0"
     903            } else {
     904                $w1.e${v}${o} insert end "0."
     905            }
     906            grid [label $w1.p${v}${o} -text " $o  +  "] \
     907                    -column [incr col] -row $row
     908        }
     909        grid [entry $w1.e${v} -width 6] -column [incr col] -row $row
     910        $w1.e${v} delete 0 end
     911        $w1.e${v} insert end "0."
     912    }
     913    grid [button $w1.do -text "Transform Coordinates" \
     914            -command "XformAtomsCoord $phase [list $numberList] $w1" \
     915            ] -row [incr row] -column 0 -columnspan 10
     916
     917    grid rowconfigure $w 3 -minsize 5
     918    grid [TitleFrame $w.4 -bd 6 -relief groove -text "Modify occupanc${suffixy}"] \
     919            -row 4 -column 0 -columnspan 10 -sticky news
     920    set w2 [$w.4 getframe]
     921    grid [label $w2.1 -text "Occupancy: "] -row 1 -column 0
     922    grid [entry $w2.e -width 10] -column 1 -row 1
     923    $w2.e delete 0 end
     924    $w2.e insert end 1.0
     925    grid columnconfigure $w2 2 -weight 1
     926    grid [button $w2.do -text "Set Occupanc${suffixy}" \
     927            -command "XformAtomsOcc $phase [list $numberList] $w2" \
     928            ] -row 2 -column 0 -columnspan 10
     929
     930    grid rowconfigure $w 5 -minsize 5
     931    grid [TitleFrame $w.6 -bd 6 -relief groove \
     932            -text "Modify Displacement Parameter$suffix"] \
     933            -row 6 -column 0 -columnspan 10 -sticky news
     934    set w2 [$w.6 getframe]
     935    grid [label $w2.1 -text "Uiso or Uequiv: "] -row 1 -column 0
     936    grid [entry $w2.e -width 10] -column 1 -row 1
     937    $w2.e delete 0 end
     938    $w2.e insert end 0.025
     939    grid columnconfigure $w2 2 -weight 1
     940    grid [button $w2.do -text "Set U" \
     941            -command "XformAtomsU $phase [list $numberList] $w2" \
     942            ] -row 2 -column 0 -columnspan 10
     943    grid [frame $w2.f] -row 3 -column 0 -columnspan 10
     944    grid [button $w2.f.iso -text "Set Isotropic" \
     945            -command "XformAtomsU $phase [list $numberList] iso" \
     946            ] -row 0 -column 0
     947    grid [button $w2.f.aniso -text "Set Anisotropic" \
     948            -command "XformAtomsU $phase [list $numberList] aniso" \
     949            ] -row 0 -column 1
     950
     951    grid rowconfigure $w 5 -minsize 5
     952    grid [TitleFrame $w.8 -bd 6 -relief groove \
     953            -text "Erase Atom$suffix"] \
     954            -row 8 -column 0 -columnspan 10 -sticky news
     955    set w2 [$w.8 getframe]
     956    grid [button $w2.do -text "Erase Atom${suffix}" \
     957            -command "EraseAtoms $phase [list $numberList] $w" \
     958            ] -row 2 -column 0 -columnspan 10
     959
     960
     961    grid rowconfigure $w 9 -minsize 5
     962    grid [frame $w.b] -row 10 -column 0
     963    pack [button $w.b.3 -text Close -command "destroy $w"] -side left
     964    bind $w <Return> "destroy $w"
     965
     966    # force the window to stay on top
     967    putontop $w
     968    focus $w.b.3
     969    tkwait window $w
     970    afterputontop
     971    # if there are selected atoms, reset their display
     972    if {[llength $expgui(selectedatomlist)] != 0} editRecord
     973}
     974
     975# transform the coordinates
     976proc XformAtomsCoord {phase numberList w1} {
     977    global expgui
     978    # get the matrix
     979    foreach v {x y z} {
     980        foreach o {x y z} {
     981            set matrix(${v}${o}) [$w1.e${v}${o} get]
     982        }
     983        set matrix(${v}) [$w1.e${v} get]
     984    }
     985    foreach atom $numberList {
     986        foreach v {x y z} {
     987            set $v [atominfo $phase $atom $v]
     988        }
     989        foreach v {x y z} {
     990            set new$v $matrix(${v})
     991            foreach o {x y z} {
     992                set new$v [expr [set new$v] + $matrix(${v}${o})*[set $o]]
     993            }
     994            atominfo $phase $atom $v set [set new$v]
     995        }
     996        incr expgui(changed)
     997    }
     998    DisplayAllAtoms noreset
     999}
     1000
     1001# set the occupancies to a single value
     1002proc XformAtomsOcc {phase numberList w2} {
     1003    global expgui
     1004    # get the value
     1005    set val [$w2.e get]
     1006    foreach atom $numberList {
     1007        atominfo $phase $atom frac set $val
     1008        incr expgui(changed)
     1009    }
     1010    DisplayAllAtoms noreset
     1011}
     1012
     1013# transform Uiso or Uij; if anisotropic set Uequiv to Uij
     1014proc XformAtomsU {phase numberList w2} {
     1015    global expgui
     1016    if {$w2 == "iso"} {
     1017        foreach atom $numberList {
     1018            if {[atominfo $phase $atom temptype] != "I"} {
     1019                atominfo $phase $atom temptype set I
     1020            }
     1021        }
     1022    } elseif {$w2 == "aniso"} {
     1023        foreach atom $numberList {
     1024            if {[atominfo $phase $atom temptype] == "I"} {
     1025                atominfo $phase $atom temptype set A
     1026            }
     1027        }
     1028    } else {
     1029        # get the value
     1030        set val [$w2.e get]
     1031        foreach atom $numberList {
     1032            if {[atominfo $phase $atom temptype] == "I"} {
     1033                atominfo $phase $atom Uiso set $val
     1034            } else {
     1035                atominfo $phase $atom U11 set $val
     1036                atominfo $phase $atom U22 set $val
     1037                atominfo $phase $atom U33 set $val
     1038                atominfo $phase $atom U12 set 0.0
     1039                atominfo $phase $atom U13 set 0.0
     1040                atominfo $phase $atom U23 set 0.0
     1041            }
     1042            incr expgui(changed)
     1043        }
     1044    }
     1045    DisplayAllAtoms noreset
     1046}
     1047
     1048# confirm and erase atoms
     1049proc EraseAtoms {phase numberList w2} {
     1050    global expgui
     1051    if {[llength $numberList] <= 0} return
     1052    # make a list of atoms
     1053    foreach atom $numberList {
     1054        append atomlist "\n\t$atom  [atominfo $phase $atom label]"
     1055    }
     1056    set msg "OK to remove the following [llength $numberList] atoms from phase $phase:$atomlist"
     1057    set val [MyMessageBox -parent $w2 -type okcancel -icon warning \
     1058            -default cancel -title "Confirm Erase" -message $msg]
     1059    if {$val == "ok"} {
     1060        foreach atom $numberList {
     1061            EraseAtom $atom $phase
     1062            incr expgui(changed)
     1063        }
     1064        mapexp
     1065        DisplayAllAtoms
     1066        destroy $w2
     1067    }
     1068}
     1069
Note: See TracChangeset for help on using the changeset viewer.