ó
±éRc           @  s%  d  Z  d d l m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d „  Z
 d d l Z e j d d k  r› d d l Z n  y d d l m Z Wn! e k
 rÒ d d l m Z n Xd d l m Z d d	 l m Z m Z m Z m Z d d
 l m Z d d l m Z d d l m Z m Z m Z m  Z  d d l! m" Z" m# Z# m$ Z$ m% Z% d d l& m' Z' d d l( m) Z) d d l* m+ Z+ m, Z, d d l- m. Z. m/ Z/ m0 Z0 d d l1 m2 Z2 d d l3 m4 Z4 d d l5 m6 Z6 d d l7 m8 Z8 d d l9 m: Z: d d l; m< Z< d d l= m> Z> d d l? Z@ d d lA ZA d d lB ZB y eC Wn! eD k
 rzd d lE mF ZC n Xe jG jH d ƒ r–d ZI n d ZI d ZJ d ZK d eL f d „  ƒ  YZM eM ƒ  ZN i d  d! f d" 6d  d# f d$ 6d! d% f d& 6d' d( f d) 6d* d' f d+ 6d, d* f d- 6d. d, f d/ 6d0 d. f d1 6d2 d0 f d3 6d4 d2 f d5 6d6 d4 f d7 6d8 d6 f d9 6d: d; f d< 6d= d: f d> 6d? d@ f dA 6dB d? f dC 6dD dB f dE 6dF dD f dG 6dH dF f dI 6dJ dH f dK 6dL dJ f dM 6dN dL f dO 6dP dN f dQ 6dR dP f dS 6dT dR f dU 6ZO dV „  ZP dW „  ZQ dX „  ZR dY „  ZS dZ „  ZT d[ e f d\ „  ƒ  YZU d] e f d^ „  ƒ  YZV d_ „  ZW d` „  ZX da e  f db „  ƒ  YZY dc „  ZZ e[ d" e\ e[ dd „ Z] e[ d" e\ e[ de „ Z^ e[ df „ Z_ dg „  Z` e\ e[ dh „ Za di e f dj „  ƒ  YZb eb Zc dk dl dm dn do dp dq g Zd d S(r   sF   
A PostScript backend, which can produce both PostScript .ps and .eps
iÿÿÿÿ(   t   divisiont   print_functionNc           C  s   t  j d ƒ j j S(   Ni   (   t   syst	   _getframet   f_codet   co_name(    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _fn_name	   s    i    i   (   t   md5(   t   mkstemp(   t   verboset   __version__t   rcParamst   checkdep_ghostscript(   t   Gcf(   t   AFM(   t   RendererBaset   GraphicsContextBaset   FigureManagerBaset   FigureCanvasBase(   t   is_string_liket   get_realpath_and_statt   is_writable_file_liket   maxdict(   t
   quad2cubic(   t   Figure(   t   findfontt   is_opentype_cff_font(   t   FT2Fontt   KERNING_DEFAULTt   LOAD_NO_HINTING(   t   convert_ttf_to_ps(   t   MathTextParser(   t	   uni2type1(   t   Text(   t   Path(   t   Affine2D(   t   MixedModeRenderer(   t   Sett   wint   &t   ;s   Level IIt   PsBackendHelperc           B  s>   e  Z d  „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   c         C  s   i  |  _  d  S(   N(   t   _cached(   t   self(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   __init__<   s    c         C  sX   y |  j  d SWn t k
 r" n Xt ƒ  \ } } | d k rG d } n  | |  j  d <| S(   s0   
        excutable name of ghostscript.
        t   gs_exet   gsN(   R*   t   KeyErrorR   t   None(   R+   R-   t
   gs_version(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR-   ?   s    	c         C  sÇ   y |  j  d SWn t k
 r" n Xd d l m } m } | |  j d d t d | ƒj } t j	 d d k r† | j
 ƒ  j d	 ƒ } n | j
 ƒ  } t t t | j ƒ  j d
 ƒ ƒ ƒ } | |  j  d <| S(   s)   
        version of ghostscript.
        R1   iÿÿÿÿ(   t   Popent   PIPEs
    --versiont   shellt   stdouti    i   t   asciit   .(   R*   R/   t   matplotlib.compat.subprocessR2   R3   R-   t   TrueR5   R   t   version_infot   readt   decodet   tuplet   mapt   intt   stript   split(   R+   R2   R3   t   pipet   verR1   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR1   Q   s    $c         C  s   |  j  d d k S(   sM   
        True if the installed ghostscript supports ps2write device.
        i    i	   (   R1   (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   supports_ps2writeg   s    (   t   __name__t
   __module__R,   t   propertyR-   R1   RD   (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR)   :   s   	g      !@i   t   letteri   t   legali   t   ledgerg®GázŽ@@gHáz®gG@t   a0g¤p=
×c7@t   a1g
×£p=Š0@t   a2gáz®Ga'@t   a3g
×£p=Š @t   a4gR¸…ëQ@t   a5g…ëQ¸…@t   a6gHáz®G@t   a7g�Âõ(\� @t   a8gZd;ßO÷?gffffff @t   a9gR¸…ëQð?t   a10gfffffFD@g)\�Âõ¨L@t   b0g)\�Âõ¨<@t   b1g…ëQ¸E4@t   b2g)\�Âõ¨,@t   b3g¸…ëQ8$@t   b4g¤p=
×£@t   b5g)\�Âõ(@t   b6g¤p=
×£@t   b7g®Gáz@t   b8g)\�Âõ(ü?t   b9g)\�Âõ(ô?t   b10c         C  sz   t  j ƒ  } | j ƒ  | j ƒ  xS | D]G } | j d ƒ rB q' n  t  | \ } } |  | k  r' | | k  r' | Sq' Wd Sd  S(   Nt   lRK   (   t	   papersizet   keyst   sortt   reverset
   startswith(   t   wt   hRc   t   keyt   pwt   ph(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _get_papertypeŠ   s    

  c         C  s^   t  |  ƒ r |  St |  ƒ } |  | k r2 t | ƒ Sd |  } | j d ƒ } | j d ƒ } | S(   Ns   %1.3ft   0R7   (   R   R?   t   strt   rstrip(   t   valt   ivalt   s(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _num_to_str•   s      

c          G  s   d j  t t |  ƒ ƒ S(   Nt    (   t   joinR>   Rs   (   t   args(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _nums_to_str    s    c         C  sv   |  j  d d ƒ }  |  j  d d ƒ }  |  j  d d ƒ }  |  j  d d ƒ }  |  j  d	 d
 ƒ }  t j d d „  |  ƒ }  |  S(   sH   Quote dangerous characters of S for use in a PostScript string constant.s   \s   \\t   (s   \(t   )s   \)t   's   \251t   `s   \301s   [^ -~\n]c         S  s   d t  |  j ƒ  ƒ S(   Ns   \%03o(   t   ordt   group(   t   x(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   <lambda>ª   s    (   t   replacet   ret   sub(   Rr   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   quote_ps_string£   s    c         C  s[   |  d k r | d k S| d k r& t St |  ƒ t | ƒ k rB t St j t j |  | ƒ ƒ S(   sŒ   
    seq1 and seq2 are either None or sequences or arrays
    Return True if both are None or both are seqs with identical
    elements
    N(   R0   t   Falset   lent   npt   alltruet   equal(   t   seq1t   seq2(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   seq_allequal®   s    
 t
   RendererPSc           B  s¬  e  Z d  Z e d ƒ Z e d ƒ Z d d „ Z d „  Z d „  Z d d „ Z	 d d „ Z
 d d	 „ Z d d
 „ Z d d „ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d d d „ Z d d „ Z d „  Z d „  Z d „  Z d, d, d, d „ Z e d, d „ Z d  „  Z  d, d! „ Z! d, d" „ Z" d# „  Z# d$ d, d% „ Z$ e d, d& „ Z% d' „  Z& d( „  Z' d) „  Z( d* „  Z) e* e* d, d+ „ Z+ RS(-   s€   
    The renderer handles all the drawing primitives using a graphics
    context instance that controls the colors/styles.
    i2   iH   c         C  sò   t  j |  ƒ | |  _ | |  _ | |  _ t d rG d |  _ g  |  _ n  | |  _ d |  _
 d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ i  |  _ | d |  _ i  |  _ d |  _ i  |  _ t d ƒ |  _ t j j t d d d ƒ |  _ d S(	   sÌ   
        Although postscript itself is dpi independent, we need to
        imform the image code about a requested dpi to generate high
        res images and them scale them before embeddin them
        s   text.usetexi    g      R@t   PSt   datapatht   fontst   afmN(   R   R,   t   widtht   heightt	   _pswriterR   t   textcntt   psfragt   imagedpiR0   t   colort	   linewidtht   linejoint   linecapt   linedasht   fontnamet   fontsizet   _hatchest   image_magnificationt   _clip_pathst   _path_collection_idt   used_charactersR   t   mathtext_parsert   ost   pathRu   t   _afm_font_dir(   R+   R‘   R’   t   pswriterR–   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR,   È   s.    			
														c         C  sa   t  | j ƒ \ } } |  j j | | t ƒ  f ƒ } | d j g  | D] } t | ƒ ^ qD ƒ d S(   sD   Keeps track of which characters are required from
        each font.i   N(   R   t   fnameR¢   t
   setdefaultt   sett   updateR|   (   R+   t   fontRr   t   realpatht   stat_keyR¢   R~   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   track_charactersê   s    	c         C  sV   xO | j  ƒ  D]A \ } \ } } |  j j | | t ƒ  f ƒ } | d j | ƒ q Wd  S(   Ni   (   t	   iteritemsR¢   R©   Rª   R«   (   R+   t   otherR®   R­   t   charsetR¢   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   merge_used_charactersò   s    	i   c         C  s†   | | | f |  j  k r‚ | | k rG | | k rG |  j j d | ƒ n |  j j d | | | f ƒ | r‚ | | | f |  _  q‚ n  d  S(   Ns   %1.3f setgray
s   %1.3f %1.3f %1.3f setrgbcolor
(   R—   R“   t   write(   R+   t   rt   gt   bt   store(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt	   set_colorø   s     c         C  s<   | |  j  k r8 |  j j d | ƒ | r8 | |  _  q8 n  d  S(   Ns   %1.3f setlinewidth
(   R˜   R“   R´   (   R+   R˜   R¸   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   set_linewidth   s     c         C  s<   | |  j  k r8 |  j j d | ƒ | r8 | |  _  q8 n  d  S(   Ns   %d setlinejoin
(   R™   R“   R´   (   R+   R™   R¸   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   set_linejoin  s     c         C  s<   | |  j  k r8 |  j j d | ƒ | r8 | |  _  q8 n  d  S(   Ns   %d setlinecap
(   Rš   R“   R´   (   R+   Rš   R¸   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   set_linecap
  s     c         C  s¡   |  j  d  k	 r4 |  j  \ } } t | | ƒ r4 d  Sn  | d  k	 ru t | ƒ ru d t | Œ  | f } |  j j | ƒ n |  j j d ƒ | r� | | f |  _  n  d  S(   Ns   [%s] %d setdash
s   [] 0 setdash
(   R›   R0   R‹   R…   Rw   R“   R´   (   R+   t   offsett   seqR¸   t   oldot   oldseqRr   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   set_linedash  s      c         C  sw   t  d r d  S| | f |  j |  j f k rs d | | f } |  j j | ƒ | r^ | |  _ n  | rs | |  _ qs n  d  S(   Ns	   ps.useafms%   /%s findfont
%1.3f scalefont
setfont
(   R   Rœ   R�   R“   R´   (   R+   Rœ   R�   R¸   t   out(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   set_font  s    
   c         C  s©   d } | |  j  k r  |  j  | Sd t |  j  ƒ } |  j j d t ƒ  ƒ |  j j |  j t j | ƒ t ƒ  j	 d ƒ d t
 ƒƒ |  j j d t ƒ  ƒ | |  j  | <| S(   NiH   s   H%dsÇ     << /PatternType 1
     /PaintType 2
     /TilingType 2
     /BBox[0 0 %(sidelen)d %(sidelen)d]
     /XStep %(sidelen)d
     /YStep %(sidelen)d

     /PaintProc {
        pop
        0 setlinewidth
g      R@t   simplifysR             stroke
     } bind
   >>
   matrix
   makepattern
   /%(name)s exch def
(   Rž   R…   R“   R´   t   localst   _convert_pathR"   t   hatchR#   t   scaleR„   (   R+   RÇ   t   sidelent   name(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   create_hatch&  s    		$
	c         C  s   |  j  |  j f S(   s4   return the canvas width and height in display coords(   R‘   R’   (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   get_canvas_width_heightE  s    c         C  s†  t  d rP |  j ƒ  } | j ƒ  } | j | | d |  ƒ\ } } } | | | f S| rŠ |  j j | d | ƒ \ }	 }
 } } } |	 |
 | f St  d r| rª | d d !} n  |  j | ƒ } | j | ƒ \ } } } } } | j ƒ  } d | } | | 9} | | 9} | | 9} | | | f S|  j | ƒ } | j	 | d d	 t
 ƒ| j ƒ  \ } } | d
 } | d
 } | j ƒ  } | d
 } | | | f S(   sm   
        get the width and height in display coords of the string s
        with FontPropertry prop

        s   text.usetext   rendereriH   s	   ps.useafmi   iÿÿÿÿgü©ñÒMbP?g        t   flagsg      P@(   R   t   get_texmanagert   get_size_in_pointst   get_text_width_height_descentR£   t   parset   _get_font_afmt   get_str_bbox_and_descentt   _get_font_ttft   set_textR   t   get_width_heightt   get_descent(   R+   Rr   t   propt   ismatht
   texmanagerR�   Rg   Rh   t   dR‘   R’   t   descentR§   R¢   R¬   Ra   R·   RÈ   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÑ   I  s8    
'
 






c         C  s   t  S(   s3   return true if small y numbers are top for renderer(   R„   (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   flipyq  s    c         C  sÕ   t  | ƒ } |  j j | ƒ } | d  k rÑ t | d d d |  j ƒ} | d  k ro t d d d d |  j ƒ} n  |  j j | ƒ } | d  k rÁ t | d ƒ � } t | ƒ } Wd  QX| |  j | <n  | |  j | <n  | S(   Nt   fontextR�   t	   directoryt	   Helveticat   rb(   t   hasht   afmfontdt   getR0   R   R¦   t   openR   (   R+   RÙ   Ri   R¬   R¨   t   fh(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÓ   u  s    c         C  s°   t  | ƒ } |  j j | ƒ } | d  k r† t | ƒ } |  j j | ƒ } | d  k rv t t | ƒ ƒ } | |  j | <n  | |  j | <n  | j ƒ  | j ƒ  } | j	 | d ƒ | S(   Ng      R@(
   Rã   t   fontdRå   R0   R   R   Rn   t   clearRÐ   t   set_size(   R+   RÙ   Ri   R¬   R¨   t   size(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÕ   …  s    
c         C  s
   | j  ƒ  S(   N(   t   as_rgba_str(   R+   t   im(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _rgba”  s    c         C  st   | j  ƒ  \ } } } t j | t j ƒ } | | d f | _ | d  d  … d  d  … d  d … f } | | | j ƒ  f S(   Ni   i   (   Rì   R†   t
   fromstringt   uint8t   shapet   tostring(   R+   Rí   Rh   Rg   Rr   t   rgbat   rgb(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _rgb—  s
    %g333333Ó?gáz®Gáâ?g)\�Âõ(¼?c         C  sï   | j  ƒ  } t j | d t j ƒ } | d | d d f | _ | j t j ƒ } | d  d  … d  d  … d f } | d  d  … d  d  … d f }	 | d  d  … d  d  … d f }
 | | |	 | |
 | j t j ƒ } | d | d | j ƒ  f S(   Ni   i    i   i   (   Rì   R†   Rï   Rð   Rñ   t   astypet   float32Rò   (   R+   Rí   t   rct   gct   bct   rgbatRó   t   rgba_fRµ   R¶   R·   t   gray(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _grayŸ  s    &i€   c         C  si   t  j | ƒ } t | ƒ } g  } xA t d | | ƒ D]- } t | | | ƒ } | j | | | !ƒ q4 W| S(   Ni    (   t   binasciit   b2a_hexR…   t   ranget   mint   append(   R+   Rr   t   chars_per_linet   nhext   linest   it   limit(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt
   _hex_linesª  s    c         C  s   |  j  S(   s­   
        Get the factor by which to magnify images passed to draw_image.
        Allows a backend to have images at a different resolution to other
        artists.
        (   RŸ   (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   get_image_magnification³  s    c         C  s   t  S(   s@   
        ps backend support arbitrary scaling of image.
        (   R9   (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   option_scale_image»  s    c         C  sX   | j  r* |  j | ƒ \ } } } d } n |  j | ƒ \ } } } d } | | | | f S(   Nt   images   false 3 colorimage(   t   is_grayscaleRþ   Rõ   (   R+   Rí   Rh   Rg   t   bitst   imagecmd(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   _get_image_h_w_bits_commandÁ  s    		c         C  sž  | j  ƒ  |  j | ƒ \ } }	 }
 } d j |  j |
 ƒ ƒ j d ƒ } | d	 k rb |	 |  j } n | } | d	 k r„ | |  j } n | } | d	 k rŸ d } n d j t t | j	 ƒ  ƒ ƒ } |  j
 d } | j ƒ  } | j ƒ  \ } } g  } | d	 k	 r2| j \ } } } } | j d t | | | | ƒ ƒ n  | d	 k	 rd|  j | | ƒ } | j d | ƒ n  d j | ƒ } d t ƒ  } |  j j | ƒ | j  ƒ  d	 S(
   sy  
        Draw the Image instance into the current axes; x is the
        distance in pixels from the left hand side of the canvas and y
        is the distance from bottom

        dx, dy is the width and height of the image.  If a transform
        (which must be an affine transform) is given, x, y, dx, dy are
        interpreted as the coordinate of the transform.
        s   
R6   s   1 0 0 1 0 0Rt   iH   s
   %s clipboxs   %ssò   gsave
%(clip)s
[%(matrix)s] concat
%(x)s %(y)s translate
%(xscale)s %(yscale)s scale
/DataString %(w)s string def
%(w)s %(h)s 8 [ %(w)s 0 0 -%(h)s 0 %(h)s ]
{
currentfile DataString readhexstring pop
} bind %(imagecmd)s
%(hexlines)s
grestore
N(   t
   flipud_outR  Ru   R	  R<   R0   RŸ   R>   Rn   t	   to_valuesR’   t   get_clip_rectanglet   get_clip_patht   boundsR  Rw   t   _get_clip_pathRÅ   R“   R´   (   R+   Rù   R~   t   yRí   t   dxt   dyt	   transformRh   Rg   R  R  t   hexlinest   xscalet   yscalet   matrixt   fight   bboxt   clippatht   clippath_transt   clipt   clipxt   clipyt   clipwt   clipht   idt   ps(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt
   draw_imageË  s4    
!	#c   	      C  s‚  g  } d  } | r5 d d |  j d |  j d f } n d  } x1| j | d | d | ƒD]\ } } | t j k rŒ | j d t | ƒ ƒ nÙ | t j k r« | j d ƒ nº | d  k rÆ t	 d ƒ ‚ nŸ | t j
 k rï | j d t | ƒ ƒ nv | t j k r<t t | d	 ƒ t | ƒ Œ  } | j d
 t | d ƒ ƒ n) | t j k re| j d
 t | ƒ ƒ n  | } qW Wd j | ƒ } | S(   Ng        g      R@R#  RÄ   s   %g %g mt   cls   Path lacks initial MOVETOs   %g %g liþÿÿÿs   %g %g %g %g %g %g ci   s   
(   R0   R‘   R’   t   iter_segmentsR"   t   MOVETOR  R=   t	   CLOSEPOLYt
   ValueErrort   LINETOt   CURVE3R   t   listt   CURVE4Ru   (	   R+   R¥   R  R#  RÄ   R)  t   last_pointst   pointst   code(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÆ     s2     	
c         C  s¬   |  j  j | | f ƒ } | d  k r¨ d t |  j  ƒ } d | g } | j |  j | | d t ƒƒ | j d d d g ƒ |  j j	 d j
 | ƒ ƒ | |  j  | | f <n  | S(   Ns   c%xs   /%s {RÄ   R#  t   newpaths   } bind def
s   
(   R    Rå   R0   R…   R  RÆ   R„   t   extendR“   R´   Ru   (   R+   R!  t   clippath_transformR(  t   ps_cmd(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR  +  s    
c         C  sb   | d k o | j ƒ  d k } | j o* | } |  j | | d | d | ƒ} |  j | | | ƒ d S(   sI   
        Draws a Path instance using the given affine transform.
        R#  RÄ   N(   R0   t   get_hatch_patht   should_simplifyRÆ   t   _draw_ps(   R+   Rù   R¥   R  t   rgbFaceR#  RÄ   R)  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt	   draw_path7  s
    c         C  s  t  r |  j j d ƒ n  |  j j } | ru | d | d k rd | d | d k rd d | d } qu d | d  } n  d d	 d
 d g }	 | j ƒ  }
 |
 d k } | ró |	 j d |
 ƒ | j ƒ  } |	 j d | ƒ | j ƒ  } |	 j d | ƒ n  |	 j |  j | | d t ƒƒ | rZ| r.|	 j d	 ƒ n  |	 j	 | d g ƒ | rZ|	 j d ƒ qZn  | rp|	 j d ƒ n  |	 j	 d d g ƒ xY | j
 | d t ƒD]B \ } } t | ƒ r™| d \ } } |	 j d | | f ƒ q™q™Wd j |	 ƒ } |  j | | | d t d t ƒd S(   s¹   
        Draw the markers defined by path at each of the positions in x
        and y.  path coordinates are points, x and y coords will be
        transformed by the transform
        s   % draw_markers 
i    i   i   s   %1.3f setgrays   %1.3f %1.3f %1.3f setrgbcolori   s   /o {t   gsaveR7  t	   translateg        s   %.1f setlinewidths   %d setlinejoins   %d setlinecapRÄ   t   fillt   grestoret   strokes
   } bind defiþÿÿÿs   %g %g os   
N(   t   debugPSR“   R´   t   get_linewidthR  t   get_joinstylet   get_capstyleRÆ   R„   R8  R,  R…   Ru   R=  (   R+   Rù   t   marker_patht   marker_transR¥   t   transR>  R´   t   ps_colorR:  t   lwRD  t   jintt   cintt   verticesR6  R~   R  R)  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   draw_markersA  sB     (
"c         C  s?  |  j  j } g  } x¤ t |  j | | | ƒ ƒ D]‡ \ } \ } } d |  j | f } d | d d g } | j |  j | | d t ƒƒ | j d g ƒ | d j	 | ƒ ƒ | j | ƒ q. Wxp |  j
 | | | | | | | | |	 |
 | | | ƒ D]; \ } } } } } d | | | f } |  j | | | ƒ qí W|  j d	 7_ d  S(
   Ns   p%x_%xs   /%s {R7  RA  RÄ   s   } bind def
s   
s   %g %g %si   (   R“   R´   t	   enumeratet   _iter_collection_raw_pathsR¡   R  RÆ   R„   R8  Ru   t   _iter_collectionR=  (   R+   Rù   t   master_transformt   pathst   all_transformst   offsetst   offsetTranst
   facecolorst
   edgecolorst
   linewidthst
   linestylest   antialiasedst   urlst   offset_positionR´   t
   path_codesR  R¥   R  RÊ   R:  t   xot   yot   path_idt   gc0R>  R)  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   draw_path_collections  s$    "	"s   TeX!c	         C  sH  |  j  | | | ƒ \ }	 }
 } | j ƒ  } d |  j } d | j ƒ  d  } i d d 6d d 6j t d d	 d
 ƒ } | | } d | | f } d	 } t d rÚ t | | | ƒ } |  j j d | | | | d | f ƒ n> t | | | | ƒ } |  j j d | | | | d | f ƒ d t	 ƒ  } |  j
 j | ƒ |  j d 7_ d S(   s&   
        draw a Text instance
        s
   psmarker%ds   %1.3f,%1.3f,%1.3fi   s   {\sffamily %s}s
   sans-serifs   {\ttfamily %s}t	   monospaces   font.familyi    s   {\rmfamily %s}s   \color[rgb]{%s} %ss   text.latex.previews/   \psfrag{%s}[Bl][Bl][1][%f]{\fontsize{%f}{%f}%s}g      ô?s/   \psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}s5   gsave
