ó
±éRc           @  sm   d  Z  d d l m Z d d l Z d d l Z d d l Z d „  Z d e f d „  ƒ  YZ e j	 e j
 ƒ d S(   s&   
Manage figures for pyplot interface.
iÿÿÿÿ(   t   print_functionNc         C  s   t  |  d t j ƒd  S(   Nt   file(   t   printt   syst   stderr(   t   msg(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt	   error_msg   s    t   Gcfc           B  s¡   e  Z d  Z g  Z i  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z RS(
   sÉ  
    Singleton to manage a set of integer-numbered figures.

    This class is never instantiated; it consists of two class
    attributes (a list and a dictionary), and a set of static
    methods that operate on those attributes, accessing them
    directly as class attributes.

    Attributes:

        *figs*:
          dictionary of the form {*num*: *manager*, ...}

        *_activeQue*:
          list of *managers*, with active one at the end

    c         C  s5   t  j j |  d ƒ } | d k	 r1 t  j | ƒ n  | S(   s„   
        If figure manager *num* exists, make it the active
        figure and return the manager; otherwise return *None*.
        N(   R   t   figst   gett   Nonet
   set_active(   t   numt   manager(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   get_fig_manager#   s    c         C  s˜   t  j |  ƒ s d St  j |  } | j j | j ƒ t  j } g  t  _ x- | D]% } | | k rM t  j j | ƒ qM qM Wt  j |  =| j ƒ  t	 j
 ƒ  d S(   s¤   
        Try to remove all traces of figure *num*.

        In the interactive backends, this is bound to the
        window "destroy" and "delete" events.
        N(   R   t
   has_fignumR   t   canvast   mpl_disconnectt   _cidgcft
   _activeQuet   appendt   destroyt   gct   collect(   R   R   t   oldQuet   f(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR   .   s     
	

c         C  s_   d } x6 t j j ƒ  D]% } | j j |  k r | j } Pq q W| d k	 r[ t j | ƒ n  d S(   s   *fig* is a Figure instanceN(   R
   R   R   t
   itervaluesR   t   figureR   R   (   t   figR   R   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   destroy_figG   s    	c          C  s[   x4 t  j j ƒ  D]# }  |  j j |  j ƒ |  j ƒ  q Wg  t  _ t  j j ƒ  t	 j
 ƒ  d  S(   N(   R   R   t   valuesR   R   R   R   R   t   clearR   R   (   R   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   destroy_allR   s    	c         C  s   |  t  j k S(   s7   
        Return *True* if figure *num* exists.
        (   R   R   (   R   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR   \   s    c           C  s   t  j j ƒ  S(   s3   
        Return a list of figure managers.
        (   R   R   R   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   get_all_fig_managersc   s    c           C  s   t  t j j ƒ  ƒ S(   s=   
        Return the number of figures being managed.
        (   t   lenR   R   R   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   get_num_fig_managersj   s    c           C  s(   t  t j ƒ d k r d St j d Sd S(   sE   
        Return the manager of the active figure, or *None*.
        i    iÿÿÿÿN(   R"   R   R   R
   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt
   get_activeq   s    c         C  sg   t  j } g  t  _ x- | D]% } | |  k r t  j j | ƒ q q Wt  j j |  ƒ |  t  j |  j <d S(   sL   
        Make the figure corresponding to *manager* the active one.
        N(   R   R   R   R   R   (   R   R   t   m(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR   z   s    
	 (   t   __name__t
   __module__t   __doc__R   R   t   staticmethodR   R   R   R    R   R!   R#   R$   R   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR      s   
	(   R(   t
   __future__R    R   R   t   atexitR   t   objectR   t   registerR    (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   <module>   s   	y