ó
ąéRc           @   sź  d  d l  Z d  d l m Z d  d l Z d  d l Z d   Z d e e d  Z d   Z e	 d k r¸d  d l
 j Z e j d d	 d  d
 d d d d d d d  d	 d d g  Z e j e e   Z e j e e d d d  d l m Z e j d	 d d d  Z e e e e  \ Z Z x0 e D]( \ Z Z e j e e d d d d qWe d d d d g  Z xS e D]H Z e j   Z x3 e D]+ \ \ Z Z Z  e j e g e g e  qWqiWn  d S(   i˙˙˙˙N(   t   degreesc         C   s=   | d k r) | d k r) t  j d  d St j |  |  Sd  S(   Ni    s   dx and dy is 0(   t   warningst   warnt   matht   atan2(   t   dyt   dx(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/mpl_toolkits/axisartist/clip_path.pyR      s    t   rightc      	   C   s  g  } g  } g  } | r! d }	 n d }	 | r6 d }
 n d }
 xLt  |  |  D];\ } } | d k r | | k  j d  } | d | d  } n' | | k j d  } | d | d  } | d rČ d } n d } g  g  } } xZt j | d k  D]C\ } | | } | d k rD| | | } | | d | | | | | d | | } | | | } | j t j | | | | d !| g g   | j t j | | | | d !| g g   d } g  g  } } | d k r| d k r| | d | | } | | d | | } n  t t |
 | |	 |   } | j | | | f  qń | d k rń | | | } | | d | | | | | d | | } | | | } | g | g } } | d } | d k rţ| d k rţ| | d | | } | | d | | } n  t t |
 | |	 |   } | j | | | f  qń qń W| d k rL | j t j | | | g   | j t j | | | g   qL qL W| | | f S(	   Ni   i˙˙˙˙t   upR   t   ii    g        (   s   ups   right(   t   zipt   astypet   npt   argwheret   appendt   concatenateR    R   (   t   xlinest   ylinest   x0t   clipt   xdirt   ydirt   clipped_xlinest   clipped_ylinest   _pos_anglest   xsignt   ysignt   xt   yt   bt   dbt   nst   segxt   segyR	   t   cR   R   t   y0t   a(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/mpl_toolkits/axisartist/clip_path.pyR      sb    		
	
.--.
 'c      
   C   sţ  | j  \ } } } } | | k } | | k } | | k r t |  g | g | d d d | d | \ }	 }
 } t |	 |
 | d d d | d | \ } } } n` t |  g | g | d d d | d | \ }	 }
 } t |	 |
 | d d d | d | \ } } } | | k ret | | | d d d | d | \ } } } t | | | d d d | d | \ } } } nZ t | | | d d d | d | \ } } } t | | | d d d | d | \ } } } g  | D]< \ } } } | j |  rĆ| | f | d d d f ^ qĆ} g  | D]8 \ } } } | j |  r| | f d | d f ^ q} g  | D]< \ } } } | j |  rT| | f | d d d f ^ qT} g  | D]< \ } } } | j |  r| | f d | d d f ^ q} t | |  | | | | g f S(   NR   R   R   R   t   leftiZ   i´   (   t   extentsR   t	   containsyt	   containsxR
   (   t   xlinet   ylinet   bboxR   R#   t   x1t   y1R   R   t   lx1t   ly1t   c_right_t   lx2t   ly2t   c_left_t   ly3t   lx3t   c_top_t   ly4t   lx4t	   c_bottom_R   R   R$   t   c_leftt   c_bottomt   c_rightt   c_top(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/mpl_toolkits/axisartist/clip_path.pyt   clip_line_to_rect]   s,    303--0--
3/33t   __main__iý˙˙˙iţ˙˙˙g        i   i   i   i    i   t   lw(   t   Bboxg      )@t   colort   gt   rot   got   rxt   bx(!   t   numpyR   R   R    R   R   t   TrueR   R>   t   __name__t   matplotlib.pyplott   pyplott   pltt   arrayR   t   aranget   lenR   t   plott   matplotlib.transformsRA   t   from_extentst   bbt   lxyt   tickst   xxt   yyt   itert   ccct   tttt   nextt   cct   aa(    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/mpl_toolkits/axisartist/clip_path.pyt   <module>   s*   	
M	)9 