ó
ÉÝ{Tc           @   s	  d  Z  d d l Td d l Td d l Td d l Td d l Td d l Td d l Td d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Td d l Z d d l Z d d l Z d d d „  ƒ  YZ d S(   sC  
     pygl/build.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC

     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ÿÿÿÿ(   t   *Nt   buildc           B   sŒ   e  Z d  Z d Z g  Z d d d d „ Z d „  Z d „  Z d „  Z d	 „  Z	 d
 „  Z
 d „  Z d d d d g d „ Z d d g d „ Z RS(   sÈ   
   Class which turns some chemical data into ball/stick pictures, etc and
   sends off abstract primitive data to OpenGL thread. Also handles selection
   of primitives, though not perfectly yet.
   t    i    t
   screenshots   .ppmc      	   C   sö  d } xét  | d ƒ D]×} t | ƒ t | ƒ } x|t  t |  j ƒ ƒ D]e}	 |  j |	 }
 d | | |	 j j d | | |	 j j d d | | |	 j j d | | |	 j j d d | | |	 j j d | | |	 j j d d | | |	 j j d | | |	 j j d g |
 j j _ d | | |	 j d | | |	 j d d | | |	 j d | | |	 j d d | | |	 j d | | |	 j d f |
 j _ qI W| d k rá| t j	 t
 | ƒ d ƒ | } q t j d ƒ q Wd S(	   sO   
       Takes two instances of buildSaveData and animates between them.
       i2   i   i    i   i   i   gš™™™™™¹?N(   t   ranget   floatt   lent   modst   quatt   dvalt   objt   origint   stringt   zfillt   strt   timet   sleep(   t   selft   pos1t   pos2t   exportt   filenamet   formatt   numstepst   jt   dxt   it   modt   fname(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   animate2   s    ///>))9#c         C   sg   |  t  _ g  |  _ d |  _ d |  _ d |  _ | |  _ d |  _ t j d ƒ |  _	 d |  _
 g  |  _ d S(   s3   
      Initilaization. Set up some defaults.
      iÿÿÿÿi    i   N(   R   t   instsR   t
   jobtypeoldt   oldxt   oldyt   glthreadt   selected_modelt   Queuet   jqt   animate_loadt   clicked_prims(   R   t   thread(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   __init__O   s    								c         C   s„   |  j  j | ƒ r7 |  j  j | ƒ } |  j  j | ƒ n  t | d ƒ rh t | j d ƒ rh | j j ƒ  n  t | d ƒ r€ | ` n  d S(   sš   
      Delete a model and all its objects and
      children, recursively hopefully. Instances
      should take care of themselves where possible.
      R
   t   clear_primst   sinfoN(   R   t   countt   indext   popt   hasattrR
   R*   R+   (   R   t   graphmodt   modid(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt	   deletemod�   s    !c         C   s   | |  _  d S(   sv   
        A function which tells the thread
        which Python Queue it is meant to 
        push events to.
        N(   R%   (   R   R%   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   registerqueue�   s    c         C   s   |  j  | ƒ |  j | ƒ d  S(   N(   t   append1t   append2(   R   R   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   append˜   s    c         C   s   | j  ƒ  d  S(   N(   t   build_primitives(   R   R   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyR4   œ   s    c         C   s9   d d  l  } | j ƒ  } | j | ƒ |  j d |  _ d  S(   Niÿÿÿÿi   (   t   MGApplicationt   GetMainWindowt   addGLDisplayObjectR#   (   R   R   R8   t   win(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyR5   Ÿ   s
    i   c         C   sš   t  j ƒ  } d | _ | | _ t d ƒ } | d | d <| d | d <d | d <| d | d <| d | d <d | d <t  j | | | ƒ |  j | ƒ d  S(	   Nt	   BILLBOARDi   i    i   i   i   i   i   (   t   cprimt   Displayobjectt   styleR
   t   doubleat   AddBillBoardImageR6   (   R   R   R   t	   coords_inR
   t   coords(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   newbillboard®   s    		

c         C   sM   t  j ƒ  } d | _ | | _ t  j | | d | d | ƒ |  j | ƒ d  S(   NR<   i    i   (   R=   R>   R?   R
   t   AddBillBoardTextLabelR6   (   R   R   t   labelRB   R
   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   newbillboardtextlabel¼   s
    		(   t   __name__t
   __module__t   __doc__R   t	   positionsR   R)   R2   R3   R6   R4   R5   RD   RG   (    (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyR   *   s   	2					(    (   RJ   t
   pygl_coordt   displayobjectt	   atom_utilt   mmdb2t   point_funcst	   eventdefst   graphicsmodelt   utilt   optsR   t	   threadingt   mathR   R$   t   syst   ost   picklet   textureR=   t   COLOURt   UtilityThreadR   (    (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/pygl/build.pyt   <module>   s(   







