ó
ÉÝ{Tc           @   sB   d  Z  d d l Z d d l Td e j f d „  ƒ  YZ d „  Z d S(   s}  
     python/ui/Annotation.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009-2010 University of York

     This library is free software: you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public License
     version 3, modified in accordance with the provisions of the 
     license to address the requirements of UK law.
 
     You should have received a copy of the modified GNU Lesser General 
     Public License along with this library.  If not, copies may be 
     downloaded from http://www.ccp4.ac.uk/ccp4license.php
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU Lesser General Public License for more details.
iÿÿÿÿN(   t   *t
   Annotationc        	   B   sÝ   e  Z i  Z d  d d  i  d d „ Z d „  Z d „  Z d „  Z d „  Z d  d „ Z d	 „  Z	 d  d  d  d  d  d  d  d d
 „ Z
 d  d  d „ Z d „  Z d „  Z d „  Z d „  Z d d „ Z d d d d d „ Z d „  Z RS(   t    i   i    c   	   
   K   s|  t  ƒ  j d ƒ } i d | d d 6d d d g d 6t d 6d d	 6} | j | ƒ | j | ƒ | j d
 ƒ r† | d
 | d <| d
 =n  | j d ƒ rÆ | d d d !| d <| d d | d	 <| d =n  | j d ƒ rØ n  | j d ƒ rê n  t j j |  d | d | d | d | ƒd d d g |  _ d d g |  _	 d |  _
 g  |  _ |  j d |  j ƒ |  j d	 |  j ƒ |  j d ƒ d  S(   Nt
   annotations   <span s   >Annotation</span>t   textg        t   positiont   centeredR   t   atom_positiont	   selectiont   stylei    i   t   colourt   fontR   t   parentt   visiblet   paramss   -5.0s   5.0t   create(   t   FONTMANAGERt   getHtmlFontt   Falset   updatet   has_keyt   dataobjt   DispObjt   __init__t   deltat   extentt   movingt   graph_objectst   set_textR   t   set_positionR   t   update_dependents(	   t   selfR   R   t   nameR   t   restore_from_versiont   keywordsR   t   pars(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR   "   s8    


		c         C   sc   d d  l  } | j ƒ  } | j t |  j ƒ ƒ | j ƒ  j ƒ  j d d ƒ } | t d t	 | ƒ ƒ  S(   Niÿÿÿÿs   
t    i   (
   t   ParseHTMLTextStringt   MyHTMLParsert   feedt   strR   t
   getAllDatat   stript   replacet   mint   len(   R   R%   t   parsert   data(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   get_text_labelV   s
    c         C   s
   |  j  ƒ  S(   N(   R0   (   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   get_selection_label^   s    c         C   s   |  j  S(   N(   R   (   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   get_positionb   s    c         C   sI   |  j  r |  j  Sd |  j d d d |  j d d d |  j d Sd  S(   Ns   %.1fi    R$   i   i   (   R   R   (   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   get_position_labelg   s    	c         C   s   | |  _  d |  _ d  S(   Ni   (   R   t	   do_redraw(   R   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR   q   s    	c         C   sJ   | j  ƒ  d k rF | j ƒ  \ } } } |  j d | d | d | ƒ n  d S(   s1   
    Handle mouse input to translate objects
    t	   translatet   dxt   dyt   dzN(   t   transformDeltaModet   worldTranslateR   (   R   t   glwidgetR6   R7   R8   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt	   transformw   s    c	         K   so  | s |  j  r" d \ }
 } } n |  j  \ }
 } } | d k r~ |  j j | ƒ } | d s~ | d \ }
 } } | |  _ q~ n  | d k r™ t | ƒ }
 n  | d k r´ t | ƒ } n  | d k rÏ t | ƒ } n  d \ } } } | ró t | ƒ } n  | rt | ƒ } n  | rt | ƒ } n  | | | g |  _ d |  _ |
 | | | | | g |  _  t |  j d ƒ |  _ d S(   s€   
    x,y,z are world coords to set position of annotation
    dx,dy,dz are delta screen coords to apply to existing postion
    g        R   i    i   N(   g        g        g        (   g        g        g        (   R   R   t
   get_centreR   t   floatR   t   maxR4   (   R   R   t   xt   yt   zR6   R7   R8   t   zeroR"   t   xoldt   yoldt   zoldt   rvt   ddxt   ddyt   ddz(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR   ‚   s2    

      	c         K   s   d |  _  d  S(   Ni   (   R4   (   R   t	   attributet   masterR"   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   handle_moving_data­   s    c         C   s^  |  j  sC d d  l } | j ƒ  |  _  t ƒ  j |  j  ƒ d |  _ n  |  j d k rÅ t |  j ƒ d k r¸ |  j  r¸ d d  l } x- |  j D]" } | j |  j  j	 | j
 ƒ  ƒ q† Wg  |  _ n  |  j ƒ  n| |  j rA|  j rAd d  l } |  j d j | j |  j d |  j d |  j d ƒ g ƒ |  j d j t |  j ƒ ƒ qAn  |  j j d ƒ d |  _ d S(   Niÿÿÿÿi   i   i    t   label_graphmod(   RN   t   graphicsmodelt   BUILDt   appendR4   R-   R   t   cprimt   DeleteTextLabelt   objt   GetIDt   create_annotationt
   pygl_coordt   SetVerticest	   CartesianR   t   SetCenteredt   boolR   t   do_rebuildGL(   R   RO   RR   t   graph_objectRW   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   unthreadedDraw³   s(    	 		;#	c         C   s  d d  l  } d d  l } g  } t ƒ  j d j j ƒ  } | j |  j d |  j d |  j d ƒ } | | } d d d g } |  j r² |  j	 j
 |  j ƒ } | d s² | d } q² n  | j ƒ  |  j d | j ƒ  |  j d | j ƒ  |  j d g |  _ | j |  j d | d |  j d | d |  j d | d ƒ }	 | j |  j d | d |  j d | d |  j d | d ƒ }
 |  j } d d  l } | j | |	 |
 ƒ } d | _ | j t |  j ƒ ƒ |  j j j | ƒ |  j j | ƒ |  j j j ƒ  d |  _ d d d g |  _ d  S(   Niÿÿÿÿi    i   i   g        (   RR   RW   t
   MAINWINDOWt	   glWidgetst   quatt   getInvMatrixRY   R   R   R   R=   t   get_xR   t   get_yt   get_zR   t	   TextLabelt   CreateTextLabelt   thisownRZ   R[   R   RN   RT   t   add_text_primitiveR   RQ   t   rebuildR4   (   R   RR   RW   t   xyzt   qmatt   cartt   cartnewt   atomxyzRG   t   pos1t   pos2R   Rf   t   label_ob(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyRV   Ø   s:    *
	
 			c         K   s²   d d  l  } d d d g } |  j rS |  j j |  j ƒ } | d sS | d } qS n  g  } x3 t d d ƒ D]" } | j |  j | | | ƒ qi Wt ƒ  j j	 j
 | |  j j ƒ d  S(   Niÿÿÿÿg        i    i   i   (   t   buildR   R   R=   t   rangeRQ   R   RP   t   glthreadt   gleventt	   centre_onRN   RT   (   R   R"   Rs   Ro   RG   Rk   t   i(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyRw     s    	
  c         K   sR   t  ƒ  } |  j r> | j |  j ƒ t ƒ  j |  j ƒ |  ` n  t j j |  ƒ d  S(   N(   R_   RN   t   removeGLDisplayObjectRP   t	   deletemodR   R   t   delete(   R   R"   t   win(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR{     s    			c         C   sI   t  j j |  ƒ } x0 d d d d g D] } t |  | d ƒ | | <q% W| S(   NR   R   R   R   R   (   R   R   R   t   getattr(   R   t   allR#   t   item(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR     s    g        c      
   K   s"  d } | r| j  j | ƒ r| r| j  j | ƒ r| j  | } | j  | } g  }	 x< t d d ƒ D]+ }
 |	 j t | |
 ƒ t | |
 ƒ ƒ qf W|  j d t | d ƒ | |	 d d t | d ƒ | |	 d d t | d ƒ | |	 d ƒ t j j |  d	 | d
 | d | d | ƒn  d  S(   NR   i    i   R@   RA   i   RB   i   t   initial_statust   final_statust   fractiont   step(	   R   R   Rt   RQ   R>   R   R   R   t   movie_interpolation(   R   R€   R�   R‚   Rƒ   R"   t   pkeyt   initialt   finalR   Rx   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR„   '  s    )%c      
   C   s  d d  l  } | j |  j ƒ  | j ƒ d } | s5 g  Sd } | j d ƒ rl d } |  j | j j d ƒ ƒ n  | j d ƒ sŠ | j d ƒ rÙ | j j d ƒ } |  j d | j j d ƒ d | d d | d d	 | d
 ƒ n  t | t j	 j
 |  | ƒ ƒ } | r|  j j d g ƒ n  | S(   Niÿÿÿÿi   i    R   R   R   R@   RA   RB   i   R   (   t   utilst
   dict_diffsR   R   R   t   getR   R?   R   R   t   update_data_status0t
   update_guiRQ   (   R   t
   shadowdispRˆ   t   diffsRG   Rk   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   update_data_status<  s      " N(   t   __name__t
   __module__t   class_dependentsR   R0   R1   R2   R3   R   R<   R   RM   R^   RV   Rw   R{   R   t   NoneR„   R�   (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyR      s(   	3				
	*	%	+		
c          C   si   d d  l  }  |  j d d d d d d d g  d	 i d
 d g d d g d
 d g g d 6d i i  d 6ƒ } | S(   NiÿÿÿÿR    t   annotation_formatt   helpt   twoDobjectst   titles   Annotation formatt   guit   defaultR   s   Res nameR$   s   Chain ids   Seq #t   formatt
   definition(   t   servicest   ParamsManager(   Rœ   t   pm(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   createAnnotationParamsManagerS  s    	((   t   __doc__R   t   global_definitionsR   R   RŸ   (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Annotation.pyt   <module>   s
   
ÿ 9