ó
ÉÝ{Tc           @   s²   d  Z  d d l Z d d l m Z m Z d d l Z d d l Td d l Z d e j f d „  ƒ  YZ	 d e j f d „  ƒ  YZ
 d	 e j f d
 „  ƒ  YZ d e j f d „  ƒ  YZ d S(   s�  
     qtgui/ContourSliceDialog.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009-2010 University of York

     This library is free software: you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public License
     version 3, modified in accordance with the provisions of the 
     license to address the requirements of UK law.
 
     You should have received a copy of the modified GNU Lesser General 
     Public License along with this library.  If not, copies may be 
     downloaded from http://www.ccp4.ac.uk/ccp4license.php
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU Lesser General Public License for more details.
iÿÿÿÿN(   t   QtGuit   QtCore(   t   *t   MapSliceSpecifyingSelectorc           B   s   e  Z d d  „ Z RS(   c         C   sÔ  t  j j |  | ƒ t  j ƒ  |  _ t  j |  j d ƒ ƒ } t  j d ƒ |  _ t  j d ƒ |  _	 t  j d ƒ |  _
 t  j d ƒ |  _ t  j d d d |  j ƒ |  _ t  j d d d |  j	 ƒ |  _ t  j d d d |  j
 ƒ |  _ t  j d d d |  j ƒ |  _ |  j j |  j ƒ |  j	 j |  j ƒ |  j
 j |  j ƒ |  j j |  j ƒ |  j j | d d ƒ |  j j |  j d d ƒ |  j j |  j	 d d	 ƒ |  j j |  j
 d d ƒ |  j j |  j d d
 ƒ |  j |  j ƒ d  S(   Ns   Plane definitions   1.0s   0.0g     @�Àg     @�@i   i    i   i   i   (   R    t   QDialogt   __init__t   QGridLayoutt   specifying_layoutt   QLabelt   trt	   QLineEditt   A_editt   B_editt   C_editt   D_editt   QDoubleValidatort   planeA_validatort   planeB_validatort   planeC_validatort   planeD_validatort   setValidatort	   addWidgett	   setLayout(   t   selft   parentt   plane_defn_label(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR      s*    N(   t   __name__t
   __module__t   NoneR   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR      s   t   MapSliceFaceSelectorc           B   s   e  Z d d  „ Z RS(   c         C   s†  t  j j |  | ƒ t  j ƒ  |  _ t  j |  j d ƒ ƒ } t  j |  j d ƒ ƒ } t  j ƒ  |  _ |  j j	 d ƒ |  j j	 d ƒ |  j j	 d ƒ t  j ƒ  |  _
 x. t d d ƒ D] } |  j
 j	 d | j ƒ q° Wx@ t d d	 ƒ D]/ } t | d
 ƒ rá |  j
 j	 d | j ƒ qá qá W|  j j | d d ƒ |  j j |  j d d ƒ |  j j | d d ƒ |  j j |  j
 d d ƒ |  j |  j ƒ d  S(   Ns   Crystal faces
   of crystalt   abt   act   bct   object_typet   MapDatas   Map: t   MolDatat   originalSymmetrys   Mol: i    i   (   R    R   R   R   t   crystal_layoutR   R	   t	   QComboBoxt   crystal_face_combot   addItemt   crystal_data_dataCombot   get_dataobjt   namet   hasattrR   R   (   R   R   t   crystal_face_labelt
   data_labelt   item(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR   6   s&    N(   R   R   R   R   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR   5   s   t   MapSliceAtomSelectorc           B   s   e  Z d d  „ Z RS(   c         C   s2  t  j j |  | ƒ t  j ƒ  |  _ t  j ƒ  |  _ t  j |  j d ƒ ƒ } t  j |  j d ƒ ƒ } t  j |  j d ƒ ƒ } |  j j	 | d d ƒ |  j j	 | d d ƒ |  j j	 | d d ƒ t
 j ƒ  |  _ t
 j ƒ  |  _ t
 j ƒ  |  _ |  j j	 |  j d d ƒ |  j j	 |  j d d ƒ |  j j	 |  j d d ƒ t  j d |  ƒ } t  j ƒ  |  _ x- t j j D] } |  j j |  j | ƒ ƒ qaW|  j j d d d d ƒ |  j j |  j ƒ t  j ƒ  |  _ |  j j d d d d ƒ |  j j	 | ƒ |  j j	 |  j ƒ |  j j d ƒ |  j j |  j ƒ |  j |  j ƒ d  S(   Ns   1st Atoms   2nd Atoms   3rd Atomi    i   i   s   Draw plane through(   R    R   R   t   QVBoxLayoutt   main_layoutR   t   atoms_layoutR   R	   R   t	   mgWidgetst   mgAtomPickert
   atom_sel_1t
   atom_sel_2t
   atom_sel_3R&   t   atom_spec_combot   MapPlanet   selection_mode_menuR(   t   setContentsMarginst	   addLayoutt   QHBoxLayoutt   spec_layoutt
   addStretchR   (   R   R   t   atom_label_1t   atom_label_2t   atom_label_3t   labelR/   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR   N   s8    N(   R   R   R   R   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR0   M   s   t   ContourSliceDialogc           B   sJ   e  Z d  „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   sˆ   x� t  | j ƒ  ƒ D]m } | j | ƒ } t | d ƒ r t | j ƒ r | j ƒ  } t | d ƒ r€ t | j ƒ r€ | j ƒ  q€ q q Wd  S(   Nt   widgett   hide(   t   ranget   countt   itemAtR,   t   callableRF   RG   (   R   t   layoutt   iR/   RF   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyt   hideWidgetso   s    c         C   sˆ   x� t  | j ƒ  ƒ D]m } | j | ƒ } t | d ƒ r t | j ƒ r | j ƒ  } t | d ƒ r€ t | j ƒ r€ | j ƒ  q€ q q Wd  S(   NRF   t   show(   RH   RI   RJ   R,   RK   RF   RO   (   R   RL   RM   R/   RF   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyt   showWidgetsw   s    c         C   sF  t  j j |  | ƒ |  j |  j d ƒ ƒ |  j ƒ  t j ƒ  } t j |  j d ƒ ƒ } t j	 ƒ  } | j
 | ƒ t j ƒ  |  _ t j d d d |  j ƒ |  _ |  j j d ƒ |  j j |  j ƒ | j
 |  j ƒ t j d ƒ } | j
 | ƒ t j |  j d ƒ ƒ } t j ƒ  |  _ | j
 |  j ƒ t ƒ  |  _ t j ƒ  } | j
 |  j ƒ | j d	 ƒ t j ƒ  |  _ |  j j | ƒ t ƒ  |  _ t ƒ  |  _ t j ƒ  } | j
 |  j d
 d ƒ | j d
 d	 ƒ | j d	 d	 ƒ | j d d	 ƒ t j ƒ  |  _  |  j  j | ƒ |  j j! |  j |  j d ƒ ƒ |  j j! |  j |  j d ƒ ƒ |  j j! |  j  |  j d ƒ ƒ t j |  j d ƒ ƒ }	 t j d ƒ }
 t j ƒ  |  _" t j d d d |  j" ƒ |  _# |  j" j d ƒ |  j" j |  j# ƒ t j	 ƒ  } | j
 |	 ƒ | j
 |  j" ƒ | j
 |
 ƒ | j d	 ƒ | j d	 ƒ | j$ | ƒ t j% |  j d ƒ ƒ |  _& | j
 |  j& ƒ | j$ | ƒ t j' ƒ  } | j( t j' j) ƒ } | j( t j' j* ƒ } | j( t j' j+ ƒ } |  j, | t- j. d ƒ |  j/ ƒ |  j, | t- j. d ƒ |  j0 ƒ |  j, | t- j. d ƒ |  j* ƒ | j
 | ƒ |  j | ƒ |  j1 d ƒ |  j2 ƒ  d  S(   Ns   Contour Slice Detailss   Contour spacingg        g     @�@i   s   1.0u   â„«s   Define planei   i    i   s   specifying planes   through selected atomss   parallel to crystal faces   Raise plane by g     @�Às&   Set camera perpendicular to this planes	   clicked()(3   t   MGSimpleDialogt   MultiDialogR   t   setWindowTitleR	   t   CreateMenuEntryR    R1   R   R>   R   R
   t   contour_spacing_editR   t   contour_validatort   setTextR   t
   QTabWidgett	   tabWidgetR   R   R@   t   QWidgett   specifying_widgetR   R0   R3   R   R%   R   t   setColumnStretcht   setRowStretcht   crystal_widgett   addTabt   raise_planet   raise_plane_validatorR=   t	   QCheckBoxt   camera_checkt   QDialogButtonBoxt	   addButtont   Okt   Applyt   Cancelt   connectR   t   SIGNALt   Closet   ApplyAndCloset   setSizeGripEnabledt   UnClose(   R   R   t
   mainLayoutt   space_labelt   spaceLayoutt   units_labelt   plane_labelt   specifying_layout_layoutt   crystal_layout_layoutt   raise_pretextt   raise_posttextt   raiseLayoutt   dialog_buttonst	   ok_buttont   apply_buttont   cancel_button(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyR      s|    
c   %      C   sñ  |  j  t j d ƒ ƒ d  Sd  } t |  j j ƒ  ƒ } d d  l } |  j j	 |  j j
 ƒ  ƒ |  j d ƒ k r=| j t |  j j j ƒ  ƒ t |  j j j ƒ  ƒ t |  j j j ƒ  ƒ t |  j j j ƒ  ƒ ƒ } |  j  t j d ƒ | ƒ | j ƒ  | j ƒ  } | | } | j | ƒ | j ƒ  G| j ƒ  G| j ƒ  G| j ƒ  GHn  |  j j	 |  j j
 ƒ  ƒ |  j d ƒ k r_	d GHd  } d  } d  } t |  j j j ƒ  ƒ j d ƒ \ }	 }
 } } } |	 G|
 G| G| G| GHt d |	 d	 d
 ƒ } t | ƒ d k rF| d rFt | d d ƒ rFd |
 d | d | d | } | d j  | d | ƒ } n  t |  j j! j ƒ  ƒ j d ƒ \ }	 }
 } } } |	 G|
 G| G| G| GHt d |	 d	 d
 ƒ } t | ƒ d k r| d rt | d d ƒ rd |
 d | d | d | } | d j  | d | ƒ } n  t |  j j" j ƒ  ƒ j d ƒ \ }	 }
 } } } |	 G|
 G| G| G| GHt d |	 d	 d
 ƒ } t | ƒ d k rÖ| d rÖt | d d ƒ rÖd |
 d | d | d | } | d j  | d | ƒ } n  | së| së| rïd  S| j# | j$ | j% | j& ƒ } | j# | j$ | j% | j& ƒ } | j# | j$ | j% | j& ƒ } |  j j' j( ƒ  |  j d ƒ k rmn  |  j j' j( ƒ  |  j d ƒ k r¸| j# j) | | | | ƒ } | | } n  |  j j' j( ƒ  |  j d ƒ k r| j# j) | | | | ƒ } | | } n  |  j j' j( ƒ  |  j d ƒ k rN| j# j) | | | | ƒ } | | } n  |  j j' j( ƒ  |  j d ƒ k rå| j# j) | | | | ƒ } | j* ƒ  | | j# j+ | | ƒ } | j* ƒ  | j# j) | | ƒ } | | } | | } n  |  j j' j( ƒ  |  j d ƒ k r|| j# j) | | | | ƒ } | j* ƒ  | | j# j+ | | ƒ } | j* ƒ  | j# j) | | ƒ } | | } | | } n  |  j j' j( ƒ  |  j d ƒ k r| j# j) | | | | ƒ } | j* ƒ  | | j# j+ | | ƒ } | j* ƒ  | j# j) | | ƒ } | | } | | } n  |  j j' j( ƒ  |  j d ƒ k rª| j# j) | | | | ƒ } | j* ƒ  | | j# j+ | | ƒ } | j* ƒ  | j# j) | | ƒ } | | } | | } n  |  j j' j( ƒ  |  j d ƒ k rA| j# j) | | | | ƒ } | j* ƒ  | | j# j+ | | ƒ } | j* ƒ  | j# j) | | ƒ } | | } | | } n  |  j j' j( ƒ  |  j d ƒ k rØ| j# j) | | | | ƒ } | j* ƒ  | | j# j+ | | ƒ } | j* ƒ  | j# j) | | ƒ } | | } | | } n  | j | | | ƒ } | j ƒ  | j ƒ  } | | } | j | ƒ | j ƒ  G| j ƒ  G| j ƒ  G| j ƒ  GH|  j  t j d ƒ | ƒ n  |  j j	 |  j j
 ƒ  ƒ |  j d ƒ k r€t |  j, j- j( ƒ  ƒ d k  r«	d  St |  j, j- j( ƒ  ƒ d } t d	 d
 ƒ } t d	 d ƒ } | j. | ƒ x‹| D]€} | j/ | k rù	t d | j/ ƒ } xR| d j0 D]C} | j1 r.