%(pos)s moveto
(%(thetext)s)
show
grestore
    i   N(   RÑ   RÐ   R”   t   get_rgbRå   R   Rw   R•   R  RÅ   R“   R´   (   R+   Rù   R~   R  Rr   RÙ   t   angleRÚ   t   mtextRg   Rh   t   blR�   t   thetextR—   t   fontcmdt   text   corrt   posR)  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   draw_tex�  s$    



*'c	         C  sÅ  |  j  j }	 t r |	 d ƒ n  | d k rG |  j | | | | | | ƒ S| ri |  j | | | | | | ƒ St d r×|  j | j ƒ  Œ  |  j | ƒ }
 |
 j	 ƒ  } | j
 ƒ  } d | } d } |
 j | ƒ d | } d } g  } xÅ | D]½ } t j t | ƒ d ƒ } y |
 j | ƒ } Wn& t k
 r@d } |
 j d ƒ } n X| d k	 rb|
 j | | ƒ } n d } | } | | | 7} | j d	 | | | f ƒ | | | 7} qç Wd
 j | ƒ } d t ƒ  } |  j  j | ƒ nê|  j | ƒ }
 |
 j | d d t ƒ|  j |
 | ƒ |  j | j ƒ  Œ  |
 j ƒ  } y | d j d ƒ } Wn$ t k
 rh| d j d ƒ } n X| j d d ƒ } |  j | | j
 ƒ  ƒ |
 j ƒ  } d } g  } d } d } xÝ | D]Õ } t | ƒ } | j | ƒ } | d k rt d ƒ } d } d } n |
 j  | ƒ } |
 j! | d t ƒ} | d k	 rL|
 j" | | t# ƒ } n d } | } | | d 7} | j d	 | | | f ƒ | | j$ d 7} q¼Wd
 j | ƒ } d t ƒ  } |  j  j | ƒ d S(   s&   
        draw a Text instance
        s   % text
t   TeXs	   ps.useafmgü©ñÒMbP?i    i   t   questiont   ?s   %f %f m /%s glyphshows   
s|   gsave
/%(fontname)s findfont
%(fontsize)s scalefont
setfont
%(x)f %(y)f translate
%(angle)f rotate
%(thetext)s
grestore
    RÎ   i   i   t   macromani   i	  s   utf-16beR6   R€   s   .notdefg      P@g      ð@sB   gsave
%(x)f %(y)f translate
%(angle)f rotate
%(thetext)s
grestore
N(   i   i    i    i   (   i   i   i	  i   (%   R“   R´   RE  Rn  t   draw_mathtextR   R¹   Rh  RÓ   t   get_fontnameRÐ   RÔ   R0   R    Rå   R|   t   get_width_from_char_nameR/   t   get_width_chart   get_kern_dist_from_nameR  Ru   RÅ   RÕ   RÖ   R   R¯   t   get_sfntR<   t   encodeRÃ   t   get_charmapt   get_glyph_namet	   load_chart   get_kerningR   t   linearHoriAdvance(   R+   Rù   R~   R  Rr   RÙ   Ri  RÚ   Rj  R´   R¬   Rœ   R�   RÈ   t   thisxt   thisyt	   last_nameR  t   cRÊ   R‘   t   kernRl  R)  t   sfntt   ps_namet   cmapt   lastgindt   ccodet   gindt   glyph(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt	   draw_text°  sŒ    



	c         C  s   t  ƒ  S(   N(   t   GraphicsContextPS(   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   new_gc  s    c         C  s�   t  r |  j j d ƒ n  |  j j | d | ƒ \ } } }	 }
 } |  j | ƒ |  j | j ƒ  Œ  |
 j ƒ  } d t	 ƒ  } |  j j | ƒ d S(   s>   
        Draw the math text using matplotlib.mathtext
        s   % mathtext
iH   sB   gsave
%(x)f %(y)f translate
%(angle)f rotate
%(thetext)s
grestore
N(
   RE  R“   R´   R£   RÒ   R³   R¹   Rh  t   getvalueRÅ   (   R+   Rù   R~   R  Rr   RÙ   Ri  R‘   R’   RÝ   R§   R¢   Rl  R)  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRv  !  s    'c         C  s,   |  j  | | j d ƒ | j d ƒ | ƒ d  S(   Ni   i   i   i   (   i   i   i   (   i   i   i   (   t   draw_gouraud_trianglest   reshape(   R+   Rù   R5  t   colorsRK  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   draw_gouraud_triangle6  s    c         C  s  t  | ƒ t  | ƒ k s t ‚ | j d k s3 t ‚ | j d d k sL t ‚ | j d d k se t ‚ | j d k sz t ‚ | j d d k s“ t ‚ | j d d k s¬ t ‚ | j } | j | d | d d f ƒ } | j | ƒ } | j | d | d d f ƒ } t j | d d ƒd } t j | d d ƒd }	 t j	 t
 d ƒ |	 | ƒ }
 | \ } } |	 \ } } t j | d | d f d	 d d d d f d d d f g ƒ} d | d
 <| | |
 | d <| d  d  … d  d … f d | d <t | j ƒ  ƒ } |  j j d t ƒ  ƒ d  S(   Ni   i   i   i   i    t   axisi   i    t   dtypeRÎ   t   u1R5  s   >u4R”  g     ào@sø   
gsave
<< /ShadingType 4
   /ColorSpace [/DeviceRGB]
   /BitsPerCoordinate 32
   /BitsPerComponent 8
   /BitsPerFlag 8
   /AntiAlias true
   /Decode [ %(xmin)f %(xmax)f %(ymin)f %(ymax)f 0 1 0 1 0 1 ]
   /DataSource (%(stream)s)
>>
shfill
grestore
i   i   l        l   ÿÿ (   s   flagss   u1(   i   (   i   (   R…   t   AssertionErrort   ndimRñ   R“  R  R†   R  t   maxt   ceilt   floatt   emptyRƒ   Rò   R“   R´   RÅ   (   R+   Rù   R5  R”  RK  Rñ   t   flat_pointst   flat_colorst
   points_mint
   points_maxt   factort   xmint   ymint   xmaxt   ymaxt	   streamarrt   stream(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR’  :  s6    	!!
$	c         C  sY  |  j  j } t r- | r- | d | d ƒ n  | j ƒ  } | oB | } | ov | d k	 ov t | ƒ d k pv | d d k } | rñ |  j | j ƒ  ƒ | j ƒ  }	 |  j	 |	 ƒ | j
 ƒ  }
 |  j |
 ƒ |  j | j ƒ  Œ  |  j | j ƒ  d  Œ  n  | d ƒ | j ƒ  } | r?| j \ } } } } | d | | | | f ƒ n  | j ƒ  \ } } | rz|  j | | ƒ } | d | ƒ n  | | j ƒ  ƒ | d ƒ | rä| r­| d ƒ n  |  j d d	 | d  Œ | d
 ƒ | rä| d ƒ qän  | j ƒ  } | r8|  j | ƒ } | d ƒ | d | j ƒ  d  ƒ | d | ƒ n  | rK| d ƒ n  | d ƒ d S(   sv  
        Emit the PostScript sniplet 'ps' with all the attributes from 'gc'
        applied.  'ps' must consist of PostScript commands to construct a path.

        The fill and/or stroke kwargs can be set to False if the
        'ps' string already includes filling and/or stroking, in
        which case _draw_ps is just supplying properties and
        clipping.
        s   % s   
i   g        s   gsave
s    %1.4g %1.4g %1.4g %1.4g clipbox
s   %s
R¸   i    s   fill
s	   grestore
s/   [/Pattern [/DeviceRGB]] setcolorspace %f %f %f s   %s setcolor fill grestore
s   stroke
N(   R“   R´   RE  t   shouldstrokeR0   R…   Rº   RF  RG  R»   RH  R¼   RÁ   t
   get_dashesR¹   Rh  R  R  R  R  R@   t	   get_hatchRË   (   R+   R)  Rù   R>  RB  RD  t   commandR´   t   mightstrokeRN  RO  t   cliprectR~   R  Rg   Rh   R!  R"  R(  RÇ   t
   hatch_name(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR=  h  sT    "



N(,   RE   RF   t   __doc__R   Rè   Rä   R,   R¯   R³   R¹   Rº   R»   R¼   RÁ   RÃ   RË   RÌ   RÑ   RÞ   RÓ   RÕ   Rî   Rõ   Rþ   R	  R
  R  R  R0   R*  R„   RÆ   R  R?  RQ  Rf  Rq  RŽ  R�  Rv  R•  R’  R9   R=  (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRŒ   ¿   sL   "					(									
B	
2	#n				.R�  c           B  s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C  s&   i d d 6d d 6d d 6t  j |  ƒ S(   Ni    t   butti   t   roundi   t
   projecting(   R   RH  (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRH  ©  s    
c         C  s&   i d d 6d d 6d d 6t  j |  ƒ S(   Ni    t   miteri   R³  i   t   bevel(   R   RG  (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRG  ®  s    
c         C  s>   |  j  ƒ  d k o= t |  j ƒ  ƒ d k p= |  j ƒ  d d k S(   Ng        i   (   RF  R…   Rh  (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRª  ³  s    (   RE   RF   RH  RG  Rª  (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR�  ¨  s   		c         O  s.   | j  d t ƒ } | | | Ž  } t |  | ƒ S(   Nt   FigureClass(   t   popR   t   new_figure_manager_given_figure(   t   numRv   t   kwargsR·  t   thisFig(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   new_figure_manager·  s    c         C  s   t  | ƒ } t | |  ƒ } | S(   sD   
    Create a new figure manager instance for the given figure.
    (   t   FigureCanvasPSt   FigureManagerPS(   Rº  t   figuret   canvast   manager(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR¹  ½  s    R¾  c           B  ss   e  Z e Z d  „  Z i d d 6d d 6Z d „  Z d „  Z d „  Z d „  Z	 d	 d
 d
 d e
 d d „ Z d „  Z RS(   c         C  s   d  S(   N(    (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   drawÈ  s    t
   PostscriptR)  s   Encapsulated Postscriptt   epsc         C  s   d S(   NR)  (    (   R+   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   get_default_filetypeÎ  s    c         O  s   |  j  | d | | Ž S(   NR)  (   t	   _print_ps(   R+   t   outfileRv   R»  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   print_psÑ  s    c         O  s   |  j  | d | | Ž S(   NRÅ  (   RÇ  (   R+   RÈ  Rv   R»  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt	   print_epsÔ  s    c      
   O  sT  | j  d t d ƒ } | j ƒ  } | d k r1 n4 | t k re t d | d j t j ƒ  ƒ f ƒ ‚ n  | j  d d ƒ j ƒ  } | d k r’ t } n! | d k r§ t } n t d	 ƒ ‚ |  j	 j
 d
 ƒ | j  d d
 ƒ } | j  d d ƒ }	 | j  d d ƒ }
 t d r+|  j | | | |	 |
 | | | | � n% |  j | | | |	 |
 | | | | � d  S(   Nt	   papertypes   ps.papersizet   autos>   %s is not a valid papertype. Use one                     of %ss   , t   orientationt   portraitt	   landscapes-   Orientation must be "portrait" or "landscape"iH   t   dpit	   facecolorRg   t	   edgecolors   text.usetex(   R¸  R   t   lowerRb   t   RuntimeErrorRu   t   iterkeysR9   R„   RÀ  t   set_dpit   _print_figure_text   _print_figure(   R+   RÈ  t   formatRv   R»  RË  RÍ  t   isLandscapeR–   RÑ  RÒ  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÇ  ×  s0    % 	 	
	
	iH   Rg   RÎ  c	            s¶  | d k ‰ t  }
 t | ƒ r' | ‰	 n' t | ƒ rB d ‰	 t }
 n t d ƒ ‚ ˆ j j ƒ  \ ‰
 ‰ ˆ d k r™ | r‡ t ˆ ˆ
 ƒ ‰ q™ t ˆ
 ˆ ƒ ‰ n  | r² t	 ˆ \ } } n t	 ˆ \ } } t
 d r>ˆ d k r>ˆ
 | k sñ ˆ | k r>| rt ˆ ˆ
 ƒ ‰ t	 ˆ \ } } q;t ˆ
 ˆ ƒ ‰ t	 ˆ \ } } q>n  d | ˆ
 ‰ d | ˆ ‰ ˆ j j j \ } } } } ˆ } ˆ } | | } | | } d ‰ | rÝ| | | | f \ } } } } d | ˆ ˆ ‰ ‰ d ‰ n  | | | | f ‰  ˆ j j ƒ  } ˆ j j ƒ  } ˆ j j | ƒ ˆ j j | ƒ |	 j d	 t  ƒ } | rjd
 t f d „  ƒ  Y} | ƒ  ˆ _ n4 t j d d k r�t j ƒ  ˆ _ n t j ƒ  ˆ _ |	 j d d ƒ } ˆ j ˆ
 ˆ ˆ j d | ƒ‰ t ˆ j ˆ
 ˆ | ˆ d | ƒ} ˆ j j | ƒ | r	d Sˆ j j | ƒ ˆ j j | ƒ ‡  ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡	 ‡
 ‡ ‡ f d †  } t
 d ršt ƒ  \ } } t j | d ƒ � ‰ | ƒ  Wd QXn5 |
 r°| ‰ | ƒ  n t | d ƒ � ‰ | ƒ  Wd QXt
 d r²t
 d d k rt | ˆ d ˆ d ˆ  ƒn, t
 d d k r1t  | ˆ d ˆ d ˆ  ƒn  |
 ret | d ƒ � } | j! | j" ƒ  ƒ Wd QXq²t | d ƒ � } Wd QXt# j$ | ƒ j% } t& j' | | ƒ t# j( | | ƒ n  d S(   s)  
        Render the figure to hardcopy.  Set the figure patch face and
        edge colors.  This is useful because some of the GUIs have a
        gray figure face color background and you'll probably want to
        override this on hardcopy

        If outfile is a string, it is interpreted as a file name.
        If the extension matches .ep* write encapsulated postscript,
        otherwise write a stand-alone PostScript file.

        If outfile is a file object, a stand-alone PostScript file is
        written into this file object.
        RÅ  s,   outfile must be a path or a file-like objectRÌ  s   ps.usedistilleriH   g      à?i    iZ   t   dryrunt
   NullWriterc           B  s   e  Z d  „  Z RS(   c         _  s   d  S(   N(    (   R+   t   klR»  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR´   ;  s    (   RE   RF   R´   (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÜ  :  s   i   t   bbox_inches_restoreR–   Nc            së  t  j d d k r+ t j ˆ d d ƒ}  n ˆ }  ˆ rJ t d d |  ƒn t d d |  ƒˆ	 rw t d ˆ	 d |  ƒn  t d	 t d
 d |  ƒt d t j t j ƒ  ƒ d |  ƒt d ˆ d |  ƒˆ sã t d ˆ d |  ƒn  t d ˆ  d |  ƒˆ st d d |  ƒn  t d d |  ƒt t	 ƒ } t d d |  ƒt
 d s\| t ˆ j ƒ 7} n  t d | d |  ƒt d d |  ƒxJ t	 D]B } | j ƒ  } x- | j d ƒ D] } t | j ƒ  d |  ƒq©Wq‡Wt
 d s½xã ˆ j j ƒ  D]Ï \ } } t | ƒ rçt t | ƒ ƒ } | j ƒ  } g  } x0 | D]( }	 | j |	 ƒ pBd }
 | j |
 ƒ q*Wt
 d } t | ƒ d k r{d } n  t | ƒ r–t d ƒ ‚ q¶|  j ƒ  t | ˆ | | ƒ qçqçWn  t d d |  ƒt d d |  ƒˆ söt d d |  ƒn  t d d |  ƒt d t ˆ ˆ ƒ d |  ƒˆ r@t d ˆ d |  ƒn  t d t ˆ
 d  ˆ d  d d ƒ d |  ƒt ˆ j j ƒ  d |  ƒt d d |  ƒt d! d |  ƒˆ s½t d" d |  ƒn  |  j ƒ  t  j d d k rç|  j ƒ  n  d  S(#   Ni    i   t   encodingR6   s   %!PS-Adobe-3.0 EPSF-3.0t   files   %!PS-Adobe-3.0s	   %%Title: s   %%Creator: matplotlib version s   , http://matplotlib.org/s   %%CreationDate: s   %%Orientation: s   %%DocumentPaperSizes: s   %%%%BoundingBox: %d %d %d %ds
   %%Pages: 1s   %%EndCommentss   %%BeginPrologs	   ps.useafms   /mpldict %d dict defs   mpldict begins   
