)Kc<@sdZddkZddkZddkZddddddddd dd d d dd ddddddddddddddddddddd dd dddddddddddd dddddddg9dgdddddddddddd ddd ddgdgdZddddddddddd d!d"d#d$d$d$d d%gd&gd'd(gdd)gdZd*Zd+ei fd,YZ e d-joddk Z ddk Zeie id.ZeiZei ed/d0d1d2Zeie ed3ed/d4d1d4d5dZeieid6dd7deid8d9d:eZeaad;Zd<Zeid=eeid>eeindS(?s Author: David J. Giesen Eastman Kodak Company Shows a molecule on a Tk canvas. The molecule can be rotated, and if it has frequencies, the frequencies can be animated iNtgreys light greys light bluetbluetgreentblacktreds light greentbrowns dark greyttantpinktyellows dark greensdark redtwhites dark bluetorangetpurpleitgoldtcyani ig?g333333?gQ?gp= ף?gQ?g?gffffff?gRQ?gzG?g?g?g(\?ig)\(?gffffff?gItMolPlotcBseZddddddedZedZdZdZdZd Z d Z d Z d Z d Z dZdZdZedZedZdZdZdZdZdZdZdZdZdddZRS(ii R ic Ks||_tii||id|d|d|d|d|| |o|i|n d|_|id|_d|_ |i d|i |i d|i d|_ t|_d |_d|_d |_|oD|idddddddddd}|i|d|indS(Ntheighttwidthtbgtbdthighlightthicknesss sg$@g@iiii ii itfillRs (ii(ii (ii(i i(ii (ii(i i(ii(tparenttTktCanvast__init__tchange_moleculetNonetmoleculet define_centert track_start_xt track_start_ytbindtrotation_trackingtstop_rotation_trackertframestFalsetfrequency_runningtfrequency_scaletfrequency_speedtafter_idtcreate_polygonttag_bindtstop_frequency( tselfRRRRRRRtstopsigntkwargs((s molshow.pycR#s$ 7         *cCs|ii|ii}x|iiD]q}|o |i}n |i}|d|ii|}|i||_|d||d||dg|_q#WdS(Niii( Rt foregroundthorizontatomst vib_coordstcoordst ball_radiustperspective_radiustperspective_coords(R+t vibratingttotal_ztatomR2t perspective((s molshow.pyctprovide_perspectiveIs   cCsB|i|_|i|_|id|i|id|idS(Nss(txRtyRRR R!(R+tevent((s molshow.pyctstart_rotation_trackerYs  cCsd|_d|_dS(N(RRR(R+R=((s molshow.pycR!_s cCs|idjo|i|_|i|_|i|i}|i|i}tid||f}|djoYt i |t |i |i }| |f}|i|||i|_|i|_qn|i|_|i|_dS(Ng(gg(RRR;t track_stop_xR<t track_stop_yRtgptdistancetmathtpitmintcenterxtcenterytrotate_molecule(R+R=tdeltaxtdeltaytlengthtangletrotation_vector((s molshow.pycR cs       c Csz|d}||}|d}||}||}d}||} ti| } ti|} ti|} d| } || | }|| | }|| | }ti|_|iiti|idi||| | |idi||idi||iiti|idi||idi||| | |idi| |iiti|idi| |idi||idi||| | x|ii D]}ti}xut dD]g}|itig}t dD]#}||i ||i||q~|di |dWqWqW|ip|indS(Niigg?iii(RCtsqrttsintcosRAtRichListtrotation_matrixtappendRR0txrangeR2tsumt frequenciest displacementsR$t plot_molecule(R+tvectortthetatutu2tvtv2tuvtwtL2tLtsinthtcostht one_m_costht vsinth_over_Lt usinth_over_Ltuv_one_m_costh_over_L2R8tdotprodstindt_[1]R;t_[2]tfreqtmovet_[3]tcoord((s molshow.pycRHzsb             M(    J  cCst|idS(NR(tinttcget(R+((s molshow.pycRscCst|idS(NR(RqRr(R+((s molshow.pycRscCs*|id|_|id|_dS(Ng@(RRFRRG(R+((s molshow.pycRscCs|i||idS(N(RRX(R+R((s molshow.pyctshow_new_molecules cCsp|io|in||_x1|iD]&}t|i|_t|i|_q+W|ii |i dS(N( R$R*RR0t ball_radiitnumberR3telement_colorstcolort center_ittfind_largest_distance(R+RR8((s molshow.pycRs    cCsed}x2|iiD]$}t|ti|id}qWtt| d|i_||i_dS(Ngg?(ggg( RR0tmaxRARBR2RER/R.(R+t max_distanceR8((s molshow.pycRys  "cCs|iddS(NR(tdelete(R+((s molshow.pycterase_moleculescCsE| p||ijo)|io|in|idndS(NR(RR$R*R|(R+R((s molshow.pyctdelete_molecules cCsa|ioS|i|ii|i|i|id||i|indS(NR6(RR}Rxtdetermine_scaleRR:tcreate_plot_listt plot_items(R+R6((s molshow.pycRXs      cCs@|i|i|id}|i|i|id}||fS(Nii(RFtpixels_per_angR5RG(R+R8RFRG((s molshow.pyct atom_centerscCsE|i|\}}|i|i}||||||||fS(N(RR4R(R+R8RFRGtradius((s molshow.pyctball_coordinatesscCs|id|iS(Ni(R5R4(R+R8((s molshow.pyctget_atom_max_zscsti_xoiiD]a}ii|gxE|iD]:}||ijo$ii|ii|gq?q?WqWfd}iid|dS(NcsOt|djoi|dSn$t|did|didSdS(Niii(tlenRRzR5(t plot_item(R+(s molshow.pyctz_sortstkey( RARQt plot_listRR0RStbondstindextsort(R+R8RjR((R+s molshow.pycRs  ,cCsT|d|d}|d|d}|d||||d|||f}|S(Nii((R+tatbt clip_ratiotrisetruntnew_b((s molshow.pyct clip_bonds,c CsIxB|iD]7}t|djo1|i|i|dd|diddq |i|d\}}|i|d\}}ti|di|di}|di |}|i ||f||f|\}} |di |}|i ||f||f|\} } |i | | || d|i ddddq WdS(NiiRttagRRs#C0C0C0( RRt create_ovalRRwRRARBR5R4Rt create_linet bondwidth( R+titemRFRGtpartnerxtpartneryRBRtendxtendytstartxtstarty((s molshow.pycRs 1 ''cCs3g}|iiD]}||idq~}t|}t|}t||dd}|i|}g}|iiD]}||idq~~} t| } t| } t| | dd} |i| } t|| |_|idjo d|_n'|idjo d|_n d|_dS( Nig@g@ig9@ig$@i( RR0R2RERzRRRR(R+RkR8txcoordstxmintxmaxtxdeltatxpixels_per_angRltycoordstymintymaxtydeltatypixels_per_ang((s molshow.pycR+s .  .    cGs'|i|it|_|idS(N(t after_cancelR'R#R$RX(R+R=((s molshow.pycR*?s ic Cs/t|_|i|i||}||ijo|id}d}n|djod}d}nt||i}|i|}xct|i|i i D]I\}}g}t dD] } ||i | || |q~|_ qW|idt|itd|i|i||||_dS(NiiiiR6g@@(tTrueR$RR'R"tfloatR%tzipRWRR0RTR2R1RXtafterRqR&tanimate_frequency( R+Rmtframetcountt frame_factortscaleRnR8RkR;((s molshow.pycREs         AN(t__name__t __module__RR#RR:R>R!R RHRRRRsRRyR}R~RXRRRRRRRR*R(((s molshow.pycR"s0&     4             t__main__iRiXRiRRidt borderwidthtpadytipadyii,twindowcCsTtdjo|ia|ian.|it}|it}tit||dS(N(t plotmove_xRR;R<t plotmove_ytcanvasRnt plot_window(R=tmovextmovey((s molshow.pyct move_plotqs      cCsdaadS(N(RRR(R=((s molshow.pyct move_plot_endzss s( t__doc__tTkinterRtgiepyRARCRvRtR/RRRtsystreadxyztxyzt read_xyz_filetargvRtrootRtpacktplotRXt create_windowRRRRRRRtmainloop(((s molshow.pycss2   `;     $