t |  j, j2 j( ƒ  ƒ d k rs
| j1 j3 j4 d ƒ } nr t |  j, j2 j( ƒ  ƒ d k r©
| j1 j3 j4 d ƒ } n< t |  j, j2 j( ƒ  ƒ d  k rß
| j1 j3 j4 d! ƒ } n d  } | rq| j5 | ƒ } | j# d d d ƒ } | j6 | j7 ƒ  | ƒ }  | j |  j8 ƒ  |  j9 ƒ  |  j: ƒ  d ƒ } |  j  t j d ƒ | ƒ qqq.
q.
WPqù	qù	Wn  |  j; j< ƒ  d k rí| ríd d  l= }! | j# | j ƒ  | j ƒ  | j ƒ  ƒ }" | j# d" d" d# ƒ } | j) |" | ƒ } t> | j8 ƒ  | j8 ƒ  | j9 ƒ  | j9 ƒ  | j: ƒ  | j: ƒ  d$ k ƒ rÂ|! j? t> | j ƒ  ƒ ƒ }# | j ƒ  d" k rv|# }# n  | j@ | j8 ƒ  | j9 ƒ  | j: ƒ  d |# d% |! jA ƒ }$ tB ƒ  jC |$ ƒ qí| j@ d" d" d" d ƒ }$ tB ƒ  jC |$ ƒ n  d  S(&   Nt   applyiÿÿÿÿs   specifying planet   PlaneChangeds   through selected atomss   Through atomst   /R+   R!   R#   i   i    t   interpretAtomIDs   Through all atomss   Through atoms 1 and 2s   Through atoms 1 and 3s   Through atoms 2 and 3s%   Through atom 1, perpendicular to 2, 3s    Through atom 1, parallel to 2, 3s%   Through atom 2, perpendicular to 1, 3s    Through atom 2, parallel to 1, 3s%   Through atom 3, perpendicular to 1, 2s    Through atom 3, parallel to 1, 2s   parallel to crystal facei   i   R"   R   t   CR   t   BR    t   Ag        g      ð?g�íµ ÷Æ°>g     €f@(D   t   emitR   Rj   R   t   floatR`   t   textt
   pygl_coordRY   t   tabTextt   currentIndexR	   t   PlaneR   R   R   R   R   t	   Normalizet   get_Dt   set_Dt   get_At   get_Bt   get_Ct   strR3   R6   t	   selectiont   splitR*   t   lenR,   R€   R7   R8   t	   Cartesiant   xt   yt   zR9   t   currentTextt   CrossProductt	   normalizet   MidPointR%   R)   t   extendR+   t   objinstst   graphmodR'   t   objt   GetUnitCellAlignmentRotationt   QuatPtrt   CartesianPtrt   getInvMatrixt   get_xt   get_yt   get_zRc   t
   checkStatet   matht   abst   acost   Quatt   pit
   MAINWINDOWt   setQuat(%   R   t   planeR`   R‡   t   orig_Dt   new_Dt   at1t   at2t   at3t   dataNamet   modelt   chaint   residuet   atomt   datat   atomidt   cart1t   cart2t   cart3t   crosst   upt   forwardt   rightR+   t   itemst	   map_itemsR/   t   molobj_listR    t   qt   quatt   zaxist   normR©   t
   plane_normt   anglet   rotquat(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyRg   Å   s$   *`

,*0/"0/"0/" !!!!!


!


!


!


!


!




)* 	*#'J 
9c         C   s   |  j  ƒ  |  j ƒ  d  S(   N(   Rg   Rk   (   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyRl   _  s    
c         C   s�  i  } d d d g |  j  j ƒ  | d <yF |  j j j ƒ  | d <|  j j j ƒ  | d <|  j j j ƒ  | d <Wn% d | d <d | d <d | d <n Xt |  j j j	 ƒ  ƒ } t
 j
 j j | ƒ rç t
 j
 j t
 j
 j j | ƒ | d	 <n  | d d k rsd
 } xP d d g d d g d d g g D]- \ } } | | | | k r| d } qqW| rst j j |  d d ƒ i  Sn  t |  j j j ƒ  ƒ | d <t |  j j j ƒ  ƒ | d <t |  j j j ƒ  ƒ | d <t |  j j j ƒ  ƒ | d <t |  j j j	 ƒ  ƒ | d <t |  j j j	 ƒ  ƒ d k r@t |  j j j	 ƒ  d ƒ | d <n  t |  j j ƒ  ƒ | d <t |  j j  ƒ  ƒ | d <t |  j! j ƒ  ƒ | d <| S(   NR°   R’   t   crystal_facet
   plane_modet
   selection1t
   selection2t
   selection3R   t   selection_modei    i   s   Error in Contour Slice Detailss$   Please select three different atoms.t   specify_plane_At   specify_plane_Bt   specify_plane_Ct   specify_plane_Di   i   t   crystalR`   t
   set_camerat   contour_spacing("   RY   R‰   R3   R6   t   modelNameAtomNameR7   R8   R‘   R9   R™   R:   R;   RI   t   selection_mode_aliast   indexR    t   QMessageBoxt   warningR…   R   R   R†   R   R   R   R%   R'   R”   R)   R`   t   intRc   R¨   RU   (   R   t   paramst	   sele_modet   errt   s1t   s2(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyt	   getParamsc  sD     

&	 #c         C   sR  d G| GH| j  d ƒ r5 |  j j t | d ƒ ƒ n  | j  d ƒ ra |  j j t | d ƒ ƒ n  | j  d ƒ r‡ |  j j | d ƒ n  | j  d ƒ r-|  j j j t | j	 d d ƒ ƒ ƒ |  j j
 j t | j	 d d ƒ ƒ ƒ |  j j j t | j	 d	 d ƒ ƒ ƒ |  j j j t | j	 d
 d ƒ ƒ ƒ n  | j  d ƒ r{t | d ƒ d k r{|  j j j | d d | d d ƒ n  | j  d ƒ rÉt | d ƒ d k rÉ|  j j j | d d | d d ƒ n  | j  d ƒ rt | d ƒ d k r|  j j j | d d | d d ƒ n  | j  d ƒ rŽxe t |  j j j ƒ  ƒ D]H } t | d ƒ t |  j j j | ƒ ƒ k r?|  j j j | ƒ Pq?q?Wn  | j  d ƒ r6| d d k rÏ|  j j |  j j |  j ƒ ƒ n  | d d k r|  j j |  j j |  j ƒ ƒ n  | d d k r6|  j j |  j j |  j ƒ ƒ q6n  | j  d ƒ r�| d t j j k r�t j j j | d ƒ } |  j j  j | ƒ q�n  | j  d ƒ rNx¯ t |  j j! j ƒ  ƒ D]’ } d t | d ƒ t |  j j! j | ƒ ƒ k r|  j j! j | ƒ Pn  d t | d ƒ t |  j j! j | ƒ ƒ k rµ|  j j! j | ƒ PqµqµWn  d  S(   Ns   ContourSliceDialog.setParamsR`   RÚ   RÙ   RÔ   g      ð?RÕ   g        RÖ   R×   RÐ   i   i    RÑ   RÒ   RÎ   RÏ   R°   R’   RÓ   RØ   s   Map: s   Mol: ("   t   has_keyR`   RW   R‘   RU   Rc   t
   setCheckedR   R   t   getR   R   R   R”   R3   R6   t   setSelectionR7   R8   RH   R%   R'   RI   t   itemTextt   setCurrentIndexRY   t   indexOfR[   R^   R:   RÜ   RÝ   R9   R)   (   R   Rá   RM   t   idx(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyt	   setParams�  sT    	   %%%(%)%)%)+""%//N(
   R   R   RN   RP   R   R   Rg   Rl   Ræ   Rï   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyRE   m   s   		F	š		-(   t   __doc__RQ   t   PyQt4R    R   R4   t   global_definitionsR:   R   R   R   R0   RR   RE   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/ContourSliceDialog.pyt   <module>   s   
 