1 | # Procedure list: |
---|
2 | # RB_Import_Data_Type {args} determines types of input available for rigid body creation panel. |
---|
3 | # RB_Load_RBdata {args} parses variables from ReadRigidBody |
---|
4 | # RB_Load_Mapdata {phase bodnum mapnum} parses variables from ReadRigidBodyMapping |
---|
5 | # RB_Control_Panel {panelnum args} builds notebook for rigid bodies |
---|
6 | # RB_Create {args} builds rigid body create panel |
---|
7 | # RB_Create_Cart {bodnum location args} creates cartesian coordinate frame in nbt window. (nbt = new body type) |
---|
8 | # RB_Create_save {bodnum args} builds rigid body from nbt window |
---|
9 | # RB_Delete_Body {bodnum location args} panel queries user confirm rigid body deletion |
---|
10 | # RB_Delete_Body_Confirm {bodnum location args} deletes and unmaps rigid body with UnMapRigidBody and DeleteRigidBody |
---|
11 | # RB_Populate {rb_notebook bodnum args} populates notebook pages with rigid body information |
---|
12 | # RB_Map_New {bodnum args} adds new map for bodnum |
---|
13 | # RB_VarNums determines (add) or removes (sub ##) rigid body variable numbers. |
---|
14 | # RB_View_RMS {address args} prints RMS data from Fit Rigid Body on mapping panel |
---|
15 | # RB_Choose_Atom {bodnum args} finds possible first atom for rigid body mapping |
---|
16 | # RB_FitBody2Coords {bodnum menu} fits rigid body to coordinates. |
---|
17 | # RB_PlotStrBody {bodnum menu} plots rigid body onto structure |
---|
18 | # RB_Write_Map {args} writes mapping information with MapRigidBody |
---|
19 | # RB_Atom_List {phase atomnum address bodnum args} returns a list of atoms in rigid body |
---|
20 | # proc RB_ProcessPhase {bodnum args} activate / deactivate buttons on rigid body mapping panel |
---|
21 | # RB_Unmap {bodnum args} writes panel for unmapping rigid body |
---|
22 | # RB_unmap_delete {panel bodnum args} unmaps rigid body |
---|
23 | # RB_Edit_Matrix {bodnum args} build edit matrix panel |
---|
24 | # RB_Sort_Inc {bodnum dir args} sort routine for edit matrix panel (dir = inc or dec) |
---|
25 | # RB_String_Reverse {string args} reverses the order or elements in a string |
---|
26 | # RB_Matrix_Update {bodnum args} updates the information in the edit matrix panel |
---|
27 | # proc RB_View_Parameters {phase x y args} not used at this time. |
---|
28 | # proc GetImportFormats {} locates the file formats for rigid body creation panel not used at this time |
---|
29 | # MakeRBPane {} called to initialize pane in notebook |
---|
30 | # NewBodyTypeWindow build new rigid body save panel |
---|
31 | # RB_Fixfrag_Load {args} build panel for generating rigid bodies from exp file |
---|
32 | # RB_FixFragSaveCoord {args} build rigid body from information on rigid bodies from exp panel |
---|
33 | # RB_FixStartAtom {phase gdisplay gcon2 args} |
---|
34 | # RB_Atom_Fixlist {phase gdisplay} |
---|
35 | # RB_Atom_Origin_Set {args} |
---|
36 | # RB_Geom_Save {args} |
---|
37 | # RB_Refine_Con {args} sets matrix to set refinement constrols |
---|
38 | # RB_Variable_Clear {} |
---|
39 | # RB_Con_But_Proc {addresses change args} |
---|
40 | # RB_Con_Button {address args} |
---|
41 | # RB_Var_Gen {varcount args} |
---|
42 | # RB_Var_Assign {args} assigns variable numbers to refinement parameters |
---|
43 | # RB_Ref_FlagEnable {phasenum bodnum mapnum var val args} |
---|
44 | # RB_Var_Save {args} |
---|
45 | # RB_TLS_Onoff {phasenum main bodnum mapnum} |
---|
46 | # RB_Load_Vars {phasenum bodnum mapnum args} |
---|
47 | # RB_VarSet {varin mulvarlist args} |
---|
48 | # RB_New_RBnum {args} |
---|
49 | # RB_CartesianTextFile {bodnum args} |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | # Important Global variable list: |
---|
54 | # ::rbtypelist variable that contains RB file format types. |
---|
55 | # ::rb_map(bodnum) number of times rigid body is mapped. |
---|
56 | # ::rb_matrix_num(bodnum) number of matrices in rigid body. |
---|
57 | # ::rb_mult(bodnum,matrixnum) multiplier for matrix. |
---|
58 | # ::rb_damp(bodnum,matrixnum) damping factor for matrix multiplier. |
---|
59 | # ::rb_var(bodnum,matrixnum) variable id for matrix multiplier. |
---|
60 | # ::rb_coord_num(bodnum,matrixnum) number of coordinates associated with matrix. |
---|
61 | # ::rb_coord(bodnum,matrixnum,coord) coordinate list |
---|
62 | # ::rb_x(bodnum,matrixnum,coordnum) x coordinate |
---|
63 | # ::rb_y(bodnum,matrixnum,coordnum) y coordinate |
---|
64 | # ::rb_z(bodnum,matrixnum,coordnum) z coordinate |
---|
65 | # ::rb_lbl(bodnum,matrixnum,coordnum) label for coordinate triplet |
---|
66 | # ::rb_map_beginning(phase,bodnum,mapnum) first atom in list |
---|
67 | # ::rb_map_origin(phase,bodnum,mapnum) origin of rigid body |
---|
68 | # ::rb_map_euler(phase,bodnum,mapnum) euler angles of rigid body |
---|
69 | # ::rb_map_positions(phase,bodnum,mapnum) positions |
---|
70 | # ::rb_map_damping(phase,bodnum,mapnum) damping |
---|
71 | # ::rb_map_tls(phase,bodnum,mapnum) tls |
---|
72 | # ::rb_map_tls_var(phase,bodnum,mapnum) tls variable id number |
---|
73 | # ::rb_map_tls_damp(phase,bodnum,mapnum) tls damping factor |
---|
74 | # ::rb_notebook contains address of rigid body notebook |
---|
75 | # ::rb_firstatom contains first atom on active rigid body. Must be gobal for variable has trace. |
---|
76 | #$ ::rb_phase phase for active map |
---|
77 | |
---|
78 | # debug code to load test files when run as an independent script |
---|
79 | if {[array name expgui shell] == ""} { |
---|
80 | lappend auto_path c:/gsas/expgui |
---|
81 | package require Tk |
---|
82 | package require BWidget |
---|
83 | set expgui(debug) 1 |
---|
84 | #package require La |
---|
85 | #namespace import La::* |
---|
86 | source c:/gsas/sandboxexpgui/readexp.tcl |
---|
87 | source c:/gsas/sandboxexpgui/gsascmds.tcl |
---|
88 | # test code (package already loaded in expgui) |
---|
89 | lappend auto_path [file dirname [info script]] |
---|
90 | source C:/gsas/sandboxexpgui/rb.tcl |
---|
91 | # puts beforeread |
---|
92 | expload c:/crystals/expgui/rigid/rb6norb.exp |
---|
93 | mapexp |
---|
94 | # puts after |
---|
95 | } else { |
---|
96 | source [file join $expgui(scriptdir) rb.tcl] |
---|
97 | } |
---|
98 | package require La |
---|
99 | |
---|
100 | # Procedure to determine possible RB file formats available |
---|
101 | |
---|
102 | proc RB_Import_Data_Type {args} { |
---|
103 | global expgui tcl_platform |
---|
104 | # only needs to be done once |
---|
105 | set ::rbtypelist "" |
---|
106 | |
---|
107 | set files [glob -nocomplain [file join $expgui(scriptdir) rbimport_*.tcl]] |
---|
108 | foreach filetype $files { |
---|
109 | set temp [lindex [string map {_ " "} $filetype] 1] |
---|
110 | lappend ::rbtypelist $temp |
---|
111 | } |
---|
112 | if {$::rbtypelist == ""} {lappend ::rbtypelist "no rigid body file types available"} |
---|
113 | foreach filetype $::rbtypelist { |
---|
114 | source $::expgui(scriptdir)/rbimport_$filetype |
---|
115 | } |
---|
116 | return $::rbtypelist |
---|
117 | } |
---|
118 | |
---|
119 | #global variables generated by RB_Load |
---|
120 | # |
---|
121 | # |
---|
122 | # ::rb_map(bodnum) number of times rigid body is mapped. |
---|
123 | # ::rb_matrix_num(bodnum) number of matrices in rigid body. |
---|
124 | # ::rb_mult(bodnum,matrixnum) multiplier for matrix. |
---|
125 | # ::rb_damp(bodnum,matrixnum) damping factor for matrix. |
---|
126 | # ::rb_var(bodnum,matrixnum) variable for matrix. |
---|
127 | # ::rb_coord_num(bodnum,matrixnum) number of coordinates associated with matrix. |
---|
128 | # ::rb_coord(bodnum,matrixnum,coord) coordinates |
---|
129 | # ::rb_x(bodnum,matrixnum,coordnum) x coordinate |
---|
130 | # ::rb_y(bodnum,matrixnum,coordnum) y coordinate |
---|
131 | # ::rb_z(bodnum,matrixnum,coordnum z coordinate |
---|
132 | # ::rb_lbl(bodnum,matrixnum,coordnum label for coordinate triplet |
---|
133 | |
---|
134 | proc RB_Load_RBdata {args} { |
---|
135 | catch {unset ::rb} |
---|
136 | #Loop over the rigid body types in EXP file |
---|
137 | foreach bodnum [RigidBodyList] { |
---|
138 | set rb($bodnum) [ReadRigidBody $bodnum] |
---|
139 | #Set the number of times rigid body is mapped. |
---|
140 | set ::rb_map($bodnum) [lindex $rb($bodnum) 0] |
---|
141 | #define the matrices |
---|
142 | set rb_mat [lindex $rb($bodnum) 1] |
---|
143 | set ::rb_matrix_num($bodnum) [llength $rb_mat] |
---|
144 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
145 | set temp [lindex $rb_mat [expr $matrixnum - 1]] |
---|
146 | set ::rb_mult($bodnum,$matrixnum) [lindex $temp 0] |
---|
147 | set ::rb_damp($bodnum,$matrixnum) [lindex $temp 1] |
---|
148 | set ::rb_var($bodnum,$matrixnum) [lindex $temp 2] |
---|
149 | if {$::rb_var($bodnum,$matrixnum) == 0} { |
---|
150 | set ::rb_varcheck($bodnum,$matrixnum) 0 |
---|
151 | } else { |
---|
152 | set ::rb_varcheck($bodnum,$matrixnum) 1 |
---|
153 | } |
---|
154 | # puts "in RB_Load_RBdata ::rb_damp = $::rb_damp($bodnum,$matrixnum)" |
---|
155 | set coords [lindex $temp 3] |
---|
156 | set ::rb_coord_num($bodnum,$matrixnum) [llength $coords] |
---|
157 | #load all coordniate information for matrix matrixnum |
---|
158 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$matrixnum)} {incr coordnum} { |
---|
159 | set ::rb_coord($bodnum,$matrixnum,$coordnum) [lindex $coords $coordnum] |
---|
160 | set ::rb_x($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0] |
---|
161 | set ::rb_y($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0] |
---|
162 | set ::rb_z($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0] |
---|
163 | set ::rb_lbl($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0] |
---|
164 | # restore values |
---|
165 | set ::rb_matrix_num_temp($bodnum) $::rb_matrix_num($bodnum) |
---|
166 | set ::rb_coord_num_temp($bodnum,1) $::rb_coord_num($bodnum,1) |
---|
167 | set ::rb_coord_temp($bodnum,$matrixnum,$coordnum) $::rb_coord($bodnum,$matrixnum,$coordnum) |
---|
168 | |
---|
169 | } |
---|
170 | } |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | ############################################ |
---|
175 | # ::rb_map_beginning(phase,bodnum,mapnum) first atom in list |
---|
176 | # ::rb_map_origin(phase,bodnum,mapnum) origin of rigid body |
---|
177 | # ::rb_map_euler(phase,bodnum,mapnum) euler angles of rigid body |
---|
178 | # ::rb_map_positions(phase,bodnum,mapnum) positions |
---|
179 | # ::rb_map_damping(phase,bodnum,mapnum) damping |
---|
180 | # ::rb_map_tls(phase,bodnum,mapnum) tls |
---|
181 | # ::rb_map_tls_var(phase,bodnum,mapnum) |
---|
182 | # ::rb_map_tls_damp(phase,bodnum,mapnum) |
---|
183 | proc RB_Load_Mapdata {phase bodnum mapnum} { |
---|
184 | set rb_map [ReadRigidBodyMapping $phase $bodnum $mapnum] |
---|
185 | set ::rb_map_beginning($phase,$bodnum,$mapnum) [lindex $rb_map 0] |
---|
186 | set ::rb_map_origin($phase,$bodnum,$mapnum) [lindex $rb_map 1] |
---|
187 | set ::rb_map_euler($phase,$bodnum,$mapnum) [lindex $rb_map 2] |
---|
188 | set ::rb_map_positionvars($phase,$bodnum,$mapnum) [lindex $rb_map 3] |
---|
189 | set ::rb_map_damping($phase,$bodnum,$mapnum) [lindex $rb_map 4] |
---|
190 | set ::rb_map_tls($phase,$bodnum,$mapnum) [lindex $rb_map 5] |
---|
191 | set ::rb_map_tls_var($phase,$bodnum,$mapnum) [lindex $rb_map 6] |
---|
192 | set ::rb_map_tls_damp($phase,$bodnum,$mapnum) [lindex $rb_map 7] |
---|
193 | } |
---|
194 | |
---|
195 | ############################################# |
---|
196 | # rcb .a initial rigid body control panel. |
---|
197 | # panelnum the notebook panel to be accessed. |
---|
198 | #::rb_notebook the notebook containing all rigid body panels. |
---|
199 | |
---|
200 | proc RB_Control_Panel {panelnum args} { |
---|
201 | #set rcb .a |
---|
202 | #destroy $rcb |
---|
203 | #catch {toplevel $rcb} err |
---|
204 | set rcb $::expgui(rbFrame) |
---|
205 | eval destroy [winfo children $rcb] |
---|
206 | #wm title $rcb "Rigid Body Control Panel" |
---|
207 | #wm geometry $rcb 700x600+10+10 |
---|
208 | set rb_nb $rcb.nb |
---|
209 | |
---|
210 | # Enable NoteBook from BWidget package |
---|
211 | |
---|
212 | set ::rb_notebook [NoteBook $rb_nb -side bottom] |
---|
213 | # loop over rigid body types, create notebook pages |
---|
214 | set pagelist {} |
---|
215 | |
---|
216 | # add create rigid body page and populate page |
---|
217 | $::rb_notebook insert 0 rb_body0 -text "Create Rigid Body" \ |
---|
218 | -raisecmd "RB_Create" |
---|
219 | lappend pagelist rb_body0 |
---|
220 | |
---|
221 | |
---|
222 | foreach bodnum [RigidBodyList] { |
---|
223 | $::rb_notebook insert $bodnum rb_body$bodnum -text "Rigid Body Type $bodnum" \ |
---|
224 | -raisecmd "RB_Populate $::rb_notebook $bodnum" |
---|
225 | lappend pagelist rb_body$bodnum |
---|
226 | } |
---|
227 | |
---|
228 | # grid notebook |
---|
229 | grid $::rb_notebook -sticky news -column 0 -row 1 -columnspan 2 |
---|
230 | grid columnconfig $rcb 1 -weight 1 |
---|
231 | grid rowconfig $rcb 1 -weight 1 |
---|
232 | $::rb_notebook raise [lindex $pagelist $panelnum] |
---|
233 | } |
---|
234 | |
---|
235 | ############################################ |
---|
236 | # Procedure to create new rigid body |
---|
237 | |
---|
238 | proc RB_Create {args} { |
---|
239 | RB_Import_Data_Type |
---|
240 | $::rb_notebook raise [$::rb_notebook page 0] |
---|
241 | #sets the new rigidbody number |
---|
242 | set bodnum [expr [llength [RigidBodyList]] + 1] |
---|
243 | #sets the phase list |
---|
244 | set phase $::expmap(phaselist) |
---|
245 | set pane [$::rb_notebook getframe rb_body0] |
---|
246 | eval destroy [winfo children $pane] |
---|
247 | set con0 $pane.con0 |
---|
248 | #set con1 $pane.con1 |
---|
249 | #set con2 $pane.con2 |
---|
250 | #set con3 $pane.con3 |
---|
251 | |
---|
252 | #initialize matrix number, multiplier and number of coordinates |
---|
253 | set ::rb_matrix_num($bodnum) 1 |
---|
254 | set ::rb_mult($bodnum,1) 1.000 |
---|
255 | |
---|
256 | if {[info vars ::rb_coord_num($bodnum,1)] == ""} {set ::rb_coord_num($bodnum,1) 1} |
---|
257 | |
---|
258 | #set check variables to see if number of matricies or coordinates incremented. |
---|
259 | set ::rb_mat_num_check 0 |
---|
260 | set ::rb_atom_num_check 0 |
---|
261 | |
---|
262 | #building rigid body creation frames |
---|
263 | pack [frame $con0 -bd 2 -relief groove] -side top -pady 10 |
---|
264 | |
---|
265 | set ::rb_loader(manual) NewBodyTypeWindow |
---|
266 | set ::rb_descriptor(manual) "Manual Input" |
---|
267 | |
---|
268 | |
---|
269 | set filedescriptors "" |
---|
270 | set filearray [array names ::rb_descriptor] |
---|
271 | foreach file $filearray { |
---|
272 | lappend filedescriptors $::rb_descriptor($file) |
---|
273 | } |
---|
274 | |
---|
275 | set filecount 0 |
---|
276 | set ::rb_file_loader "Choose Method" |
---|
277 | grid [label $con0.lbl -text "How are rigid body coordinates \n to be entered?"] -row 0 -column 0 -sticky ns |
---|
278 | set menu [eval tk_optionMenu $con0.filematrix ::rb_file_loader $filedescriptors] |
---|
279 | foreach file $filearray { |
---|
280 | $menu entryconfig $filecount -command "eval $::rb_loader($file)" |
---|
281 | incr filecount |
---|
282 | } |
---|
283 | $con0.filematrix configure -width 50 |
---|
284 | grid $con0.filematrix -row 0 -column 1 |
---|
285 | |
---|
286 | } |
---|
287 | |
---|
288 | ############################################################ |
---|
289 | #procedure to create tables of cartesian coordinates |
---|
290 | |
---|
291 | proc RB_Create_Cart {bodnum location args} { |
---|
292 | if {$::rb_matrix_num($bodnum) == $::rb_mat_num_check && $::rb_coord_num($bodnum,1) == $::rb_atom_num_check} {return} |
---|
293 | if {[catch {expr $::rb_matrix_num($bodnum)}] == 1 || [catch {expr $::rb_coord_num($bodnum,1)}] == 1} {return} |
---|
294 | if {$::rb_matrix_num($bodnum) != int($::rb_matrix_num($bodnum)) || $::rb_coord_num($bodnum,1) != int($::rb_coord_num($bodnum,1)) } {return} |
---|
295 | eval destroy [winfo children $location] |
---|
296 | foreach {top main side lbl} [MakeScrollTable $location] {} |
---|
297 | set ::rb_atom_num_check $::rb_coord_num($bodnum,1) |
---|
298 | set ::rb_mat_num_check $::rb_matrix_num($bodnum) |
---|
299 | set col 0 |
---|
300 | grid [label $top.multilbl -text "Matrix Multiplier"] -row 1 -column 0 |
---|
301 | # grid [label $top.damplbl -text "Damping Factor"] -row 2 -column 0 |
---|
302 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
303 | grid [label $top.matlbl$matrixnum -text "Matrix $matrixnum"] -row 0 -column [expr $col + 2] |
---|
304 | grid [entry $top.multi$matrixnum -textvariable ::rb_mult($bodnum,$matrixnum) -width 7 -takefocus 1] -row 1 -column [expr $col +2] |
---|
305 | # puts "in RB_Create_Cart damp = $::rb_damp($bodnum,$matrixnum)" |
---|
306 | |
---|
307 | # set dampfactors "0 1 2 3 4 5 6 7 8 9" |
---|
308 | # eval tk_optionMenu $top.damp$matrixnum ::rb_damp($bodnum,$matrixnum) $dampfactors |
---|
309 | # grid $top.damp$matrixnum -row 2 -column [expr $col +2] |
---|
310 | # $top.damp$matrixnum config -width 4 |
---|
311 | |
---|
312 | |
---|
313 | # grid [entry $top.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 7 -takefocus 1] -row 2 -column [expr $col +2] |
---|
314 | |
---|
315 | |
---|
316 | if {$::rb_mult($bodnum,$matrixnum) == ""} {set ::rb_mult($bodnum,$matrixnum) 1.000} |
---|
317 | # if {$::rb_damp($bodnum,$matrixnum) == ""} {set ::rb_damp($bodnum,$matrixnum) 0} |
---|
318 | |
---|
319 | grid [label $main.x$matrixnum -text "X"] -row 0 -column [expr $col + 1] |
---|
320 | grid [label $main.y$matrixnum -text "Y"] -row 0 -column [expr $col + 2] |
---|
321 | grid [label $main.z$matrixnum -text "Z"] -row 0 -column [expr $col + 3] |
---|
322 | grid [label $main.b$matrixnum -text " "] -row 0 -column [expr $col +4] |
---|
323 | incr col 4 |
---|
324 | } |
---|
325 | |
---|
326 | for {set coordnum 0} {$coordnum <= [expr $::rb_coord_num($bodnum,1) - 1]} {incr coordnum} { |
---|
327 | grid [label $main.lbl$coordnum -text "Site [expr $coordnum + 1]"] -row [expr $coordnum+10] -column 0 |
---|
328 | set col 0 |
---|
329 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
330 | grid [entry $main.x($matrixnum,$coordnum) -textvariable ::rb_x($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+10] -column [expr $col + 1] |
---|
331 | if {$::rb_x($bodnum,$matrixnum,$coordnum) == ""} {set ::rb_x($bodnum,$matrixnum,$coordnum) 0} |
---|
332 | grid [entry $main.y($matrixnum,$coordnum) -textvariable ::rb_y($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+10] -column [expr $col + 2] |
---|
333 | if {$::rb_y($bodnum,$matrixnum,$coordnum) == ""} {set ::rb_y($bodnum,$matrixnum,$coordnum) 0} |
---|
334 | grid [entry $main.z($matrixnum,$coordnum) -textvariable ::rb_z($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+10] -column [expr $col + 3] |
---|
335 | if {$::rb_z($bodnum,$matrixnum,$coordnum) == ""} {set ::rb_z($bodnum,$matrixnum,$coordnum) 0} |
---|
336 | grid [label $main.b($matrixnum,$coordnum) -text " "] -row [expr $coordnum+10] -column [expr $col +4] |
---|
337 | incr col 4 |
---|
338 | } |
---|
339 | ResizeScrollTable $location |
---|
340 | } |
---|
341 | } |
---|
342 | ######################################################## |
---|
343 | # Procedure to save new rigid body to EXP file. |
---|
344 | |
---|
345 | proc RB_Create_Save {bodnum args} { |
---|
346 | set temp_mat "" |
---|
347 | set temp_car "" |
---|
348 | set temp_mat_group "" |
---|
349 | set temp_car_group "" |
---|
350 | set total "" |
---|
351 | # puts $::::rb_coord_num($bodnum,1) |
---|
352 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
353 | lappend temp_mat $::rb_mult($bodnum,$matrixnum) |
---|
354 | } |
---|
355 | |
---|
356 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
357 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
358 | set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$coordnum) $::rb_y($bodnum,$matrixnum,$coordnum) $::rb_z($bodnum,$matrixnum,$coordnum)" |
---|
359 | lappend temp $temp_cart_triplet |
---|
360 | } |
---|
361 | lappend temp_car $temp |
---|
362 | } |
---|
363 | # puts "sites: $::rb_coord_num($bodnum,1)" |
---|
364 | # puts "matrix multiplier: $temp_mat" |
---|
365 | # puts "cartesian coords: $temp_car" |
---|
366 | AddRigidBody $temp_mat $temp_car |
---|
367 | RecordMacroEntry "AddRigidBody $temp_mat $temp_car" 0 |
---|
368 | |
---|
369 | incr ::expgui(changed) |
---|
370 | destroy .nbt |
---|
371 | RB_Load_RBdata |
---|
372 | RB_Control_Panel $bodnum |
---|
373 | } |
---|
374 | |
---|
375 | ################################################### |
---|
376 | # Procedures to delete rigid bodies |
---|
377 | |
---|
378 | proc RB_Delete_Body {bodnum location args} { |
---|
379 | destroy $location.delete |
---|
380 | set really $location.delete |
---|
381 | toplevel $really |
---|
382 | putontop $really |
---|
383 | wm title $really "Delete Rigid Body" |
---|
384 | grid [label $really.lbl -text "Confirm \n Is rigid body $bodnum to be deleted?"] -row 0 -column 0 -columnspan 2 -pady 15 |
---|
385 | grid [button $really.save -text "Delete" -bg red -command "RB_Delete_Body_Confirm $bodnum $location.delete"] \ |
---|
386 | -row 1 -column 0 -padx 5 -pady 5 |
---|
387 | grid [button $really.abort -text "Abort" -bg green -command "RB_Populate $::rb_notebook $bodnum; \ |
---|
388 | $::rb_notebook raise rb_body$bodnum"] -row 1 -column 1 \ |
---|
389 | -padx 5 -pady 5 |
---|
390 | } |
---|
391 | |
---|
392 | proc RB_Delete_Body_Confirm {bodnum location args} { |
---|
393 | |
---|
394 | # unmap all instances of the rigid body |
---|
395 | foreach phase $::expmap(phaselist) { |
---|
396 | foreach mapnum [RigidBodyMappingList $phase $bodnum] { |
---|
397 | UnMapRigidBody $phase $bodnum $mapnum |
---|
398 | RecordMacroEntry "UnMapRigidBody $phase $bodnum $mapnum" 0 |
---|
399 | } |
---|
400 | } |
---|
401 | # puts "delete rigid body number $bodnum" |
---|
402 | DeleteRigidBody $bodnum |
---|
403 | RecordMacroEntry "DeleteRigidBody $bodnum" 0 |
---|
404 | # puts "destroy location $location" |
---|
405 | destroy $location |
---|
406 | # increment expgui |
---|
407 | incr ::expgui(changed) |
---|
408 | RB_Load_RBdata |
---|
409 | RB_Control_Panel 0 |
---|
410 | } |
---|
411 | |
---|
412 | ############################################################ |
---|
413 | # Procedure to populate notebook pages |
---|
414 | |
---|
415 | proc RB_Populate {rb_notebook bodnum args} { |
---|
416 | RB_Load_RBdata |
---|
417 | set ::rb_panel $bodnum |
---|
418 | set phaselist $::expmap(phaselist) |
---|
419 | # set notebook frame |
---|
420 | set pane [$rb_notebook getframe rb_body$bodnum] |
---|
421 | eval destroy [winfo children $pane] |
---|
422 | set con $pane.con |
---|
423 | grid [frame $con -bd 2 -relief groove] -row 0 -column 1 -pady 10 |
---|
424 | |
---|
425 | #Rigid body mapping control panel along with matrix multipliers and damping factor labels |
---|
426 | grid [label $con.rb_num -text "Rigid Body Type $bodnum"] -row 0 -column 0 -padx 5 -pady 5 |
---|
427 | grid [button $con.rb_newmap -text "Map Body $bodnum" -command "RB_Map_New $bodnum" -width 18] -row 0 -column 1 -padx 5 -pady 5 |
---|
428 | grid [button $con.rb_unmap -text "Unmap Body $bodnum" -command "RB_Unmap $bodnum" -width 18] -row 0 -column 2 -padx 5 -pady 5 |
---|
429 | button $con.rb_delete -text "Delete Body $bodnum" -command "RB_Delete_Body $bodnum $con.rb_delete" -width 18 |
---|
430 | grid $con.rb_delete -row 4 -column 2 -padx 5 -pady 5 |
---|
431 | |
---|
432 | grid [label $con.rb_mlbl1 -text "Matrix"] -row 1 -column 0 |
---|
433 | grid [label $con.rb_mlbl2 -text "Multiplier"] -row 2 -column 0 |
---|
434 | grid [label $con.rb_mlbl3 -text "Damping Factor"] -row 3 -column 0 |
---|
435 | grid [button $con.plot -text "Plot Rigid Body" -command "PlotRBtype $bodnum" -width 18] -row 4 -column 0 |
---|
436 | |
---|
437 | set matrixnum 0 |
---|
438 | for {set mnum 1} {$mnum <= $::rb_matrix_num($bodnum)} {incr mnum} { |
---|
439 | incr matrixnum |
---|
440 | grid [label $con.rb_mm$mnum -text "$mnum"] -row 1 -column $matrixnum |
---|
441 | grid [label $con.rb_mult$mnum -text "$::rb_mult($bodnum,$mnum)"] -row 2 -column $matrixnum |
---|
442 | grid [label $con.rb_damp$mnum -text "$::rb_damp($bodnum,$mnum)"] -row 3 -column $matrixnum |
---|
443 | } |
---|
444 | |
---|
445 | button $con.rb_vmatrix -text "Edit Matrix" -command "RB_Edit_Matrix $bodnum" -width 18 |
---|
446 | grid $con.rb_vmatrix -row 4 -column 1 -padx 5 -pady 5 |
---|
447 | grid [button $con.refine -text "Refinement \n Flags" -command "RB_Refine_Con" -width 18 ] -row 5 -column 1 |
---|
448 | |
---|
449 | # create header for mapping data |
---|
450 | foreach {top main side lbl} [MakeScrollTable $pane] {} |
---|
451 | grid [label $main.rb_origin -text "Origin"] -row 0 -column 3 -columnspan 3 |
---|
452 | grid [label $main.rb_euler -text "Euler Angles"] -row 0 -column 6 -columnspan 3 |
---|
453 | grid [label $main.rb_site -text "Sites"] -row 0 -column 10 -columnspan 3 |
---|
454 | grid [label $main.rb_ref -text "Phase"] -row 1 -column 2 |
---|
455 | grid [label $main.rb_map -text "Map"] -row 1 -column 1 |
---|
456 | grid [label $main.rb_x -text "x"] -row 1 -column 3 |
---|
457 | grid [label $main.rb_y -text "y"] -row 1 -column 4 |
---|
458 | grid [label $main.rb_z -text "z"] -row 1 -column 5 |
---|
459 | grid [label $main.rb_euler_x -text "x"] -row 1 -column 6 |
---|
460 | grid [label $main.rb_euler_y -text "y"] -row 1 -column 7 |
---|
461 | grid [label $main.rb_euler_z -text "z"] -row 1 -column 8 |
---|
462 | set col 11 |
---|
463 | for {set coordnum 1} {$coordnum <= $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
464 | label $main.rb_site$coordnum -text "$coordnum" |
---|
465 | grid $main.rb_site$coordnum -row 1 -column $col -padx 5 |
---|
466 | incr col |
---|
467 | } |
---|
468 | |
---|
469 | # populate mapping data table |
---|
470 | set row 2 |
---|
471 | foreach phase $phaselist { |
---|
472 | incr row |
---|
473 | foreach mapnum [RigidBodyMappingList $phase $bodnum] { |
---|
474 | set row [expr $row + $mapnum] |
---|
475 | RB_Load_Mapdata $phase $bodnum $mapnum |
---|
476 | grid [label $main.rb_map$phase$mapnum -text "$mapnum"] -row $row -column 1 |
---|
477 | grid [label $main.rb_cb$phase$mapnum -text $phase] -row $row -column 2 |
---|
478 | set origin $::rb_map_origin($phase,$bodnum,$mapnum) |
---|
479 | |
---|
480 | grid [label $main.rb_x$phase$mapnum -text "[format %1.3f [lindex $origin 0]]"] -row $row -column 3 -padx 5 |
---|
481 | grid [label $main.rb_y$phase$mapnum -text "[format %1.3f [lindex $origin 1]]"] -row $row -column 4 -padx 5 |
---|
482 | grid [label $main.rb_z$phase$mapnum -text "[format %1.3f [lindex $origin 2]]"] -row $row -column 5 -padx 5 |
---|
483 | set euler $::rb_map_euler($phase,$bodnum,$mapnum) |
---|
484 | for {set j 0} {$j < 3} {incr j} { |
---|
485 | set euler1 [lindex $euler $j] |
---|
486 | set angle [lindex $euler1 0] |
---|
487 | set axis [lindex $euler1 1] |
---|
488 | label $main.rb_euler_$phase$mapnum$axis -text "[format %1.2f $angle]" |
---|
489 | } |
---|
490 | |
---|
491 | grid [label $main.rb_tls$phase$mapnum -text " "] -row $row -column 9 |
---|
492 | set q 1 |
---|
493 | grid $main.rb_euler_$phase$mapnum$q -row $row -column 6 -padx 5 |
---|
494 | set q 2 |
---|
495 | grid $main.rb_euler_$phase$mapnum$q -row $row -column 7 -padx 5 |
---|
496 | set q 3 |
---|
497 | grid $main.rb_euler_$phase$mapnum$q -row $row -column 8 -padx 5 |
---|
498 | set col 11 |
---|
499 | set atomnum $::rb_map_beginning($phase,$bodnum,$mapnum) |
---|
500 | for {set coordnum 1} {$coordnum <=$::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
501 | set atom [atominfo $phase $atomnum label] |
---|
502 | grid [label $main.rb_site$phase$mapnum$coordnum -text "$atom"] -row $row -column $col -padx 5 |
---|
503 | incr atomnum |
---|
504 | incr col |
---|
505 | } |
---|
506 | } |
---|
507 | incr row |
---|
508 | } |
---|
509 | ResizeScrollTable $pane |
---|
510 | } |
---|
511 | |
---|
512 | proc DisplayRB {} { ;# called each time the panel is raised |
---|
513 | eval destroy [winfo children $::expgui(rbFrame)] |
---|
514 | RB_Load_RBdata |
---|
515 | RB_Control_Panel 0 |
---|
516 | #label $::expgui(rbFrame).l -text "RB Parameters" |
---|
517 | #grid $::expgui(rbFrame).l -column 1 -row 1 |
---|
518 | ResizeNotebook |
---|
519 | } |
---|
520 | |
---|
521 | proc MakeRBPane {} { ;# called to create the panel intially |
---|
522 | # label $::expgui(rbFrame).l -text "RB Parameters" |
---|
523 | # grid $::expgui(rbFrame).l -column 1 -row 1 |
---|
524 | # ResizeNotebook |
---|
525 | } |
---|
526 | |
---|
527 | ####################################################################### |
---|
528 | # New Mapping Event |
---|
529 | # not updated |
---|
530 | |
---|
531 | proc RB_Map_New {bodnum args} { |
---|
532 | catch {unset ::rb_firstatom} |
---|
533 | set ::rb_firstatom "" |
---|
534 | set ::body_type $bodnum |
---|
535 | catch {destroy .newmap} |
---|
536 | set nm .newmap |
---|
537 | toplevel $nm |
---|
538 | putontop $nm |
---|
539 | wm title $nm "Map Rigid Body #$bodnum" |
---|
540 | |
---|
541 | foreach item [trace vinfo ::rb_phase] { |
---|
542 | eval trace vdelete ::rb_phase $item |
---|
543 | } |
---|
544 | |
---|
545 | set ::rb_phase [lindex $::expmap(phaselist) 0] |
---|
546 | set nmap [expr $::rb_map($bodnum) + 1] |
---|
547 | eval tk_optionMenu $nm.pinput ::rb_phase $::expmap(phaselist) |
---|
548 | grid [label $nm.phase -text "Phase: "] -row 3 -column 1 |
---|
549 | grid [label $nm.f_atom -text "Choose first atom Number"] -row 4 -column 1 |
---|
550 | grid [label $nm.origin -text "input origin in fractional coordinates: "] -row 6 -column 1 |
---|
551 | grid [label $nm.euler -text "input Euler angles: "] -row 7 -column 1 |
---|
552 | grid [entry $nm.finputm -textvariable ::rb_firstatom -width 8 -takefocus 1] -row 4 -column 2 |
---|
553 | |
---|
554 | foreach item [trace vinfo ::rb_firstatom] { |
---|
555 | eval trace vdelete ::rb_firstatom $item |
---|
556 | } |
---|
557 | trace variable ::rb_firstatom w "RB_Atom_List \$::rb_phase \$::rb_firstatom $nm $bodnum" |
---|
558 | |
---|
559 | grid [button $nm.finput -text "list allowed" -command "RB_Choose_Atom $bodnum"] -row 4 -column 3 |
---|
560 | grid [label $nm.o1l -text "x"] -row 5 -column 2 |
---|
561 | grid [label $nm.o2l -text "y"] -row 5 -column 3 |
---|
562 | grid [label $nm.o3l -text "z"] -row 5 -column 4 |
---|
563 | |
---|
564 | set ::origin1 0 |
---|
565 | set ::origin2 0 |
---|
566 | set ::origin3 0 |
---|
567 | set ::euler1 0 |
---|
568 | set ::euler2 0 |
---|
569 | set ::euler3 0 |
---|
570 | |
---|
571 | grid [entry $nm.o1 -width 8 -textvariable ::origin1 -takefocus 1] -row 6 -column 2 |
---|
572 | grid [entry $nm.o2 -width 8 -textvariable ::origin2 -takefocus 1] -row 6 -column 3 |
---|
573 | grid [entry $nm.o3 -width 8 -textvariable ::origin3 -takefocus 1] -row 6 -column 4 |
---|
574 | grid [entry $nm.e1 -width 8 -textvariable ::euler1 -takefocus 1] -row 7 -column 2 |
---|
575 | grid [entry $nm.e2 -width 8 -textvariable ::euler2 -takefocus 1] -row 7 -column 3 |
---|
576 | grid [entry $nm.e3 -width 8 -textvariable ::euler3 -takefocus 1] -row 7 -column 4 |
---|
577 | |
---|
578 | grid $nm.pinput -row 3 -column 3 |
---|
579 | |
---|
580 | grid [frame $nm.p] -row 8 -column 1 -columnspan 4 -sticky e |
---|
581 | grid [button $nm.p.fit -text "Fit rigid body to phase" -command "RB_FitBody2Coords $bodnum $nm; RB_View_RMS $nm"] -row 0 -column 1 |
---|
582 | grid [button $nm.p.plot -text "Plot rigid body & phase" -command "RB_PlotStrBody $bodnum $nm"] -row 1 -column 1 |
---|
583 | grid [label $nm.p.l -text "Bonds: "] -row 1 -column 2 |
---|
584 | grid [entry $nm.p.e] -row 1 -column 3 |
---|
585 | $nm.p.e delete 0 end |
---|
586 | $nm.p.e insert 0 "0.9-1.1, 1.3-1.6" |
---|
587 | |
---|
588 | grid [frame $nm.l] -row 9 -column 2 -columnspan 3 |
---|
589 | grid [button $nm.l.s -text "map update" -width 12 -command {RB_Write_Map}] -column 1 -row 1 |
---|
590 | grid [button $nm.l.q -text "Abort" -width 6 -command "destroy $nm"] -column 2 -row 1 |
---|
591 | |
---|
592 | foreach item [trace vinfo ::rb_phase] { |
---|
593 | eval trace vdelete ::rb_phase $item |
---|
594 | } |
---|
595 | trace variable ::rb_phase w "RB_ProcessPhase $bodnum" |
---|
596 | } |
---|
597 | |
---|
598 | proc RB_View_RMS {address args} { |
---|
599 | set addrms $address.rms |
---|
600 | catch {destroy $addrms} |
---|
601 | grid [frame $addrms -bd 2] -row 5 -column 8 -columnspan 99 -rowspan 99 |
---|
602 | set row 1 |
---|
603 | |
---|
604 | grid [label $addrms.atomlbl -text " atom"] -row 0 -column 0 |
---|
605 | grid [label $addrms.rmslbl -text "\t rms"] -row 0 -column 1 |
---|
606 | foreach i $::rb_atom_rms { |
---|
607 | set atom [lindex $i 0] |
---|
608 | set temp [lindex $i 1] |
---|
609 | set rms [format %.3f $temp] |
---|
610 | set id [string tolower $atom] |
---|
611 | grid [label $addrms.$id$row -text " $atom"] -row $row -column 0 |
---|
612 | grid [label $addrms.rms$id$row -text "\t $rms"] -row $row -column 1 |
---|
613 | incr row |
---|
614 | } |
---|
615 | } |
---|
616 | |
---|
617 | ########################################################### |
---|
618 | # Procedure for choosing first atom during mapping event. |
---|
619 | # not updated |
---|
620 | |
---|
621 | proc RB_Choose_Atom {bodnum args} { |
---|
622 | set phase $::rb_phase |
---|
623 | # get the number of atoms in this type of body |
---|
624 | set natoms [llength [lindex [lindex [lindex [ReadRigidBody $bodnum] 1] 0] 3]] |
---|
625 | set atomlist [RigidStartAtoms $::rb_phase $natoms] |
---|
626 | if {[llength $atomlist] == 0} { |
---|
627 | RB_ProcessPhase $bodnum |
---|
628 | return |
---|
629 | } |
---|
630 | catch {destroy .chooseatom} |
---|
631 | set ca .chooseatom |
---|
632 | toplevel $ca |
---|
633 | wm title $ca "Choose Atom" |
---|
634 | # puts $atomlist |
---|
635 | foreach {top main side lbl} [MakeScrollTable $ca] {} |
---|
636 | set row 0 |
---|
637 | set column 0 |
---|
638 | foreach atom $atomlist { |
---|
639 | set label "[atominfo $phase $atom label] \($atom\)" |
---|
640 | button $main.$atom -text $label -command "set ::rb_firstatom $atom; destroy $ca" |
---|
641 | incr row |
---|
642 | if {$row > 5} { |
---|
643 | set row 1 |
---|
644 | incr column |
---|
645 | } |
---|
646 | grid $main.$atom -row $row -column $column -padx 5 -pady 5 |
---|
647 | } |
---|
648 | ResizeScrollTable $ca |
---|
649 | putontop $ca |
---|
650 | tkwait window $ca |
---|
651 | afterputontop |
---|
652 | raise .newmap |
---|
653 | } |
---|
654 | |
---|
655 | ########################################################## |
---|
656 | ########################################################## |
---|
657 | |
---|
658 | proc RB_FitBody2Coords {bodnum menu} { |
---|
659 | set warn "" |
---|
660 | foreach i {1 2 3} lbl {x y z} { |
---|
661 | if {[string trim [set ::euler$i]] == ""} { |
---|
662 | set ::euler$i 0.0 |
---|
663 | } |
---|
664 | if {[string trim [set ::origin$i]] == ""} { |
---|
665 | set ::origin$i .0 |
---|
666 | } |
---|
667 | if {[catch {expr [set ::euler$i]}]} { |
---|
668 | append warn "\tError in Euler angle around $lbl\n" |
---|
669 | } |
---|
670 | if {[catch {expr [set ::origin$i]}]} { |
---|
671 | append warn "\tError in origin $lbl\n" |
---|
672 | } |
---|
673 | } |
---|
674 | if {[catch {expr $::rb_firstatom}]} { |
---|
675 | append warn "\tError in 1st atom number\n" |
---|
676 | } |
---|
677 | if {$warn != ""} { |
---|
678 | MyMessageBox -parent $menu -title "Input error" \ |
---|
679 | -message "Invalid input:\n$warn" -icon warning |
---|
680 | return |
---|
681 | } |
---|
682 | set Euler [list "1 $::euler1" "2 $::euler2" "3 $::euler3"] |
---|
683 | set origin "$::origin1 $::origin2 $::origin3" |
---|
684 | set phase $::rb_phase |
---|
685 | set cell {} |
---|
686 | foreach p {a b c alpha beta gamma} { |
---|
687 | lappend cell [phaseinfo $phase $p] |
---|
688 | } |
---|
689 | set coords [RB2cart [lindex [ReadRigidBody $bodnum] 1]] |
---|
690 | set natom [llength $coords] |
---|
691 | set firstind [lsearch $::expmap(atomlist_$phase) $::rb_firstatom] |
---|
692 | set atoms [lrange \ |
---|
693 | [lrange $::expmap(atomlist_$phase) $firstind end] \ |
---|
694 | 0 [expr {$natom-1}]] |
---|
695 | # now loop over atoms |
---|
696 | set frcoords {} |
---|
697 | foreach atom $atoms { |
---|
698 | set xyz {} |
---|
699 | foreach v {x y z} { |
---|
700 | lappend xyz [atominfo $phase $atom $v] |
---|
701 | } |
---|
702 | lappend frcoords $xyz |
---|
703 | } |
---|
704 | # it would be nice to have checkboxes for each atom, but for now use em all |
---|
705 | set useflags {} |
---|
706 | foreach i $coords {lappend useflags 1} |
---|
707 | # puts "frcoords $frcoords" |
---|
708 | # puts "coords $coords" |
---|
709 | # do the fit |
---|
710 | foreach {neworigin newEuler rmsdev newfrac rmsbyatom} \ |
---|
711 | [FitBody $Euler $cell $coords $useflags $frcoords $origin] {} |
---|
712 | foreach i {1 2 3} val $neworigin pair $newEuler { |
---|
713 | set ::origin$i $val |
---|
714 | set ::euler$i [lindex $pair 1] |
---|
715 | } |
---|
716 | # show deviations |
---|
717 | |
---|
718 | set ::rb_atom_rms "" |
---|
719 | foreach atom $atoms rms $rmsbyatom { |
---|
720 | # puts "[atominfo $phase $atom label]\t$rms" |
---|
721 | lappend ::rb_atom_rms "[atominfo $phase $atom label] $rms" |
---|
722 | } |
---|
723 | #puts "CalcBody $Euler $cell $coords $origin" |
---|
724 | #puts $coords |
---|
725 | #puts $frcoords |
---|
726 | #DRAWxtlPlotRBFit $frcoords $phase $::rb_firstatom 0 $bondlist $bondlist |
---|
727 | } |
---|
728 | |
---|
729 | proc RB_PlotStrBody {bodnum menu} { |
---|
730 | set warn "" |
---|
731 | foreach i {1 2 3} lbl {x y z} { |
---|
732 | if {[catch {expr [set ::euler$i]}]} { |
---|
733 | append warn "\tError in Euler angle around $lbl\n" |
---|
734 | } |
---|
735 | if {[catch {expr [set ::origin$i]}]} { |
---|
736 | append warn "\tError in origin $lbl\n" |
---|
737 | } |
---|
738 | } |
---|
739 | if {[catch {expr $::rb_firstatom}]} { |
---|
740 | append warn "\tError in 1st atom number\n" |
---|
741 | } |
---|
742 | if {$warn != ""} { |
---|
743 | MyMessageBox -parent $menu -title "Input error" \ |
---|
744 | -message "Invalid input:\n$warn" -icon warning |
---|
745 | return |
---|
746 | } |
---|
747 | # translate bond list |
---|
748 | set bl [$menu.p.e get] |
---|
749 | regsub -all "," $bl " " bl |
---|
750 | set bondlist {} |
---|
751 | set warn "" |
---|
752 | foreach b $bl { |
---|
753 | if {[llength [split $b "-"]] == 2} { |
---|
754 | lappend bondlist [split $b "-"] |
---|
755 | } else { |
---|
756 | set warn "error parsing bond list" |
---|
757 | } |
---|
758 | } |
---|
759 | if {$warn != ""} { |
---|
760 | MyMessageBox -parent . -title "Input warning" \ |
---|
761 | -message "Invalid bond input" -icon warning |
---|
762 | } |
---|
763 | set Euler [list "1 $::euler1" "2 $::euler2" "3 $::euler3"] |
---|
764 | set origin "$::origin1 $::origin2 $::origin3" |
---|
765 | set phase $::rb_phase |
---|
766 | set cell {} |
---|
767 | foreach p {a b c alpha beta gamma} { |
---|
768 | lappend cell [phaseinfo $phase $p] |
---|
769 | } |
---|
770 | set coords [RB2cart [lindex [ReadRigidBody $bodnum] 1]] |
---|
771 | set frcoords [CalcBody $Euler $cell $coords $origin] |
---|
772 | #puts "CalcBody $Euler $cell $coords $origin" |
---|
773 | #puts $coords |
---|
774 | #puts $frcoords |
---|
775 | DRAWxtlPlotRBFit $frcoords $phase $::rb_firstatom 0 $bondlist $bondlist |
---|
776 | } |
---|
777 | # |
---|
778 | |
---|
779 | proc RB_Write_Map {args} { |
---|
780 | if {$::rb_firstatom == ""} { |
---|
781 | MyMessageBox -title "warning" -message "The first atom for the rigid body must be choosen to update mapping" |
---|
782 | return |
---|
783 | } |
---|
784 | set origin "$::origin1 $::origin2 $::origin3" |
---|
785 | set euler "$::euler1 $::euler2 $::euler3" |
---|
786 | # puts "phase = $::rb_phase" |
---|
787 | # puts "bodnum = $::body_type" |
---|
788 | # puts "firstatom = $::rb_firstatom" |
---|
789 | # puts "position = $origin" |
---|
790 | # puts "Euler = $euler" |
---|
791 | MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler |
---|
792 | RecordMacroEntry "MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler" 0 |
---|
793 | incr ::rb_map($::body_type) |
---|
794 | incr ::expgui(changed) |
---|
795 | set curpage [$::rb_notebook raise] |
---|
796 | $::rb_notebook raise [$::rb_notebook page end] |
---|
797 | $::rb_notebook raise $curpage |
---|
798 | destroy .newmap |
---|
799 | RunRecalcRBCoords |
---|
800 | incr ::expgui(changed) |
---|
801 | RB_Populate $::rb_notebook $::body_type |
---|
802 | $::rb_notebook raise rb_body$::body_type |
---|
803 | } |
---|
804 | |
---|
805 | proc RB_Atom_List {phase atomnum address bodnum args} { |
---|
806 | foreach w [winfo children $address] { |
---|
807 | if {[string first ".atom" $w] != -1} {destroy $w} |
---|
808 | } |
---|
809 | set col 8 |
---|
810 | if {$atomnum == ""} return |
---|
811 | grid [label $address.atomlbl -text "Atoms Mapped to Rigid Body"] -row 3 -column 8 -columnspan 99 |
---|
812 | # get the number of atoms in this type of body |
---|
813 | set natoms [llength [lindex [lindex [lindex [ReadRigidBody $bodnum] 1] 0] 3]] |
---|
814 | set atoms [RigidStartAtoms $phase $natoms] |
---|
815 | if {[lsearch $atoms $atomnum] == -1} { |
---|
816 | grid [label $address.atomerr -text "(invalid 1st atom)"] -row 4 -column $col |
---|
817 | return |
---|
818 | } |
---|
819 | set atoms [lrange $::expmap(atomlist_$phase) \ |
---|
820 | [lsearch $::expmap(atomlist_$phase) $atomnum] end] |
---|
821 | foreach j [lrange $atoms 0 [expr {$natoms - 1}]] { |
---|
822 | set atom [atominfo $phase $j label] |
---|
823 | grid [label $address.atom$phase$bodnum$j -text $atom] -row 4 -column $col |
---|
824 | incr col |
---|
825 | } |
---|
826 | } |
---|
827 | |
---|
828 | proc RB_ProcessPhase {bodnum args} { |
---|
829 | if {$::rb_phase == ""} { |
---|
830 | set atoms {} |
---|
831 | } else { |
---|
832 | # get the number of atoms in this type of body |
---|
833 | set natoms [llength [lindex [lindex [lindex [ReadRigidBody $bodnum] 1] 0] 3]] |
---|
834 | |
---|
835 | set atoms [RigidStartAtoms $::rb_phase $natoms] |
---|
836 | } |
---|
837 | set nm .newmap |
---|
838 | if {[llength $atoms] == 0} { |
---|
839 | foreach w "$nm.finputm $nm.p.plot $nm.p.fit $nm.p.e $nm.l.s" { |
---|
840 | $w config -state disabled |
---|
841 | } |
---|
842 | $nm.finput config -text "None allowed" -state disabled |
---|
843 | } else { |
---|
844 | foreach w "$nm.finputm $nm.p.plot $nm.p.fit $nm.p.e $nm.l.s" { |
---|
845 | $w config -state normal |
---|
846 | } |
---|
847 | $nm.finput config -text "Show allowed" -state normal |
---|
848 | } |
---|
849 | } |
---|
850 | |
---|
851 | proc RB_Unmap {bodnum args} { |
---|
852 | catch {unset ::rb_firstatom} |
---|
853 | set ::rb_firstatom "" |
---|
854 | set ::body_type $bodnum |
---|
855 | catch {destroy .unmap} |
---|
856 | set um .unmap |
---|
857 | toplevel $um |
---|
858 | putontop $um |
---|
859 | wm title $um "Map Rigid Body #$bodnum" |
---|
860 | set ::phase 1 |
---|
861 | set umap $::rb_map($bodnum) |
---|
862 | # eval tk_optionMenu $um.pinput ::rb_phase $::expmap(phaselist) |
---|
863 | # grid [label $um.phase -text "Phase: "] -row 3 -column 1 |
---|
864 | # grid $um.pinput -row 3 -column 2 |
---|
865 | |
---|
866 | set mapnumber $::rb_map($bodnum) |
---|
867 | set unpane $um.pane |
---|
868 | foreach {top main side lbl} [MakeScrollTable $um] {} |
---|
869 | grid [label $main.cb -text "unmap"] -row 1 -column 0 -padx 5 |
---|
870 | grid [label $main.map -text "map"] -row 1 -column 1 -padx 5 |
---|
871 | grid [label $main.ph -text "Phase"] -row 1 -column 2 -padx 5 |
---|
872 | set matrixnum $::rb_matrix_num($bodnum) |
---|
873 | for {set coordnum 1} {$coordnum <= $::rb_coord_num($bodnum,$matrixnum)} {incr coordnum} { |
---|
874 | label $main.rb_site$coordnum -text "Site $coordnum" |
---|
875 | grid $main.rb_site$coordnum -row 1 -column [expr 2 + $coordnum] |
---|
876 | } |
---|
877 | set row 2 |
---|
878 | foreach phase $::expmap(phaselist) { |
---|
879 | incr row |
---|
880 | foreach coordnum [RigidBodyMappingList $phase $bodnum] { |
---|
881 | set row [expr $row + $coordnum] |
---|
882 | RB_Load_Mapdata $phase $bodnum $coordnum |
---|
883 | checkbutton $main.unmap$phase$coordnum -variable ::rb_unmap($phase,$bodnum,$coordnum) |
---|
884 | grid $main.unmap$phase$coordnum -row $row -column 0 |
---|
885 | grid [label $main.rb_map$phase$coordnum -text "$coordnum"] -row $row -column 1 |
---|
886 | grid [label $main.rb_cb$phase$coordnum -text $phase] -row $row -column 2 |
---|
887 | set atomnum $::rb_map_beginning($phase,$bodnum,$coordnum) |
---|
888 | set col 3 |
---|
889 | for {set j 1} {$j <=$::rb_coord_num($bodnum,$matrixnum)} {incr j} { |
---|
890 | set atom [atominfo $phase $atomnum label] |
---|
891 | grid [label $main.rb_site$phase$coordnum$j -text "$atom"] -row $row -column $col |
---|
892 | incr atomnum |
---|
893 | incr col |
---|
894 | } |
---|
895 | } |
---|
896 | incr row |
---|
897 | } |
---|
898 | ResizeScrollTable $um |
---|
899 | |
---|
900 | grid [frame $um.update -bd 2 -relief groove] -row 0 -column 1 -pady 10 |
---|
901 | button $um.update.con -text "Update Rigid Body Mapping" -command "RB_unmap_delete $um $bodnum" |
---|
902 | button $um.update.abort -text "Abort" -command "destroy $um" |
---|
903 | grid $um.update.con -row 0 -column 0 -padx 5 -pady 5 |
---|
904 | grid $um.update.abort -row 0 -column 1 |
---|
905 | incr ::expgui(changed) |
---|
906 | |
---|
907 | } |
---|
908 | |
---|
909 | proc RB_unmap_delete {panel bodnum args} { |
---|
910 | # puts $panel |
---|
911 | foreach phase $::expmap(phaselist) { |
---|
912 | foreach mapnum [RigidBodyMappingList $phase $bodnum] { |
---|
913 | if {$::rb_unmap($phase,$bodnum,$mapnum) == 1} { |
---|
914 | RecordMacroEntry "UnMapRigidBody $phase $bodnum $mapnum" 0 |
---|
915 | UnMapRigidBody $phase $bodnum $mapnum |
---|
916 | } |
---|
917 | } |
---|
918 | incr ::expgui(changed) |
---|
919 | destroy $panel |
---|
920 | set curpage [$::rb_notebook raise] |
---|
921 | RB_Populate $::rb_notebook $bodnum |
---|
922 | $::rb_notebook raise rb_body$bodnum |
---|
923 | } |
---|
924 | } |
---|
925 | |
---|
926 | proc RB_Create_from_Edit {args} { |
---|
927 | set bodnum [RB_New_RBnum] |
---|
928 | RB_Create_Save $bodnum |
---|
929 | } |
---|
930 | |
---|
931 | |
---|
932 | |
---|
933 | proc RB_Edit_Matrix {bodnum args} { |
---|
934 | # puts "Bodnum = $bodnum" |
---|
935 | catch {destroy .viewmatrix} |
---|
936 | set em .viewmatrix |
---|
937 | toplevel $em |
---|
938 | putontop $em |
---|
939 | wm title $em "Edit Matrices for Rigid Body $bodnum" |
---|
940 | |
---|
941 | set vm $em.entry |
---|
942 | set um $em.update |
---|
943 | set sm $em.sort |
---|
944 | grid [frame $vm -bd 2 -relief groove] -row 0 -column 0 -columnspan 2 |
---|
945 | grid [frame $sm -bd 2 -relief groove] -row 1 -column 0 -columnspan 2 -pady 10 |
---|
946 | grid [frame $um -bd 2 -relief groove] -row 2 -column 0 -columnspan 2 |
---|
947 | |
---|
948 | # Editor Options |
---|
949 | grid [label $sm.title -text "Matrix Editor Control Panel"] -row 0 -column 0 -columnspan 4 |
---|
950 | grid [label $sm.sort -width 21 -text "Move Checked Elements"] -row 1 -column 0 |
---|
951 | grid [button $sm.inc -text "\u2191" -command "RB_Sort_Inc $bodnum inc"] -row 1 -column 1 -padx 5 |
---|
952 | grid [button $sm.dec -text "\u2193" -command "RB_Sort_Inc $bodnum dec"] -row 1 -column 2 -padx 5 |
---|
953 | grid [button $sm.swap -width 21 -text "Swap Checked Elements" -command "RB_Sort_Swap $bodnum"] -row 2 -column 0 -columnspan 3 |
---|
954 | grid [button $sm.delete -width 21 -text "Delete Checked Elements" -command "RB_Delete_Element $bodnum"] -row 3 -column 0 -columnspan 3 |
---|
955 | grid [button $sm.add -width 21 -text "Increase Number of Sites" -command "RB_Add_Element $bodnum"] -row 4 -column 0 -columnspan 3 |
---|
956 | grid [button $sm.addmatrix -width 21 -text "Add New Matrix" -command "RB_Add_New_Matrix $bodnum"] -row 5 -column 0 -columnspan 3 |
---|
957 | |
---|
958 | # Save Options |
---|
959 | grid [button $um.update -width 24 -text "Save Changes" -bg green -command "RB_Matrix_Update $bodnum"] -row 3 -column 0 -padx 5 |
---|
960 | grid [button $um.new -width 24 -text "Save Rigid Body Type" -command "RB_Create_from_Edit"] -row 0 -column 1 -padx 5 |
---|
961 | # grid [button $um.sort -text "Sort Matrix Info" -command "RB_Cart_Sort $bodnum"] -row 0 -column 1 |
---|
962 | |
---|
963 | grid [button $um.print -width 24 -text "Export Cartesian \n Coordinates to File" -command "RB_CartesianTextFile $bodnum"] -row 2 -column 1 -pady 5 |
---|
964 | grid [button $um.restore -width 24 -text "Undo Changes" -command "RB_Restore_Matrix $bodnum"] -row 3 -column 1 -padx 5 |
---|
965 | grid [button $um.abort -text "Abort" -width 24 -command "RB_Edit_Matrix_Abort $bodnum $em"] -row 3 -column 2 -padx 5 |
---|
966 | |
---|
967 | grid [label $vm.lblmm -text "Matrix Multiplier"] -row 3 -column 2 |
---|
968 | grid [label $vm.lbldamp -text "Damping Factor"] -row 4 -column 2 |
---|
969 | grid [label $vm.lblvar -text "Refine Multiplier"] -row 5 -column 2 |
---|
970 | |
---|
971 | set w 1 |
---|
972 | grid [label $vm.site -text "sort"] -row 6 -column 0 -columnspan 2 |
---|
973 | |
---|
974 | |
---|
975 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} { |
---|
976 | grid [checkbutton $vm.sort$coordnum -variable ::rb_sort($coordnum)] -row [expr $coordnum + 7] -column 1 |
---|
977 | grid [label $vm.lbls$coordnum -text "Site [expr $coordnum + 1]"] -row [expr $coordnum + 7] -column 2 |
---|
978 | } |
---|
979 | set col 3 |
---|
980 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
981 | grid [label $vm.lblm$matrixnum -text "Matrix #$matrixnum"] -row 2 -column [expr $col +1] |
---|
982 | grid [entry $vm.mult$matrixnum -textvariable ::rb_mult($bodnum,$matrixnum) -width 8 -takefocus 1] -row 3 -column [expr $col + 1] |
---|
983 | set dampfactors "0 1 2 3 4 5 6 7 8 9" |
---|
984 | eval tk_optionMenu $vm.damp$matrixnum ::rb_damp($bodnum,$matrixnum) $dampfactors |
---|
985 | grid $vm.damp$matrixnum -row 4 -column [expr $col + 1] |
---|
986 | $vm.damp$matrixnum config -width 4 |
---|
987 | # grid [entry $vm.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 8 -takefocus 1 -state normal] -row 4 -column [expr $col + 1] |
---|
988 | grid [checkbutton $vm.var$matrixnum -variable ::rb_varcheck($bodnum,$matrixnum) -text $::rb_var($bodnum,$matrixnum) \ |
---|
989 | -state normal -command "RB_MMultRef $bodnum $matrixnum"] -row 5 -column [expr $col +1] |
---|
990 | |
---|
991 | grid [label $vm.x$matrixnum -text "X"] -row 6 -column [expr $col] |
---|
992 | grid [label $vm.y$matrixnum -text "Y"] -row 6 -column [expr $col + 1] |
---|
993 | grid [label $vm.z$matrixnum -text "Z"] -row 6 -column [expr $col + 2] |
---|
994 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} { |
---|
995 | # puts $::rb_coord($bodnum,$i,$j) |
---|
996 | |
---|
997 | set ::rb_x($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0] |
---|
998 | set ::rb_y($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 1] |
---|
999 | set ::rb_z($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 2] |
---|
1000 | set ::rb_lbl($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 3] |
---|
1001 | |
---|
1002 | |
---|
1003 | grid [entry $vm.lblcx$matrixnum$coordnum -textvariable ::rb_x($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col] |
---|
1004 | grid [entry $vm.lblcy$matrixnum$coordnum -textvariable ::rb_y($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col + 1] |
---|
1005 | grid [entry $vm.lblcz$matrixnum$coordnum -textvariable ::rb_z($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col + 2] |
---|
1006 | grid [label $vm.lblcb$matrixnum$coordnum -text " "] -row [expr $coordnum+6] -column [expr $col + 3] |
---|
1007 | } |
---|
1008 | incr col 4 |
---|
1009 | } |
---|
1010 | } |
---|
1011 | |
---|
1012 | proc RB_Restore_Matrix {bodnum} { |
---|
1013 | set ::rb_matrix_num($bodnum) $::rb_matrix_num_temp($bodnum) |
---|
1014 | set ::rb_coord_num($bodnum,1) $::rb_coord_num_temp($bodnum,1) |
---|
1015 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
1016 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
1017 | set ::rb_coord($bodnum,$matrixnum,$coordnum) $::rb_coord_temp($bodnum,$matrixnum,$coordnum) |
---|
1018 | |
---|
1019 | } |
---|
1020 | } |
---|
1021 | RB_Edit_Matrix $bodnum |
---|
1022 | } |
---|
1023 | |
---|
1024 | proc RB_Add_New_Matrix {bodnum} { |
---|
1025 | incr ::rb_matrix_num($bodnum) |
---|
1026 | set matrixnum $::rb_matrix_num($bodnum) |
---|
1027 | set ::rb_var($bodnum,$matrixnum) 0 |
---|
1028 | set ::rb_mult($bodnum,$matrixnum) 1.000 |
---|
1029 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
1030 | set ::rb_coord($bodnum,$matrixnum,$::rb_coord_num($bodnum,1) "" |
---|
1031 | lappend ::rb_coord($bodnum,$matrixnum,$coordnum) 0 0 0 lbl |
---|
1032 | } |
---|
1033 | RB_Edit_Matrix $bodnum |
---|
1034 | |
---|
1035 | |
---|
1036 | } |
---|
1037 | |
---|
1038 | |
---|
1039 | |
---|
1040 | proc RB_Edit_Matrix_Abort {bodnum location} { |
---|
1041 | # reset matrix |
---|
1042 | # set ::rb_coord_num($bodnum,1) $::rb_coord_num_temp($bodnum,1) |
---|
1043 | # for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
1044 | # for {set coordnum 0} {$coordnum < $::rb_coord_num_temp($bodnum,1)} {incr coordnum} { |
---|
1045 | # set ::rb_coord($bodnum,$matrixnum,$coordnum) $::rb_coord_temp($bodnum,$matrixnum,$coordnum) |
---|
1046 | # } |
---|
1047 | # } |
---|
1048 | destroy $location |
---|
1049 | } |
---|
1050 | |
---|
1051 | proc RB_Add_Element {bodnum} { |
---|
1052 | incr ::rb_coord_num($bodnum,1) |
---|
1053 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
1054 | set ::rb_coord($bodnum,$matrixnum,$::rb_coord_num($bodnum,1) "" |
---|
1055 | lappend ::rb_coord($bodnum,$matrixnum,[expr $::rb_coord_num($bodnum,1)- 1]) 0 0 0 lbl |
---|
1056 | puts $::rb_coord($bodnum,$matrixnum,[expr $::rb_coord_num($bodnum,1) - 1]) |
---|
1057 | } |
---|
1058 | RB_Edit_Matrix $bodnum |
---|
1059 | } |
---|
1060 | |
---|
1061 | proc RB_Delete_Element {bodnum} { |
---|
1062 | |
---|
1063 | set newcoord 0 |
---|
1064 | set deletedrecords 0 |
---|
1065 | |
---|
1066 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
1067 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
1068 | |
---|
1069 | if {$::rb_sort($coordnum) != 1} { |
---|
1070 | set xtemp $::rb_x($bodnum,$matrixnum,$coordnum) |
---|
1071 | set ytemp $::rb_y($bodnum,$matrixnum,$coordnum) |
---|
1072 | set ztemp $::rb_z($bodnum,$matrixnum,$coordnum) |
---|
1073 | set lbltemp [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 3] |
---|
1074 | |
---|
1075 | |
---|
1076 | set ::rb_x($bodnum,$matrixnum,$newcoord) $xtemp |
---|
1077 | set ::rb_y($bodnum,$matrixnum,$newcoord) $ytemp |
---|
1078 | set ::rb_z($bodnum,$matrixnum,$newcoord) $ztemp |
---|
1079 | puts "array element = $::rb_coord($bodnum,$matrixnum,$coordnum)" |
---|
1080 | set ::rb_coord($bodnum,$matrixnum,$newcoord) "" |
---|
1081 | puts "xyztemp = $xtemp $ytemp $ztemp $lbltemp" |
---|
1082 | lappend ::rb_coord($bodnum,$matrixnum,$newcoord) $xtemp $ytemp $ztemp $lbltemp |
---|
1083 | puts "goofy output = $::rb_coord($bodnum,$matrixnum,$newcoord)" |
---|
1084 | incr newcoord |
---|
1085 | } else { |
---|
1086 | incr deletedrecords |
---|
1087 | } |
---|
1088 | } |
---|
1089 | } |
---|
1090 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
1091 | set ::rb_sort($coordnum) 0 |
---|
1092 | } |
---|
1093 | set tempcoord [expr $::rb_coord_num($bodnum,1) - $deletedrecords] |
---|
1094 | set ::rb_coord_num($bodnum,1) $tempcoord |
---|
1095 | RB_Edit_Matrix $bodnum |
---|
1096 | } |
---|
1097 | |
---|
1098 | |
---|
1099 | |
---|
1100 | proc RB_VarNums {toggle {var ""} args} { |
---|
1101 | # initalize rigid body variable list if not already initialized |
---|
1102 | # toggle can be: |
---|
1103 | # add This returns the smallest unused variable number |
---|
1104 | # sub ## This removes variable ## from the varlist. |
---|
1105 | |
---|
1106 | if {[info vars ::rb_varlist] == ""} { |
---|
1107 | set ::rb_varlist "" |
---|
1108 | } |
---|
1109 | if {$::rb_varlist == ""} { |
---|
1110 | set ::rb_varlist [RigidBodyGetVarNums] |
---|
1111 | } |
---|
1112 | |
---|
1113 | if {$toggle == "add"} { |
---|
1114 | set count 1 |
---|
1115 | while {[lsearch $::rb_varlist $count] > 0} { |
---|
1116 | incr count |
---|
1117 | } |
---|
1118 | lappend ::rb_varlist $count |
---|
1119 | # puts $::rb_varlist |
---|
1120 | return $count |
---|
1121 | } |
---|
1122 | if {$toggle == "sub"} { |
---|
1123 | set temp "" |
---|
1124 | foreach v $::rb_varlist { |
---|
1125 | if {$v != $var} { |
---|
1126 | lappend temp $v |
---|
1127 | } |
---|
1128 | } |
---|
1129 | set ::rb_varlist $temp |
---|
1130 | # puts $::rb_varlist |
---|
1131 | return 0 |
---|
1132 | } |
---|
1133 | } |
---|
1134 | |
---|
1135 | proc RB_MMultRef {bodnum matrixnum args} { |
---|
1136 | # procedure sets or unsets the variable number for the matrix multiplier |
---|
1137 | # puts "boing:" |
---|
1138 | if {$::rb_varcheck($bodnum,$matrixnum) == "0"} { |
---|
1139 | set ::rb_var($bodnum,$matrixnum) [RB_VarNums sub $::rb_var($bodnum,$matrixnum)] |
---|
1140 | } else { |
---|
1141 | set ::rb_var($bodnum,$matrixnum) [RB_VarNums add] |
---|
1142 | } |
---|
1143 | destroy .viewmatrix |
---|
1144 | RB_Edit_Matrix $bodnum |
---|
1145 | } |
---|
1146 | |
---|
1147 | proc RB_Sort_Swap {bodnum args} { |
---|
1148 | set count 0 |
---|
1149 | set rb_swap_list "" |
---|
1150 | for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} { |
---|
1151 | if {$::rb_sort($coordnum) == 1} { |
---|
1152 | incr count |
---|
1153 | lappend rb_swap_list $coordnum |
---|
1154 | } |
---|
1155 | } |
---|
1156 | if {$count != 2} { |
---|
1157 | # puts "wrong number of arguments, swap failed" |
---|
1158 | bell |
---|
1159 | return |
---|
1160 | } |
---|
1161 | # puts "swap happens" |
---|
1162 | # puts $rb_swap_list |
---|
1163 | for {set i 1} {$i <= $::rb_matrix_num($bodnum)} {incr i} { |
---|
1164 | set coord1 [lindex $rb_swap_list 0] |
---|
1165 | set coord2 [lindex $rb_swap_list 1] |
---|
1166 | set x1dum $::rb_x($bodnum,$i,$coord1) |
---|
1167 | set y1dum $::rb_y($bodnum,$i,$coord1) |
---|
1168 | set z1dum $::rb_z($bodnum,$i,$coord1) |
---|
1169 | set ::rb_x($bodnum,$i,$coord1) $::rb_x($bodnum,$i,$coord2) |
---|
1170 | set ::rb_y($bodnum,$i,$coord1) $::rb_y($bodnum,$i,$coord2) |
---|
1171 | set ::rb_z($bodnum,$i,$coord1) $::rb_z($bodnum,$i,$coord2) |
---|
1172 | set ::rb_x($bodnum,$i,$coord2) $x1dum |
---|
1173 | set ::rb_y($bodnum,$i,$coord2) $y1dum |
---|
1174 | set ::rb_z($bodnum,$i,$coord2) $z1dum |
---|
1175 | } |
---|
1176 | |
---|
1177 | } |
---|
1178 | |
---|
1179 | proc RB_Sort_Inc {bodnum dir args} { |
---|
1180 | set sortlist "" |
---|
1181 | for {set count 0} {$count < $::rb_coord_num($bodnum,1)} {incr count} { |
---|
1182 | if {$::rb_sort($count) == 1} { |
---|
1183 | lappend sortlist $count |
---|
1184 | } |
---|
1185 | } |
---|
1186 | # puts $sortlist |
---|
1187 | |
---|
1188 | foreach check $sortlist { |
---|
1189 | set checkup [expr $check - 1] |
---|
1190 | set checkdwn [expr $check + 1] |
---|
1191 | if {$checkup < 0} { |
---|
1192 | if {$dir == "inc"} { |
---|
1193 | bell |
---|
1194 | return |
---|
1195 | } |
---|
1196 | } |
---|
1197 | if {$checkdwn >= $::rb_coord_num($bodnum,1)} { |
---|
1198 | if {$dir == "dec"} { |
---|
1199 | bell |
---|
1200 | return |
---|
1201 | } |
---|
1202 | } |
---|
1203 | } |
---|
1204 | if {$dir == "dec"} {set sortlist [RB_String_Reverse $sortlist]} |
---|
1205 | |
---|
1206 | for {set i 1} {$i <= $::rb_matrix_num($bodnum)} {incr i} { |
---|
1207 | foreach sort $sortlist { |
---|
1208 | if {$dir == "inc"} {set line1 [expr $sort - 1]} |
---|
1209 | if {$dir == "dec"} {set line1 [expr $sort + 1]} |
---|
1210 | set x1dum $::rb_x($bodnum,$i,$line1) |
---|
1211 | set y1dum $::rb_y($bodnum,$i,$line1) |
---|
1212 | set z1dum $::rb_z($bodnum,$i,$line1) |
---|
1213 | set ::rb_x($bodnum,$i,$line1) $::rb_x($bodnum,$i,$sort) |
---|
1214 | set ::rb_y($bodnum,$i,$line1) $::rb_y($bodnum,$i,$sort) |
---|
1215 | set ::rb_z($bodnum,$i,$line1) $::rb_z($bodnum,$i,$sort) |
---|
1216 | set ::rb_x($bodnum,$i,$sort) $x1dum |
---|
1217 | set ::rb_y($bodnum,$i,$sort) $y1dum |
---|
1218 | set ::rb_z($bodnum,$i,$sort) $z1dum |
---|
1219 | |
---|
1220 | set ::rb_sort($sort) 0 |
---|
1221 | if {$dir == "inc"} {set ::rb_sort([expr $sort - 1]) 1} |
---|
1222 | if {$dir == "dec"} { |
---|
1223 | foreach relabel $sortlist { |
---|
1224 | set ::rb_sort([expr $relabel +1]) 1 |
---|
1225 | } |
---|
1226 | } |
---|
1227 | } |
---|
1228 | } |
---|
1229 | |
---|
1230 | } |
---|
1231 | |
---|
1232 | proc RB_String_Reverse {string args} { |
---|
1233 | # puts "$string" |
---|
1234 | set rstring "" |
---|
1235 | set len [expr [llength $string] - 1] |
---|
1236 | while {$len > -1} { |
---|
1237 | lappend rstring [lindex $string $len] |
---|
1238 | incr len -1 |
---|
1239 | } |
---|
1240 | # puts "contents of rstring = $rstring" |
---|
1241 | return $rstring |
---|
1242 | } |
---|
1243 | |
---|
1244 | proc RB_Matrix_Update {bodnum args} { |
---|
1245 | set temp_mat "" |
---|
1246 | set temp_damp "" |
---|
1247 | set temp_var "" |
---|
1248 | set temp_car "" |
---|
1249 | set temp_mat_group "" |
---|
1250 | set temp_car_group "" |
---|
1251 | set total "" |
---|
1252 | |
---|
1253 | for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} { |
---|
1254 | set temp "" |
---|
1255 | lappend temp_mat $::rb_mult($bodnum,$matrixnum) |
---|
1256 | lappend temp_var $::rb_var($bodnum,$matrixnum) |
---|
1257 | lappend temp_damp $::rb_damp($bodnum,$matrixnum) |
---|
1258 | # puts "temp_damp = $::rb_damp($bodnum,$matrixnum)" |
---|
1259 | for {set atomnum 0} {$atomnum < $::::rb_coord_num($bodnum,1)} {incr atomnum} { |
---|
1260 | set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$atomnum) $::rb_y($bodnum,$matrixnum,$atomnum) $::rb_z($bodnum,$matrixnum,$atomnum)" |
---|
1261 | lappend temp $temp_cart_triplet |
---|
1262 | } |
---|
1263 | lappend temp_car $temp |
---|
1264 | } |
---|
1265 | |
---|
1266 | # puts "Matrix Update Info = $bodnum $temp_mat $temp_car" |
---|
1267 | # puts "Matrix damping = $temp_damp" |
---|
1268 | # puts "Matrix vars = $temp_var" |
---|
1269 | SetRigidBodyVar $bodnum $temp_var $temp_damp |
---|
1270 | RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0 |
---|
1271 | ReplaceRigidBody $bodnum $temp_mat $temp_car $temp_var $temp_damp |
---|
1272 | RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0 |
---|
1273 | #SetRigidBodyVar $bodnum $temp_var $temp_damp |
---|
1274 | incr ::expgui(changed) |
---|
1275 | RB_Load_RBdata |
---|
1276 | RB_Control_Panel $bodnum |
---|
1277 | destroy .viewmatrix |
---|
1278 | |
---|
1279 | } |
---|
1280 | |
---|
1281 | |
---|
1282 | proc GetImportFormats {} { |
---|
1283 | global expgui tcl_platform |
---|
1284 | # only needs to be done once |
---|
1285 | if [catch {set expgui(importFormatList)}] { |
---|
1286 | set filelist [glob -nocomplain [file join $expgui(scriptdir) import_*.tcl]] |
---|
1287 | foreach file $filelist { |
---|
1288 | set description "" |
---|
1289 | source $file |
---|
1290 | if {$description != ""} { |
---|
1291 | lappend expgui(importFormatList) $description |
---|
1292 | if {$tcl_platform(platform) == "unix"} { |
---|
1293 | set extensions "[string tolower $extensions] [string toupper $extensions]" |
---|
1294 | } |
---|
1295 | set expgui(extensions_$description) $extensions |
---|
1296 | set expgui(proc_$description) $procname |
---|
1297 | } |
---|
1298 | } |
---|
1299 | } |
---|
1300 | } |
---|
1301 | |
---|
1302 | proc NewBodyTypeWindow {} { |
---|
1303 | destroy .nbt |
---|
1304 | toplevel .nbt |
---|
1305 | putontop .nbt |
---|
1306 | set con1 .nbt.1 |
---|
1307 | set con2 .nbt.2 |
---|
1308 | set con3 .nbt.3 |
---|
1309 | |
---|
1310 | set bodnum [RB_New_RBnum] |
---|
1311 | # set bodnum [expr [llength [RigidBodyList]] + 1] |
---|
1312 | pack [frame $con1 -bd 2 -relief groove] -side top -pady 10 |
---|
1313 | pack [frame $con2 -bd 2 -relief groove] -side top -expand 1 -fill both |
---|
1314 | pack [frame $con3 -bd 2 -relief groove] -side top |
---|
1315 | grid [label $con1.lbl -text "New Rigid Body Type $bodnum"] -row 0 -column 0 |
---|
1316 | grid [label $con1.mat -text "Number of Matricies Describing Rigid Body"] -row 1 -column 0 |
---|
1317 | |
---|
1318 | |
---|
1319 | |
---|
1320 | spinbox $con1.matnum -from 1 -to 10 -textvariable ::rb_matrix_num($bodnum) -width 5 -command "RB_Create_Cart $bodnum $con2" |
---|
1321 | grid $con1.matnum -row 1 -column 1 -padx 10 |
---|
1322 | grid [label $con1.atoms -text "Number of Cartesian Sites"] -row 2 -column 0 |
---|
1323 | spinbox $con1.atomsnum -from 3 -to 1000 -textvariable ::rb_coord_num($bodnum,1) -width 5 -command "RB_Create_Cart $bodnum $con2" |
---|
1324 | grid $con1.atomsnum -row 2 -column 1 -padx 10 |
---|
1325 | |
---|
1326 | |
---|
1327 | grid [button $con3.save -text "Save \n Rigid Body" -command "RB_Create_Save $bodnum"] -row 0 -column 2 -padx 5 -pady 5 |
---|
1328 | grid [button $con3.print -text "Export Cartesian \n Coordinates to File" -command "RB_CartesianTextFile $bodnum"] -row 0 -column 3 -padx 5 |
---|
1329 | # $con3.print configure -status disable |
---|
1330 | grid [button $con3.abort -text "Abort \n Rigid Body" -command "destroy .nbt; RB_Control_Panel end"] -row 0 -column 4 -padx 5 -pady 5 |
---|
1331 | |
---|
1332 | RB_Create_Cart $bodnum $con2 |
---|
1333 | |
---|
1334 | bind $con1.atomsnum <Leave> "RB_Create_Cart $bodnum $con2" |
---|
1335 | bind $con1.atomsnum <Return> "RB_Create_Cart $bodnum $con2" |
---|
1336 | bind $con1.matnum <Leave> "RB_Create_Cart $bodnum $con2" |
---|
1337 | bind $con1.matnum <Return> "RB_Create_Cart $bodnum $con2" |
---|
1338 | } |
---|
1339 | |
---|
1340 | proc RB_Fixfrag_Load {args} { |
---|
1341 | destroy .geometry |
---|
1342 | toplevel .geometry |
---|
1343 | putontop .geometry |
---|
1344 | set geo .geometry |
---|
1345 | |
---|
1346 | |
---|
1347 | pack [frame $geo.con -bd 2 -relief groove] -side top |
---|
1348 | pack [frame $geo.display -bd 2 -relief groove] -side top -expand 1 -fill both |
---|
1349 | pack [frame $geo.con2 -bd 2 -relief groove] -side bottom |
---|
1350 | # pack [frame $geo.save -bd 2 -relief groove] -side bottom |
---|
1351 | |
---|
1352 | wm title $geo "Fix Molecular Fragment from EXP File" |
---|
1353 | wm geometry $geo 800x400+10+10 |
---|
1354 | |
---|
1355 | set phase 1 |
---|
1356 | set gcon $geo.con |
---|
1357 | set gcon2 $geo.con2 |
---|
1358 | set gdisplay $geo.display |
---|
1359 | set ::gcon_atoms 3 |
---|
1360 | |
---|
1361 | eval tk_optionMenu $geo.con.phaseinput ::rb_phase $::expmap(phaselist) |
---|
1362 | grid [label $gcon.phaselbl -text "Input Phase"] -row 0 -column 0 |
---|
1363 | grid $gcon.phaseinput -row 0 -column 1 |
---|
1364 | set ::gcon_atoms_total $::expmap(atomlist_$phase) |
---|
1365 | grid [label $gcon.atomlbl -text "Number of atoms in fragment: "] -row 1 -column 0 |
---|
1366 | spinbox $gcon.atom -from 3 -to [lrange $::expmap(atomlist_$phase) end end] -textvariable ::gcon_atoms -width 5 |
---|
1367 | grid $gcon.atom -row 1 -column 1 -padx 5 |
---|
1368 | grid [button $gcon.atomchoice -text "Choose Start Atom" -command "RB_FixStartAtom $phase $gdisplay $gcon2"] -row 1 -column 2 |
---|
1369 | grid [button $gcon2.save -text "Save and Map \n Rigid Body" -width 15 -command "RB_Geom_Save"] -row 0 -column 0 -padx 5 |
---|
1370 | $gcon2.save config -state disable |
---|
1371 | grid [button $gcon2.savec -text "Export Cartesian \n Coordinates" -width 15 -command "RB_FixFragSaveCoord"] -row 0 -column 1 -padx 5 |
---|
1372 | $gcon2.savec config -state disable |
---|
1373 | grid [button $gcon2.abort -text "Abort" -width 15 -command "destroy .geometry"] -row 0 -column 2 -sticky ns -padx 5 |
---|
1374 | |
---|
1375 | } |
---|
1376 | |
---|
1377 | proc RB_FixFragSaveCoord {args} { |
---|
1378 | # number of atoms in rigid body ::gcon_atoms |
---|
1379 | # first atom in rigid body ::gcon_start |
---|
1380 | # origin list ::gcon_origin_list |
---|
1381 | |
---|
1382 | set vector1list "X" |
---|
1383 | set vector2list "Y" |
---|
1384 | |
---|
1385 | lappend vector1list [expr $::geom_x1 - [expr $::gcon_start -1]] |
---|
1386 | lappend vector1list [expr $::geom_x2 - [expr $::gcon_start -1]] |
---|
1387 | lappend vector2list [expr $::geom_y1 - [expr $::gcon_start -1]] |
---|
1388 | lappend vector2list [expr $::geom_y2 - [expr $::gcon_start -1]] |
---|
1389 | |
---|
1390 | set ::gcon_origin_list "" |
---|
1391 | foreach item $::rb_atom_range { |
---|
1392 | if {$::rb_atom_origin_set($item) == 1} { |
---|
1393 | set temp [expr $item - [expr $::gcon_start - 1]] |
---|
1394 | lappend ::gcon_origin_list $temp |
---|
1395 | } |
---|
1396 | } |
---|
1397 | |
---|
1398 | set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list] |
---|
1399 | if {[lindex $temp1 0] == {} || [lindex $temp1 1] == {} || [lindex $temp1 2] == {}} { |
---|
1400 | } |
---|
1401 | |
---|
1402 | set coordlist "" |
---|
1403 | lappend coordlist [lindex $temp1 2] |
---|
1404 | # puts $coordlist |
---|
1405 | |
---|
1406 | set bodnum [RB_New_RBnum] |
---|
1407 | # puts "body number = $bodnum" |
---|
1408 | set coordnum 0 |
---|
1409 | # set ::rb_damp($bodnum,1) 0 |
---|
1410 | set ::rb_coord_num($bodnum,1) $::gcon_atoms |
---|
1411 | |
---|
1412 | catch {array unset ::rb_x $bodnum,1,*} |
---|
1413 | catch {array unset ::rb_y $bodnum,1,*} |
---|
1414 | catch {array unset ::rb_z $bodnum,1,*} |
---|
1415 | |
---|
1416 | |
---|
1417 | foreach coord $coordlist { |
---|
1418 | |
---|
1419 | set ::rb_x($bodnum,1,$coordnum) [lindex $coord 1] |
---|
1420 | set ::rb_y($bodnum,1,$coordnum) [lindex $coord 2] |
---|
1421 | set ::rb_z($bodnum,1,$coordnum) [lindex $coord 3] |
---|
1422 | incr coordnum |
---|
1423 | } |
---|
1424 | |
---|
1425 | |
---|
1426 | NewBodyTypeWindow |
---|
1427 | destroy .geometry |
---|
1428 | # RB_Control_Panel 0 |
---|
1429 | |
---|
1430 | |
---|
1431 | } |
---|
1432 | |
---|
1433 | proc RB_FixStartAtom {phase gdisplay gcon2 args} { |
---|
1434 | set ::gcon_start "" |
---|
1435 | set possible_start [RigidStartAtoms $phase $::gcon_atoms] |
---|
1436 | |
---|
1437 | if {$possible_start == ""} { |
---|
1438 | set ::gdisplay $gdisplay |
---|
1439 | #grid [label $ca.stop -text "Warning, action failed due to lack of unmapped atoms."] -row 0 -column 0 |
---|
1440 | #grid [button $ca.cont -text "continue" -command "destroy $ca"] -row 1 -column 0 |
---|
1441 | MyMessageBox -parent $gdisplay \ |
---|
1442 | -message "There are not enough atoms in this phase that are not already mapped to a rigid body to use." |
---|
1443 | return |
---|
1444 | } |
---|
1445 | |
---|
1446 | catch {destroy .chooseatom} |
---|
1447 | set ca .chooseatom |
---|
1448 | toplevel $ca |
---|
1449 | wm title $ca "Choose Atom" |
---|
1450 | |
---|
1451 | # puts $atomlist |
---|
1452 | foreach {top main side lbl} [MakeScrollTable $ca] {} |
---|
1453 | |
---|
1454 | set row 0 |
---|
1455 | set column 0 |
---|
1456 | foreach atom $possible_start { |
---|
1457 | set label "[atominfo $phase $atom label] \($atom\)" |
---|
1458 | button $main.$atom -text $label -command "set ::gcon_start $atom; destroy $ca" |
---|
1459 | |
---|
1460 | incr row |
---|
1461 | if {$row > 5} { |
---|
1462 | set row 1 |
---|
1463 | incr column |
---|
1464 | } |
---|
1465 | grid $main.$atom -row $row -column $column -padx 5 -pady 5 |
---|
1466 | } |
---|
1467 | ResizeScrollTable $ca |
---|
1468 | putontop $ca |
---|
1469 | tkwait window $ca |
---|
1470 | afterputontop |
---|
1471 | $gcon2.save config -state normal |
---|
1472 | $gcon2.savec config -state normal |
---|
1473 | RB_Atom_Fixlist $phase $gdisplay |
---|
1474 | } |
---|
1475 | |
---|
1476 | proc RB_Atom_Fixlist {phase gdisplay} { |
---|
1477 | # set ::gcon_start "" |
---|
1478 | set start_loc [lsearch $::expmap(atomlist_$phase) $::gcon_start] |
---|
1479 | set ::rb_atom_range [lrange $::expmap(atomlist_$phase) $start_loc [expr $start_loc + $::gcon_atoms - 1]] |
---|
1480 | # puts "location = $start_loc range = $::rb_atom_range" |
---|
1481 | set rownum 1 |
---|
1482 | set colnum 1 |
---|
1483 | |
---|
1484 | eval destroy [winfo children $gdisplay] |
---|
1485 | grid [frame $gdisplay.lbl -bd 2 -relief groove] -row 0 -column 0 |
---|
1486 | grid [frame $gdisplay.atoms -bd 2 -relief groove] -row 1 -column 0 |
---|
1487 | grid [frame $gdisplay.param -bd 2 -relief groove] -row 1 -column 1 |
---|
1488 | |
---|
1489 | grid [label $gdisplay.lbl.state -text "Select atoms to define centroid for origin"] -row 0 -column 0 |
---|
1490 | # grid [button $gdisplay.lbl.set -text "Set Origin" -command "RB_Atom_Origin_Set"] -row 3 -column 0 |
---|
1491 | |
---|
1492 | foreach {top main side lbl} [MakeScrollTable $gdisplay.atoms] {} |
---|
1493 | eval destroy [winfo children $main] |
---|
1494 | foreach atom $::rb_atom_range { |
---|
1495 | |
---|
1496 | |
---|
1497 | if {[expr $colnum % 4] == 0} {incr rownum; set colnum 1} |
---|
1498 | set atomid [atominfo $phase $atom label] |
---|
1499 | # puts $atomid |
---|
1500 | set ::rb_atom_origin_set($atom) 1 |
---|
1501 | grid [checkbutton $main.$atom -text "$atomid" -variable ::rb_atom_origin_set($atom)] -row $rownum -column $colnum |
---|
1502 | incr colnum |
---|
1503 | |
---|
1504 | } |
---|
1505 | ResizeScrollTable $gdisplay.atoms |
---|
1506 | |
---|
1507 | |
---|
1508 | set paramlist $gdisplay.param |
---|
1509 | # [atominfo $phase $::rb_atom_range label] |
---|
1510 | grid [label $paramlist.lbl -text "Define Axes"] -row 0 -column 0 -columnspan 2 |
---|
1511 | grid [label $paramlist.lbl1 -text "Atom 1"] -row 1 -column 0 |
---|
1512 | grid [label $paramlist.lbl2 -text "Atom 2"] -row 1 -column 1 |
---|
1513 | grid [label $paramlist.lblx -text "Choose two atoms to define vector for x-axis: "] -row 2 -column 0 -pady 10 -columnspan 2 |
---|
1514 | grid [label $paramlist.lbly -text "Choose two atoms to define second vector defining xy plane: "] -row 4 -column 0 -pady 10 -columnspan 2 |
---|
1515 | |
---|
1516 | set atom_info_list "" |
---|
1517 | set atom_list "" |
---|
1518 | foreach atom $::rb_atom_range { |
---|
1519 | lappend atom_info_list $atom |
---|
1520 | lappend atom_info_list [atominfo $phase $atom label] |
---|
1521 | lappend atom_list [atominfo $phase $atom label] |
---|
1522 | } |
---|
1523 | |
---|
1524 | # puts $atom_info_list |
---|
1525 | set ::rb_param_x1 [lindex $atom_list 0] |
---|
1526 | set ::rb_param_x2 [lindex $atom_list 1] |
---|
1527 | set ::rb_param_y1 [lindex $atom_list 0] |
---|
1528 | set ::rb_param_y2 [lindex $atom_list 2] |
---|
1529 | set ::geom_x1 [lindex $::rb_atom_range 0] |
---|
1530 | set ::geom_x2 [lindex $::rb_atom_range 1] |
---|
1531 | set ::geom_y1 [lindex $::rb_atom_range 0] |
---|
1532 | set ::geom_y2 [lindex $::rb_atom_range 2] |
---|
1533 | |
---|
1534 | set menu [eval tk_optionMenu $paramlist.x1 ::rb_param_x1 $atom_list] |
---|
1535 | foreach item $atom { |
---|
1536 | set max [llength $atom] |
---|
1537 | for {set count 0} {$count <= [expr $max - 1]} {incr count} { |
---|
1538 | $menu entryconfig $count -command "set ::geom_x1 [lindex $atom_info_list [expr $count*2]]" |
---|
1539 | } |
---|
1540 | } |
---|
1541 | |
---|
1542 | set menu [eval tk_optionMenu $paramlist.x2 ::rb_param_x2 $atom_list] |
---|
1543 | foreach item $atom { |
---|
1544 | set max [llength $atom] |
---|
1545 | for {set count 0} {$count <= [expr $max - 1]} {incr count} { |
---|
1546 | $menu entryconfig $count -command "set ::geom_x2 [lindex $atom_info_list [expr $count*2]]" |
---|
1547 | } |
---|
1548 | } |
---|
1549 | |
---|
1550 | set menu [eval tk_optionMenu $paramlist.y1 ::rb_param_y1 $atom_list] |
---|
1551 | foreach item $atom { |
---|
1552 | set max [llength $atom] |
---|
1553 | for {set count 0} {$count <= [expr $max - 1]} {incr count} { |
---|
1554 | $menu entryconfig $count -command "set ::geom_y1 [lindex $atom_info_list [expr $count*2]]" |
---|
1555 | } |
---|
1556 | } |
---|
1557 | |
---|
1558 | set menu [eval tk_optionMenu $paramlist.y2 ::rb_param_y2 $atom_list] |
---|
1559 | foreach item $atom { |
---|
1560 | set max [llength $atom] |
---|
1561 | for {set count 0} {$count <= [expr $max - 1]} {incr count} { |
---|
1562 | $menu entryconfig $count -command "set ::geom_y2 [lindex $atom_info_list [expr $count*2]]" |
---|
1563 | } |
---|
1564 | } |
---|
1565 | |
---|
1566 | |
---|
1567 | grid $paramlist.x1 -row 3 -column 0 |
---|
1568 | grid $paramlist.x2 -row 3 -column 1 |
---|
1569 | grid $paramlist.y1 -row 5 -column 0 |
---|
1570 | grid $paramlist.y2 -row 5 -column 1 |
---|
1571 | |
---|
1572 | |
---|
1573 | $paramlist.x1 config -width 4 |
---|
1574 | $paramlist.x2 config -width 4 |
---|
1575 | $paramlist.y1 config -width 4 |
---|
1576 | $paramlist.y2 config -width 4 |
---|
1577 | |
---|
1578 | } |
---|
1579 | |
---|
1580 | |
---|
1581 | proc RB_Atom_Origin_Set {args} { |
---|
1582 | set ::rb_origin_list "" |
---|
1583 | foreach item $::rb_atom_range { |
---|
1584 | if {$::rb_atom_origin_set($item) == 1} { |
---|
1585 | lappend ::rb_origin_list $item |
---|
1586 | } |
---|
1587 | } |
---|
1588 | # puts "Origin list = $::rb_origin_list" |
---|
1589 | } |
---|
1590 | |
---|
1591 | proc RB_Geom_Save {args} { |
---|
1592 | # number of atoms in rigid body ::gcon_atoms |
---|
1593 | # first atom in rigid body ::gcon_start |
---|
1594 | # origin list ::gcon_origin_list |
---|
1595 | |
---|
1596 | set vector1list "X" |
---|
1597 | set vector2list "Y" |
---|
1598 | |
---|
1599 | lappend vector1list [expr $::geom_x1 - [expr $::gcon_start -1]] |
---|
1600 | lappend vector1list [expr $::geom_x2 - [expr $::gcon_start -1]] |
---|
1601 | lappend vector2list [expr $::geom_y1 - [expr $::gcon_start -1]] |
---|
1602 | lappend vector2list [expr $::geom_y2 - [expr $::gcon_start -1]] |
---|
1603 | |
---|
1604 | set ::gcon_origin_list "" |
---|
1605 | foreach item $::rb_atom_range { |
---|
1606 | if {$::rb_atom_origin_set($item) == 1} { |
---|
1607 | set temp [expr $item - [expr $::gcon_start - 1]] |
---|
1608 | lappend ::gcon_origin_list $temp |
---|
1609 | } |
---|
1610 | } |
---|
1611 | # puts "Origin list = $::gcon_origin_list" |
---|
1612 | # puts "vector 1 list = $vector1list" |
---|
1613 | # puts "vector 2 list = $vector2list" |
---|
1614 | # puts "number atoms = $::gcon_atoms" |
---|
1615 | # puts "start atom = $::gcon_start" |
---|
1616 | |
---|
1617 | set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list] |
---|
1618 | if {[lindex $temp1 0] == {} || [lindex $temp1 1] == {} || [lindex $temp1 2] == {}} { |
---|
1619 | # puts "Geometry Crashed" |
---|
1620 | } |
---|
1621 | #puts "string 1 = [lindex $temp1 0]" |
---|
1622 | #puts "string 2 = [lindex $temp1 1]" |
---|
1623 | #puts "string 3 = [lindex $temp1 2]" |
---|
1624 | |
---|
1625 | set cartesian "" |
---|
1626 | lappend cartesian [lindex $temp1 2] |
---|
1627 | #puts "Cartesian = $cartesian" |
---|
1628 | |
---|
1629 | set bodnum [AddRigidBody 1 $cartesian] |
---|
1630 | # set ::rb_damp($bodnum,1) 0 |
---|
1631 | set ::rb_coord_num($bodnum,1) $::gcon_atoms |
---|
1632 | |
---|
1633 | MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1] |
---|
1634 | RecordMacroEntry "MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1]" 0 |
---|
1635 | destroy .geometry |
---|
1636 | RB_Control_Panel 0 |
---|
1637 | } |
---|
1638 | |
---|
1639 | proc RB_Refine_Con {args} { |
---|
1640 | catch {destroy .refcon} |
---|
1641 | set con .refcon |
---|
1642 | toplevel $con |
---|
1643 | wm title $con "Rigid Body Refinement Controls" |
---|
1644 | wm geometry $con 1150x600+10+10 |
---|
1645 | set ::rb_var_list "" |
---|
1646 | set ::rb_var_list_tls "" |
---|
1647 | set ::varnum 1 |
---|
1648 | set ::rb_var_name "var$::varnum" |
---|
1649 | # putontop $con |
---|
1650 | grid [frame $con.info -bd 2 -relief groove] -row 1 -column 0 -sticky news |
---|
1651 | grid columnconfig $con 0 -weight 1 |
---|
1652 | grid [frame $con.con -bd 2 -relief groove] -row 0 -column 0 |
---|
1653 | grid [frame $con.terminate -bd 2 -relief groove] -row 2 -column 0 |
---|
1654 | |
---|
1655 | #bandaid fix: load all mapping data |
---|
1656 | foreach phase $::expmap(phaselist) { |
---|
1657 | foreach bodnum [RigidBodyList] { |
---|
1658 | foreach mapnum [RigidBodyMappingList $phase $bodnum] { |
---|
1659 | RB_Load_Mapdata $phase $bodnum $mapnum |
---|
1660 | } |
---|
1661 | } |
---|
1662 | } |
---|
1663 | |
---|
1664 | #grid rowconfig $con 0 -weight 1 |
---|
1665 | |
---|
1666 | foreach {top main side lbl} [MakeScrollTable $con.info] {} |
---|
1667 | grid [label $top.rb -text "Body"] -row 1 -column 1 -padx 3 |
---|
1668 | grid [label $top.phase -text "Ph"] -row 1 -column 2 -padx 3 |
---|
1669 | grid [label $top.mapnum -text "Map"] -row 1 -column 3 -padx 3 |
---|
1670 | grid [label $top.x -text "X"] -row 1 -column 4 -padx 3 |
---|
1671 | grid [label $top.y -text "Y"] -row 1 -column 5 -padx 3 |
---|
1672 | grid [label $top.z -text "Z"] -row 1 -column 6 -padx 3 |
---|
1673 | grid [label $top.b1 -text " "] -row 1 -column 7 -padx 3 |
---|
1674 | grid [label $top.e1 -text "E1"] -row 1 -column 8 -padx 3 |
---|
1675 | grid [label $top.e2 -text "E2"] -row 1 -column 9 -padx 3 |
---|
1676 | grid [label $top.e3 -text "E3"] -row 1 -column 10 -padx 3 |
---|
1677 | grid [label $top.tlscon1 -text "on/off"] -row 1 -column 11 -padx 3 |
---|
1678 | # grid [label $top.b2 -text " "] -row 1 -column 11 -padx 3 |
---|
1679 | grid [label $top.t11 -text "T11"] -row 1 -column 12 -padx 3 |
---|
1680 | grid [label $top.t22 -text "T22"] -row 1 -column 13 -padx 3 |
---|
1681 | grid [label $top.t33 -text "T33"] -row 1 -column 14 -padx 3 |
---|
1682 | grid [label $top.t12 -text "T12"] -row 1 -column 15 -padx 3 |
---|
1683 | grid [label $top.t13 -text "T13"] -row 1 -column 16 -padx 3 |
---|
1684 | grid [label $top.t23 -text "T23"] -row 1 -column 17 -padx 3 |
---|
1685 | grid [label $top.b3 -text " "] -row 1 -column 18 -padx 3 |
---|
1686 | grid [label $top.l11 -text "L11"] -row 1 -column 19 -padx 3 |
---|
1687 | grid [label $top.l22 -text "L22"] -row 1 -column 20 -padx 3 |
---|
1688 | grid [label $top.l33 -text "L33"] -row 1 -column 21 -padx 3 |
---|
1689 | grid [label $top.l12 -text "L12"] -row 1 -column 22 -padx 3 |
---|
1690 | grid [label $top.l13 -text "L13"] -row 1 -column 23 -padx 3 |
---|
1691 | grid [label $top.l23 -text "L23"] -row 1 -column 24 -padx 3 |
---|
1692 | grid [label $top.zb4 -text " "] -row 1 -column 25 -padx 3 |
---|
1693 | grid [label $top.s12 -text "S12"] -row 1 -column 26 -padx 3 |
---|
1694 | grid [label $top.s13 -text "S13"] -row 1 -column 27 -padx 3 |
---|
1695 | grid [label $top.s21 -text "S21"] -row 1 -column 28 -padx 3 |
---|
1696 | grid [label $top.s23 -text "S23"] -row 1 -column 29 -padx 3 |
---|
1697 | grid [label $top.s31 -text "S31"] -row 1 -column 30 -padx 3 |
---|
1698 | grid [label $top.s32 -text "S32"] -row 1 -column 31 -padx 3 |
---|
1699 | grid [label $top.saa -text "SAA"] -row 1 -column 32 -padx 3 |
---|
1700 | grid [label $top.sbb -text "SBB"] -row 1 -column 33 -padx 3 |
---|
1701 | |
---|
1702 | grid [label $top.refcoord -text "Origin"] -row 0 -column 4 -padx 5 -columnspan 3 |
---|
1703 | grid [label $top.refeuler -text "Euler Angles"] -row 0 -column 8 -padx 5 -columnspan 3 |
---|
1704 | grid [label $top.tlscon2 -text "TLS"] -row 0 -column 11 |
---|
1705 | grid [label $top.tls -text "TLS"] -row 0 -column 12 -padx 5 -columnspan 6 |
---|
1706 | # grid [label $top.atoms -text "Atoms in Mapping"] -row 0 -column 6 -padx 5 -columnspan 10 |
---|
1707 | |
---|
1708 | #Determine number of rigid bodies and rigid body mappings |
---|
1709 | set rb_num [RigidBodyList] |
---|
1710 | set row 1 |
---|
1711 | foreach phasenum $::expmap(phaselist) { |
---|
1712 | foreach bodnum $rb_num { |
---|
1713 | set rb_map_num($phasenum,$bodnum) [RigidBodyMappingList $phasenum $bodnum] |
---|
1714 | |
---|
1715 | foreach mapnum $rb_map_num($phasenum,$bodnum) { |
---|
1716 | # puts "mapnum = $mapnum" |
---|
1717 | # grid [checkbutton $main.check($phasenum,$bodnum,$mapnum)] -row $row -column 0 |
---|
1718 | grid [label $main.body($phasenum,$bodnum,$mapnum) -text $bodnum] -row $row -column 1 |
---|
1719 | grid [label $main.phase($phasenum,$bodnum,$mapnum) -text $phasenum] -row $row -column 2 |
---|
1720 | grid [label $main.map($phasenum,$bodnum,$mapnum) -text $mapnum] -row $row -column 3 |
---|
1721 | RB_Load_Vars $phasenum $bodnum $mapnum |
---|
1722 | # puts "the checkbutton variable is $::rb_var($phasenum,$bodnum,$mapnum,tls)" |
---|
1723 | |
---|
1724 | # puts $main |
---|
1725 | grid [button $main.cfefx($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.cfefx($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,x) -width 5] -row $row -column 4 |
---|
1726 | grid [button $main.cfefy($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.cfefy($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,y) -width 5] -row $row -column 5 |
---|
1727 | grid [button $main.cfefz($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.cfefz($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,z) -width 5] -row $row -column 6 |
---|
1728 | grid [label $main.b1($phasenum,$bodnum,$mapnum) -text " "] -row $row -column 7 |
---|
1729 | |
---|
1730 | grid [button $main.eref1($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.eref1($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,e1) -width 5] -row $row -column 8 |
---|
1731 | grid [button $main.eref2($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.eref2($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,e2) -width 5] -row $row -column 9 |
---|
1732 | grid [button $main.eref3($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.eref3($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,e3) -width 5] -row $row -column 10 |
---|
1733 | # grid [label $main.b2($phasenum,$bodnum,$mapnum) -text " "] -row $row -column 11 |
---|
1734 | |
---|
1735 | grid [checkbutton $main.tlscon($phasenum,$bodnum,$mapnum) -variable ::rb_var($phasenum,$bodnum,$mapnum,tls) -command "RB_TLS_Onoff $phasenum $main $bodnum $mapnum" -width 5] -row $row -column 11 |
---|
1736 | |
---|
1737 | |
---|
1738 | grid [button $main.t11ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.t11ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,t11) -width 5] -row $row -column 12 |
---|
1739 | grid [button $main.t22ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.t22ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,t22) -width 5] -row $row -column 13 |
---|
1740 | grid [button $main.t33ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.t33ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,t33) -width 5] -row $row -column 14 |
---|
1741 | grid [button $main.t12ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.t12ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,t12) -width 5] -row $row -column 15 |
---|
1742 | grid [button $main.t13ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.t13ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,t13) -width 5] -row $row -column 16 |
---|
1743 | grid [button $main.t23ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.t23ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,t23) -width 5] -row $row -column 17 |
---|
1744 | grid [label $main.b3($phasenum,$bodnum,$mapnum) -text " "] -row $row -column 18 |
---|
1745 | |
---|
1746 | grid [button $main.l11ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.l11ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,l11) -width 5] -row $row -column 19 |
---|
1747 | grid [button $main.l22ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.l22ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,l22) -width 5] -row $row -column 20 |
---|
1748 | grid [button $main.l33ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.l33ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,l33) -width 5] -row $row -column 21 |
---|
1749 | grid [button $main.l12ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.l12ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,l12) -width 5] -row $row -column 22 |
---|
1750 | grid [button $main.l13ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.l13ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,l13) -width 5] -row $row -column 23 |
---|
1751 | grid [button $main.l23ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.l23ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,l23) -width 5] -row $row -column 24 |
---|
1752 | grid [label $main.b4($phasenum,$bodnum,$mapnum) -text " "] -row $row -column 25 |
---|
1753 | |
---|
1754 | grid [button $main.s12ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.s12ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,s12) -width 5] -row $row -column 26 |
---|
1755 | grid [button $main.s13ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.s13ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,s13) -width 5] -row $row -column 27 |
---|
1756 | grid [button $main.s21ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.s21ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,s21) -width 5] -row $row -column 28 |
---|
1757 | grid [button $main.s23ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.s23ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,s23) -width 5] -row $row -column 29 |
---|
1758 | grid [button $main.s31ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.s31ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,s31) -width 5] -row $row -column 30 |
---|
1759 | grid [button $main.s32ref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.s32ref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,s32) -width 5] -row $row -column 31 |
---|
1760 | grid [button $main.saaref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.saaref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,saa) -width 5] -row $row -column 32 |
---|
1761 | grid [button $main.sbbref($phasenum,$bodnum,$mapnum) -command "RB_Con_Button $main.sbbref($phasenum,$bodnum,$mapnum)" -textvariable ::rb_var($phasenum,$bodnum,$mapnum,sbb) -width 5] -row $row -column 33 |
---|
1762 | |
---|
1763 | RB_TLS_Onoff $phasenum $main $bodnum $mapnum |
---|
1764 | |
---|
1765 | |
---|
1766 | # set col 4 |
---|
1767 | set atomnum $::rb_map_beginning($phasenum,$bodnum,$mapnum) |
---|
1768 | # puts "first atom = $atomnum" |
---|
1769 | # set atomlist "atoms in rigid body #$bodnum: " |
---|
1770 | set atomlist "atoms in rigid body: " |
---|
1771 | for {set j 1} {$j <=$::rb_coord_num($bodnum,1)} {incr j} { |
---|
1772 | set atom [atominfo $phasenum $atomnum label] |
---|
1773 | lappend atomlist $atom |
---|
1774 | # grid [label $main.rb_site$phasenum$mapnum$j -text "$atom"] -row [expr $row +1] -column $col -padx 5 |
---|
1775 | incr atomnum |
---|
1776 | # incr col |
---|
1777 | } |
---|
1778 | grid [label $main.rb_site$phasenum$bodnum$mapnum -text "$atomlist"] -row [expr $row + 1] -column 4 -padx 5 -columnspan 999 -sticky w |
---|
1779 | incr row 2 |
---|
1780 | } |
---|
1781 | } |
---|
1782 | } |
---|
1783 | ResizeScrollTable $con.info |
---|
1784 | set ::rbaddresses [winfo children .refcon.info.can.f] |
---|
1785 | |
---|
1786 | set ::rb_var_name "var$::varnum" |
---|
1787 | set free "free" |
---|
1788 | set const "" |
---|
1789 | |
---|
1790 | grid [label $con.con.lbl -text "Set Variables Selected Below"] -row 1 -column 1 |
---|
1791 | grid [button $con.con.free -width 22 -text "Set Free Variable" -command {RB_Con_But_Proc $::rbaddresses free}] -row 2 -column 1 |
---|
1792 | grid [button $con.con.const -width 22 -text "Do Not Refine Variables" -command {RB_Con_But_Proc $::rbaddresses ""}] -row 3 -column 1 |
---|
1793 | grid [button $con.con.var -width 22 -text "Set Constrained Variables" -command {RB_Con_But_Proc $::rbaddresses $::rb_var_name; incr ::varnum; set ::rb_var_name "var$::varnum"}] -row 4 -column 1 |
---|
1794 | grid [entry $con.con.vare -textvariable ::rb_var_name -width 5] -row 4 -column 2 |
---|
1795 | grid [button $con.con.clear -width 22 -text "Clear All Variables" -command {RB_Variable_Clear}] -row 5 -column 1 |
---|
1796 | |
---|
1797 | grid [label $con.terminate.originlabel -text "Origin Damping Factor "] -row 5 -column 1 |
---|
1798 | eval tk_optionMenu $con.terminate.origindamp ::rb_damp_origin 0 1 2 3 4 5 6 7 8 9 |
---|
1799 | grid $con.terminate.origindamp -row 5 -column 2 |
---|
1800 | $con.terminate.origindamp config -width 4 -state disable |
---|
1801 | |
---|
1802 | grid [label $con.terminate.anglelabel -text "Angle Damping Factor "] -row 6 -column 1 |
---|
1803 | eval tk_optionMenu $con.terminate.angledamp ::rb_damp_angle 0 1 2 3 4 5 6 7 8 9 |
---|
1804 | grid $con.terminate.angledamp -row 6 -column 2 |
---|
1805 | $con.terminate.angledamp config -width 4 -state disable |
---|
1806 | |
---|
1807 | grid [button $con.terminate.save -width 22 -text "Assign Variables and Save" -command RB_Var_Assign] -row 7 -column 1 -columnspan 2 |
---|
1808 | grid [button $con.terminate.abort -width 22 -text "Abort" -command {destroy .refcon}] -row 8 -column 1 -columnspan 2 |
---|
1809 | |
---|
1810 | } |
---|
1811 | |
---|
1812 | proc RB_Variable_Clear {} { |
---|
1813 | foreach var $::rb_var_list { |
---|
1814 | set $var "" |
---|
1815 | } |
---|
1816 | foreach var $::rb_var_list_tls { |
---|
1817 | set $var "" |
---|
1818 | } |
---|
1819 | |
---|
1820 | } |
---|
1821 | |
---|
1822 | proc RB_Con_But_Proc {addresses change args} { |
---|
1823 | # puts "$addresses $change" |
---|
1824 | foreach address $addresses { |
---|
1825 | set a [eval $address cget -bg] |
---|
1826 | if {$a == "yellow"} { |
---|
1827 | set var [eval $address cget -textvariable] |
---|
1828 | set $var $change |
---|
1829 | $address config -relief raised -bg lightgray |
---|
1830 | } |
---|
1831 | } |
---|
1832 | } |
---|
1833 | |
---|
1834 | #procedure to turn buttons on (sunken yellow) and off (lightgray raised). |
---|
1835 | proc RB_Con_Button {address args} { |
---|
1836 | set a [eval $address cget -relief] |
---|
1837 | if {$a == "raised"} { |
---|
1838 | $address config -relief sunken -bg yellow |
---|
1839 | } |
---|
1840 | if {$a == "sunken"} { |
---|
1841 | $address config -relief raised |
---|
1842 | $address config -bg lightgray |
---|
1843 | } |
---|
1844 | } |
---|
1845 | |
---|
1846 | |
---|
1847 | |
---|
1848 | #procedure to determine next available variable number for GSAS |
---|
1849 | proc RB_Var_Gen {varcount args} { |
---|
1850 | while {[lsearch $::rb_varlist $varcount] != -1} {incr varcount} |
---|
1851 | lappend ::rb_varlist $varcount |
---|
1852 | return $varcount |
---|
1853 | } |
---|
1854 | |
---|
1855 | #procedure to assign variable names to relationships |
---|
1856 | proc RB_Var_Assign {args} { |
---|
1857 | set ::rb_varlist [RigidBodyGetVarNums] |
---|
1858 | set varcount 1 |
---|
1859 | set varlist "" |
---|
1860 | catch {array unset rb_var_temp} |
---|
1861 | foreach var $::rb_var_list { |
---|
1862 | if {[set $var] == ""} { |
---|
1863 | set $var 0 |
---|
1864 | } elseif {[set $var] == "free"} { |
---|
1865 | set $var [RB_Var_Gen $varcount] |
---|
1866 | set varcount [set $var] |
---|
1867 | } else { |
---|
1868 | # puts [lsearch $varlist [set $var]] |
---|
1869 | if {[lsearch $varlist [set $var]] == -1} { |
---|
1870 | lappend varlist [set $var] |
---|
1871 | # puts $varlist |
---|
1872 | set rb_variable([set $var]) [RB_Var_Gen $varcount] |
---|
1873 | set $var $rb_variable([set $var]) |
---|
1874 | |
---|
1875 | } else { |
---|
1876 | set $var $rb_variable([set $var]) |
---|
1877 | } |
---|
1878 | } |
---|
1879 | } |
---|
1880 | |
---|
1881 | foreach var $::rb_var_list_tls { |
---|
1882 | if {[set $var] == ""} { |
---|
1883 | set $var 0 |
---|
1884 | } elseif {[set $var] == "free"} { |
---|
1885 | set $var [RB_Var_Gen $varcount] |
---|
1886 | set varcount [set $var] |
---|
1887 | } else { |
---|
1888 | # puts [lsearch $varlist [set $var]] |
---|
1889 | if {[lsearch $varlist [set $var]] == -1} { |
---|
1890 | lappend varlist [set $var] |
---|
1891 | # puts $varlist |
---|
1892 | set rb_variable([set $var]) [RB_Var_Gen $varcount] |
---|
1893 | set $var $rb_variable([set $var]) |
---|
1894 | |
---|
1895 | } else { |
---|
1896 | set $var $rb_variable([set $var]) |
---|
1897 | } |
---|
1898 | } |
---|
1899 | } |
---|
1900 | |
---|
1901 | RB_Var_Save |
---|
1902 | incr ::expgui(changed) |
---|
1903 | destroy .refcon |
---|
1904 | } |
---|
1905 | |
---|
1906 | #procedure for enabling refinement flags |
---|
1907 | proc RB_Ref_FlagEnable {phasenum bodnum mapnum var val args} { |
---|
1908 | set atomlist "" |
---|
1909 | set atomnum $::rb_map_beginning($phasenum,$bodnum,$mapnum) |
---|
1910 | for {set j 1} {$j <=$::rb_coord_num($bodnum,1)} {incr j} { |
---|
1911 | lappend atomlist $atomnum |
---|
1912 | incr atomnum |
---|
1913 | } |
---|
1914 | atominfo $phasenum $atomlist $var set $val |
---|
1915 | |
---|
1916 | } |
---|
1917 | |
---|
1918 | |
---|
1919 | |
---|
1920 | |
---|
1921 | #procedure to send variable numbers to EXP file. |
---|
1922 | proc RB_Var_Save {args} { |
---|
1923 | |
---|
1924 | #Determine number of rigid bodies and rigid body mappings |
---|
1925 | set rb_num [RigidBodyList] |
---|
1926 | foreach phasenum $::expmap(phaselist) { |
---|
1927 | foreach bodnum $rb_num { |
---|
1928 | set rb_map_num($phasenum,$bodnum) [RigidBodyMappingList $phasenum $bodnum] |
---|
1929 | foreach mapnum $rb_map_num($phasenum,$bodnum) { |
---|
1930 | set refcoordflag 0 |
---|
1931 | set reftlsflag 0 |
---|
1932 | set rb_list "$::rb_var($phasenum,$bodnum,$mapnum,x) \ |
---|
1933 | $::rb_var($phasenum,$bodnum,$mapnum,y) $::rb_var($phasenum,$bodnum,$mapnum,z) \ |
---|
1934 | $::rb_var($phasenum,$bodnum,$mapnum,e1) $::rb_var($phasenum,$bodnum,$mapnum,e2) \ |
---|
1935 | $::rb_var($phasenum,$bodnum,$mapnum,e3) 0 0 0" |
---|
1936 | RigidBodyVary $phasenum $bodnum $mapnum $rb_list |
---|
1937 | RecordMacroEntry "incr expgui(changed); RigidBodyVary $phasenum $bodnum $mapnum [list $rb_list]" 0 |
---|
1938 | foreach test $rb_list { |
---|
1939 | if {$test != 0} { |
---|
1940 | set refcoordflag 1 |
---|
1941 | } |
---|
1942 | } |
---|
1943 | RB_Ref_FlagEnable $phasenum $bodnum $mapnum xref $refcoordflag |
---|
1944 | |
---|
1945 | if {$::rb_var($phasenum,$bodnum,$mapnum,tls) == 1} { |
---|
1946 | set rb_tls "$::rb_var($phasenum,$bodnum,$mapnum,t11) $::rb_var($phasenum,$bodnum,$mapnum,t22) \ |
---|
1947 | $::rb_var($phasenum,$bodnum,$mapnum,t33) $::rb_var($phasenum,$bodnum,$mapnum,t12) \ |
---|
1948 | $::rb_var($phasenum,$bodnum,$mapnum,t13) $::rb_var($phasenum,$bodnum,$mapnum,t23) \ |
---|
1949 | $::rb_var($phasenum,$bodnum,$mapnum,l11) $::rb_var($phasenum,$bodnum,$mapnum,l22) \ |
---|
1950 | $::rb_var($phasenum,$bodnum,$mapnum,l33) $::rb_var($phasenum,$bodnum,$mapnum,l12) \ |
---|
1951 | $::rb_var($phasenum,$bodnum,$mapnum,l13) $::rb_var($phasenum,$bodnum,$mapnum,l23) \ |
---|
1952 | $::rb_var($phasenum,$bodnum,$mapnum,s12) $::rb_var($phasenum,$bodnum,$mapnum,s13) \ |
---|
1953 | $::rb_var($phasenum,$bodnum,$mapnum,s21) $::rb_var($phasenum,$bodnum,$mapnum,s23) \ |
---|
1954 | $::rb_var($phasenum,$bodnum,$mapnum,s31) $::rb_var($phasenum,$bodnum,$mapnum,s32) \ |
---|
1955 | $::rb_var($phasenum,$bodnum,$mapnum,saa) $::rb_var($phasenum,$bodnum,$mapnum,sbb)" |
---|
1956 | # puts "TLS param save for $rb_tls" |
---|
1957 | RigidBodyTLSVary $phasenum $bodnum $mapnum $rb_tls |
---|
1958 | RecordMacroEntry "RigidBodyTLSVary $phasenum $bodnum $mapnum [list $rb_tls]" 0 |
---|
1959 | foreach test $rb_tls { |
---|
1960 | if {$test != 0} { |
---|
1961 | set reftlsflag 1 |
---|
1962 | } |
---|
1963 | } |
---|
1964 | RB_Ref_FlagEnable $phasenum $bodnum $mapnum uref $reftlsflag |
---|
1965 | } |
---|
1966 | incr ::expgui(changed) |
---|
1967 | #RecordMacroEntry "incr expgui(changed)" 0 |
---|
1968 | |
---|
1969 | } |
---|
1970 | } |
---|
1971 | # puts "phasenumber is $phasenum" |
---|
1972 | DisplayAllAtoms $phasenum |
---|
1973 | #need to track body number from button on notebook page. Below is a temporary fix |
---|
1974 | RB_Control_Panel $::rb_panel |
---|
1975 | # RB_Populate $::rb_notebook 1 |
---|
1976 | } |
---|
1977 | } |
---|
1978 | |
---|
1979 | # procedure to turn tls buttons on or off |
---|
1980 | proc RB_TLS_Onoff {phasenum main bodnum mapnum} { |
---|
1981 | |
---|
1982 | lappend tlsparam $main.t11ref($phasenum,$bodnum,$mapnum) $main.t22ref($phasenum,$bodnum,$mapnum) $main.t33ref($phasenum,$bodnum,$mapnum) \ |
---|
1983 | $main.t12ref($phasenum,$bodnum,$mapnum) $main.t13ref($phasenum,$bodnum,$mapnum) $main.t23ref($phasenum,$bodnum,$mapnum) \ |
---|
1984 | $main.l11ref($phasenum,$bodnum,$mapnum) $main.l22ref($phasenum,$bodnum,$mapnum) $main.l33ref($phasenum,$bodnum,$mapnum) \ |
---|
1985 | $main.l12ref($phasenum,$bodnum,$mapnum) $main.l13ref($phasenum,$bodnum,$mapnum) $main.l23ref($phasenum,$bodnum,$mapnum) \ |
---|
1986 | $main.s12ref($phasenum,$bodnum,$mapnum) $main.s13ref($phasenum,$bodnum,$mapnum) $main.s21ref($phasenum,$bodnum,$mapnum) \ |
---|
1987 | $main.s23ref($phasenum,$bodnum,$mapnum) $main.s31ref($phasenum,$bodnum,$mapnum) $main.s32ref($phasenum,$bodnum,$mapnum) \ |
---|
1988 | $main.saaref($phasenum,$bodnum,$mapnum) $main.sbbref($phasenum,$bodnum,$mapnum) |
---|
1989 | # puts $tlsparam |
---|
1990 | if {$::rb_var($phasenum,$bodnum,$mapnum,tls) == 0} { |
---|
1991 | RigidBodyEnableTLS $phasenum $bodnum $mapnum 0 |
---|
1992 | foreach x $tlsparam { |
---|
1993 | $x config -state disable -relief sunken |
---|
1994 | } |
---|
1995 | } else { |
---|
1996 | RigidBodyEnableTLS $phasenum $bodnum $mapnum 1 |
---|
1997 | foreach x $tlsparam { |
---|
1998 | $x config -state normal -relief raised |
---|
1999 | } |
---|
2000 | } |
---|
2001 | } |
---|
2002 | |
---|
2003 | |
---|
2004 | proc RB_Load_Vars {phasenum bodnum mapnum args} { |
---|
2005 | foreach var $::rb_map_positionvars($phasenum,$bodnum,$mapnum) { |
---|
2006 | catch {unset temp($var)} |
---|
2007 | } |
---|
2008 | |
---|
2009 | foreach var $::rb_map_positionvars($phasenum,$bodnum,$mapnum) { |
---|
2010 | if {[info exists temp($var)] == "0"} { |
---|
2011 | set temp($var) $var |
---|
2012 | } else { |
---|
2013 | lappend mulvarlist $var |
---|
2014 | } |
---|
2015 | } |
---|
2016 | |
---|
2017 | foreach var $::rb_map_tls_var($phasenum,$bodnum,$mapnum) { |
---|
2018 | if {[info exists temp($var)] == "0"} { |
---|
2019 | set temp($var) $var |
---|
2020 | } else { |
---|
2021 | lappend mulvarlist $var |
---|
2022 | } |
---|
2023 | } |
---|
2024 | |
---|
2025 | set ::rb_var($phasenum,$bodnum,$mapnum,x) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 0] $mulvarlist] |
---|
2026 | set ::rb_var($phasenum,$bodnum,$mapnum,y) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 1] $mulvarlist] |
---|
2027 | set ::rb_var($phasenum,$bodnum,$mapnum,z) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 2] $mulvarlist] |
---|
2028 | |
---|
2029 | lappend ::rb_var_list ::rb_var($phasenum,$bodnum,$mapnum,x) ::rb_var($phasenum,$bodnum,$mapnum,y) ::rb_var($phasenum,$bodnum,$mapnum,z) |
---|
2030 | |
---|
2031 | set ::rb_var($phasenum,$bodnum,$mapnum,e1) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 3] $mulvarlist] |
---|
2032 | set ::rb_var($phasenum,$bodnum,$mapnum,e2) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 4] $mulvarlist] |
---|
2033 | set ::rb_var($phasenum,$bodnum,$mapnum,e3) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 5] $mulvarlist] |
---|
2034 | |
---|
2035 | lappend ::rb_var_list ::rb_var($phasenum,$bodnum,$mapnum,e1) ::rb_var($phasenum,$bodnum,$mapnum,e2) ::rb_var($phasenum,$bodnum,$mapnum,e3) |
---|
2036 | |
---|
2037 | if {$::rb_map_tls_var($phasenum,$bodnum,$mapnum) != ""} { |
---|
2038 | |
---|
2039 | |
---|
2040 | set ::rb_var($phasenum,$bodnum,$mapnum,t11) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 0] $mulvarlist] |
---|
2041 | set ::rb_var($phasenum,$bodnum,$mapnum,t22) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 1] $mulvarlist] |
---|
2042 | set ::rb_var($phasenum,$bodnum,$mapnum,t33) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 2] $mulvarlist] |
---|
2043 | set ::rb_var($phasenum,$bodnum,$mapnum,t12) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 3] $mulvarlist] |
---|
2044 | set ::rb_var($phasenum,$bodnum,$mapnum,t13) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 4] $mulvarlist] |
---|
2045 | set ::rb_var($phasenum,$bodnum,$mapnum,t23) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 5] $mulvarlist] |
---|
2046 | |
---|
2047 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,t11) ::rb_var($phasenum,$bodnum,$mapnum,t22) ::rb_var($phasenum,$bodnum,$mapnum,t33) |
---|
2048 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,t12) ::rb_var($phasenum,$bodnum,$mapnum,t13) ::rb_var($phasenum,$bodnum,$mapnum,t23) |
---|
2049 | |
---|
2050 | set ::rb_var($phasenum,$bodnum,$mapnum,l11) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 6] $mulvarlist] |
---|
2051 | set ::rb_var($phasenum,$bodnum,$mapnum,l22) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 7] $mulvarlist] |
---|
2052 | set ::rb_var($phasenum,$bodnum,$mapnum,l33) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 8] $mulvarlist] |
---|
2053 | set ::rb_var($phasenum,$bodnum,$mapnum,l12) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 9] $mulvarlist] |
---|
2054 | set ::rb_var($phasenum,$bodnum,$mapnum,l13) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 10] $mulvarlist] |
---|
2055 | set ::rb_var($phasenum,$bodnum,$mapnum,l23) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 11] $mulvarlist] |
---|
2056 | |
---|
2057 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,l11) ::rb_var($phasenum,$bodnum,$mapnum,l22) ::rb_var($phasenum,$bodnum,$mapnum,l33) |
---|
2058 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,l12) ::rb_var($phasenum,$bodnum,$mapnum,l13) ::rb_var($phasenum,$bodnum,$mapnum,l23) |
---|
2059 | |
---|
2060 | set ::rb_var($phasenum,$bodnum,$mapnum,s12) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 12] $mulvarlist] |
---|
2061 | set ::rb_var($phasenum,$bodnum,$mapnum,s13) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 13] $mulvarlist] |
---|
2062 | set ::rb_var($phasenum,$bodnum,$mapnum,s21) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 14] $mulvarlist] |
---|
2063 | set ::rb_var($phasenum,$bodnum,$mapnum,s23) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 15] $mulvarlist] |
---|
2064 | set ::rb_var($phasenum,$bodnum,$mapnum,s31) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 16] $mulvarlist] |
---|
2065 | set ::rb_var($phasenum,$bodnum,$mapnum,s32) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 17] $mulvarlist] |
---|
2066 | set ::rb_var($phasenum,$bodnum,$mapnum,saa) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 18] $mulvarlist] |
---|
2067 | set ::rb_var($phasenum,$bodnum,$mapnum,sbb) [RB_VarSet [lindex $::rb_map_tls_var($phasenum,$bodnum,$mapnum) 19] $mulvarlist] |
---|
2068 | |
---|
2069 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,s12) ::rb_var($phasenum,$bodnum,$mapnum,s13) ::rb_var($phasenum,$bodnum,$mapnum,s21) |
---|
2070 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,s23) ::rb_var($phasenum,$bodnum,$mapnum,s31) ::rb_var($phasenum,$bodnum,$mapnum,s32) |
---|
2071 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,saa) ::rb_var($phasenum,$bodnum,$mapnum,sbb) |
---|
2072 | |
---|
2073 | set ::rb_var($phasenum,$bodnum,$mapnum,tls) 1 |
---|
2074 | |
---|
2075 | } else { |
---|
2076 | set ::rb_var($phasenum,$bodnum,$mapnum,t11) "" |
---|
2077 | set ::rb_var($phasenum,$bodnum,$mapnum,t22) "" |
---|
2078 | set ::rb_var($phasenum,$bodnum,$mapnum,t33) "" |
---|
2079 | set ::rb_var($phasenum,$bodnum,$mapnum,t12) "" |
---|
2080 | set ::rb_var($phasenum,$bodnum,$mapnum,t13) "" |
---|
2081 | set ::rb_var($phasenum,$bodnum,$mapnum,t23) "" |
---|
2082 | |
---|
2083 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,t11) ::rb_var($phasenum,$bodnum,$mapnum,t22) ::rb_var($phasenum,$bodnum,$mapnum,t33) |
---|
2084 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,t12) ::rb_var($phasenum,$bodnum,$mapnum,t13) ::rb_var($phasenum,$bodnum,$mapnum,t23) |
---|
2085 | |
---|
2086 | set ::rb_var($phasenum,$bodnum,$mapnum,l11) "" |
---|
2087 | set ::rb_var($phasenum,$bodnum,$mapnum,l22) "" |
---|
2088 | set ::rb_var($phasenum,$bodnum,$mapnum,l33) "" |
---|
2089 | set ::rb_var($phasenum,$bodnum,$mapnum,l12) "" |
---|
2090 | set ::rb_var($phasenum,$bodnum,$mapnum,l13) "" |
---|
2091 | set ::rb_var($phasenum,$bodnum,$mapnum,l23) "" |
---|
2092 | |
---|
2093 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,l11) ::rb_var($phasenum,$bodnum,$mapnum,l22) ::rb_var($phasenum,$bodnum,$mapnum,l33) |
---|
2094 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,l12) ::rb_var($phasenum,$bodnum,$mapnum,l13) ::rb_var($phasenum,$bodnum,$mapnum,l23) |
---|
2095 | |
---|
2096 | set ::rb_var($phasenum,$bodnum,$mapnum,s12) "" |
---|
2097 | set ::rb_var($phasenum,$bodnum,$mapnum,s13) "" |
---|
2098 | set ::rb_var($phasenum,$bodnum,$mapnum,s21) "" |
---|
2099 | set ::rb_var($phasenum,$bodnum,$mapnum,s23) "" |
---|
2100 | set ::rb_var($phasenum,$bodnum,$mapnum,s31) "" |
---|
2101 | set ::rb_var($phasenum,$bodnum,$mapnum,s32) "" |
---|
2102 | set ::rb_var($phasenum,$bodnum,$mapnum,saa) "" |
---|
2103 | set ::rb_var($phasenum,$bodnum,$mapnum,sbb) "" |
---|
2104 | |
---|
2105 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,s12) ::rb_var($phasenum,$bodnum,$mapnum,s13) ::rb_var($phasenum,$bodnum,$mapnum,s21) |
---|
2106 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,s23) ::rb_var($phasenum,$bodnum,$mapnum,s31) ::rb_var($phasenum,$bodnum,$mapnum,s32) |
---|
2107 | lappend ::rb_var_list_tls ::rb_var($phasenum,$bodnum,$mapnum,saa) ::rb_var($phasenum,$bodnum,$mapnum,sbb) |
---|
2108 | |
---|
2109 | set ::rb_var($phasenum,$bodnum,$mapnum,tls) 0 |
---|
2110 | } |
---|
2111 | |
---|
2112 | } |
---|
2113 | |
---|
2114 | proc RB_VarSet {varin mulvarlist args} { |
---|
2115 | if {$varin == 0} {set varout "" |
---|
2116 | } else { |
---|
2117 | set temp [lsearch $mulvarlist $varin] |
---|
2118 | if {$temp == "-1"} {set varout "free" |
---|
2119 | } else { |
---|
2120 | set varout var$varin |
---|
2121 | } |
---|
2122 | } |
---|
2123 | return $varout |
---|
2124 | } |
---|
2125 | |
---|
2126 | #returns next unused rigid body number |
---|
2127 | proc RB_New_RBnum {args} { |
---|
2128 | |
---|
2129 | set temp [RigidBodyList] |
---|
2130 | for {set count 1} {[lsearch $temp $count] != -1} {incr count} { |
---|
2131 | } |
---|
2132 | return $count |
---|
2133 | } |
---|
2134 | |
---|
2135 | proc RB_CartesianTextFile {bodnum args} { |
---|
2136 | if {$::rb_matrix_num($bodnum) > 1} { |
---|
2137 | MyMessageBox -message "Multiple matrices present, cannot save coordinates to file" |
---|
2138 | return |
---|
2139 | } |
---|
2140 | set rb_file_write [tk_getSaveFile -filetypes {{"Cartesian output" .cart} {"All files" *}}] |
---|
2141 | set fh [open $rb_file_write w] |
---|
2142 | set coordnummax $::rb_coord_num($bodnum,1) |
---|
2143 | for {set coord 0} {$coord < $coordnummax} {incr coord} { |
---|
2144 | set line [list $::rb_x($bodnum,1,$coord) $::rb_y($bodnum,1,$coord) $::rb_z($bodnum,1,$coord)] |
---|
2145 | # puts $line |
---|
2146 | # puts $fh $line |
---|
2147 | } |
---|
2148 | close $fh |
---|
2149 | } |
---|
2150 | |
---|
2151 | ############################################################################################ |
---|
2152 | proc RB_View_Parameters {phase x y args} { |
---|
2153 | set euler $::rb_map_euler($phase,$x,$y) |
---|
2154 | set positions $::rb_map_positions($phase,$x,$y) |
---|
2155 | set damping $::rb_map_damping($phase,$x,$y) |
---|
2156 | catch {destroy .viewparam} |
---|
2157 | set vp .viewparam |
---|
2158 | toplevel $vp |
---|
2159 | wm title $vp "Refinement Options" |
---|
2160 | frame $vp.con -bd 2 -relief groove |
---|
2161 | frame $vp.spa -bd 2 -relief groove |
---|
2162 | frame $vp.refflag -bd 2 -relief groove |
---|
2163 | grid $vp.con -row 0 -column 0 |
---|
2164 | |
---|
2165 | grid $vp.spa -row 2 -column 0 |
---|
2166 | grid $vp.refflag -row 1 -column 0 |
---|
2167 | |
---|
2168 | set con $vp.con |
---|
2169 | label $con.lbl -text "Refine: " |
---|
2170 | button $con.tog -text "off" |
---|
2171 | grid $con.lbl -row 0 -column 0 |
---|
2172 | grid $con.tog -row 0 -column 1 |
---|
2173 | |
---|
2174 | grid [label $vp.spa.lbl1 -text "Supplemental Position Angles"] row 0 -column 0 -columnspan 3 |
---|
2175 | set ::e_angle1$y [lindex [lindex $euler 3] 0] |
---|
2176 | |
---|
2177 | set ::e_angle2$y [lindex [lindex $euler 4] 0] |
---|
2178 | set ::e_angle3$y [lindex [lindex $euler 5] 0] |
---|
2179 | grid [label $vp.spa.angle1l -text "Sup. Angle 1"] -row 1 -column 0 |
---|
2180 | grid [label $vp.spa.angle2l -text "Sup. Angle 2"] -row 2 -column 0 |
---|
2181 | grid [label $vp.spa.angle3l -text "Sup. Angle 3"] -row 3 -column 0 |
---|
2182 | grid [entry $vp.spa.angle1 -textvariable ::e_angle1$y] -row 1 -column 1 |
---|
2183 | grid [entry $vp.spa.angle2 -textvariable ::e_angle2$y] -row 2 -column 1 |
---|
2184 | grid [entry $vp.spa.angle3 -textvariable ::e_angle3$y] -row 3 -column 1 |
---|
2185 | |
---|
2186 | set e_axis1 [lindex [lindex $euler 3] 1] |
---|
2187 | set e_axis2 [lindex [lindex $euler 4] 1] |
---|
2188 | set e_axis3 [lindex [lindex $euler 5] 1] |
---|
2189 | |
---|
2190 | grid [label $vp.refflag.lbl1 -text "Refinement Flags"] -row 0 -column 0 -columnspan 3 |
---|
2191 | grid [label $vp.refflag.x_axis -text "X-axis"] -row 1 -column 0 |
---|
2192 | grid [label $vp.refflag.y_axis -text "Y-axis"] -row 1 -column 1 |
---|
2193 | grid [label $vp.refflag.z_axis -text "Z-axis"] -row 1 -column 2 |
---|
2194 | grid [label $vp.refflag.euler1 -text "Euler Angle 1"] -row 3 -column 0 |
---|
2195 | grid [label $vp.refflag.euler2 -text "Euler Angle 2"] -row 3 -column 1 |
---|
2196 | grid [label $vp.refflag.euler3 -text "Euler Angle 3"] -row 3 -column 2 |
---|
2197 | grid [label $vp.refflag.sup1 -text "Sup. Angle 1"] -row 5 -column 0 |
---|
2198 | grid [label $vp.refflag.sup2 -text "Sup. Angle 2"] -row 5 -column 1 |
---|
2199 | grid [label $vp.refflag.sup3 -text "Sup. Angle 3"] -row 5 -column 2 |
---|
2200 | |
---|
2201 | for {set j 0} {$j < 9} {incr j} { |
---|
2202 | label $vp.refflag.$j -text [lindex $positions $j] |
---|
2203 | } |
---|
2204 | grid $vp.refflag.0 -row 2 -column 0 |
---|
2205 | grid $vp.refflag.1 -row 2 -column 1 |
---|
2206 | grid $vp.refflag.2 -row 2 -column 2 |
---|
2207 | grid $vp.refflag.3 -row 4 -column 0 |
---|
2208 | grid $vp.refflag.4 -row 4 -column 1 |
---|
2209 | grid $vp.refflag.5 -row 4 -column 2 |
---|
2210 | grid $vp.refflag.6 -row 6 -column 0 |
---|
2211 | grid $vp.refflag.7 -row 6 -column 1 |
---|
2212 | grid $vp.refflag.8 -row 6 -column 2 |
---|
2213 | |
---|
2214 | } |
---|
2215 | |
---|