ó
±éRc           @  sÃ   d  Z  d d l m Z d d l Z d d l m Z m Z m Z d „  Z d „  Z	 d „  Z
 d „  Z i  Z x* d	 d
 d d d d g D] Z e	 e e <q� Wx' d d d d d g D] Z e
 e e <q« Wd S(   sD   
This module is to support *bbox_inches* option in savefig command.
iÿÿÿÿ(   t   print_functionN(   t   Bboxt   TransformedBboxt   Affine2Dc           s  ˆ j  ‰ ˆ j ‰ ˆ j j ‰  g  ‰ g  ‰ xu ˆ j D]j } | j d t ƒ j ƒ  } ˆ j | j	 ƒ  ƒ ˆ j | j
 ƒ  ƒ | d „ } | j | ƒ | j d ƒ q4 W‡  ‡ ‡ ‡ ‡ ‡ f d †  } t j | ƒ } | d k	 rì | ˆ | ƒ | St j d | ƒ d Sd S(   sO  
    Temporarily adjust the figure so that only the specified area
    (bbox_inches) is saved.

    It modifies fig.bbox, fig.bbox_inches,
    fig.transFigure._boxout, and fig.patch.  While the figure size
    changes, the scale of the original figure is conserved.  A
    function which restores the original values are returned.
    t   originalc         S  s   | S(   N(    (   t   at   rt   pos(    (    sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   _l    s    t   autoc            s‹   x@ t  ˆ j ˆ ˆ ƒ D]) \ }  } } |  j | ƒ |  j | ƒ q Wˆ ˆ _ ˆ ˆ _ ˆ  ˆ j _ ˆ j j ƒ  ˆ j	 j
 d d d d ƒ d  S(   Ni    i   (   t   zipt   axest
   set_aspectt   set_axes_locatort   bboxt   bbox_inchest   transFiguret   _boxoutt
   invalidatet   patcht
   set_bounds(   t   axt   aspt   loc(   R   t   asp_listt   figt   locator_listt   origBboxt   origBboxInches(    sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   restore_bbox%   s    %		s9   bbox_inches option for %s backend is not implemented yet.N(   R   R   R   R   R   t   get_positiont   Falset   frozent   appendt   get_axes_locatort
   get_aspectR   R   t   _adjust_bbox_handler_dt   gett   Nonet   warningst   warn(   R   t   formatR   R   R   R   R   t   adjust_bbox_handler(    (   R   R   R   R   R   R   sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   adjust_bbox
   s(    			c         C  só   |  j  } t | | ƒ } | j | j } } t j d d | j | j ƒ |  _ | j | j } } |  j	 j |  j	 j } } t j | | | | ƒ |  j
 _ |  j
 j ƒ  t |  j | ƒ |  _	 |  j j | | | | |  j	 j | |  j	 j | ƒ d S(   s*   
    adjust_bbox for png (Agg) format
    i    N(   t   dpi_scale_transR   t   x0t   y0R   t   from_boundst   widtht   heightR   R   R   R   R   R   R   (   R   R   t   trt   _bboxR-   R.   t   w1t   h1(    (    sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   adjust_bbox_png;   s    		c   	      C  s1  |  j  j j d k r3 t ƒ  j |  j ƒ } d } n t ƒ  j d ƒ } d |  j } t | | ƒ } t j d d | j	 | j
 ƒ |  _ | j | j } } |  j j	 | |  j j
 | } } t j | | | | ƒ |  j _ |  j j ƒ  t |  j | ƒ |  _ |  j j | | | | |  j j	 | |  j j
 | ƒ d S(   s*   
    adjust_bbox for pdf & eps format
    t   RendererPgfg      ð?iH   g      R@i    N(   t   _cachedRenderert	   __class__t   __name__R   t   scalet   dpiR   R   R/   R0   R1   R   R-   R.   R   R   R   R   R   R   (	   R   R   R2   t   fR3   R-   R.   R4   R5   (    (    sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   adjust_bbox_pdfU   s"    	!c         C  s/   | \ } } | ƒ  t  |  | | ƒ } | | f S(   s    
    This need to be called when figure dpi changes during the drawing
    (e.g., rasterizing). It recovers the bbox and re-adjust it with
    the new dpi.
    (   R+   (   t   figuret   bbox_inches_restoret   modeR   R   R   (    (    sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   process_figure_for_rasterizingr   s
    			t   pngt   rawt   rgbat   jpgt   jpegt   tifft   pgft   pdft   epst   svgt   svgz(   t   __doc__t
   __future__R    R'   t   matplotlib.transformsR   R   R   R+   R6   R>   RB   R$   R)   (    (    (    sO   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/tight_bbox.pyt   <module>   s   	1			