� �)�Uc@s�dZddlmZmZddlmZddljZde fd��YZ de fd��YZ d e fd ��YZ d e fd ��YZ dS( s  This provides several classes used for blocking interaction with figure windows: :class:`BlockingInput` creates a callable object to retrieve events in a blocking way for interactive sessions :class:`BlockingKeyMouseInput` creates a callable object to retrieve key or mouse clicks in a blocking way for interactive sessions. Note: Subclass of BlockingInput. Used by waitforbuttonpress :class:`BlockingMouseInput` creates a callable object to retrieve mouse clicks in a blocking way for interactive sessions. Note: Subclass of BlockingInput. Used by ginput :class:`BlockingContourLabeler` creates a callable object to retrieve mouse clicks in a blocking way that will then be used to place labels on a ContourSet Note: Subclass of BlockingMouseInput. Used by clabel i����(tpathtverbose(tis_sequence_of_stringsNt BlockingInputcBsqeZdZd d�Zd�Zd�Zd�Zd�Zdd�Zdd�Z eje _d d d �Z RS( sX Class that creates a callable object to retrieve events in a blocking way. cCs.||_t|�s!td��||_dS(Ns)Requires a sequence of event name strings(tfigRtAssertionErrort eventslist(tselfRR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyt__init__s cCso|j|�tjdt|j��|j�t|j�|jkrk|jdkrk|jjj �ndS(se Event handler that will be passed to the current figure to retrieve events. sEvent %iiN( t add_eventRtreporttlenteventst post_eventtnRtcanvaststop_event_loop(Rtevent((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyton_event"s   'cCsdS(s,For baseclass, do nothing but collect eventsN((R((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR 5scCs4x$|jD]}|jjj|�q Wg|_dS(sDisconnect all callbacksN(t callbacksRRtmpl_disconnect(Rtcb((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pytcleanup9scCs|jj|�dS(s5For base class, this just appends an event to events.N(R tappend(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR @si����cCs|jj|�dS(s' This removes an event from the event list. Defaults to removing last event, but an index can be supplied. Note that this does not check that there are events, much like the normal pop method. If not events exist, this will throw an exception. N(R tpop(Rtindex((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyt pop_eventDscCs|j|�dS(N(R(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRNsiicCs�t|t�std��||_g|_g|_|jj�x6|jD]+}|jj |jj j ||j ��qMWz|jj j d|�Wd|j�X|jS(s4 Blocking call to retrieve n events sRequires an integer argumentttimeoutN(t isinstancetintRRR RRtshowRRRt mpl_connectRtstart_event_loopR(RRR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyt__call__Rs    ) (( t__name__t __module__t__doc__RRR RR RRR!(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRs       tBlockingMouseInputcBs�eZdZdZdZdZdddd�Zd�Zd�Zd�Z d�Z d �Z d �Z d �Z d d �Zd d�Zdd�Zdded�ZRS(s; Class that creates a callable object to retrieve mouse clicks in a blocking way. This class will also retrieve keyboard clicks and treat them like appropriate mouse clicks (delete and backspace are like mouse button 3, enter is like mouse button 2 and all others are like mouse button 1). iiicCs8tj|d|dd�||_||_||_dS(NRRtbutton_press_eventtkey_press_event(R&R'(RRt button_addt button_popt button_stop(RRt mouse_addt mouse_popt mouse_stop((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR|s   cCsRt|j�dks!td��|jdjdkrD|j�n |j�dS(s7 This will be called to process events is No events yeti����R'N(R R Rtnamet key_eventt mouse_event(R((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR �s! cCse|jd}|j}||jkr5|j|�n,||jkrT|j|�n |j|�dS(sProcess a mouse click eventi����N(R tbuttonR)tmouse_event_popR*tmouse_event_stoptmouse_event_add(RRR1((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR0�s  cCsx|jd}|jdkr dS|jj�}|dkrK|j|�n)|dkrg|j|�n |j|�dS( so Process a key click event. This maps certain keys to appropriate mouse click events. i����Nt backspacetdeletetescapetenter(R5R6(sescapeR8(R tkeytNonetlowerR2R3R4(RRR9((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR/�s   cCs-|jr|j|�ntj|d�dS(s� Will be called for any event involving a button other than button 2 or 3. This will add a click if it is inside axes. i����N(tinaxest add_clickRR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR4�s cCs$tj|d�|jjj�dS(sh Will be called for any event involving button 2. Button 2 ends blocking input. i����N(RRRRR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR3�scCs<tj|d�t|j�dkr8|j|d�ndS(sk Will be called for any event involving button 3. Button 3 removes the last click. i����iN(RRR R (RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR2�scCs�|jj|j|jf�tjdt|j�|j|jf�|jr�tj |jg|jgdddd�}|j j |�|j j|�|j jj�ndS(sL This add the coordinates of an event to the list of clicks sinput %i: %f,%ftmarkert+tcolortrN(tclicksRtxdatatydataRR R t show_clickstmlinestLine2DR<tadd_linetmarksRRtdraw(RRtline((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR=�s   i����cCsL|jj|�|jrH|jj|�}|j�|jjj�ndS(sm This removes a click from the list of clicks. Defaults to removing the last click. N(RBRRERItremoveRRRJ(RRRtmark((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyt pop_click�s   cCs$|j||�tj||�dS(s� This removes a click and the associated event from the object. Defaults to removing the last click, but any index can be supplied. N(RNRR(RRR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR�scCsT|jrCx|jD]}|j�qWg|_|jjj�ntj|�dS(N(RERIRLRRRJRR(RRRM((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRs   icCs;||_g|_g|_tj|d|d|�|jS(s\ Blocking call to retrieve n coordinate pairs through mouse clicks. RR(RERBRIRR!(RRRRE((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR!s    N(R"R#R$R(R)R*RR R0R/R4R3R2R=RNRR:RtTrueR!(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR%ns      tBlockingContourLabelercBsPeZdZd�Zd�Zdd�Zd�Zd�Zdddd�ZRS( s� Class that creates a callable object that uses mouse clicks or key clicks on a figure window to place contour labels. cCs&||_tj|d|jj�dS(NR(tcsR%Rtaxtfigure(RRQ((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR#s cCs|j|�dS(N(tbutton1(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR='si����cCs|j|�dS(N(tbutton3(RRR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRN*scCs�|j}|j|jkr�|j|j|j|j�d \}}}}}|jj|�}|j|j �} | |j } |jj j | �} |j |j||j|j|�} |jr�| } nd} |j| || | |j�\}}|j||||j||j|�|jrq| j|�x<|D]1}t|�dkr9| jtj|��q9q9Wn|jjj�n tj|�dS(s� This will be called if an event involving a button other than 2 or 3 occcurs. This will add a label to a contour. iiN( RQR<RRtfind_nearest_contourtxtytlabelIndiceListRt collectionst get_pathstverticest transDatat transformtget_label_widthtlabelLevelListtlabelFmttlabelFontSizeListtinlineR:tcalc_label_rot_and_inlinetinline_spacingt add_labeltlabelCValueListRR RRtPathRRRJR(RRRQtconmintsegmintimintxmintymintlmintpathstlctslctlwtlcargtrotationtnlcR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRT-s2 +       cCs3|jr n#|jj�|jjjjj�dS(sY This will be called if button 3 is clicked. This will remove a label if not in inline mode. Unfortunately, if one is doing inline labels, then there is currently no way to fix the broken contour - once humpty-dumpty is broken, he can't be put back together. In inline mode, this does nothing. N(RcRQt pop_labelRRRSRRJ(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRUfs  icCs5||_||_tj|d|d|dt�dS(NRRRE(RcReR%R!tFalse(RRcReRR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR!us  ( R"R#R$RR=RNRTRUR!(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRPs    9 tBlockingKeyMouseInputcBs,eZdZd�Zd�Zdd�ZRS(s_ Class that creates a callable object to retrieve a single mouse or keyboard click cCstj|d|dd�dS(NRRR&R'(sbutton_press_eventskey_press_event(RR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR�scCs>t|j�dks!td��|jdjdk|_dS(s1 Determines if it is a key event is No events yeti����R'N(R R RR.t keyormouse(R((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR �s!icCs)d|_tj|ddd|�|jS(s� Blocking call to retrieve a single mouse or key click Returns True if key click, False if mouse, or None if timeout RiRN(R:RyRR!(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR!�s (R"R#R$RR R!(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRx|s  (R$t matplotlibRRtmatplotlib.cbookRtmatplotlib.linestlinesRFtobjectRR%RPRx(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyt<module>sV�^