ó
ÉÝ{Tc           @   s  d  Z  d d l Z d d l m Z m Z d d l Td d l Z d d l Z d d l Z d Z	 d d „ Z
 d d	 d
 „ 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 e j f d „  ƒ  YZ d „  Z d S(   sš  
     qtgui/mgPresentation.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ÿÿÿÿN(   t   QtGuit   QtCore(   t   *i–   t   open_presentationc         C   s×   d d  l  } | j |  d ƒ \ }  } t ƒ  j t ƒ } | s| t d t ƒ  d |  d | ƒ } t j | t j d ƒ t j	 ƒ n  | j
 ƒ  } | sÉ | j j ƒ  } | rÉ t	 t t d ƒ d |  d | ƒqÉ n  | j ƒ  d  S(   Niÿÿÿÿt   _t   parentt   modet   applicationt   savei    (   t   stringt   splitt
   MAINWINDOWt	   findChildt   guiOpenPresentationt   selft   connectR   t   SIGNALt   openPresentationt   exec_t
   filedialogt   selectedFilest   strt   filet   close(   R   R	   R   t   gui_opent   rvt   files(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   handlePresentation   s    "&t    t   presentationc   	      K   s  d d  l  } | j |  ƒ } | s% d  Sx: t ƒ  j t j ƒ D]# } | j  | k r; | j ƒ  d  Sq; Wx$ t ƒ  j t ƒ D] } | j ƒ  qu W| d k r¼ d d  l } | j t ƒ  d | ƒ} nK | d k rï d d  l	 } | j	 t ƒ  d | ƒ} n t j t ƒ  d | ƒ} | j ƒ  d  S(   Niÿÿÿÿt   movieR   t	   animation(
   R   R   R   t   findChildrent   mgPresentationt   showR   R   t   movieGuit   animationGui(	   R   R   t   kwR   t   pt   guit   itemR#   R$   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR   2   s$     
R   c           B   s,   e  Z d d  d d „ Z d „  Z d „  Z RS(   t   openR   c   	      C   s[  t  j j | ƒ |  j d ƒ |  j | ƒ t  j ƒ  } t j |  ƒ } | j | ƒ | j	 ƒ  |  _
 | d k r† |  j
 j |  j
 j ƒ n |  j
 j t  j j ƒ |  j
 j t ƒ |  j
 j t  j d ƒ } xa | D]Y } | j ƒ  |  j d ƒ k rË | j |  j d ƒ ƒ |  j | t j d ƒ |  j ƒ qË qË W|  j d ƒ g } |  j
 j | ƒ |  j | ƒ d  S(   Nt   dialogPresentationR)   R   s   &Saves   &Creates	   pressed()s.   Presentation directory (*.ccp4mg_presentation)(   R    t   QDialogt   __init__t   setObjectNamet   setAppt   QVBoxLayoutt	   mgWidgetst   MGFileDialogt	   addWidgett   getFileDialogR   t   setFileModet   DirectoryOnlyt   setAcceptModet   QFileDialogt
   AcceptSavet   setDirectoryt   proj_dirR    t   QPushButtont   textt   trt   setTextR   R   R   t   saveFilet   setNameFilterst	   setLayout(	   R   R   R   R   t   layoutR   t   childrent   childt   filter_list(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR,   ^   s&    &c         C   s"   |  j  d | d ƒ | |  _ d  S(   Ns   Open s
    directory(   t   setWindowTitleR   (   R   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR.   ~   s    c         C   s?   |  j  j ƒ  } | r; |  j t j d ƒ t | d ƒ ƒ n  d  S(   NR   i    (   R   R   t   emitR   R   R   (   R   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR?   …   s    N(   t   __name__t
   __module__t   NoneR,   R.   R?   (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR   X   s    	R!   c           B   s—  e  Z d  Z d  Z d Z d Z d Z d „  Z d( d „ Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d  d „ Z d d  d  d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d  d( d „ Z d „  Z d „  Z d „  Z d d  d d „ Z g  d  d „ Z i  d „ Z d „  Z d „  Z  d( d  d „ Z! d( d  d „ Z" d  d  d  d  „ Z# d! „  Z$ d" d# d  d$ „ Z% d% „  Z& d& „  Z' d' „  Z( RS()   R   i   i   i    c         C   s   t  j j |  ƒ |  j ƒ  d  S(   N(   t   MGSimpleDialogt   MGSimpleDockDialogt   UnCloset   highlightSelectedFrames(   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR"   ž   s    c         C   sô  t  j j |  | ƒ t |  _ t j d k r7 t |  _ n  t j s˜ t	 d t j
 d t j t _ |  j ƒ  j t j j t j j ƒ t _ t j j t _ n  d |  _ | |  _ |  j |  j j ƒ d  |  _ d |  _ g  |  _ g  |  _ d |  _  d |  _! |  j" ƒ  |  _# |  j$ ƒ  |  j% d t j ƒ |  j r6|  j& ƒ  n  |  j' j( ƒ  j) |  j* ƒ |  j+ ƒ  |  j sqt j d k rzd } n |  j, j- ƒ  j. ƒ  } t j | |  j/ j0 ƒ  j- ƒ  j. ƒ  |  j# } |  j' j1 t j |  j# ƒ |  j' j2 t j |  j# ƒ d  S(   Nt   darwini   i    R   i   (3   RK   RL   R,   t   Truet   dockActionst   syst   platformR!   t
   frameWidtht   SNAPSHOT_SIZEt   frameMargint   frameBordert   palettet   colorR    t   QPalettet   Normalt   Buttont   regularColourR   t   Qtt   cyant   selectedColourt   block_updateR   RF   t
   identifierRJ   t   frameWidgett   picDirt   select_ranget   selectedFramest   lastRestoredFramet   pasteBuffert   getFrameUiHeightt   frameUiHeightt   drawt   setMinimumWidtht   loadPresentationFramest   bodyRB   R2   t
   blankFramet   setBodyWidtht   menubart   sizet   heightt   scrollt   horizontalScrollBart   setMinimumHeightt   setMaximumHeight(   R   R   R   t   menu_heightRs   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR,   ¤   s<    		'								
	 
	-c         C   sò   |  j  j ƒ  } | d d k r# d  S| d d k r[ t j j |  d d t | d ƒ ƒ d  S| d d k rî d d  l } | j |  d | d d | d ƒ|  _ |  j j ƒ  } | t j	 j
 k rî |  j j ƒ  \ } } |  j  j | | ƒ } qî n  d  S(	   Ni    i   s   Restoring movie status files s&   Can not read status file for snapshot i   iÿÿÿÿt   lostt   defn(   R   t   check_status_filesR    t   QMessageBoxt   warningR   t	   statusGuit   lostFilesGuiR   R+   t   Acceptedt   getFilest   edit_status_data_files(   R   R   R~   t   objListt   fileDefn(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   checkStatusFilesÕ   s    $&c         C   sE   |  j  |  d ƒ } | r; | j ƒ  | j ƒ  } | j ƒ  n d } | S(   NR   i    (   t   drawFrameGuiR"   Rs   R   (   R   t   uiRs   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRi   æ   s    
c         C   sr   d d  l  } |  j t j | ƒ } | re | j ƒ  |  j | ƒ } | j |  | |  j | ƒ d d ƒn	 d G| GHd  S(   Niÿÿÿÿt   default_iconR   s(   ERROR in mgPresentation.drawMenu drawing(   t   guiUtilsR   R    t   QMenut   cleart	   getGuiDeft   populateMenu(   R   t	   menu_nameR‰   t
   menuWidgett   menudef(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   drawMenuó   s    
%c   
      C   s!  d d  l  } d } |  j sÃ t j |  ƒ |  _ x“ |  j d ƒ D] } |  j j | d ƒ } | j | d ƒ | j d ƒ r« |  j	 | t
 j d ƒ | j |  j | d ƒ ƒ q= |  j | d ƒ q= Wn  t j |  ƒ |  _ |  j j t
 j j ƒ d } t j |  ƒ |  _ t j ƒ  } | j | ƒ | j | | | | ƒ |  j j | ƒ t j ƒ  } | j | ƒ | j | | | | ƒ |  j s�| j |  j ƒ | j |  j ƒ ndt j ƒ  } | j d d d d ƒ | j |  j d d ƒt j ƒ  } xö |  j d ƒ D]å } t j | d |  ƒ } t j ƒ  }	 |	 j t j j ƒ |	 j | d ƒ | j | d ƒ | j d ƒ r�|  j	 | t
 j d ƒ | j |  j | d ƒ ƒ n |  j | d ƒ |	 j  | ƒ |	 j! t j" j# t j" j$ ƒ | j |	 ƒ qñW| j% d ƒ | j& | ƒ | j& | ƒ |  j | ƒ t' |  ƒ |  _( d  S(	   Niÿÿÿÿi    t   menusi   t   aboutToShows   aboutToShow()i   t   stretch()   R‰   RQ   R    t   QMenuBarRq   RŒ   t   addMenuR-   t   countR   R   R   t   partialR‘   t   QScrollAreaRt   t   setVerticalScrollBarPolicyR^   t   ScrollBarAlwaysOfft   QWidgetRn   t   QHBoxLayoutt
   setSpacingt   setContentsMarginsRA   R/   R2   RŠ   t   QToolButtont   setPopupModet   InstantPopupR>   t   setMenut   setSizePolicyt   QSizePolicyt   MinimumExpandingt   Maximumt
   addStretcht	   addLayoutt   presentationBlankWidgetRo   (
   R   R‰   t   margint	   menu_defnt   menut   body_layoutRB   t
   mainLayoutt
   toolLayoutt   tb(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRk   ÿ   sZ    	2	2c         C   s   | |  _  d  S(   N(   Rd   (   R   t   dir(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   setPictureDirectory9  s    c         C   s|   |  j  s d  Sd |  _ x$ |  j  j D] } |  j d | ƒ q# W|  j  j ƒ  } | j d ƒ ro |  j | d ƒ n  d |  _ d  S(   Ni   t   idt   snapshot_detailsi    (   R   Ra   t   snapshot_listt   addFramet	   getparamst   has_keyt	   setParams(   R   t   indxt   pars(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRm   ?  s    	 	 c         C   sÉ   | sF y |  j  j ƒ  \ } } WqF d d  l } | j |  ƒ d  SXn  | r¥ |  j j ƒ  j |  j t d ƒ ƒ } d |  _	 |  j
 d | d | ƒ |  j ƒ  d |  _	 n  t j j |  d d t | ƒ ƒ d  S(	   Niÿÿÿÿt   insert_framei   t   indexR´   i    s   Failed to add movie frames   Failed to add movie frame (   R   t   add_movie_snapshott   exceptionHandlert   criticalExceptionHandlerRn   RB   t   indexOfR   Rª   Ra   R·   t   updateSnapshotListR    R|   t   criticalR   (   R   R´   t   backupRÀ   R»   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   newFrameO  s    $	
iÿÿÿÿc         C   s}   t  d |  d | d | ƒ } | d k rC |  j j ƒ  j | | ƒ n |  j j ƒ  j | ƒ |  j ƒ  |  j t j d ƒ ƒ d  S(   NR   R´   t   picture_filei    t
   frameAdded(	   t   presentationFrameWidgetRn   RB   t   insertWidgetR2   Rp   RG   R   R   (   R   R¾   RÇ   R´   t   frame(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR·   c  s    
c         C   sª   |  j  s d  St j j |  j j |  j  d ƒ ƒ sW t j j |  j j |  j  d ƒ ƒ r[ d  S|  j j |  j  ƒ } | d r’ t ƒ  j | d ƒ d  S|  j	 d | d ƒ d  S(   Nt   snapshott   statusi    i   R´   (
   Rh   t   ost   patht   existsR   t   snapshot_filet   makeCopyt   MGGUIt   WarningMessageRÆ   (   R   t   targetR   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   pastep  s    	 J
c         C   sg   |  j  j ƒ  j ƒ  } |  j  j t j | ƒ |  j  j t j | ƒ |  j  j ƒ  |  j j	 |  j  ƒ d  S(   N(
   Rn   RB   R—   Rl   R!   RT   t   setMaximumWidtht   updateGeometryRt   t	   setWidget(   R   t   nFrames(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRp   €  s
    c         C   s   t  | ƒ |  _ d  S(   N(   R   Rh   (   R   R´   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   setPasteBuffer‹  s    c         C   sy   t  | ƒ } |  j | ƒ |  j t | ƒ } |  j j ƒ  j | ƒ | j ƒ  |  j ƒ  |  j	 ƒ  |  j
 t j d ƒ ƒ d  S(   Nt   frameDeleted(   R   RÛ   R   RÉ   Rn   RB   t   removeWidgetR   Rp   RÃ   RG   R   R   (   R   R´   t   widget(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   deleteFrame�  s    


c         C   s‹   |  j  d ƒ |  j j d ƒ |  j t ƒ } x. | D]& } |  j j ƒ  j | ƒ | j ƒ  q3 W|  j	 ƒ  |  j
 ƒ  |  j t j d ƒ ƒ d  S(   Ni    t
   delete_allRÜ   (   RÛ   R   t   applyR    RÉ   Rn   RB   RÝ   R   Rp   RÃ   RG   R   R   (   R   t   widget_listRÞ   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   deleteAllFrames�  s    

c         C   sj   |  j  j t ƒ } | r\ d } x$ | D] } | j r% | d } q% q% W| rO | St | ƒ Sn
 t | ƒ Sd  S(   Ni    i   (   Rn   R    RÉ   t   selectedt   len(   R   Rä   t   framest   nst   f(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   numberOfFramesª  s    	 c         C   sn   | d k r+ d d g d d g d d g g S| d k rD d d	 d
 g S| d k rW d g S| d k rj d g Sd  S(   NR’   t   Actions   &Actiont   Edits   &Editt   Helps   &Helpt   nextt   previousR   t   helpt   package(    (   R   t   namet	   pickevent(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRŒ   »  s    c      	   K   s>  d d  l  } | d k rF t d |  j d ƒ d |  j d ƒ d |  j ƒ S| d k r€ t d |  j d	 ƒ d |  j d
 ƒ d |  j ƒ S| d k rÆ t d |  j d ƒ d |  j d ƒ d | j |  j d ƒ ƒ S| d k r t d |  j d ƒ d |  j d ƒ d |  j ƒ S| d k r:t d |  j d ƒ d |  j d ƒ d |  j ƒ Si  S(   NiÿÿÿÿR   R<   s   Close presentationt   tips-   Close this presentation saving current statust   slotRí   s   &Nexts&   Restore the status from the next frameRî   s	   &Previouss*   Restore the status from the previous frameRï   s   &Helps   Help on CCP4mg PresentationsRð   s   Package presentations3   Make compressed file of presentation and data files(   R‰   t   dictR=   t   Closet   restoreStatusR˜   Rï   t   packagePresentation(   R   Rñ   t   infoR‰   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   getActionDefÇ  s6    



c         C   s   t  ƒ  j d ƒ d  S(   Ns   presentation.html(   t   HELPBROWSERt
   loadMgHelp(   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRï   í  s    c         C   s   |  j  j | ƒ d  S(   N(   Rq   R–   (   R   R­   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR–   ò  s    c         C   sÉ   | d k  r= |  j  j ƒ  j |  j t t | ƒ ƒ ƒ | } n  | d k rÅ |  j  j ƒ  j |  j ƒ } | | k rt d S| | k  r� | d } n  |  j  j ƒ  j |  j ƒ |  j  j ƒ  j | |  j ƒ n  d S(   s´   
    Reset position of the blank/insert frame
    Input is either new position or the id a frame that
    the blank frame should be placed before or after (increment = 0 or 1)
    i    Ni   (	   Rn   RB   RÂ   R   RÉ   R   Ro   RÝ   RÊ   (   R   t   positionR´   t	   incrementt   current(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   setInsertPosition÷  s    1c         C   so  d d  l  } i  } | r0 |  j t | ƒ g } n |  j j t ƒ } x&| D]} t | j ƒ  ƒ } i  | | <xù| D]ñ} | j t j | ƒ }	 d }
 |	 rr t	 |	 t j
 ƒ rê t |	 j |	 j ƒ  ƒ j ƒ  ƒ }
 |
 sIt |	 j ƒ  ƒ }
 qIn_t	 |	 t j ƒ rt |	 j ƒ  ƒ }
 n8t	 |	 t j ƒ r8t |	 j ƒ  ƒ }
 nt	 |	 t j ƒ r_t |	 j ƒ  ƒ }
 nê t	 |	 | j ƒ r†t |	 j ƒ  ƒ }
 nÃ t	 |	 | j ƒ r­t |	 j ƒ  ƒ }
 nœ t	 |	 | j ƒ rÔt |	 j ƒ  ƒ }
 nu t	 |	 t j ƒ rût |	 j ƒ  ƒ }
 nN t	 |	 t j ƒ r"t |	 j ƒ  ƒ }
 n' t	 |	 | j ƒ rIt |	 j ƒ  ƒ }
 n  |
 rc|
 | | | <qcqr qr WqI W| S(   NiÿÿÿÿR   (   R0   R   RÉ   Rn   R    R   t
   objectNameR    Rœ   t
   isinstancet	   QComboBoxt   itemDatat   currentIndext   toStringt   currentTextt   QLabelR<   t	   QLineEditt   QAbstractButtont   intt	   isCheckedt   mgSelectionCombot   mgColourCombot
   get_colourt   mgAtomPickert	   selectiont   QDoubleSpinBoxt   floatt   valuet   QSpinBoxt   mgSlider(   R   t   keyListR¾   R0   t   paramst	   frameListRË   R´   t   keyRÞ   R  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt	   getParams  sJ    
!  c         K   sh  d d  l  } | j | ƒ | j ƒ  } d } x6| D].} |  j j t | ƒ } | r2 x
| | j ƒ  D]õ\ } }	 | j t j | ƒ }
 |
 rd t	 |
 t j
 ƒ rû |
 j t j |	 ƒ ƒ } | d k  rÜ |
 j t j |	 ƒ ƒ } n  | d k rV|
 j | ƒ qVqYt	 |
 t j ƒ r#|
 j t |	 ƒ ƒ qYt	 |
 t j ƒ rK|
 j t |	 ƒ ƒ qYt	 |
 t j ƒ rm|
 j |	 ƒ qYt	 |
 | j ƒ r—|
 j | | t ƒ qYt	 |
 | j ƒ r¹|
 j |	 ƒ qYt	 |
 | j ƒ rÞ|
 j d |	 ƒ qYt	 |
 t j ƒ r|
 j t |	 ƒ ƒ qYt	 |
 t j  ƒ r.|
 j t! |	 ƒ ƒ qYt	 |
 | j" ƒ rY|
 j t |	 ƒ ƒ qYqd qd Wq2 q2 Wd  S(   Niÿÿÿÿi    t   atomName(#   R0   t   updatet   keysRn   R   RÉ   t   itemsR    Rœ   R  R  t   findTextR   t   QStringt   findDatat   QVariantt   setCurrentIndexR	  R>   R   R  R
  t
   setCheckedR  t   jjR  t
   set_colourR  t   setSelectionR  t   setValueR  R  R  R  (   R   R  R%   R0   t   idListt
   blank_incrR´   RË   R  R  RÞ   t   ic(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRº   ?  sD     c         C   sy   g  } xl t  d |  j j ƒ  j ƒ  ƒ D]L } t |  j j ƒ  j | ƒ j ƒ  j ƒ  ƒ } | d k r% | j | ƒ q% q% W| S(   Ni    R½   (	   t   rangeRn   RB   R—   R   t   itemAtRÞ   R  t   append(   R   R¶   R»   R´   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   snapshotListk  s    %* c         C   s'   |  j  j |  j ƒ  ƒ |  j  j ƒ  d  S(   N(   R   t   set_snapshot_listR0  t   pickle_movie(   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRÃ   u  s    c         C   s   d  S(   N(   RJ   (   R   RË   R´   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR†   {  s    c         K   s   d  S(   N(    (   R   RË   R´   R%   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   updateFrameGuiƒ  s    c   	      C   s'  | d k r | | g |  _  n  | d k rƒ | t j } t |  j j ƒ  j | ƒ j ƒ  j ƒ  ƒ } | d k rq d  S| | g |  _  n� | d k rñ t	 |  j  ƒ d k rß |  j  d | k rß |  j  d | k rß g  |  _  g  |  _
 q| | g |  _  n! | d k rg  |  _  g  |  _
 n  t	 |  j  ƒ d k r|  j ƒ  } | j |  j  d ƒ sa| j |  j  d ƒ rmg  |  _  n€ | j |  j  d ƒ } | j |  j  d ƒ } | | k rÙ|  j  d |  j  d g |  _  | | | d !|  _
 n | | | d !|  _
 |  j j d	 |  j  ƒ n |  j j d
 d ƒ |  j ƒ  d  S(   Ns   shift-presss   shift-releaseR½   s   single-clicki   i    i   t   undot   selectt   actiont   undo_selection(   Re   R!   RT   R   Rn   RB   R.  RÞ   R  Rå   Rf   R0  R—   R¾   R   Rá   RN   (	   R   R6  R´   t   xxR»   t   id1R¶   t   l1t   l2(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   selectFrames‹  s:    * ;		.c         C   sÉ   xÂ t  d |  j j ƒ  j ƒ  ƒ D]¢ } |  j j ƒ  j | ƒ j ƒ  } t | j ƒ  ƒ } | d k rd q |  j j | ƒ r® d } | j	 | ƒ | j
 rÁ d } | j
 j	 | ƒ qÁ q d } | j	 | ƒ q Wd  S(   Ni    R½   s3   presentationFrameWidget { border: 4px solid green;}s1   presentationFrameWidget { border: 4px solid red;}(   R-  Rn   RB   R—   R.  RÞ   R   R  Rf   t   setStyleSheetR‡   (   R   R»   RÞ   R´   t   sheet(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRN   ¼  s    %	i   t   restorec         C   s  | s£ |  j  ƒ  } | s d  S|  j s9 | j |  j ƒ rB d } nT | j |  j ƒ | } | t | ƒ d k rw d } n | d k  r– t | ƒ d } n  | | } n  |  j j d | d | ƒ } | d rß t ƒ  j | d ƒ n9 | |  _ d d  l	 } | j
 ƒ  t ƒ  j ƒ  t ƒ  j ƒ  d  S(   Ni    i   R6  R´   iÿÿÿÿ(   R0  Rg   R—   R¾   Rå   R   t   restore_statusRÓ   RÔ   t   rebuildt   UpdateDisplayR   t   updateGLWindowst   DISPLAYTABLER  (   R   Rþ   R6  R´   R¶   t   iiR   RA  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR÷   Î  s(     		
	
c         C   sf   | j  ƒ  } |  j j ƒ  } | d k  rA | j | j ƒ  d ƒ n | j | j ƒ  d ƒ | j ƒ  d  S(   Ni    i   (   t   deltaRt   Ru   R)  R  t   accept(   R   t   eventRF  t   bar(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt
   wheelEventï  s    c         C   s   d  S(   N(    (   R   RÕ   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   loadSnapshotû  s    c         C   s_   d GH|  j  j d d ƒ } | d rA t j j |  d | d ƒ n t j j |  d | d ƒ d  S(   NRø   t   compressi   i    s   Package presentation (   R   t   do_backup_data_filesR    R|   R}   t   information(   R   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRø      s
    
N()   RH   RI   R`   R]   RV   RW   RT   R"   RJ   R,   R…   Ri   R‘   Rk   R³   Rm   RÆ   R·   RÖ   Rp   RÛ   Rß   Rã   Ré   RŒ   Rú   Rï   R–   R   R  Rº   R0  RÃ   R†   R3  R<  RN   R÷   RJ  RK  Rø   (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR!   “   sL   	1				:								&		-,	
	1	!		RÉ   c           B   sJ   e  Z d  d  d „ Z d „  Z d  d „ Z d „  Z d „  Z d  d „ Z RS(   R   c         C   sc  t  j j |  | ƒ | |  _ |  j | ƒ d |  _ |  j t  j j ƒ |  j t	 j
 ƒ t  j ƒ  } t	 j } | j | | | | ƒ | j d ƒ t t |  j ƒ  ƒ |  ƒ |  _ | j |  j ƒ |  j ƒ  |  j j d |  d | ƒ |  _ |  j rÿ | j |  j ƒ n  |  j t	 j ƒ |  j t	 j ƒ | j ƒ  |  j | ƒ |  j ƒ  |  j r_|  j j d | ƒ n  d  S(   Ni    RË   R´   (   R    t   QFrameR,   t   presentationGuiR-   Rä   t   setFrameStylet   Boxt   setLineWidthR!   RW   R/   RV   RŸ   Rž   t   presentationPictureWidgetR   R  t   picFrameR2   t	   loadImageR†   R‡   R×   RT   Rl   R¨   RA   R"   R3  (   R   R   R´   RÇ   RB   R«   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR,     s.    			
	 

	 c         C   sA   t  j } |  j r. | |  j j ƒ  j ƒ  } n  t j t  j | ƒ S(   N(   R!   RT   R‡   Rr   Rs   R   t   QSize(   R   t   h(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   sizeHint7  s    		 c         C   sk   | s- |  j  j j t |  j ƒ  ƒ d ƒ } n | } t j j | ƒ rg t j	 | ƒ } |  j
 j | ƒ n  d  S(   NRÌ   (   RP  R   RÑ   R   R  RÎ   RÏ   RÐ   R    t   QPixmapRU  t	   setPixmap(   R   RÇ   t   picfilet   pixmap(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRV  @  s    'c         C   sÈ   t  |  d ƒ s… t j |  ƒ |  _ d d  l } | j |  |  j |  j d ƒ d d d g d d d	 d
 |  j d ƒ d d g g d d ƒn  |  j j |  j t	 j
 | j ƒ  ƒ ƒ ƒ |  j j ƒ  | j ƒ  d  S(   Nt   context_menuiÿÿÿÿs	   Restore..R?  t   restore_displayt   restore_viewt   replacet   cutt   copyt   seps   Set insert..t   insert_beforet   insert_afterRˆ   R   (   t   hasattrR    RŠ   R^  R‰   R�   R=   t   popupt   mapToGlobalR   t   QPointt   posR   RG  (   R   RH  R‰   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   contextMenuEventQ  s    X(c      	   K   sR  d d  l  } | d k rR t d |  j d ƒ d |  j d ƒ d | j |  j | ƒ ƒ S| d k r˜ t d |  j d	 ƒ d |  j d
 ƒ d | j |  j | ƒ ƒ S| d k rÞ t d |  j d ƒ d |  j d ƒ d | j |  j | ƒ ƒ S| d k r$t d |  j d ƒ d |  j d ƒ d | j |  j | ƒ ƒ S| d k rjt d |  j d ƒ d |  j d ƒ d | j |  j | ƒ ƒ S| d k r°t d |  j d ƒ d |  j d ƒ d | j |  j | ƒ ƒ S| d k rÿt d |  j d ƒ d |  j d ƒ d | j |  j j |  j ƒ  ƒ ƒ S| d k rNt d |  j d ƒ d |  j d ƒ d | j |  j j |  j ƒ  ƒ ƒ Sd  S(   NiÿÿÿÿR?  R<   s   Display and viewRó   s0   Restore the display and view shown in this frameRô   R_  t   Displays'   Restore the display shown in this frameR`  t   Views$   Restore the view shown in this frameRa  t   Replaces*   Replace this frame with the current statusRe  s   Before this frames&   Set the insert frame before this frameRf  s   After this frames%   Set the insert frame after this frameRb  t   Cuts   Remove this frameRc  t   Copys   Copy this frame(	   R‰   Rõ   R=   R˜   t   handleActionRP  Rß   R  RÛ   (   R   Rñ   Rù   R‰   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRú   ]  sR    c         C   sÜ   | d k r. |  j  j d |  j ƒ  d d ƒ nª | d k r\ |  j  j d |  j ƒ  d d ƒ n| | d d !d k r— |  j  j d	 | d t |  j ƒ  ƒ ƒ nA | d
 k rØ |  j  j j d t |  j ƒ  ƒ d d ƒ |  j ƒ  n  d  S(   NRe  R´   Rþ   i    Rf  i   i   t   restR6  Ra  R¾   t   save_changest   replaced(   RP  R   R  R÷   R   R   R¿   RV  (   R   R6  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRr  Œ  s    ""(((   RH   RI   R,   RY  RV  Rl  Rú   Rr  (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRÉ     s   $				/Rª   c           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s  t  j j |  | ƒ | |  _ |  j t  j j ƒ |  j d ƒ t  j ƒ  } t j	 } | j
 | | | | ƒ | j d ƒ t  j |  j d ƒ |  ƒ } | j ƒ  | j | ƒ | j ƒ  |  j | ƒ |  j t j ƒ |  j t j ƒ |  j t j |  j j ƒ |  j t j |  j j ƒ |  j ƒ  d  S(   NR½   i
   s   Save snapshot here(   R    RO  R,   RP  RQ  RR  R-   R/   R!   RV   RŸ   Rž   R  R=   R¨   R2   RA   R×   RT   Rl   Rw   Rj   Rv   R"   (   R   R   RB   R«   t   label(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR,   ¢  s$    		

c         C   s¥   t  |  d ƒ s$ t j |  ƒ |  _ n  |  j j ƒ  d d  l } | j |  |  j d d d g d d ƒ|  j j |  j t	 j
 | j ƒ  ƒ ƒ ƒ |  j j ƒ  | j ƒ  d  S(   NR^  iÿÿÿÿt   save_statusRÖ   t   load_snapshotRˆ   R   (   Rg  R    RŠ   R^  R‹   R‰   R�   Rh  Ri  R   Rj  Rk  R   RG  (   R   RH  R‰   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRl  ¼  s     %(c      	      sú   d d  l  } | d k rI t d ˆ  j d ƒ d ˆ  j d ƒ d ˆ  j j ƒ S| d k r§ ‡  f d	 †  } t d ˆ  j d
 ƒ d ˆ  j d ƒ d | j ˆ  j j d ƒ d | ƒ S| d k rö t d ˆ  j d ƒ d ˆ  j d ƒ d | j ˆ  j j d ƒ d d ƒ Sd  S(   NiÿÿÿÿRw  R<   s   Save current view/displayRó   s*   Save snapshot of current view/display hereRô   RÖ   c              s   ˆ  j  j d k S(   NR   (   RP  Rh   (    (   R   (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   eÔ  s    t   Pastes   Paste the saved snapshott   enabledRx  s   Load snapshot files
   Load from i    (   R‰   Rõ   R=   RP  RÆ   R˜   RÖ   RK  (   R   Rñ   Rù   R‰   Ry  (    (   R   sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRú   Ê  s&    c         C   s   |  j  j ƒ  | j ƒ  d  S(   N(   RP  RÆ   RG  (   R   RH  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   mouseDoubleClickEventä  s    (   RH   RI   R,   Rl  Rú   R|  (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRª   œ  s   			RT  c           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s<   t  j j |  | ƒ |  j t j ƒ t  j | |  ƒ |  _ d  S(   N(   R    R  R,   t	   setMarginR!   RW   Rv  (   R   R<   R   (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR,   ô  s    c         C   s!   |  j  ƒ  j d ƒ | j ƒ  d  S(   NR?  (   R   Rr  RG  (   R   RH  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyR|  û  s    c         C   sr   | j  ƒ  t j j @rd | j ƒ  t j j @rd |  j ƒ  j j d t	 |  j ƒ  j
 ƒ  ƒ ƒ | j ƒ  n
 | j ƒ  d  S(   Ns   shift-press(   t   buttonsR   R^   t
   LeftButtont	   modifierst   ShiftModifierR   RP  R<  R   R  RG  t   ignore(   R   RH  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   mousePressEvent  s    ,+c         C   sß   | j  ƒ  t j j k rÑ | j ƒ  t j j @r™ |  j ƒ  j |  j | j ƒ  ƒ ƒ } |  j ƒ  j	 j
 d d t |  j ƒ  j ƒ  ƒ d | j ƒ  ƒ| j ƒ  qÛ |  j ƒ  j	 j
 d t |  j ƒ  j ƒ  ƒ ƒ | j ƒ  n
 | j ƒ  d  S(   Ns   shift-releaseR´   R8  s   single-click(   t   buttonR   R^   R  R€  R�  R   t   mapToParentRk  RP  R<  R   R  t   xRG  R‚  (   R   RH  Rk  (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   mouseReleaseEvent  s    $:+(   RH   RI   R,   R|  Rƒ  R‡  (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyRT  î  s   			c          C   so   t  j t j ƒ }  t  j ƒ  } t | ƒ } | j d ƒ | j d d ƒ | j d d ƒ | j ƒ  |  j	 ƒ  d  S(   Ns1   /home/lizp/ccp4mg_tutorial/tt.ccp4mg_presentationiÿÿÿÿs   snapshot_00001.ppms   snapshot_00002.ppm(
   R    t   QApplicationRR   t   argvt   QMainWindowt   presentationDialogR³   R·   R"   R   (   t   appt   maint   mv(    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   test  s    
(   t   __doc__RR   t   PyQt4R    R   t   global_definitionsRK   R0   RÎ   RU   R   R   R+   R   RL   R!   RO  RÉ   Rª   R  RT  R�  (    (    (    sA   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgPresentation.pyt   <module>   s    
&;ÿ ÿ |�R1