ó
 m[c           @` s‚   d  Z  d d l m Z m Z m Z m Z d d l Z d d l Z d d l Z d d l	 Z	 d e
 f d „  ƒ  YZ e j e j ƒ d S(   u&   
Manage figures for pyplot interface.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNt   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 e e d
 „ ƒ Z RS(   uÉ  
    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   |  j  j | d ƒ } | d k	 r1 |  j | ƒ n  | S(   u„   
        If figure manager *num* exists, make it the active
        figure and return the manager; otherwise return *None*.
        N(   t   figst   gett   Nonet
   set_active(   t   clst   numt   manager(    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   get_fig_manager#   s    c         C` sh   |  j  | ƒ s d S|  j | } | j j | j ƒ |  j j | ƒ |  j | =| j ƒ  t j	 d ƒ d S(   u¤   
        Try to remove all traces of figure *num*.

        In the interactive backends, this is bound to the
        window "destroy" and "delete" events.
        Ni   (
   t
   has_fignumR   t   canvast   mpl_disconnectt   _cidgcft
   _activeQuet   removet   destroyt   gct   collect(   R	   R
   R   (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR   .   s    

c         ` sK   t  ‡  f d †  t j |  j ƒ Dƒ d ƒ } | d k	 rG |  j | ƒ n  d S(   u   *fig* is a Figure instancec         3` s*   |  ]  } | j  j ˆ  k r | j Vq d  S(   N(   R   t   figureR
   (   t   .0R   (   t   fig(    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pys	   <genexpr>B   s    N(   t   nextt   sixt
   itervaluesR   R   R   (   R	   R   R
   (    (   R   s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   destroy_fig?   s    "	c         C` sp   d d  l  } x: t |  j j ƒ  ƒ D]# } | j j | j ƒ | j ƒ  q" Wg  |  _ |  j j	 ƒ  | j
 d ƒ d  S(   Ni    i   (   R   t   listR   t   valuesR   R   R   R   R   t   clearR   (   R	   R   R   (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   destroy_allG   s    	c         C` s   | |  j  k S(   u7   
        Return *True* if figure *num* exists.
        (   R   (   R	   R
   (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR   T   s    c         C` s   t  |  j j ƒ  ƒ S(   u3   
        Return a list of figure managers.
        (   R   R   R   (   R	   (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   get_all_fig_managers[   s    c         C` s   t  |  j ƒ S(   u=   
        Return the number of figures being managed.
        (   t   lenR   (   R	   (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   get_num_fig_managersb   s    c         C` s(   t  |  j ƒ d k r d S|  j d Sd S(   uE   
        Return the manager of the active figure, or *None*.
        i    iÿÿÿÿN(   R"   R   R   (   R	   (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt
   get_activei   s    c         C` sg   |  j  } g  |  _  x- | D]% } | | k r |  j  j | ƒ q q W|  j  j | ƒ | |  j | j <d S(   uL   
        Make the figure corresponding to *manager* the active one.
        N(   R   t   appendR   R
   (   R	   R   t   oldQuet   m(    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR   s   s    
	c         C` s@   x9 |  j  ƒ  D]+ } | s( | j j j r | j j ƒ  q q Wd S(   uV   
        Redraw all figures registered with the pyplot
        state machine.
        N(   R!   R   R   t   stalet	   draw_idle(   R	   t   forcet   f_mgr(    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   draw_all€   s    (   t   __name__t
   __module__t   __doc__R   R   t   classmethodR   R   R   R    R   R!   R#   R$   R   t   FalseR,   (    (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyR      s   
(   R/   t
   __future__R    R   R   R   R   t   atexitR   t   syst   objectR   t   registerR    (    (    (    s8   lib/python2.7/site-packages/matplotlib/_pylab_helpers.pyt   <module>   s   "|