s   ps.fonttypeiÿ   i*   sy   OpenType CFF fonts can not be saved using the internal Postscript backend at this time.
Consider using the Cairo backend.t   ends   %%EndPrologs   %%Page: 1 1s   %s translates	   %d rotates
   %s clipboxiH   t   showpages   %%EOF(   R   R:   t   iot   TextIOWrappert   printR
   t   timet   ctimeR…   t   psDefsR   R¢   R@   RA   t
   itervaluesR   Rn   R}  Rå   R  R   RÔ  t   flushR   Rw   R“   R‘  t   detach(   Rç   t   NdictRÜ   Ra   t   font_filenamet   charsR¬   R‰  t	   glyph_idsR…  RŒ  t   fonttype(   R   R’   t   isEPSFRÍ  RË  t   ps_renderert   raw_fht   rotationR+   t   titleR‘   Rb  Rc  (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   print_figure_implV  sz      #  


	
  + 
t   wbt   ghostscriptt   ptypeR   t   xpdfRâ   Rg   g      B@g      B@()   R„   R   R   R0   R9   R/  RÀ  t   get_size_inchesRl   Rb   R   R   R  t   get_facecolort   get_edgecolort   set_facecolort   set_edgecolorRå   t   objectR“   R   R:   Rã  t   StringIOt	   cStringIOR¸  t   _renderer_classR$   RÃ  R   Ræ   t
   gs_distillt   xpdf_distillR´   R;   R¤   t   statt   st_modet   shutilt   movet   chmod(    R+   RÈ  RÙ  RÐ  RÑ  RÒ  RÍ  RÚ  RË  R»  t   passed_in_file_objectt   paperHeightt
   paperWidthRa   R·   Rg   Rh   t   llxt   llyt   urxt   uryt   origfacecolort   origedgecolorRÛ  RÜ  t   _bbox_inches_restoreRÍ   Rö  t   fdt   tmpfileRç   t   mode(    (   R   R’   Rñ  RÍ  RË  Rò  Ró  Rô  R+   Rõ  R‘   Rb  Rc  sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRØ  ó  s¢    		  

				3N


c	   .      K  s–  | d k }
 | } d |  j  _ |  j  j ƒ  \ } } d } d } |  j  j j \ } } } } | } | } | | } | | } | | | | f } |  j  j ƒ  } |  j  j ƒ  } |  j  j | ƒ |  j  j | ƒ |	 j	 d t
 ƒ } | rd t f d „  ƒ  Y} | ƒ  |  _ n4 t j d d k r,t j ƒ  |  _ n t j ƒ  |  _ |	 j d d
 ƒ } |  j | | |  j d	 | ƒ} t |  j  | | | | d | ƒ} |  j  j | ƒ | r¦d
 S|  j  j | ƒ |  j  j | ƒ t ƒ  \ }  }! t j d d k rt j |  d d d ƒ}" n t j |  d ƒ }" |" �Ùt d d |" ƒ| rIt d | d |" ƒn  t d t d d |" ƒt d t j t j ƒ  ƒ d |" ƒt d | d |" ƒt d d |" ƒt t ƒ }# t d d |" ƒt d |# d |" ƒt d d |" ƒxJ t D]B }$ |$ j ƒ  }$ x- |$ j  d ƒ D] } t | j ƒ  d |" ƒqWqïWt d d |" ƒt d d |" ƒt d d |" ƒt d t! | | ƒ d |" ƒt d t! | d | d d d ƒ d |" ƒt |  j j" ƒ  d |" ƒt d d |" ƒt d d |" ƒ|" j# ƒ  Wd
 QX| r$t$ } | | } } | | | | f } n  |
 rX|  j  j ƒ  \ }% }& | rç|& |% }% }& qçn� t% | | ƒ }' | d  k rŒ|' } t& |' \ }% }& n[ t& | \ }% }& | |% k s´| |& k rç|
 rçt& |' \ }% }& t' j( d! | |' f d" ƒ n  | j) ƒ  }( |( j* ƒ  }) |( j+ ƒ  }* t, |! | j- |) |* |% |& | ƒ }+ t. d# d$ k r^t/ |! |
 d% | d& | d' |+ ƒng t. d# d( k r�t0 |! |
 d% | d& | d' |+ ƒn5 t. d) rÅt
 r£qÅt/ |! |
 d% | d& | d' |+ ƒn  t
 }, t j d d k rüt1 | t j2 ƒ rt$ }, qn t1 | t3 ƒ rt$ }, n  |, rHt |! d* ƒ � }" | j4 |" j5 ƒ  ƒ Wd
 QXnJ t | d ƒ � }" Wd
 QXt6 j7 | ƒ j8 }- t9 j: |! | ƒ t6 j; | |- ƒ d
 S(+   sê   
        If text.usetex is True in rc, a temporary pair of tex/eps files
        are created to allow tex to manage the text layout via the PSFrags
        package. These files are processed to yield the final ps or eps file.
        RÅ  iH   i    RÛ  RÜ  c           B  s   e  Z d  „  Z RS(   c         _  s   d  S(   N(    (   R+   RÝ  R»  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR´   ã  s    (   RE   RF   R´   (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyRÜ  â  s   i   RÞ  R–   NRg   Rß  R6   R÷  s   %!PS-Adobe-3.0 EPSF-3.0Rà  s	   %%Title: s   %%Creator: matplotlib version s   , http://matplotlib.org/s   %%CreationDate: s   %%%%BoundingBox: %d %d %d %ds   %%EndCommentss   %%BeginPrologs   /mpldict %d dict defs   mpldict begins   
Rá  s   %%EndPrologs   %s translates
   %s clipboxRâ  RÌ  sY   Your figure is too big to fit on %s paper. %s     paper will be used to prevent clipping.t   helpfuls   ps.usedistillerRø  Rù  R   t   rotatedRú  s   text.usetexRâ   (<   RÀ  RÐ  Rû  R   R  Rü  Rý  Rþ  Rÿ  Rå   R„   R   R“   R   R:   Rã  R  R  R¸  R0   R  R$   RÃ  R   Ræ   Rå  R
   Ræ  Rç  R…   Rè  R@   RA   Rw   R‘  Rê  R9   Rl   Rb   R	   t   reportRÏ   t   get_font_preamblet   get_custom_preamblet   convert_psfragsR•   R   R  R  t
   isinstancet   IOBaseRà  R´   R;   R¤   R  R  R  R	  R
  (.   R+   RÈ  RÙ  RÐ  RÑ  RÒ  RÍ  RÚ  RË  R»  Rñ  Rõ  R‘   R’   Rb  Rc  Ra   R·   Rg   Rh   R  R  R  R  R   R  R  RÛ  RÜ  R  Rò  RÍ   R  R  Rç   Rì  RÜ   R  R  t   temp_papertypeRÛ   t   font_preamblet   custom_preamblet   psfrag_rotatedt   is_fileR  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR×  Ã  sâ    

		 #+		


 
	N(   RE   RF   RŒ   R  RÃ  t	   filetypesRÆ  RÉ  RÊ  RÇ  R„   R0   RØ  R×  (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR¾  Å  s   	

					Ïc         C  sW  t  j j |  ƒ d } |  d } t j |  | ƒ |  d }	 |  d }
 |  d } |  d } | d k rm d } n d } t d	 r† d
 } n d } d | | | | | | | d j | ƒ | t  j j | ƒ d f
 } t j |	 d ƒ �k } t d	 r| j	 | j
 d ƒ ƒ nA y | j	 | j
 d ƒ ƒ Wn$ t k
 rEt j d d ƒ ‚  n XWd QXt j d k rxd t  j j | ƒ d } n d } d | | |	 |
 f } t j | d ƒ t  j | ƒ } t j |
 d ƒ �< } | rçt d | j ƒ  ƒ ‚ n t j | j ƒ  d ƒ Wd QXt  j |
 ƒ d | | t  j j | ƒ d t  j j | ƒ d |
 f } t j | d ƒ t  j | ƒ } t j |
 d ƒ �@ } | r t d | | j ƒ  ƒ ‚ n t j | j ƒ  d ƒ Wd QXt  j |
 ƒ t  j | ƒ t j | |  ƒ t |  ƒ �+ } d | j d ƒ k rt } n t } Wd QXt sSx+ t j |  d ƒ D] } t  j | ƒ q9Wn  | S(    sj  
    When we want to use the LaTeX backend with postscript, we write PSFrag tags
    to a temporary postscript file, each one marking a position for LaTeX to
    render some text. convert_psfrags generates a LaTeX document containing the
    commands to convert those tags to text. LaTeX/dvips produces the postscript
    file that includes the actual text.
    i    s   .epss   .texs   .outputs   .dvis   .psRÏ  iZ   s   text.latex.unicodes-   \usepackage{ucs}
\usepackage[utf8x]{inputenc}t    sE  \documentclass{article}
%s
%s
%s
\usepackage[dvips, papersize={%sin,%sin}, body={%sin,%sin}, margin={0in,0in}]{geometry}
\usepackage{psfrag}
\usepackage[dvips]{graphicx}
\usepackage{color}
\pagestyle{empty}
\begin{document}
\begin{figure}
\centering
\leavevmode
%s
\includegraphics*[angle=%s]{%s}
\end{figure}
\end{document}
s   
iÿÿÿÿR÷  t   utf8R6   sb   You are using unicode and latex, but have not enabled the matplotlib 'text.latex.unicode' rcParam.R  Nt   win32s   %s &&s8   %s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"t   debugRâ   s]   LaTeX was not able to process your file:    
Here is the full report generated by LaTeX: 

%ss.   %s cd "%s" && dvips -q -R0 -o "%s" "%s" > "%s"sk   dvips was not able to     process the following file:
%s
Here is the full report generated by dvips:     

t	   Landscapeiè  s   .*(   R¤   R¥   RA   R  R	  R   Ru   Rã  Ræ   R´   R|  t   UnicodeEncodeErrorR	   R  R   t   platformt
   splitdrivet   systemRÔ  R;   t   removeR9   R„   RE  t   glob(   R  t   psfragsR!  R"  R  R  RÍ  t   tmpdirt   epsfilet	   latexfileRÈ  t   dvifilet   psfileRi  t   unicode_preambleRr   t   latexht   precmdR­  t   exit_statusRç   R#  R¨   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR  f  st    	




 	
	)
	 	0		c         C  sF  | r d } n
 d | } |  d } |  d } t  d } t j }	 t j rR d }
 n d }
 d |	 | |
 | | |  | f } t j | d	 ƒ t j | ƒ } t j	 | d
 ƒ �< } | rÊ t
 d | j ƒ  ƒ ‚ n t j | j ƒ  d	 ƒ Wd QXt j | ƒ t j |  ƒ t j | |  ƒ | rBt j r5t |  | d | ƒqBt |  ƒ n  d S(   sÔ   
    Use ghostscript's pswrite or epswrite device to distill a file.
    This yields smaller files without illegal encapsulated postscript
    operators. The output is low-level, converting text to outlines.
    s	   -dEPSCrops   -sPAPERSIZE=%ss   .pss   .outputs   ps.distiller.rest   ps2writet   pswritesV   %s -dBATCH -dNOPAUSE -r%d -sDEVICE=%s %s -sOutputFile="%s"                 "%s" > "%s"R)  Râ   sg   ghostscript was not able to process     your image.
