ó
ÉÝ{Tc           @   s/  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m	 Z	 d e j
 f d „  ƒ  YZ e d k r+d „  Z e j e j ƒ Z e j j d	 ƒ rÃ e e j j ƒ Z n e e j j ƒ Z e j d
 d ƒ e j e e j d ƒ e ƒ e j ƒ  e j ƒ  e j e j ƒ  ƒ n  d S(   sb  
     qtgui/mgUpperLowerSlider.py: CCP4MG Molecular Graphics Program
     Copyright (C) 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   SVGLabelt   UpperLowerSliderc           B   sn   e  Z d d  „ Z d „  Z d d d „ Z d „  Z d „  Z d „  Z d d „ Z	 d „  Z
 d	 „  Z d
 „  Z RS(   c         C   sŠ   d |  j  |  _  t j j t j d d ƒ } |  j  d k r] |  j j t j j | d ƒ ƒ n |  j j t j j | d ƒ ƒ |  j ƒ  d  S(   Ni   t   CCP4MGt   qticonsi    s   padlock_open.svgs   padlock.svg(   t   _lockt   ost   patht   joint   environt   padlockt   loadFilet   repaint(   t   selft   et	   icon_path(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyt
   toggleLock   s    "c         C   s•   |  j  t j j k rG t j |  j j ƒ  d d d d d ƒ |  j _ n@ t j |  j	 j ƒ  d d |  j j
 ƒ  d d d d ƒ |  j _ | j ƒ  d  S(   Ni   i
   iýÿÿÿi   i   (   t   _orientationR   t   Qtt
   Horizontalt   QRectFt   s1t   widthR   t   _boundst	   lowerSpint   heightt   accept(   R   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyt   resizeEvent%   s    2@c         C   s2  t  j j |  | ƒ | |  _ t  j ƒ  |  _ t  j ƒ  |  _ t  j ƒ  } | t j	 j
 k r‘ t  j t j	 j
 | ƒ |  _ t  j t j	 j
 | ƒ |  _ n$ t  j | ƒ |  _ t  j | ƒ |  _ t j j t j d d ƒ } |  j j d d ƒ |  j j d d ƒ |  j j d d ƒ |  j j d d ƒ t ƒ  |  _ |  j j t j j | d ƒ ƒ d |  _ |  j |  j t j d ƒ |  j ƒ | t j	 j
 k r‡| j |  j d d d d ƒ | j |  j d d d d ƒ | j |  j d d d d ƒ | j |  j d d d d ƒ | j |  j d d d d ƒ t  j |  j d	 ƒ ƒ } t  j |  j d
 ƒ ƒ } | j | d d ƒ | j | d d ƒ | j d d ƒ | j d ƒ n© | j |  j d d d d ƒ | j |  j d d d d ƒ | j |  j d d d d ƒ | j |  j d d d d ƒ | j |  j d d d d ƒ | j d d ƒ | j  d ƒ |  j! | ƒ d |  _" |  j j# ƒ  |  _$ |  j j# ƒ  |  _% |  j |  j t j d ƒ t& j' |  j( |  j ƒ ƒ |  j |  j t j d ƒ t& j' |  j( |  j ƒ ƒ |  j |  j t j d ƒ t& j' |  j( |  j ƒ ƒ |  j |  j t j d ƒ t& j' |  j( |  j ƒ ƒ d  S(   NR   R   i    id   s   padlock_open.svgt   MousePressedi   i   s   Lower values   Upper valuei   g      ð?s   valueChanged(int)s   valueChanged(double)()   R    t   QWidgett   __init__R   t   QDoubleSpinBoxR   t	   upperSpint   QGridLayoutR   R   R   t   QSliderR   t   s2R   R   R	   R
   t   setRangeR   R   R   R   t   connectt   SIGNALR   t	   addWidgett   QLabelt   trt   setRowStretcht   setVerticalSpacingt   setColumnStretcht   setHorizontalSpacingt	   setLayoutt   sliderScalet   valuet   oldS1Valt   oldS2Valt	   functoolst   partialt
   valChanged(   R   t   orientationt   parentt   layoutR   t
   lowerLabelt
   upperLabel(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR   ,   s\    		"	111c         C   s   |  j  j ƒ  S(   N(   R   t   maximum(   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR<   a   s    c         C   s   |  j  j ƒ  S(   N(   R   t   minimum(   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR=   d   s    c         C   s   |  j  j ƒ  S(   N(   R   t   decimals(   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR>   g   s    i   c         C   sc  | | d k  r d  S| | } d | |  _  t t j |  j  | ƒ ƒ |  _ t t j |  j  | ƒ ƒ |  _ |  j j |  j |  j ƒ |  j j |  j |  j ƒ |  j j	 |  j ƒ |  j j	 |  j ƒ |  j
 j | | ƒ |  j j | | ƒ | | d k  r't t j t j d | | d ƒ ƒ d ƒ } n d } |  j
 j t | | ƒ ƒ |  j j t | | ƒ ƒ d  S(   Ng:Œ0âŽyE>g     jø@g{®Gáz„?g      ð?i
   i   i   (   R0   t   intt   matht   floort	   sliderMint	   sliderMaxR   R%   R$   t   setValueR   R!   t   ceilt   logt   setDecimalst   max(   R   t   lowert   uppert   minDecimalst	   realRangeR>   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR%   j   s"    
0c         C   s   |  j  S(   N(   R   (   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyt	   isClamped~   s    c         C   s   |  j  j ƒ  |  j j ƒ  f S(   N(   R   R1   R!   (   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyt	   getValues‚   s    c         C   s'  |  j  j t ƒ |  j j t ƒ |  j j t ƒ |  j j t ƒ | |  j k r­ |  j  j t | |  j ƒ ƒ |  j  j	 ƒ  |  j j	 ƒ  k r­ |  j j t | |  j ƒ ƒ q­ n  | |  j k r|  j j t | |  j ƒ ƒ |  j j	 ƒ  |  j  j	 ƒ  k  r|  j  j t | |  j ƒ ƒ qn  |  j j	 ƒ  |  j  j	 ƒ  k  rc| |  j k rc|  j  j |  j j	 ƒ  ƒ nQ | |  j k r´|  j
 ƒ  r´|  j j	 ƒ  |  j } |  j  j |  j  j	 ƒ  | ƒ n  |  j  j	 ƒ  |  j j	 ƒ  k rý| |  j  k rý|  j j |  j  j	 ƒ  ƒ nQ | |  j  k rN|  j
 ƒ  rN|  j  j	 ƒ  |  j } |  j j |  j j	 ƒ  | ƒ n  |  j j |  j  j	 ƒ  |  j ƒ |  j j |  j j	 ƒ  |  j ƒ |  j  j t ƒ |  j j t ƒ |  j j t ƒ |  j j t ƒ |  j  j	 ƒ  |  _ |  j j	 ƒ  |  _ |  j t j d ƒ |  j j	 ƒ  |  j j	 ƒ  f ƒ d  S(   Nt   rangeChanged(   R   t   blockSignalst   TrueR$   R   R!   RD   R?   R0   R1   RM   R3   R2   t   Falset   emitR   R'   (   R   t   emittert   valt   diff(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR6   …   s>    ##- -   N(   t   __name__t
   __module__t   NoneR   R   R   R<   R=   R>   R%   RM   RN   R6   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyR      s   		5					t   __main__c         C   s!   |  \ } } | G| G| | GHd  S(   N(    (   t   valst   minRH   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyRO   ¬   s    s   -viöÿÿÿix   RO   (   t   __doc__t   sysR   R@   R4   t   PyQt4R    R   t   MGSimpleWidgetsR   R   R   RW   RO   t   QApplicationt   argvt   appt   countR   t   Verticalt   sliderR   R%   R&   R'   t   showt   raise_t   exitt   exec_(    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/mgUpperLowerSlider.pyt   <module>   s$   �	

