ó
ÉÝ{Tc           @   s%  d  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 y d d l Z Wn n Xe j j	 d ƒ r‰ d d l
 Z n d d l Z d d l m Z m Z m Z d d l Z e d k oÕ e j d k r?d d l Z e j ƒ  Z d e k od e k r<d d l Z d d	 l m Z e j e d
 ƒ ƒ Z n  n  d „  Z d e j f d „  ƒ  YZ d f  d „  ƒ  YZ d f  d „  ƒ  YZ e d k r!e j j d ƒ rºe e j  ƒ e _  n  g  e j D] Z! e! d k rÜe! ^ qÄe _ g  e j D] Z! e! d k re! ^ qïe _ e j d k rÄd d l" Z" e" j# ƒ  d d l$ Z$ d d l% Z% d d l& Z& e j d k rÁe& j' ƒ  Z( e j) j* e( d e+ e% j, j- ƒ  ƒ d e j. d ƒ d ƒ Z/ e$ j0 e/ ƒ n  n  d d l1 Z1 d d l2 Z2 e j j	 d ƒ pýe j j	 d ƒ rhe j) j* e j d d d d ƒ Z3 e2 j4 e3 d  d! ƒ Z5 e5 r[e5 j6 ƒ  Z7 e5 j8 ƒ  e7 GHn  e j9 ƒ  n  e j j	 d" ƒ rœd d# l: m; Z; e; GHe j9 ƒ  n  e< e j) j* e j d d$ d% d& ƒ ƒ Z= i  Z> xk e= j? ƒ  D]] Z@ e@ d' jA ƒ  \ ZB ZC ZD ZE e jF ƒ  jG e@ d'  eH eB ƒ eH eC ƒ eH eD ƒ eH eE ƒ ƒ q×We= j8 ƒ  e j j	 d( ƒ d) k ràx€ e j j	 d( ƒ d) k rÜe j jI d( ƒ e j j	 d* ƒ d) k rÏx, e j j	 d* ƒ d) k rËe j jI d* ƒ q Wn
 e2 jJ ƒ  q]Wn  e j j	 d* ƒ d) k r*x, e j j	 d* ƒ d) k r&e j jI d* ƒ qûWn  e j j	 d+ ƒ rRe1 j1 e j ƒ ZK nR e j d k rye jL e j eM ƒ ZK n e jL e j eN ƒ ZK eK jO e jP jQ eM ƒ eK jR d, eM ƒ e j j	 d+ ƒ re jS e jT jU ƒ ZV e jW eV ƒ ZX eX jY ƒ  jZ ƒ  Z[ eX j8 ƒ  eX j\ ƒ  n eM Z[ eK j] e j) j* e j d d- ƒ ƒ e j j d. ƒ ržeK j] e j) j* e j d. d- ƒ ƒ eK j] e j) j* e j d. d/ d0 d1 ƒ ƒ n  d2 „  Z^ d d l_ Z_ e_ j` e^ ƒ e ƒ  Za d d lb Zb eb jb jc ea ƒ ea jd eK ƒ eK je e jf d3 ƒ eK ƒ e j9 eK jg ƒ  ƒ n  d S(4   s�  
     qtgui/main.py: CCP4MG Molecular Graphics Program
     Copyright (C) 2001-2008 University of York, CCLRC
     Copyright (C) 2009-2011 University of York
     Copyright (C) 2012 STFC

     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ÿÿÿÿNs   -osmesa(   t   QtGuit   QtCoret   QtOpenGLt   __main__t   linux2s   debian-5t   x86_64(   t   find_libraryt   xml2c          C   sl   t  j  t j j t j d d d ƒ ƒ }  |  sH t j j t j d d ƒ St t j ƒ  t |  ƒ ƒ } |  | S(   Nt   CCP4MGt   splashs   *.pngs
   splash.png(   t   globt   ost   patht   joint   environt   intt   timet   len(   t	   file_listt   ii(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyt   random_splash_file8   s
    ( t   BevelledSplashScreenc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   t  j j |  | ƒ d  S(   N(   R    t   QSplashScreent   __init__(   t   selft   pixmap(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR   @   s    c   	      C   sÀ  t  j j |  | ƒ t  j ƒ  } d } | j d d ƒ | j | | ƒ | j | |  j ƒ  | ƒ | j d |  j ƒ  ƒ | j d d ƒ t  j t  j d d d ƒ ƒ } | j	 | ƒ t  j d d d ƒ } t  j d d d ƒ } t  j
 t j d d ƒ t j d d ƒ ƒ } | j d | ƒ | j d | ƒ t  j | ƒ } | j | | ƒ t  j ƒ  } | j |  j ƒ  d ƒ | j |  j ƒ  | | ƒ | j |  j ƒ  | |  j ƒ  | ƒ | j |  j ƒ  |  j ƒ  ƒ | j |  j ƒ  d ƒ t  j d d d ƒ } t  j d d d ƒ } t  j
 t j |  j ƒ  | d ƒ t j |  j ƒ  d d ƒ ƒ } | j d | ƒ | j d | ƒ t  j | ƒ } | j | | ƒ t  j ƒ  } | j d d ƒ | j | | ƒ | j |  j ƒ  | d | ƒ | j |  j ƒ  d ƒ | j d d ƒ t  j d d d ƒ } t  j d d d ƒ } t  j
 t j d | ƒ t j d d ƒ ƒ } | j d | ƒ | j d | ƒ t  j | ƒ } | j | | ƒ t  j ƒ  } | j d |  j ƒ  ƒ | j | |  j ƒ  | ƒ | j |  j ƒ  | |  j ƒ  | ƒ | j |  j ƒ  |  j ƒ  ƒ | j d |  j ƒ  ƒ t  j d d d ƒ } t  j d d d ƒ } t  j
 t j d |  j ƒ  | d ƒ t j d |  j ƒ  d ƒ ƒ } | j d | ƒ | j d | ƒ t  j | ƒ } | j | | ƒ d  S(	   Ni   i    iÿ   i`   i
   i   i    i    (   R    R   t   drawContentst   QPainterPatht   moveTot   lineTot   heightt   QPent   QColort   setPent   QLinearGradientR   t   QPointFt
   setColorAtt   QBrusht   fillPatht   width(	   R   t   painterR   t   border_widtht   pent   startColourt	   endColourt
   linearGradt   brush(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR   C   sp    *$>*$B(   t   __name__t
   __module__R   R   (    (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR   ?   s   	t   MainLoopc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s	   d GHd  S(   Ns   Finishing CCP4MG MainLoop(    (   R   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyt   __del__‚   s    c         C   s   d  S(   N(    (   R   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR   …   s    c   ,         s2  d d l  m  } m } d d  l } d d  l } d d  l } d } | j ƒ  } | j ƒ  }	 t |	 ƒ t k r« |	 d k r« t	 j
 j d ƒ r« t j j d  d |	 t j j ƒ n  t ƒ  }
 t	 j
 j d ƒ st j |
 ƒ } t j | ƒ } | j t j j ƒ t j ƒ  } | j | ƒ | j d d | ƒ | j ƒ  t | ƒ } d d  l } | j d ƒ t j | j ƒ } t	 j  d	 k r¬| j! | j d
 ƒ | t j j" t j j# Bt j j$ ƒ n  | j% ƒ  | j& ƒ  t	 j  d	 k r| j! | j d
 ƒ | t j j" t j j# Bt j j$ ƒ qn  d } d } y¦ | j' d ƒ } | r¼t( | d ƒ r¼| j) d ƒ r¼| d } | rˆt( | d ƒ rˆ| j) d ƒ rˆ| d } n  | r¼t( | d ƒ r¼| j) d ƒ r¼| d } q¼n  Wn n Xt	 j
 j d ƒ rú| d ˆ  d t* ƒ ‰ ˆ t+ _, nY y: | j' d ƒ } | d ˆ  d | d t* d | d | ƒ ‰ Wn | d ˆ  d t* ƒ ‰ n Xt j- d d ƒ } t	 j
 j d ƒ s ˆ j. | j/ d ƒ j0 ƒ  ƒ ˆ j% ƒ  n  d d  l1 } | j2 ƒ  |  _1 |  j1 j3 ƒ  t	 j
 j d ƒ sþ| j4 ˆ ƒ ˆ j5 ƒ  | j& ƒ  n  t	 j
 j d ƒ r<ˆ j6 ƒ  t( ˆ d ƒ r<ˆ j7 j6 ƒ  q<n  t8 } t9 } x- t	 j
 D]" } t: j; d | ƒ rRt8 } PqRqRWt	 j
 j d ƒ sYyh | rñ| j< ƒ  rñt j j= ˆ d d t j j> t j j? Bt j j> ƒ } | t j j> k rñt9 } qñn  Wq_t	 j@ ƒ  d  \ } } } t	 jA jB t | ƒ d ƒ t	 jA jB t | ƒ d ƒ tC jD | ƒ q_Xn t9 } tE jF d | ƒ yh | jG d | ƒ } t	 j
 j d ƒ s©| jH ƒ  jI ƒ  n  | rÉtE jF d  t | ƒ ƒ n tE jF d! ƒ Wna t	 j@ ƒ  d  \ } } } t	 jA jB t | ƒ d ƒ t	 jA jB t | ƒ d ƒ tC jD | ƒ n Xt	 j
 j d ƒ sZˆ jJ ƒ  n  ˆ jK ƒ  tE jF d" | ƒ y | jL ƒ  } Wna t	 j@ ƒ  d  \ } } } t	 jA jB t | ƒ d ƒ t	 jA jB t | ƒ d ƒ tC jD | ƒ n X| jM ƒ  }  | jN ƒ  t	 j
 j d ƒ s¤ˆ j5 ƒ  t( ˆ d ƒ r¤y ˆ j7 j5 ƒ  Wq¡t	 j@ ƒ  d  \ } } } t	 jA jB t | ƒ d ƒ t	 jA jB t | ƒ d ƒ tC jD | ƒ q¡Xq¤n  ˆ jO ƒ  t	 j
 j d ƒ sUd d# l mP }! mQ }" ˆ  jR d$ t8 ƒ |! d% ƒ jS ƒ  }# |# j) d& ƒ rUˆ  jR d$ |# d& ƒ x |" ƒ  D] }$ |$ jT ƒ  q%Wd d  l } | jN ƒ  qUn  t |	 ƒ tU k rŸx5 ˆ jV D]' }% t( |% d' ƒ rq|% j |	 ƒ }	 qqqqWn  d }& t	 j
 j d ƒ r7x d |	 k rÖ|	 jW d ƒ qºWx‡ d( |	 k r`	|	 jX d( ƒ }' |' d tY |	 ƒ k  rP	tY |	 |' d ƒ d k rP	|	 |' d d d) k rP	|	 jZ |' ƒ qP	n  |	 jZ |' ƒ qÚWxId* |	 k r¬
|	 jX d* ƒ }' d+ }( |' d tY |	 ƒ k  rî	tY |	 |' d ƒ d k rî	|	 |' d d d) k rî	|	 |' d }( |	 jZ |' ƒ qî	n  |	 jZ |' ƒ ˆ rd	t( ˆ d, ƒ rd	t( ˆ j[ d- ƒ rd	d. G|( GHyJ ˆ j[ j\ t9 ƒ ˆ j[ j] ƒ  ˆ j[ jB |( ƒ ˆ j[ j\ t8 ƒ d/ G|( GHWq©
t	 j@ ƒ  d0  \ } } d1 G|( G| G| GHq©
Xqd	qd	WtE j^ ƒ  |	 sÉ
| sÉ
|  rd2 GHt	 j_ j` ƒ  |	 Gt |	 ƒ GH| Gt | ƒ GH|  Gt |  ƒ GHt	 ja d ƒ q7d3 GHt	 j_ j` ƒ  t	 ja ƒ  n  x |	 D] }) |& |) d4 }& q>W|& d k r›t	 j
 j d ƒ r›t j j d  d d5 |& t j j ƒ n  ‡  ‡ f d6 †  }* d d  lb }+ |+ jc |* ƒ t	 jd d7 ƒ t	 j
 j d ƒ r.t( ˆ d ƒ r.ˆ j7 j. | j/ d8 ƒ j0 ƒ  ƒ ˆ j7 j% ƒ  | je ƒ  n  d  S(9   Niÿÿÿÿ(   t   MGMainWindowt   MGMainWindowSimplei   t    s   -quits   Input commmand not recognisedi    s   CCP4MG version R   s	   Starting t   params2t   has_keyt   advanced_optionst   dockable_display_tablet   super_compact_display_tablet   applicationt   stereoFormatAvailablet
   gui_paramst   dockedDTt   super_compactt   CCP4R   s   mainwindow/geometryt   wMGDisplayTables   -nores   Restore status?s9   A saved status file exists. Would you like to restore it?i   s   
s   Restoring program status..t   restore_past_or_prevs   ...DONE status: s   ...DONEs   Applying command line..(   t   PMt   get_dispobjt   flip_labelst   miscell_prefst	   flip_textt   parse_program_command_lines   -OSMesaOt   -s   -osmesas   mgosmesa.pngt   glWidgett   osMesaBuffers   Attempting to write filet   Writteni   s   Failed to writes   Quitting with errors   Quitting successfullyt    s   Input commmand not recognised: c             s¿   d d  l  }  d d  l } |  j ƒ  j ƒ  |  j ƒ  j ƒ  ˆ  j ƒ  t j d d ƒ } | j d t j	 ˆ j
 ƒ  ƒ ƒ t ˆ d ƒ r§ | j d t j	 ˆ j j
 ƒ  ƒ ƒ n  | j ƒ  | j ƒ  d  S(   NiÿÿÿÿR@   R   s   mainwindow/geometryRA   s   displaytable/geometry(   t   global_definitionst   utilst   DISPLAYTABLEt   Exitt   HISTORYt   closeAllWindowsR   t	   QSettingst   setValuet   QVariantt   saveGeometryt   hasattrRA   t   synct   deleteTemporaryFiles(   RN   RO   t   settings(   t   appt   window(    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyt   MyExith  s    
%
iˆ  s   displaytable/geometry(f   R3   R4   t   mgappRN   t   rebuildRR   RH   t   typet   strt   syst   argvt   countR    t   QMessageBoxt   criticalt   Nonet   OkR   t   QPixmapt   fillR   t   Qtt   whitet   QPaintert   begint
   drawPixmapt   endR   t   versiont   trt   QStringt   ccp4mg_versiont   platformt   showMessaget   AlignHCentert   AlignBottomt   blackt   showt   raise_t   restore_paramsRX   R7   R<   t   MGApplicationt   _dummyWindowRT   t   restoreGeometryt   valuet   toByteArrayt	   resourcest
   CResourcest   load_resourcest   finisht   UnCloset   hideRA   t   Falset   Truet   ret   matcht$   check_data_valid_last_program_statust   questiont   Yest   Not   exc_infot   stderrt   writet	   tracebackt   print_tbRO   t   printOutputt   restore_program_statusRP   t   loadAllDataObjt   applyGLLightingt   loadPluginst   apply_program_command_linet   run_command_line_scriptt   UpdateDisplayt   applyStereoPrefsRC   RD   t   setPropertyt	   getparamst   set_redraw_textt   listt   pluginst   removet   indexR   t   popRJ   t	   setDoDrawt   updateGLRZ   t   stdoutt   flusht   exitt   atexitt   registert   setrecursionlimitRY   (,   R   R\   R3   R4   R_   RN   R`   t	   developerRR   t   rvt   splash_fileR   t   pix2R(   R	   Rr   t   version_stringR>   R?   R6   t   advOptR=   R[   Rƒ   RB   t
   askRestoret   argt   restoreAnswert   exc_typet	   exc_valuet   exc_tbt   statust   rsRC   RD   t   paramst   dispobjt   plugt   rverrt   it   ft   sR^   R¬   (    (   R\   R]   s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyt
   initializeŽ   sl   1"	
9

<$
$$+

 4



  22'	
  &"(   R/   R0   R2   R   RÄ   (    (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR1   �   s   			t   trace_print_statements_writerc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         G   s   | |  _  d  S(   N(   t   writers(   R   RÆ   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR   �  s    c         C   s"   x |  j  D] } | j ƒ  q
 Wd  S(   N(   RÆ   Rª   (   R   t   w(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyRª   „  s    c         C   s/   t  j ƒ  x |  j D] } | j | ƒ q Wd  S(   N(   R”   t   print_stackRÆ   R“   (   R   t   textRÇ   (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR“   ˆ  s    
(   R/   R0   R   Rª   R“   (    (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyRÅ   €  s   		t   CCP4MG_DEBUG_TRACEPRINTs   -gdbs	   -valgrindt   win32t   CCP4MG_t   _s   %H-%M-%Ss   .mdmps   -helps   -hR   t   pythont   etcs   help.txtt   ri   s   -version(   Ru   t   shaderst   texturest   atom_texture_coords_tablei   s	   -redirecti    s   -noredirects   -quitRE   t	   QtPluginsR@   t   libt   qt4R£   c          C   s   d GHg  }  d  S(   Nt   Exiting(    (   t	   mainloops(    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyR^   Þ  s    t   ApplicationReady(h   t   __doc__Rc   R   R
   R‹   R   R”   t   ccp4mgRd   Re   t   mgOSMesat   openglt   PyQt4R    R   R   t   cprimR/   Rv   t   plattert   ctypest   ctypes.utilR   t   CDLLt   cdumR   R   R   R1   RÅ   R   R7   R©   t   at   mg2t   setup_pythonpatht   crash_handlert   datetimet   tempfilet
   gettempdirt   tdirR   R   Rb   t   datet   todayt   strftimet   dumpfilet   SetCrashHandlerR~   RO   t   helpfilet   openFileRÂ   t   readt   helptextt   closeR«   Rr   Ru   t   opent   tex_ft	   tex_atomst	   readlinest   lt   splitt   tsxt   text   tsyt   teyt	   TexCoordst	   AddCoordst   floatR¤   t   redirectOutputR\   t   QApplicationR‰   RŠ   t   setAttributeRl   t   AA_DontShowIconsInMenusRŸ   t	   QGLFormatt   QGLt   StereoBufferst   stereoFormatt	   QGLWidgett   glWidgetTestt   formatt   stereoR<   t   deleteLatert   addLibraryPathR^   R¬   R­   t   mt   MainLoopContainert   appendRÄ   t   emitt   SIGNALt   exec_(    (    (    s7   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/main.pyt   <module>   sÀ   $		Bÿ++
=$"
(?

##,		