Changeset 1140 for branches/sandbox
 Timestamp:
 Apr 28, 2011 10:46:45 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/sandbox/rigid.tcl
r1135 r1140 11 11 # RB_Populate {rb_notebook bodnum args} populates notebook pages with rigid body information 12 12 # RB_Map_New {bodnum args} adds new map for bodnum 13 # RB_VarNums determines (add) or removes (sub ##) rigid body variable numbers. 13 14 # RB_View_RMS {address args} prints RMS data from Fit Rigid Body on mapping panel 14 15 # RB_Choose_Atom {bodnum args} finds possible first atom for rigid body mapping … … 113 114 } 114 115 115 116 116 #global variables generated by RB_Load 117 117 # … … 149 149 set ::rb_varcheck($bodnum,$matrixnum) 1 150 150 } 151 puts "in RB_Load_RBdata ::rb_damp = $::rb_damp($bodnum,$matrixnum)" 151 152 set coords [lindex $temp 3] 152 153 set ::rb_coord_num($bodnum,$matrixnum) [llength $coords] … … 294 295 grid [label $top.matlbl$matrixnum text "Matrix $matrixnum"] row 0 column [expr $col + 2] 295 296 grid [entry $top.multi$matrixnum textvariable ::rb_mult($bodnum,$matrixnum) width 7 takefocus 1] row 1 column [expr $col +2] 297 puts "in RB_Create_Cart damp = $::rb_damp($bodnum,$matrixnum)" 296 298 grid [entry $top.damp$matrixnum textvariable ::rb_damp($bodnum,$matrixnum) width 7 takefocus 1] row 2 column [expr $col +2] 297 299 if {$::rb_mult($bodnum,$matrixnum) == ""} {set ::rb_mult($bodnum,$matrixnum) 1.000} … … 346 348 # puts "cartesian coords: $temp_car" 347 349 AddRigidBody $temp_mat $temp_car 350 RecordMacroEntry "AddRigidBody $temp_mat $temp_car" 0 348 351 349 352 incr ::expgui(changed) … … 375 378 foreach phase $::expmap(phaselist) { 376 379 foreach mapnum [RigidBodyMappingList $phase $bodnum] { 377 UnMapRigidBody $pphase $bodnum $mapnum 380 UnMapRigidBody $phase $bodnum $mapnum 381 RecordMacroEntry "UnMapRigidBody $phase $bodnum $mapnum" 0 378 382 } 379 383 } 380 384 # puts "delete rigid body number $bodnum" 381 385 DeleteRigidBody $bodnum 386 RecordMacroEntry "DeleteRigidBody $bodnum" 0 382 387 # puts "destroy location $location" 383 388 destroy $location … … 768 773 # puts "Euler = $euler" 769 774 MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler 775 RecordMacroEntry "MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler" 0 770 776 incr ::rb_map($::body_type) 771 777 incr ::expgui(changed) … … 890 896 if {$::rb_unmap($phase,$bodnum,$mapnum) == 1} { 891 897 UnMapRigidBody $phase $bodnum $mapnum 898 RecordMacroEntry "MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler" 0 892 899 } 893 900 } … … 932 939 grid [label $vm.site text "sort"] row 6 column 0 columnspan 2 933 940 934 for {set z 0} {$z < $::rb_coord_num($bodnum,$w)} {incr z} {935 grid [checkbutton $vm.sort$ z variable ::rb_sort($z)] row [expr $z+ 7] column 1936 grid [label $vm.lbls$ z text "Site [expr $z+ 1]"] row [expr $z+7] column 2941 for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} { 942 grid [checkbutton $vm.sort$coordnum variable ::rb_sort($coordnum)] row [expr $coordnum + 7] column 1 943 grid [label $vm.lbls$coordnum text "Site [expr $coordnum + 1]"] row [expr $coordnum + 7] column 2 937 944 } 938 945 set col 3 939 for {set i 1} {$i <= $::rb_matrix_num($bodnum)} {incr i} {940 grid [label $vm.lblm$ i text "Matrix #$i"] row 2 column [expr $col +1]941 grid [entry $vm.mult$ i textvariable ::rb_mult($bodnum,$i) width 8 takefocus 1] row 3 column [expr $col + 1]942 grid [entry $vm.damp$ i textvariable ::rb_damp($bodnum,$i) width 8 takefocus 1 state disable] row 4 column [expr $col + 1]943 grid [checkbutton $vm.var$ i variable ::rb_varcheck($bodnum,$i) text $::rb_var($bodnum,$i) state disable command ""] row 5 column [expr $col +1]944 945 grid [label $vm.x$ itext "X"] row 6 column [expr $col]946 grid [label $vm.y$ itext "Y"] row 6 column [expr $col + 1]947 grid [label $vm.z$ itext "Z"] row 6 column [expr $col + 2]948 for {set j 0} {$j < $::rb_coord_num($bodnum,$w)} {incr j} {946 for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { 947 grid [label $vm.lblm$matrixnum text "Matrix #$matrixnum"] row 2 column [expr $col +1] 948 grid [entry $vm.mult$matrixnum textvariable ::rb_mult($bodnum,$matrixnum) width 8 takefocus 1] row 3 column [expr $col + 1] 949 grid [entry $vm.damp$matrixnum textvariable ::rb_damp($bodnum,$matrixnum) width 8 takefocus 1 state normal] row 4 column [expr $col + 1] 950 grid [checkbutton $vm.var$matrixnum variable ::rb_varcheck($bodnum,$matrixnum) text $::rb_var($bodnum,$matrixnum) state normal command "RB_MMultRef $bodnum $matrixnum"] row 5 column [expr $col +1] 951 952 grid [label $vm.x$matrixnum text "X"] row 6 column [expr $col] 953 grid [label $vm.y$matrixnum text "Y"] row 6 column [expr $col + 1] 954 grid [label $vm.z$matrixnum text "Z"] row 6 column [expr $col + 2] 955 for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} { 949 956 # puts $::rb_coord($bodnum,$i,$j) 950 957 951 set ::rb_x($bodnum,$ i,$j) [lindex $::rb_coord($bodnum,$i,$j) 0]952 set ::rb_y($bodnum,$ i,$j) [lindex $::rb_coord($bodnum,$i,$j) 1]953 set ::rb_z($bodnum,$ i,$j) [lindex $::rb_coord($bodnum,$i,$j) 2]954 set ::rb_lbl($bodnum,$ i,$j) [lindex $::rb_coord($bodnum,$i,$j) 3]955 956 grid [entry $vm.lblcx$ i$j textvariable ::rb_x($bodnum,$i,$j) width 8 takefocus 1] row [expr $j+7] column [expr $col]957 grid [entry $vm.lblcy$ i$j textvariable ::rb_y($bodnum,$i,$j) width 8 takefocus 1] row [expr $j+7] column [expr $col + 1]958 grid [entry $vm.lblcz$ i$j textvariable ::rb_z($bodnum,$i,$j) width 8 takefocus 1] row [expr $j+7] column [expr $col + 2]959 grid [label $vm.lblcb$ i$j text " "] row [expr $j+6] column [expr $col + 3]958 set ::rb_x($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0] 959 set ::rb_y($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 1] 960 set ::rb_z($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 2] 961 set ::rb_lbl($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 3] 962 963 grid [entry $vm.lblcx$matrixnum$coordnum textvariable ::rb_x($bodnum,$matrixnum,$coordnum) width 8 takefocus 1] row [expr $coordnum+7] column [expr $col] 964 grid [entry $vm.lblcy$matrixnum$coordnum textvariable ::rb_y($bodnum,$matrixnum,$coordnum) width 8 takefocus 1] row [expr $coordnum+7] column [expr $col + 1] 965 grid [entry $vm.lblcz$matrixnum$coordnum textvariable ::rb_z($bodnum,$matrixnum,$coordnum) width 8 takefocus 1] row [expr $coordnum+7] column [expr $col + 2] 966 grid [label $vm.lblcb$matrixnum$coordnum text " "] row [expr $coordnum+6] column [expr $col + 3] 960 967 } 961 968 incr col 4 … … 963 970 } 964 971 965 972 proc RB_VarNums {toggle {var ""} args} { 973 # initalize rigid body variable list if not already initialized 974 # toggle can be: 975 # add This returns the smallest unused variable number 976 # sub ## This removes variable ## from the varlist. 977 978 if {[info vars ::rb_varlist] == ""} { 979 set ::rb_varlist "" 980 } 981 if {$::rb_varlist == ""} { 982 set ::rb_varlist [RigidBodyGetVarNums] 983 } 984 985 if {$toggle == "add"} { 986 set count 1 987 while {[lsearch $::rb_varlist $count] > 0} { 988 incr count 989 } 990 lappend ::rb_varlist $count 991 puts $::rb_varlist 992 return $count 993 } 994 if {$toggle == "sub"} { 995 set temp "" 996 foreach v $::rb_varlist { 997 if {$v != $var} { 998 lappend temp $v 999 } 1000 } 1001 set ::rb_varlist $temp 1002 puts $::rb_varlist 1003 return 0 1004 } 1005 } 1006 1007 proc RB_MMultRef {bodnum matrixnum args} { 1008 # procedure sets or unsets the variable number for the matrix multiplier 1009 puts "boing:" 1010 if {$::rb_varcheck($bodnum,$matrixnum) == "0"} { 1011 set ::rb_var($bodnum,$matrixnum) [RB_VarNums sub $::rb_var($bodnum,$matrixnum)] 1012 } else { 1013 set ::rb_var($bodnum,$matrixnum) [RB_VarNums add] 1014 } 1015 destroy .viewmatrix 1016 RB_Edit_Matrix $bodnum 1017 } 966 1018 967 1019 proc RB_Sort_Inc {bodnum dir args} { … … 1032 1084 proc RB_Matrix_Update {bodnum args} { 1033 1085 set temp_mat "" 1086 set temp_damp "" 1087 set temp_var "" 1034 1088 set temp_car "" 1035 1089 set temp_mat_group "" … … 1038 1092 1039 1093 for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { 1094 set temp "" 1040 1095 lappend temp_mat $::rb_mult($bodnum,$matrixnum) 1041 } 1042 1043 for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { 1044 set temp "" 1096 lappend temp_var $::rb_var($bodnum,$matrixnum) 1097 lappend temp_damp $::rb_damp($bodnum,$matrixnum) 1098 puts "temp_damp = $::rb_damp($bodnum,$matrixnum)" 1045 1099 for {set atomnum 0} {$atomnum < $::::rb_coord_num($bodnum,1)} {incr atomnum} { 1046 set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$atomnum) $::rb_y($bodnum,$matrixnum,$atomnum) $::rb_z($bodnum,$matrixnum,$atomnum)" 1047 # puts "$temp_cart_triplet $atomnum" 1048 lappend temp $temp_cart_triplet 1049 } 1100 set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$atomnum) $::rb_y($bodnum,$matrixnum,$atomnum) $::rb_z($bodnum,$matrixnum,$atomnum)" 1101 lappend temp $temp_cart_triplet 1102 } 1050 1103 lappend temp_car $temp 1051 1104 } 1105 1052 1106 puts "Matrix Update Info = $bodnum $temp_mat $temp_car" 1053 ReplaceRigidBody $bodnum $temp_mat $temp_car 1107 puts "Matrix damping = $temp_damp" 1108 puts "Matrix vars = $temp_var" 1109 SetRigidBodyVar $bodnum $temp_var $temp_damp 1110 RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0 1111 ReplaceRigidBody $bodnum $temp_mat $temp_car $temp_var $temp_damp 1112 RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0 1113 #SetRigidBodyVar $bodnum $temp_var $temp_damp 1054 1114 incr ::expgui(changed) 1055 1115 RB_Load_RBdata … … 1187 1247 puts "body number = $bodnum" 1188 1248 set coordnum 0 1189 set ::rb_damp($bodnum,1) 01249 # set ::rb_damp($bodnum,1) 0 1190 1250 set ::rb_coord_num($bodnum,1) $::gcon_atoms 1191 1251 … … 1395 1455 puts "start atom = $::gcon_start" 1396 1456 1397 set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list] 1398 if {[lindex $temp1 0] == {}  [lindex $temp1 1] == {}  [lindex $temp1 2] == {}} { 1399 # puts "Geometry Crashed" 1400 } 1401 #puts "string 1 = [lindex $temp1 0]" 1402 #puts "string 2 = [lindex $temp1 1]" 1403 #puts "string 3 = [lindex $temp1 2]" 1404 1405 set cartesian "" 1406 lappend cartesian [lindex $temp1 2] 1407 #puts "Cartesian = $cartesian" 1408 1409 set bodnum [AddRigidBody 1 $cartesian] 1410 set ::rb_damp($bodnum,1) 0 1411 set ::rb_coord_num($bodnum,1) $::gcon_atoms 1412 1413 MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1] 1414 1415 destroy .geometry 1416 1417 1418 RB_Control_Panel 0 1457 set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list] 1458 if {[lindex $temp1 0] == {}  [lindex $temp1 1] == {}  [lindex $temp1 2] == {}} { 1459 # puts "Geometry Crashed" 1460 } 1461 #puts "string 1 = [lindex $temp1 0]" 1462 #puts "string 2 = [lindex $temp1 1]" 1463 #puts "string 3 = [lindex $temp1 2]" 1464 1465 set cartesian "" 1466 lappend cartesian [lindex $temp1 2] 1467 #puts "Cartesian = $cartesian" 1468 1469 set bodnum [AddRigidBody 1 $cartesian] 1470 # set ::rb_damp($bodnum,1) 0 1471 set ::rb_coord_num($bodnum,1) $::gcon_atoms 1472 1473 MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1] 1474 RecordMacroEntry "MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1]" 0 1475 destroy .geometry 1476 RB_Control_Panel 0 1419 1477 } 1420 1478 … … 1432 1490 grid [frame $con.info bd 2 relief groove] row 1 column 0 sticky news 1433 1491 grid columnconfig $con 0 weight 1 1434 grid [frame $con.con bd 2 relief groove] row 0 column 0 1492 grid [frame $con.con bd 2 relief groove] row 0 column 0 1435 1493 grid [frame $con.terminate bd 2 relief groove] row 2 column 0 1436 1494 1437 1495 #bandaid fix: load all mapping data 1496 foreach phase $::expmap(phaselist) { 1497 foreach bodnum [RigidBodyList] { 1498 foreach mapnum [RigidBodyMappingList $phase $bodnum] { 1499 RB_Load_Mapdata $phase $bodnum $mapnum 1500 } 1501 } 1502 } 1438 1503 1439 1504 #grid rowconfig $con 0 weight 1 … … 1551 1616 # incr col 1552 1617 } 1553 grid [label $main.rb_site$phasenum$ mapnum$jtext "$atomlist"] row [expr $row + 1] column 4 padx 5 columnspan 999 sticky w1618 grid [label $main.rb_site$phasenum$bodnum$mapnum text "$atomlist"] row [expr $row + 1] column 4 padx 5 columnspan 999 sticky w 1554 1619 incr row 2 1555 1620 } … … 1699 1764 $::rb_var($phasenum,$bodnum,$mapnum,e3) 0 0 0" 1700 1765 RigidBodyVary $phasenum $bodnum $mapnum $rb_list 1701 1766 RecordMacroEntry "incr expgui(changed); RigidBodyVary $phasenum $bodnum $mapnum [list $rb_list]" 0 1702 1767 foreach test $rb_list { 1703 1768 if {$test != 0} { … … 1720 1785 puts "TLS param save for $rb_tls" 1721 1786 RigidBodyTLSVary $phasenum $bodnum $mapnum $rb_tls 1722 1787 RecordMacroEntry "RigidBodyTLSVary $phasenum $bodnum $mapnum [list $rb_tls]" 0 1723 1788 foreach test $rb_tls { 1724 1789 if {$test != 0} { … … 1729 1794 } 1730 1795 incr ::expgui(changed) 1796 #RecordMacroEntry "incr expgui(changed)" 0 1731 1797 1732 1798 } … … 1765 1831 1766 1832 1767 1768 1769 1770 1833 proc RB_Load_Vars {phasenum bodnum mapnum args} { 1771 1834 foreach var $::rb_map_positionvars($phasenum,$bodnum,$mapnum) { … … 1788 1851 } 1789 1852 } 1790 1791 1792 1853 1793 1854 set ::rb_var($phasenum,$bodnum,$mapnum,x) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 0] $mulvarlist] … … 1980 2041 grid $vp.refflag.8 row 6 column 2 1981 2042 1982 1983 1984 } 1985 2043 } 2044
Note: See TracChangeset
for help on using the changeset viewer.