Here is the full report generated by ghostscript:

NR  (   R   t   ps_backend_helperR-   RD   R	   R  R¤   R.  Rã  Ræ   RÔ  R;   R/  R  R	  t   pstoeps(   R  RÅ  Rù  R   R  t   paper_optionR6  RÈ  RÐ  R-   t   device_nameR­  R:  Rç   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR  Õ  s4     	



				c         C  sÛ  |  d } |  d } |  d } | r- d } n
 d | } d | |  | | f }	 t  j d k rq |	 j d d	 ƒ }	 n  t j |	 d
 ƒ t j |	 ƒ }
 t j | d ƒ �< } |
 rÄ t	 d | j
 ƒ  ƒ ‚ n t j | j
 ƒ  d
 ƒ Wd QXt j | ƒ d | | | f }	 t j |	 d
 ƒ t j |	 ƒ }
 t j | d ƒ �< } |
 rSt	 d | j
 ƒ  ƒ ‚ n t j | j
 ƒ  d
 ƒ Wd QXt j | ƒ t j |  ƒ t j | |  ƒ | r¬t |  ƒ n  x( t j |  d ƒ D] } t j | ƒ qÀWd S(   s
  
    Use ghostscript's ps2pdf and xpdf's/poppler's pdftops to distill a file.
    This yields smaller files without illegal encapsulated postscript
    operators. This distiller is preferred, generating high-level postscript
    output that treats text as text.
    s   .pdfs   .pss   .outputs	   -dEPSCrops   -sPAPERSIZE=%ssW   ps2pdf -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode %s "%s" "%s" > "%s"R(  t   =t   #R)  Râ   sZ   ps2pdf was not able to process your image.
\Here is the report generated by ghostscript:

Ns-   pdftops -paper match -level2 "%s" "%s" > "%s"s\   pdftops was not able to process your image.
Here is the full report generated by pdftops: 

s   .*(   R   R,  R€   R	   R  R¤   R.  Rã  Ræ   RÔ  R;   R/  R  R	  R>  R0  (   R  RÅ  Rù  R   R  t   pdffileR6  RÈ  R?  R­  R:  Rç   R¨   (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR    sD    


 	
 c   	      C  sŒ   |  \ } } } } | r/ d | | d f } n d } d | | t  j | ƒ t  j | ƒ f } d | | | | f } d j | | g ƒ | f S(   sw   
    return a postscript header stringfor the given bbox lbrt=(l, b, r, t).
    Optionally, return rotate command.
    s   %.2f %.2f  translate
90 rotatei    R&  s   %%%%BoundingBox: %d %d %d %ds)   %%%%HiResBoundingBox: %.6f %.6f %.6f %.6fs   
(   R†   Rœ  Ru   (	   t   lbrtR  Ra   R·   Rµ   t   tt   rotatet	   bbox_infot   hires_bbox_info(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   get_bbox_header;  s    (c         C  sí  |  d } t  j } d | |  f } t j | d ƒ t j | ƒ \ } } } t j | j ƒ  d ƒ | j ƒ  } t j | d ƒ t j d | ƒ }	 |	 r¤ |	 j	 ƒ  } n t
 d | ƒ ‚ g  | j ƒ  d D] }
 t |
 ƒ ^ qÅ \ } } } } | d k r&| d	 | d	 | d	 | d	 f \ } } } } nv | | d
 } | | d
 } | d
 | d d
 } | d | d	 d
 } | | | | | | | | f \ } } } } d | | t j | ƒ t j | ƒ f } d | | | | f } d j | | g ƒ S(   s£   
    Use ghostscript's bbox device to find the center of the bounding box. Return
    an appropriately sized bbox centered around that point. A bit of a hack.
    s   .outputs'   %s -dBATCH -dNOPAUSE -sDEVICE=bbox "%s"R)  s   debug-annoyingR  s   %%HiResBoundingBox: .*sV   Ghostscript was not able to extract a bounding box.Here is the Ghostscript output:

%siüÿÿÿi   i   i    i   s   %%%%BoundingBox: %d %d %d %ds)   %%%%HiResBoundingBox: %.6f %.6f %.6f %.6fs   
N(   R=  R-   R	   R  R¤   t   popen3R;   R�   t   searchR}   RÔ  RA   R�  R0   R†   Rœ  Ru   (   R  R   RÈ  R-   R­  t   stdinR5   t   stderrRG  t
   bbox_foundR  Ra   R·   Rµ   RE  R~   R  R  R  RH  (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   get_bboxN  s2    
	51.(c   
      C  sc  | r! t  | d | ƒ\ } } n d \ } } |  d } t j | d ƒ �÷} | j } t j |  d ƒ �Ó} | j ƒ  }	 x8|	 r°|	 j d ƒ r» | d ƒ | r¡| | j d ƒ d ƒ q¡næ |	 j d	 ƒ rR| |	 ƒ | d
 ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | d ƒ | rN| | j d ƒ d ƒ n  PnO | r—|	 j d ƒ s¡|	 j d ƒ s¡|	 j d ƒ s¡|	 j d ƒ r—n
 | |	 ƒ | j ƒ  }	 qy W| j ƒ  }	 xv |	 r5|	 j d ƒ r
