set ::rb_loader(zmatrix) RB_Zmat_Load set ::rb_descriptor(zmatrix) "Cartesian Coordinates generated by Z-Matrix" proc RB_Zmat_Load {args} { destroy .zmatrix toplevel .zmatrix set zmat .zmatrix pack [frame $zmat.con -bd 2 -relief groove] -side top pack [frame $zmat.display -bd 2 -relief groove] -side top -expand 1 -fill both pack [frame $zmat.save -bd 2 -relief groove] -side bottom wm title $zmat "Load rigid body information from Z-Matrix" wm geometry $zmat 600x600+10+10 set ::rb_file_load "" set ::rb_zmatfile "" set filelist "" set files [glob -nocomplain [file join $::expgui(scriptdir) *.zmat]] foreach file $files { lappend ::rb_zmatfile [lindex [string map {"/" " "} $file] end] } puts $::rb_zmatfile set ::rb_file_load [lindex $::rb_zmatfile 0] # grid [label $zmat.con.lbl -text "Choose Z-Matrix file to load"] -row 1 -column 0 # eval tk_optionMenu $zmat.con.file ::rb_file_load $::rb_zmatfile # grid $zmat.con.file -row 1 -column 1 grid [button $zmat.con.but -text "Load Z-Matrix" -width 22 -command "RB_Zmat $zmat.display"] -row 2 -column 1 grid [button $zmat.save.but2 -text "Continue" -width 17 -command "RB_Zmat_Convert"] -row 2 -column 1 -padx 5 $zmat.save.but2 config -state disable grid [button $zmat.save.but3 -text "Abort" -width 17 -command "destroy .zmatrix"] -row 2 -column 2 -padx 5 -sticky ns } proc RB_Zmat {location args} { set ::rb_file_load [tk_getOpenFile -parent .zmatrix -filetypes { {"Z-matrix input" .zmat} {"All files" *} }] if {[string trim $::rb_file_load] == ""} return set fh [open $::rb_file_load r] set ::rb_linenum 1 while {[eof $fh] != 1} { set temp [gets $fh line] set ::tline($::rb_linenum) $line puts "$::rb_linenum line = $::tline($::rb_linenum)" incr ::rb_linenum } RB_Zmat_Display $location .zmatrix.save.but2 config -state normal } proc RB_Zmat_Display {location args} { eval destroy [winfo children $location] foreach {top main side lbl} [MakeScrollTable $location] {} grid [label $main.dlbl -text "Dummy Atom"] -row 0 -column 0 for {set z 1} {$z <= [expr $::rb_linenum - 1]} {incr z} { switch -exact $z { 1 {set ::zlabel($z) [lindex $::tline($z) 0] set ::zc1($z) 0 set ::zdist($z) 0 set ::zc2($z) 0 set ::zangle($z) 0 set ::zc3($z) 0 set ::ztors($z) 0 if {$::zlabel($z) == "X"} {set ::rb_dummy_atom($z) 1 } else { set ::rb_dummy_atom($z) 0} grid [checkbutton $main.d$z -variable ::rb_dummy_atom($z)] -row $z -column 0 grid [entry $main.zlabel$z -width 3 -textvariable ::zlabel($z)] -row $z -column 1 } 2 {set ::zlabel($z) [lindex $::tline($z) 0] set ::zc1($z) [lindex $::tline($z) 1] set ::zdist($z) [lindex $::tline($z) 2] set ::zc2($z) 0 set ::zangle($z) 0 set ::zc3($z) 0 set ::ztors($z) 0 if {$::zlabel($z) == "X"} {set ::rb_dummy_atom($z) 1 } else { set ::rb_dummy_atom($z) 0} grid [checkbutton $main.d$z -variable ::rb_dummy_atom($z)] -row $z -column 0 grid [entry $main.zlabel$z -width 3 -textvariable ::zlabel($z)] -row $z -column 1 grid [entry $main.zc1$z -width 3 -textvariable ::zc1($z)] -row $z -column 2 grid [entry $main.zdist$z -width 6 -textvariable ::zdist($z)] -row $z -column 3 } 3 {set ::zlabel($z) [lindex $::tline($z) 0] set ::zc1($z) [lindex $::tline($z) 1] set ::zdist($z) [lindex $::tline($z) 2] set ::zc2($z) [lindex $::tline($z) 3] set ::zangle($z) [lindex $::tline($z) 4] set ::zc3($z) 0 set ::ztors($z) 0 if {$::zlabel($z) == "X"} {set ::rb_dummy_atom($z) 1 } else { set ::rb_dummy_atom($z) 0} grid [checkbutton $main.d$z -variable ::rb_dummy_atom($z)] -row $z -column 0 grid [entry $main.zlabel$z -width 3 -textvariable ::zlabel($z)] -row $z -column 1 grid [entry $main.zc1$z -width 3 -textvariable ::zc1($z)] -row $z -column 2 grid [entry $main.zdist$z -width 6 -textvariable ::zdist($z)] -row $z -column 3 grid [entry $main.zc2$z -width 3 -textvariable ::zc2($z)] -row $z -column 4 grid [entry $main.zangle$z -width 8 -textvariable ::zangle($z)] -row $z -column 5 } default {set ::zlabel($z) [lindex $::tline($z) 0] set ::zc1($z) [lindex $::tline($z) 1] set ::zdist($z) [lindex $::tline($z) 2] set ::zc2($z) [lindex $::tline($z) 3] set ::zangle($z) [lindex $::tline($z) 4] set ::zc3($z) [lindex $::tline($z) 5] set ::ztors($z) [lindex $::tline($z) 6] if {$::zlabel($z) == "X"} {set ::rb_dummy_atom($z) 1 } else { set ::rb_dummy_atom($z) 0} grid [checkbutton $main.d$z -variable ::rb_dummy_atom($z)] -row $z -column 0 grid [entry $main.zlabel$z -width 3 -textvariable ::zlabel($z)] -row $z -column 1 grid [entry $main.zc1$z -width 3 -textvariable ::zc1($z)] -row $z -column 2 grid [entry $main.zdist$z -width 6 -textvariable ::zdist($z)] -row $z -column 3 grid [entry $main.zc2$z -width 3 -textvariable ::zc2($z)] -row $z -column 4 grid [entry $main.zangle$z -width 8 -textvariable ::zangle($z)] -row $z -column 5 grid [entry $main.zc3$z -width 3 -textvariable ::zc3($z)] -row $z -column 6 grid [entry $main.ztors$z -width 6 -textvariable ::ztors($z)] -row $z -column 7 } } ResizeScrollTable $location } } proc RB_Zmat_Convert {args} { set bodytyp [RB_New_RBnum] puts "bodytyp = $bodytyp" # set bodytyp [expr [llength [RigidBodyList]] + 1] set atomlist "" for {set z 1} {$z <= [expr $::rb_linenum - 1]} {incr z} { set temp "" set temp "$::zlabel($z) $::zc1($z) $::zdist($z) $::zc2($z) $::zangle($z) $::zc3($z) $::ztors($z)" lappend atomlist $temp } puts $atomlist set precoordlist [zmat2coord $atomlist] #remove dummy atoms before transfer to Create Rigid Body procedure set coordnum 1 set sitenum 0 set coordlist "" foreach coord $precoordlist { if {$::rb_dummy_atom($coordnum) != 1} {lappend coordlist $coord; incr sitenum} incr coordnum } set ::rb_num 1 set ::rb_matrix_num($bodytyp) 1 set ::rb_coord_num($bodytyp,1) $sitenum set coordnum 0 catch {array unset ::rb_x $bodytyp,1,*} catch {array unset ::rb_y $bodytyp,1,*} catch {array unset ::rb_z $bodytyp,1,*} foreach coord $coordlist { incr coordnum set ::rb_x($bodytyp,1,$coordnum) [lindex $coord 1] set ::rb_y($bodytyp,1,$coordnum) [lindex $coord 2] set ::rb_z($bodytyp,1,$coordnum) [lindex $coord 3] } destroy .cartesian NewBodyTypeWindow # $::rb_notebook raise [$::rb_notebook page 0] # set pane [$::rb_notebook getframe rb_body0] # set con2 $pane.con2 # RB_Create_Cart $bodytyp $con2 destroy .zmatrix }