ó
ÉŻ{Tc           @   s^   d  Z  d d l Z d d l Z d d l Td e j f d     YZ d e j f d     YZ d S(   sy  
     python/ui/Legend.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
   GL2dScreenc           B   s8   e  Z g  Z g  Z d  d i  d d  Z d i  d  Z RS(   s   Legends&Imagest    i    c         K   st   t  j j |  d d | d d d | d | t t j  d k rP |  t j d <n t j j |   t j j d  d  S(   NR   t   namet   modulet   Legendt   filenamet
   dataparamsi    (   t   dataobjt   DataObjt   __init__t   lenR   t   instst   appendt   names(   t   selfR   R   R   t   restore_from_versiont   kw(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR
      s    R   c         K   ss   | d k r- t  d |  j d d d |  } nB | d k ri d d  l } | j d |  j d d d |  } n d  } | S(   NR   t   parentt   visiblei   t   paramst   Imagei’’’’(   R   R   t	   MGGLImageR   t   None(   R   t   object_typeR   t   keywordst   dobjR   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt
   add_object.   s    !$(   t   __name__t
   __module__R   R   R
   R   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR      s   R   c           B   sŃ   e  Z i  Z d  d d  d i  d d  Z d   Z d   Z d d  Z d	   Z d
   Z d   Z	 d   Z
 d   Z d  d  Z d  d  Z d   Z d   Z d d  Z d   Z d d d d d  Z d   Z RS(   R   t   1R   i    c   
   
   K   sę  d d  l  } t   j d  }	 d |	 d |  _ d d g |  _ | j d  r» | j d  r» | j d  r» | j d  r» t j | d d  t j | d d  g | d <| d =| d =n  | j d	  r| j d
  rt j | d	 d  t j | d
 d  g | d <| d	 =| d
 =n  | j d  rN| j d  rNd GH| d =| d =n  | j	 |  t
 j j |  | | d | d | d | d |  _ g  |  _ | j    |  _ t   j |  j  d |  _ |  j d |  j d d  d |  _ d  S(   Ni’’’’t   legends   <span s   >Legend</span>g{®Gįz?t   colourt   stylet   positiont   xt   yt   text_colourt   fonts+   Can not restore Legend text_colour and fontR   R   R   R   i    t   textt   forcei   i   (   t   graphicsmodelt   FONTMANAGERt   getHtmlFontt	   selectionR"   t   has_keyt   gett   utilst	   safeFloatt   updateR   t   DispObjR
   t
   name_labelt   graph_objectst   label_graphmodt   BUILDR   t   movingt   set_selectiont	   do_redraw(
   R   R   R   R   t   typeR   t   restore_from_legendR   R)   R&   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR
   E   s,    <00(			c         C   s(   t  |  t  |  g |  _ d |  _ d  S(   Ni   (   t   floatR"   R9   (   R   R#   R$   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   set_positioni   s    c         C   s   |  j  S(   N(   R"   (   R   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   get_positiono   s    i   c         C   sI   t  j j |  d | } x* d d g D] } t |  | d  | | <q% W| S(   Nt   allR"   R,   R   (   R   R2   R   t   getattr(   R   R?   t   parst   key(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR   t   s    c         C   sŪ   d d  l  } d } | j |  j   | j  d } | rS d } |  j j d g  n  xc | j   D]U } | d k r |  j | d  q` | d k r` |  j | d d | d d  q` q` Wt | t	 j
 j |  |   } | S(   Ni’’’’i    i   R1   R,   R"   (   R/   t
   dict_diffsR   t
   update_guiR   t   keyst   set_textR=   t   maxR   R2   t   update_data_status0(   R   t
   shadowdispR/   t   rvt   diffsRB   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   update_data_status}   s    'c         C   s   d |  j  d |  j  d f S(   Ns	   %.2f %.2fi    i   (   R"   (   R   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   get_position_label   s    c         C   s]   d d  l  } | j   } | j |  j  | j   j   j d d  } | t d t |    S(   Ni’’’’s   
t    i   (	   t   ParseHTMLTextStringt   MyHTMLParsert   feedR,   t
   getAllDatat   stript   replacet   minR   (   R   RO   t   parsert   data(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   get_text_label   s
    c         C   s
   |  j    S(   N(   RX   (   R   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   get_selection_label   s    c         C   s   |  j  S(   N(   R,   (   R   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   get_text   s    c         K   s   |  j  |  d  S(   N(   RF   (   R   R'   t   args(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR8   ”   s    c         K   s   t  |  |  _ d |  _ d  S(   Ni   (   t   strR,   R9   (   R   R'   R[   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyRF   ¦   s    c         C   s·   |  j  d k r d S|  j  d k rB t j |  d d |  j   nX |  j  r |  j r d d  l } |  j d j | j |  j d |  j d d  g  q n  d |  _  |  j	 j
 d  d S(   Ni    i   t   deletei’’’’g        R5   (   R9   R   R]   t   create_annotationR4   t
   pygl_coordt   SetVerticest	   CartesianR"   t   do_rebuildGLR   (   R   R_   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   unthreadedDraw¬   s    		:	c   	      C   sÄ   d d  l  } d d  l } d d  l } |  j } d d  l } |  j \ } } | j | | j | | d  | j | | d   } d | _ |  j	 j
 j |  |  j j |  |  j	 j
 j   d |  _ d  S(   Ni’’’’g        i    (   t   cprimR_   R)   R,   t	   TextLabelR"   t   CreateBillBoardTextLabelRa   t   thisownR5   t   objt   add_text_primitiveR4   R   t   rebuildR9   (	   R   Rd   R_   R)   R'   Re   R#   R$   t   label_ob(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR^   ¼   s    	3		c         K   sÕ   d d  l  } | ru t   } | j |  j  |  j rJ t   j |  j  n  d |  j j _ d |  _ t j	 j
 |   n\ t |  j  d k s |  j r d  Sx- |  j D]" } | j |  j j | j    q¢ Wg  |  _ d  S(   Ni’’’’i    R   (   Rd   t
   MAINWINDOWt   removeGLDisplayObjectR5   R6   t	   deletemodRh   Rg   R   R2   R]   R   R4   t   DeleteTextLabelt   GetID(   R   R]   R   Rd   t   wint   graph_object(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR]   Ų   s    		 	  c         C   sn   | j    \ } } } | r6 |  j d | |  j d <n  | rW |  j d | |  j d <n  d |  _ |  j   d S(   s1   
    Handle mouse input to translate objects
    i    i   N(   t   screenTransformR"   R9   t   draw(   R   t   glwidgett   dxt   dyt   dz(    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt	   transformģ   s      	g        c      
   K   s­   | r | r | j  d \ } } | j  d \ } }	 t |  t |  }
 t |  t |	  } |  j | | |
 |	 | |  n  t j j |  d | d | d | d | d  S(   NR"   t   initial_statust   final_statust   fractiont   step(   R   R<   R=   R   R2   t   movie_interpolation(   R   Rz   R{   R|   R}   R   t   final_xt   final_yt	   initial_xt	   initial_yRv   Rw   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR~   ś   s    #c         C   s   d  S(   N(    (   R   (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   clone  s    N(   R   R   t   class_dependentsR
   R=   R>   R   RL   RM   RX   RY   RZ   R8   RF   Rc   R^   R]   Ry   R   R~   R   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyR   =   s(   	#											(   t   __doc__R   R/   t   global_definitionsR	   R   R2   R   (    (    (    s=   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/python/ui/Legend.pyt   <module>   s   
#