| d ƒ | d ƒ | d ƒ | d ƒ | d ƒ n |	 j d ƒ rn
 | |	 ƒ | j ƒ  }	 qÀWWd QXWd QXt j	 |  ƒ t
 j | |  ƒ d S(   s´   
    Convert the postscript to encapsulated postscript.  The bbox of
    the eps file will be replaced with the given *bbox* argument. If
    None, original bbox will be used.
    R  s   .epsR÷  Râ   s   %!PSs   %!PS-Adobe-3.0 EPSF-3.0
R6   s   
s   %%EndCommentss   %%BeginProlog
s   save
s   countdictstack
s   mark
s   newpath
s   /showpage {} def
s   /setpagedevice {pop} def
s   %%EndProlog
s   %%Page 1 1
s   %%Bounds   %%HiResBounds   %%DocumentMedias   %%Pagess   %%EOFs   cleartomark
s   exch sub { end } repeat
s   restore
s   %%EOF
s   %%PageBoundingBoxN(   NN(   RI  R0   Rã  Ræ   R´   t   readlineRf   R|  R¤   R/  R  R	  (
   R  R   R  RG  RF  R3  t   epshR´   t   tmpht   line(    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR>  x  s`    
		











	




R¿  c           B  s   e  Z RS(    (   RE   RF   (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyR¿  ¼  s   s   /m { moveto } bind defs   /l { lineto } bind defs   /r { rlineto } bind defs   /c { curveto } bind defs   /cl { closepath } bind defsU   /box {
      m
      1 index 0 r
      0 exch r
      neg 0 r
      cl
    } bind defs<   /clipbox {
      box
      clip
      newpath
    } bind def(e   R±  t
   __future__R    R   R0  t   mathR¤   R  R   Ræ  R   Rã  R:   R  t   hashlibR   t   ImportErrort   tempfileR   t
   matplotlibR	   R
   R   R   t   matplotlib._pylab_helpersR   t   matplotlib.afmR   t   matplotlib.backend_basesR   R   R   R   t   matplotlib.cbookR   R   R   R   t   matplotlib.mlabR   t   matplotlib.figureR   t   matplotlib.font_managerR   R   t   matplotlib.ft2fontR   R   R   t   matplotlib.ttconvR   t   matplotlib.mathtextR   t   matplotlib._mathtext_dataR    t   matplotlib.textR!   t   matplotlib.pathR"   t   matplotlib.transformsR#   t!   matplotlib.backends.backend_mixedR$   t   numpyR†   Rÿ   R�   Rª   t	   NameErrort   setsR%   R,  Rf   t	   cmd_splitt   backend_versionRE  R   R)   R=  Rb   Rl   Rs   Rw   Rƒ   R‹   RŒ   R�  R½  R¹  R¾  R  R„   R0   R  R  RI  RO  R>  R¿  t   FigureManagerRè  (    (    (    sX   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_ps.pyt   <module>   s¼   H	""" 	4						ÿ ÿ ë		ÿ ¢	o60	*D