ó ù)°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||_||_dS(N(tfigt 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||_g|_g|_|jjƒx6|jD]+}|jj|jjj||j ƒƒq2Wz|jjj d|ƒWd|j ƒX|jS(s4 Blocking call to retrieve n events ttimeoutN( R R RRtshowRRRt mpl_connectRtstart_event_loopR(RR R((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyt__call__Rs    ) (( t__name__t __module__t__doc__RRR RRRRR(((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   cCs1|jdjdkr#|jƒn |jƒdS(s7 This will be called to process events iÿÿÿÿR$N(R tnamet 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(RRR.((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR-‘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(R2R3(sescapeR5(R tkeytNonetlowerR/R0R1(RRR6((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.pyR1²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.pyR0¼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.pyR/Ë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_clickstmlinestLine2DR9tadd_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(R?RRBRFtremoveRRRG(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(RKRR(RRR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRüscCsT|jrCx|jD]}|jƒqWg|_|jjjƒntj|ƒdS(N(RBRFRIRRRGRR(RRRJ((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. R R(RBR?RFRR(RR RRB((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRs    N(RR R!R%R&R'RR R-R,R1R0R/R:RKRR7RtTrueR(((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(RRN((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.pyRK*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( RNR9ROtfind_nearest_contourtxtytlabelIndiceListRt collectionst get_pathstverticest transDatat transformtget_label_widthtlabelLevelListtlabelFmttlabelFontSizeListtinlineR7tcalc_label_rot_and_inlinetinline_spacingt add_labeltlabelCValueListRR RRtPathRRRGR(RRRNtconmintsegmintimintxmintymintlmintpathstlctslctlwtlcargtrotationtnlcR ((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRQ-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(R`RNt pop_labelRORPRRG(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRRfs  icCs5||_||_tj|d|d|dtƒdS(NR RRB(R`RbR"RtFalse(RR`RbR R((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRus  ( RR R!RR:RKRQRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRMs    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.pyRscCs|jdjdk|_dS(s1 Determines if it is a key event iÿÿÿÿR$N(R R+t keyormouse(R((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyR „sicCs)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 R iRN(R7RvRR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRŒs (RR R!RR R(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pyRu|s  (R!t matplotlibRRtmatplotlib.cbookRtmatplotlib.linestlinesRCtobjectRR"RMRu(((sL/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/blocking_input.pytsV°^