ó
u™xTc           @   sÝ   d  d l  m Z d  d l m Z d  d l m Z m Z d  d l m Z d  d l	 m
 Z
 d  d l m Z d  d l Z d  d l Z d e
 j f d	 „  ƒ  YZ d
 e
 j f d „  ƒ  YZ d „  Z e d k rÙ e e j d ƒ n  d S(   iÿÿÿÿ(   t   division(   t   tst_molecules(   t   minimum_covering_spheret	   sphere_3d(   t   flex(   t	   wx_viewer(   t   UsageNt   viewerc           B   s_   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z e e d „ Z d „  Z	 d „  Z
 d „  Z RS(	   c         O   s   t  t |  ƒ j | | Ž  d  S(   N(   t   superR   t   __init__(   t   selft   argst   kwds(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyR	      s    c         C   s€   |  j  j ƒ  xQ t |  j j |  j j ƒ D]4 \ } } x% | j D] } |  j  j | | ƒ q? Wq) Wd  |  _	 d  |  _
 d  |  _ d  S(   N(   t   pointst   cleart   zipt   simt   bodiest   AJA_accut   sitest   appendt   Nonet   labels_display_listt   lines_display_listt   points_display_list(   R
   t   Bt   AJAt   s(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt
   set_points   s    (		c   
         so  | d k r$ t  j d | ƒ ˆ _ n t  j | ƒ  ˆ _ t j ƒ  ˆ _ ˆ j ƒ  ‡ f d †  } g  ˆ _ g  ‰ x˜ ˆ j j	 D]Š ‰  ˆ j
 t ˆ j ƒ ƒ ˆ j j ˆ  j ƒ ‡  ‡ f d †  } xF ˆ  j D]; } g  | D] } | | ƒ ^ qÓ \ } } | | | d ƒ qÆ Wq{ Wt ˆ j d d ƒ}	 t d |	 j ƒ  d	 |	 j ƒ  d
 ƒ ˆ _ t ˆ _ t ˆ _ d ˆ _ ˆ j ƒ  d  S(   Ni    t   NBc            s-   |  | f } ˆ  j  j | ƒ | ˆ  j | <d  S(   N(   t   line_i_seqsR   t   line_colors(   t   it   jt   colort   line(   R
   (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   add_line   s    c            s/   |  d k  r ˆ ˆ  j  d |  Sˆ d |  Sd  S(   Ni    i   iÿÿÿÿ(   t   parent(   R    (   R   t   B_off(    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   add_off(   s     i   t   epsilong{®Gáz„?t   centert   radiusgÍÌÌÌÌÌô?(   i   i    i    (   R   t   simulation_zigzagR   t   simulation_factoriesR   t   vec3_doubleR   R   t   labelsR   R   t   lent   extendt   bondsR   R   R)   R*   t   Falset!   flag_show_minimum_covering_spheret   flag_show_rotation_centert   steps_per_tabt   show_key_stroke_help(
   R
   t   simulation_factory_indext   n_zigzagR$   R'   t   bondt   bR    R!   t   mcs(    (   R   R&   R
   sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   set_points_and_lines   s,    
	%"			c         C   s   d GHd GHd GHd GHd GHd  S(   Ns-   Press and hold Tab key to run the simulation.s"   Press Shift-Tab to increase speed.s"   Press Ctrl-Tab  to decrease speed.sF   Press [0-9A-F] for sensitivity test with this many significant digits.s   Press M for minimization.(    (   R
   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyR6   6   s
    c         C   sn   | t  d ƒ k r |  j ƒ  Sx< t d ƒ D]. \ } } | t  | ƒ k r) |  j d | ƒ Sq) Wd GH|  j ƒ  d  S(   Nt   Mt   0123456789ABCDEFt   n_significant_digitss   No action for this key stroke.(   t   ordt   minimizationt	   enumeratet   sensitivity_testR6   (   R
   t   keyt   nt   digit(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   process_key_stroke>   s    
c         C   s‚   | s | rW | r. t  d |  j d ƒ |  _ n t d |  j d ƒ |  _ d G|  j GHd  S|  j j d d ƒ |  j ƒ  |  j ƒ  d  S(   Ni   i   i   s   Steps per Tab:t   delta_tgš™™™™™©?(   t   minR5   t   maxR   t   dynamics_stepR   t   OnRedraw(   R
   t
   shift_downt   control_down(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   tab_callbackG   s    
c         C   s[   | d k r d GHd  } n	 d | GH|  j j d | ƒ } t j | ƒ j ƒ  j d d ƒ d  S(   Ni    s"   Sensitivity test (full precision):s)   Sensitivity test (%d significant digits):R?   t   prefixt    (   R   R   RC   R   t   doublet   min_max_meant   show(   R
   R?   t   qdd(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyRC   S   s    		c         C   sC   d GHd G|  j  j GH|  j  j d d d |  j ƒ d G|  j  j GHd  S(   Ns   Minimization:s     start e_pot:t   max_iterationsi
   t   callback_after_steps     final e_pot:(   R   t   e_potRA   t   minimization_callback(   R
   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyRA   \   s    
c         C   s'   d G|  j  j GH|  j ƒ  |  j ƒ  d  S(   Ns           e_pot:(   R   RX   R   RL   (   R
   t	   minimizer(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyRY   d   s    
(   t   __name__t
   __module__R	   R   R<   R6   RG   R2   RO   RC   RA   RY   (    (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyR   
   s   										t   Appc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s¶   t  t j ƒ } t  | ƒ d k r0 t d ƒ ‚ n  t | d ƒ |  _ t  | ƒ d k rk t | d ƒ |  _ n	 d |  _ d |  j k oŽ | k  n s™ t ‚ t t	 |  ƒ j
 d d ƒ d  S(	   Ni   i   s2   scitbx.python wx_molecules.py sim_index [n_zigzag]i    i
   t   titlet   wx_molecules(   i   i   (   R/   R   R,   R   t   intR7   R8   t   AssertionErrorR   R]   R	   (   R
   R   RE   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyR	   k   s    	%c         C   s‰   t  j t  j ƒ } t |  j d d ƒ|  _ |  j j d |  j d |  j ƒ | j	 |  j t  j
 t  j
 ƒ |  j j | ƒ | j |  j ƒ d  S(   Nt   sizeiX  R7   R8   (   iX  iX  (   t   wxt   BoxSizert   VERTICALR   t   framet   view_objectsR<   R7   R8   t   Addt   EXPANDt   SetSizert   SetSizeHints(   R
   t   box(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   init_view_objectsw   s    	
(   R[   R\   R	   Rm   (    (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyR]   i   s   	c         C   s   t  |  ƒ j ƒ  d  S(   N(   R]   t   MainLoop(   R   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   run�   s    t   __main__i   (   t
   __future__R    t   scitbx.rigid_body.protoR   t   scitbx.mathR   R   t   scitbx.array_familyR   t   gltbxR   t   libtbx.utilsR   Rc   t   syst   show_points_and_lines_mixinR   R]   Ro   R[   t   argv(    (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/rigid_body/proto/wx_molecules.pyt   <module>   s   _	