ó
±éRc           @  sZ   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ	 d S(   iÿÿÿÿ(   t   print_function(   t
   frombuffer(   t   RendererAgg(   t   process_figure_for_rasterizingt   MixedModeRendererc           B  sD   e  Z d  Z d d d „ Z d j ƒ  Z d „  Z d „  Z d „  Z	 RS(   s&  
    A helper class to implement a renderer that switches between
    vector and raster drawing.  An example may be a PDF writer, where
    most things are drawn with PDF vector commands, but some very
    complex objects, such as quad meshes, are rasterised and then
    output as images.
    c         C  s™   | d k r t } n  | |  _ | |  _ | |  _ | |  _ | j ƒ  sL t ‚ | |  _ d |  _	 d |  _
 | |  _ | j ƒ  |  _ | |  _ |  j | ƒ d S(   s  
        figure: The figure instance.

        width: The width of the canvas in logical units

        height: The height of the canvas in logical units

        dpi: The dpi of the canvas

        vector_renderer: An instance of a subclass of RendererBase
        that will be used for the vector drawing.

        raster_renderer_class: The renderer class to use for the
        raster drawing.  If not provided, this will use the Agg
        backend (which is currently the only viable option anyway.)
        i    N(   t   NoneR   t   _raster_renderer_classt   _widtht   _heightt   dpit   option_image_nocompositet   AssertionErrort   _vector_renderert   _raster_renderert   _rasterizingt   figuret   get_dpit   _figdpit   _bbox_inches_restoret   _set_current_renderer(   t   selfR   t   widtht   heightR	   t   vector_renderert   raster_renderer_classt   bbox_inches_restore(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyt   __init__   s    										s²  
        close_group draw_image draw_markers draw_path
        draw_path_collection draw_quad_mesh draw_tex draw_text
        finalize flipy get_canvas_width_height get_image_magnification
        get_texmanager get_text_width_height_descent new_gc open_group
        option_image_nocomposite points_to_pixels strip_math
        start_filter stop_filter draw_gouraud_triangle
        draw_gouraud_triangles option_scale_image
        c         C  sd   | |  _  x< |  j D]1 } t | | ƒ r t |  | t | | ƒ ƒ q q W|  j | _ |  j | _ d  S(   N(   t	   _renderert   _methodst   hasattrt   setattrt   getattrt   start_rasterizingt   stop_rasterizing(   R   t   renderert   method(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR   B   s    	 c         C  s§   |  j  j |  j ƒ |  j rC t |  j  |  j d d ƒ} | |  _ n  |  j d k r” |  j |  j |  j |  j |  j |  j ƒ |  _	 |  j
 |  j	 ƒ n  |  j d 7_ d S(   s  
        Enter "raster" mode.  All subsequent drawing commands (until
        stop_rasterizing is called) will be drawn with the raster
        backend.

        If start_rasterizing is called multiple times before
        stop_rasterizing is called, this method has no effect.
        t   modet   pngi    i   N(   R   t   set_dpiR	   R   R   R   R   R   R   R   R   (   R   t   r(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR    L   s    				)c         C  sm  |  j  d 8_  |  j  d k r9|  j |  j ƒ |  j |  j |  j |  j } } |  j j ƒ  \ } } | \ } } } } | d k r| d k rt | | | t	 ƒ }	 t
 |	 _ |	 j ƒ  |  j j ƒ  }
 |  j j |
 t | ƒ |  j |  j t | ƒ | | |  j |  j |	 ƒ n  d |  _ t
 |  _  |  j j |  j ƒ n  |  j rit |  j |  j d d ƒ} | |  _ n  d S(   s9  
        Exit "raster" mode.  All of the drawing that was done since
        the last start_rasterizing command will be copied to the
        vector backend by calling draw_image.

        If stop_rasterizing is called multiple times before
        start_rasterizing is called, this method has no effect.
        i   i    R$   t   pdfN(   R   R   R   R   R	   R   R   t   tostring_rgba_minimizedR   t   Truet   Falset   is_grayscalet
   flipud_outR   t   new_gct
   draw_imaget   floatR   R   R   R&   R   R   (   R   R   R   t   buffert   boundst   lt   bt   wt   ht   imaget   gcR'   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR!   h   s0    	!	
	
						N(
   t   __name__t
   __module__t   __doc__R   R   t   splitR   R   R    R!   (    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyR      s   1	
	N(
   t
   __future__R    t   matplotlib._imageR   t   matplotlib.backends.backend_aggR   t   matplotlib.tight_bboxR   t   objectR   (    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_mixed.pyt   <module>   s   