ó
,™xTc           @   sû   d  d l  m Z d  d l Z d  d l m Z m Z d  d l Z d  d l	 m
 Z
 d  d l Z d  d l Z e j j d d e ƒZ e j e d „ Z d „  Z d	 e j j j f d
 „  ƒ  YZ d e j j j f d „  ƒ  YZ e d k r÷ e e j d ƒ n  d S(   iÿÿÿÿ(   t   divisionN(   t   Sorryt   Usage(   t   StringIOsô   
include scope cctbx.miller.display.master_phil
h = None
  .type = int
k = None
  .type = int
l = None
  .type = int
output_file = None
  .type = path
width = 800
  .type = int
height = 800
  .type = int
format = *Auto png eps
  .type = choice
t   process_includesc      	   C   sÄ  t  |  ƒ d k rJ t ƒ  } t j d | d d ƒ t d | j ƒ  ƒ ‚ n  d d  l } d d l m } d d  l	 } d d  l
 } t j j d ƒ } t j d	 | ƒ }	 | j j d
 |  d |	 d d d d ƒ }
 |
 j j ƒ  } | j | j d d ƒ} | j d ƒ d  } g  } g  } x� | j j D]� } | j d  k rx| j ƒ  sI| j ƒ  rY| j | ƒ q�| j ƒ  r�| j | ƒ q�q| j ƒ  j ƒ  | j k r| } PqqW| d  k r6t  | ƒ d k ræ| d } | d | j ƒ  j ƒ  IJq6t  | ƒ d k r6t d d j  g  | D] } | j ƒ  j ƒ  ^ qƒ ƒ ‚ q6n  t! | _" | j# d  k	 rŠ| j$ d  k rl| j% d  k srt& ‚ d | _' | j# | _( n– | j$ d  k	 rÕ| j# d  k r·| j% d  k s½t& ‚ d | _' | j$ | _( nK | j% d  k	 r | j# d  k r| j$ d  k st& ‚ d | _' | j% | _( n  t) j* j+ j, d | d | ƒ } t- } | j. d  k	 r°| j. j/ d ƒ rŒ| j0 d k rƒt d ƒ ‚ n  t! } q}| j. j/ d ƒ s}t d ƒ ‚ q}nÍ t1 j2 j3 t1 j2 j4 | j ƒ d ƒ } | j0 d k só| j0 d k rd } t- } n d } t! } | j' d k r9d | | j( | f | _. nD | j' d k rdd  | | j( | f | _. n d! | | j( | f | _. | j5 r�d( } n d) } | rît6 d# | j7 d | j8 d$ | d | ƒ } t9 | j. d# ƒ } | j: | ƒ | j; ƒ  n® | sœt< d# | j7 d% d | j8 d% d$ | d | ƒ } | j= d& | j7 d% | j8 d% f | ƒ } | j> | ƒ } | j? | ƒ | j@ | j7 | j8 f | jA ƒ } | jB | j. ƒ n  | s¶| d' | j. IJn
 | | f Sd  S(*   Ni    t   outt   prefixs     s  cctbx.precession_view data.mtz [ [h=X] | [k=X] | [l=X] ] output_file=img.png

Draws a color image of a reciprocal space plane.  For interactive use, run
phenix.data_viewer, which includes both 2D and 3D views (and can also save
images).

Full parameters:
%siÿÿÿÿ(   t   file_readers?   
expand_to_p1 = True
expand_anomalous = True
slice_mode = True
t   sourcet   argst   master_philt   reflection_file_deft   datat   pdb_file_deft   symmetry_filet
   force_typet   hkli   s(   Using %s since no labels were specified.sl   Multiple equally suitable arrays of data found:
  %s
Please choose one by specifying the 'labels' parameter.t   ht   kt   lt   miller_arrayt   settingst   epst   pngs:   Postscript format requested, but output file ends in .png!s+   Output file extension must be .eps or .png.t   Autos
   %s_%dkl.%ss
   %s_h%dl.%ss
   %s_hk%d.%siÿ   t   wt   scenei   t   RGBAs   Wrote %s(   i    i    i    (   iÿ   iÿ   iÿ   (C   t   lenR   R
   t   showR   t   getvaluet
   iotbx.philt   iotbxR   t	   ImageDrawt   Imaget   libtbxt   philt   parset   fetcht   process_command_line_with_filest   workt   extractt   any_fileR   t   check_file_typet   Nonet   file_servert   miller_arrayst   labelst   is_xray_amplitude_arrayt   is_xray_intensity_arrayt   appendt   is_complex_arrayt   infot   label_stringR   t   joint   Truet
   slice_modeR   R   R   t   AssertionErrort
   slice_axist   slice_indext   cctbxt   millert   displayR   t   Falset   output_filet   endswitht   formatt   ost   patht   basenamet   splitextt   black_backgroundt   render_postscriptt   widtht   heightt   opent   paintt   closet
   render_pilt   newt   Drawt   rendert   resizet	   ANTIALIASt   save(   R	   R   t   silentt
   params_outR    R   R!   R"   t	   phil_modst   master_phil_modt   cmdlinet   paramst   hkl_int   selected_arrayt
   obs_arrayst   complex_arrayst   arrayt   aR   t	   postcriptR   t   extt
   postscriptt   bgRQ   t   canvast   imt   im2(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   run   sÎ    				
8	$	$	$			%							)!c         C   s7   t  |  d d ƒ t  |  d d ƒ t  |  d d ƒ f S(   Ni    iÿ   i   i   (   t   int(   t   c(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   frac2int˜   s    RN   c           B   sJ   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z	 RS(   c         O   s2   | |  _  | |  _ t j j j j |  | | Ž d  S(   N(   t   _wt   _hR<   R=   R>   t	   render_2dt   __init__(   t   selfR   R   R	   t   kwds(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRo   œ   s    		c         C   s   |  j  |  j f S(   N(   Rl   Rm   (   Rp   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   GetSize¡   s    c         C   s   d S(   Ng     €[@(    (   Rp   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   get_scale_factor¤   s    c         C   s8   | j  | | f | | f g d t |  j ƒ d d ƒd  S(   Nt   fillRI   i   (   t   lineRk   t   _foreground(   Rp   Re   t   x1t   y1t   x2t   y2(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt	   draw_line§   s    c         C   s)   | j  | | f | d t |  j ƒ ƒd  S(   NRt   (   t   textRk   Rv   (   Rp   Re   R|   t   xt   y(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt	   draw_textª   s    c         C   sx   t  | d ƒ } | d  k r' |  j } n  | j d | | | | f | | | | f g d t | ƒ d t |  j ƒ ƒ d  S(   Ng      @t   xyt   outlineRt   (   t   maxR,   Rv   t   ellipseRk   t   _background(   Rp   Re   R}   R~   t   radiust   color(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   draw_open_circle®   s     	(c         C   s]   t  | d ƒ } | j d | | | | f | | | | f g d t | ƒ d t | ƒ ƒ d  S(   Ng      @R€   R�   Rt   (   R‚   Rƒ   Rk   (   Rp   Re   R}   R~   R…   R†   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   draw_filled_circle¶   s
    	(N(
   t   __name__t
   __module__Ro   Rr   Rs   R{   R   R,   R‡   Rˆ   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRN   ›   s   					RH   c           B   sS   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z	 d „  Z
 RS(	   c         O   s2   | |  _  | |  _ t j j j j |  | | Ž d  S(   N(   Rl   Rm   R<   R=   R>   Rn   Ro   (   Rp   R   R   R	   Rq   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRo   ¾   s    		c         C   s   |  j  |  j f S(   N(   Rl   Rm   (   Rp   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRr   Ã   s    c         C   s   d S(   Ng     €[@(    (   Rp   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRs   Æ   s    c         C   s¨   |  j  ƒ  | j d ƒ | j d ƒ | j d ƒ | j d |  j ƒ  ƒ | j d |  j ƒ  ƒ | j d ƒ | j d |  j ƒ | j d |  j ƒ  ƒ |  j | ƒ d  S(	   Ns   %!PS-Adobe-3.0 EPSF-3.0
s   %%Pages: 1
s   %%BeginPreview:
s   %%%%BoundingBox: 0 0 %d %d
s:   << /PageSize [ %d %d ] /ImagingBBox null >> setpagedevice
s)   /Helvetica findfont 14 scalefont setfont
s   %g %g %g setrgbcolor
s   0 0 %d %d rectfill
(   t   setup_colorst   writeRr   R„   RQ   (   Rp   Re   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRL   É   s    
	c   	   
   C   sY   |  j  ƒ  \ } } |  j } | j d | | | | | | | d | d | d f ƒ d  S(   Ns?   
newpath
%d %d moveto
%d %d lineto
%g %g %g setrgbcolor
stroke
i    i   i   (   Rr   Rv   RŒ   (	   Rp   Re   Rw   Rx   Ry   Rz   R   R   Rj   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyR{   Ø   s    	c      	   C   sR   |  j  ƒ  \ } } |  j } | j d | | | | | d | d | d f ƒ d  S(   NsE   
newpath
%d %d moveto
(%s) true charpath
%g %g %g setrgbcolor
stroke
i    i   i   (   Rr   Rv   RŒ   (   Rp   Re   R|   R}   R~   R   R   Rj   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyR   ã   s    	c      	   C   sa   |  j  ƒ  \ } } | d  k r* |  j } n  | j d | | | | | d | d | d f ƒ d  S(   Ns8   
newpath
%d %d %d 0 360 arc
%g %g %g setrgbcolor
stroke
i    i   i   (   Rr   R,   Rv   RŒ   (   Rp   Re   R}   R~   R…   R†   R   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyR‡   î   s
     c      	   C   sI   |  j  ƒ  \ } } | j d | | | | | d | d | d f ƒ d  S(   Ns6   
newpath
%d %d %d 0 360 arc
%g %g %g setrgbcolor
fill
i    i   i   (   Rr   RŒ   (   Rp   Re   R}   R~   R…   R†   R   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRˆ   ø   s    N(   R‰   RŠ   Ro   Rr   Rs   RL   R{   R   R,   R‡   Rˆ   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyRH   ½   s   						
t   __main__i   (   t
   __future__R    t   cctbx.miller.displayR<   t   libtbx.utilsR   R   t   libtbx.philR#   t	   cStringIOR   RC   t   sysR$   R%   R7   R
   t   stdoutRh   Rk   R=   R>   Rn   RN   RH   R‰   t   argv(    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/command_line/precession_view.pyt   <module>   s   	y	"D