ó
ÉÝ{Tc           @   sp   d  Z  d d l m Z m Z d d l Z d d l Z d d d d „ Z d d
 d „  ƒ  YZ d d d	 „  ƒ  YZ	 d S(   s†  
     qtgui/FontedPositionedStrings.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ÿÿÿÿ(   t   QtCoret   QtGuiNi    c         C   s„  | s t  j d d ƒ } n  | j ƒ  j ƒ  } xCt |  t t |  ƒ ƒ ƒ D]%\ } } | d d d k rÉ t  j | ƒ } | d d d k r« | j t | d d ƒ ƒ q´| j	 t | d d ƒ ƒ në t  j | d d ƒ } | d d d k r| j t | d d ƒ ƒ n | j	 t | d d ƒ ƒ | j
 t | d d	 ƒ ƒ | j t | d d
 ƒ ƒ | j t | d d ƒ ƒ | j t | d d ƒ ƒ | j t | d d ƒ ƒ | d d d k rØ| j | ƒ nU t  j | d d ƒ }	 | d j d ƒ r |	 j t | d d ƒ ƒ n  | j |	 ƒ | j | ƒ | d \ }
 } | d } | j |
 | | | | ƒ qJ W| j | ƒ d S(   sq   
		This function needs implementing in C++ also, wherein the strings
		will have to be more managable objects.
		t   Timesi   t   fontt   facet   defaultt	   fontUnitst   pxt   sizet   boldt   italict	   underlinet   overlinet   linethrought   colourt   alphat   post   textN(   R   t   QFontt   pent   colort   zipt   ranget   lent   setPixelSizet   intt   setPointSizet   setBoldt	   setItalict   setUnderlinet   setOverlinet   setStrikeOutt   setPent   QColort   has_keyt   setAlphat   setFontt   drawText(   t   stringst   paintert   xorigt   yorigt   defaultFontt   defaultPenColort   st   iR   t   colt   xt   yR   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyt   drawFontedPositionedStrings   s:     )
	t   FontedPositionedStringsFromTextc           B   s2   e  Z d  „  Z d „  Z d „  Z d d d „ Z RS(   c         C   s   |  j  j ƒ  S(   N(   t   fonted_stringst   getBoundingRect(   t   self(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR4   H   s    c         C   s   |  j  j ƒ  S(   N(   R3   t
   getDescent(   R5   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR6   K   s    c         C   s   |  j  j ƒ  S(   N(   R3   t
   getStrings(   R5   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR7   N   s    g      ð?c         C   s¸   | s t  j d d ƒ } n  | j ƒ  d k rO t j t | j ƒ  | ƒ ƒ } n" t j t | j ƒ  | ƒ d ƒ } | j | ƒ | j ƒ  |  _	 | j
 ƒ  |  _ t |  j	 | | ƒ |  _ d  S(   NR   i   i    R   (   R   R   t	   pointSizet   ParseHTMLTextStringt   MyHTMLParserR   t	   pixelSizet   feedR7   t   fontedStringst   getDataLengtht   fontedStringsLengtht   FontedPositionedStringsR3   (   R5   R   R*   t   fontScalingt   parser(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyt   __init__Q   s     ""N(   t   __name__t
   __module__R4   R6   R7   t   NoneRC   (    (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR2   G   s   			R@   c           B   s2   e  Z d  „  Z d „  Z d „  Z d d d „ Z RS(   c         C   s   |  j  S(   N(   R&   (   R5   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR7   ]   s    c         C   s   |  j  S(   N(   t   descent(   R5   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR6   `   s    c         C   s   |  j  S(   N(   t   boundingRect(   R5   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR4   c   s    g      ð?c   1      C   s3
  d } d } d } d |  _  d } d } d }	 d }
 d } d } d } d } | } | } t } t } t } t } t } t } d } d d g g } d \ } } t } g  } | sÍ t j d t d | ƒ ƒ } n  x®| D]¥} | d d d k rNt j | ƒ } | d d d k r0| j t | d d	 ƒ ƒ qA| j t | d d	 ƒ ƒ nó t j | d d ƒ } | d d d k r›| j t | d d	 | ƒ ƒ n | j t | d d	 | ƒ ƒ | j t | d d
 ƒ ƒ | j t | d d ƒ ƒ | j	 t | d d ƒ ƒ | j
 t | d d ƒ ƒ | j t | d d ƒ ƒ | d d d k rd| j ƒ  } n | j ƒ  } t }  t }! t }" t }# t }$ | d d } t | d d ƒ | k rø| d } t | d | | d ƒ } | d | } t }  t }! n  t | d d ƒ | k  rr| d t | d | | d ƒ } t | d d ƒ } t | d | | d ƒ } t }  t }# n  t | d d ƒ | k rÎ| d } t | d | | d ƒ } | d | } t }  t }" n  t | d d ƒ | k  rH| d t | d | | d ƒ } t | d d ƒ } t | d | | d ƒ } t }  t }$ n  |  slt | d | | d ƒ } n  | d d | k r²| d } | } | t j | ƒ j ƒ  } d } nÌ | t j | ƒ j ƒ  | k r~| d k r~x‚ | D]y }% |% d d | k rå|% | k	 rå|% j d ƒ rå|% d \ }& }' |' | t j | ƒ j ƒ  | }' |& |' f |% d <qåqåW| t j | ƒ j ƒ  } n  t | d d ƒ d k r¡| }( n† t | d d ƒ d k rß| | d }( t | d d ƒ } nH t | d d ƒ d k r| | d }( t | d d ƒ } n
 | | }( | d d d k rQ| j t | ƒ ƒ n | j t | ƒ ƒ t j | ƒ }) |" s|! rÏ| r¦|" r‘| s�|! r¦| r¦| } n  | d } | j | t | | ƒ g ƒ n  |$ sÛ|# r | d } | j ƒ  \ } } | } n  |# rt } n  |$ rt } n  | t |( ƒ f | d <t | ƒ | d d	 <| j | ƒ |) j | d ƒ }* t |) j  ƒ  |  j  ƒ |  _  | |	 k r˜| }	 n  |( |
 k r­|( }
 n  | | k  rÂ| } n  |( | k  r×|( } n  | |* j ƒ  | k  r | |* j ƒ  } n  | |* j ƒ  |	 k r)| |* j ƒ  }	 n  |( |* j ƒ  | k  rR|( |* j ƒ  } n  |( |* j ƒ  |
 k r{|( |* j ƒ  }
 n  | |* j ƒ  |	 k r¤| |* j ƒ  }	 n  | |* j ƒ  | k  rÍ| |* j ƒ  } n  |( |* j ƒ  |
 k rö|( |* j ƒ  }
 n  |( |* j ƒ  | k  r	|( |* j ƒ  } n  | |) j | d ƒ } t | | | d ƒ | | d <t | d ƒ d k rÕ t } t } qÕ qÕ W|	 | d }+ |
 | d }, | }- | }. t j |- |. |+ |, ƒ |  _ | |  _ t |  j ƒ d k r/
|  j d d d }/ x8 |  j D]* }0 |0 d d |0 d d |/ f |0 d <qþ	Wn  d  S(   Ni    R   i   R   R   R   R   R   R   R	   R
   R   R   R   t
   mathmarkupt   superscripti   gffffffæ?i	   t	   subscriptg333333Ó?t	   paragraphR   t   valigni   g      à?R   iÿÿÿÿ(   i    i    (   RG   t   FalseR   R   R   R   R   R   R   R   R   R   R;   R8   t   maxt   Truet   QFontMetricst   heightR"   t   appendt   popRH   t   leftt   rightt   topt   bottomt   widthR   R    t   QRectR&   (1   R5   R&   R*   RA   t   currentParagraphR/   R0   t
   baseline_yt   old_baseline_yt   max_xt   max_yt   min_xt   min_yt   currentSubLevelt   currentSupLevelt   lastSubLevelt   lastSupLevelt   previousStartSupt   previousStartSubt   previousEndSupt   previousEndSubt   justDoneSupt   justDoneSubt   branchDeptht   branchest   branch_start_xt   branch_end_xt   doMathMarkupt   fontedPositionedStringsR,   R   t   desiredSizet   changet   startSupt   startSubt   endSupt   endSubt   soldt   xoldt   yoldt   ydrawt   fmt   rectt   bwidtht   bheightt   bxt   byt   ymaxt   sss(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyRC   f   s>   	 "
	#	
	#	 
	+/!	
	

			 	 	 	 	        	N(   RD   RE   R7   R6   R4   RF   RC   (    (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyR@   \   s   			(    (    (
   t   __doc__t   PyQt4R    R   R9   t   sysRF   R1   R2   R@   (    (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/FontedPositionedStrings.pyt   <module>   s   /