
    h                        S r SSKrSSKrSSKrSSKrSSKJr  SSKrSSKJ	r	  SSK
rSSKrSSKJr  SSKJrJr   " S S\R$                  5      r\r\" 5       rSWS	 jrS
 rSr " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S S\5      r! " S S\5      r" " S S\5      r# " S  S!\5      r$ " S" S#\$5      r% " S$ S%\$5      r& " S& S'\5      r' " S( S)\5      r( " S* S+\(5      r) " S, S-\(5      r* " S. S/\(5      r+ " S0 S1\5      r, " S2 S3\5      r- " S4 S5\5      r. " S6 S7\.5      r/ " S8 S9\.5      r0 " S: S;\5      r1 " S< S=\5      r20 S>\)_S?\*_S@\+_SA\/_SB\0_SC\,_SD\-_SE\!_SF\"_SG\#_SH\_SI\ _SJ\&_SK\%_SL\_\\'_SM\_\\1\2SN.Er3SO/ SPQ/SQ/ SRQ/SSSDST///r4\34SU jr5\44SV jr6g)XaR  
Abstract base classes define the primitives for Tools.
These tools are used by `matplotlib.backend_managers.ToolManager`

:class:`ToolBase`
    Simple stateless tool

:class:`ToolToggleBase`
    Tool that has two states, only one Toggle tool can be
    active at any given time for the same
    `matplotlib.backend_managers.ToolManager`
    N)SimpleNamespace)WeakKeyDictionary)Gcf)_apicbookc                      \ rS rSrSr\R                  " 5       r\R                  " 5       r\R                  " 5       r	\R                  " 5       r
\R                  " 5       r\R                  " 5       r\R                  " 5       rSrg)Cursors   z!Backend-independent cursor types. N)__name__
__module____qualname____firstlineno____doc__enumautoPOINTERHANDSELECT_REGIONMOVEWAITRESIZE_HORIZONTALRESIZE_VERTICAL__static_attributes__r       J/var/www/html/env/lib/python3.13/site-packages/matplotlib/backend_tools.pyr	   r	      sS    +iikG99;DIIKM99;D99;D		iikOr   r	   c                 n    Uc  [         R                  " [        U 5      $ [        R	                  X45        U$ )zBDecorator registering *tool_cls* as a tool class for *canvas_cls*.)	functoolspartial_register_tool_class_tool_registryadd)
canvas_clstool_clss     r   r    r    4   s2      !5zBB
-.Or   c                     U R                    H1  n[        R                  " U5       H  nX#4[        ;   d  M  Us  s  $    M3     U$ )z:Find a subclass of *tool_cls* registered for *canvas_cls*.)__mro__r   recursive_subclassesr!   )r#   r$   canvas_parent
tool_childs       r   _find_tool_classr*   <   s?    #++33H=J*n<!! > , Or   viewposc                       \ rS rSrSrSr Sr Sr S r\	" S SS9r
\	" S S	S9r\	" S
 SS9rS r\	" S S SS9rS rSS jrSrg)ToolBaseI   z
Base tool class.

A base tool, only implements `trigger` method or no method at all.
The tool is instantiated by `matplotlib.backend_managers.ToolManager`.
Nc                 *    X l         Xl        S U l        g N)_name_toolmanager_figure)selftoolmanagernames      r   __init__ToolBase.__init__n   s    
'r   c                     U R                   $ r0   )r1   r4   s    r   <lambda>ToolBase.<lambda>t   s    TZZr   z@The tool id (str, must be unique among tools of a tool manager).)docc                     U R                   $ r0   )r2   r:   s    r   r;   r<   w   s
    T&&r   z+The `.ToolManager` that controls this tool.c                 L    U R                   b  U R                   R                  $ S $ r0   )r3   canvasr:   s    r   r;   r<   z   s    DLL,DT\\((N$Nr   z8The canvas of the figure affected by this tool, or None.c                     Xl         g r0   r3   r4   figures     r   
set_figureToolBase.set_figure}   s    r   c                     U R                   $ r0   rB   r:   s    r   r;   r<      s    T\\r   c                 $    U R                  U5      $ r0   )rE   rC   s     r   r;   r<      s    T__V4r   z*The Figure affected by this tool, or None.c                 (    [        U R                  S9$ )z
Return a placeholder object with a single `canvas` attribute.

This is useful to reuse the implementations of tools already provided
by the classic Toolbars.
)r@   )r   r@   r:   s    r   "_make_classic_style_pseudo_toolbar+ToolBase._make_classic_style_pseudo_toolbar   s     dkk22r   c                     g)a  
Called when this tool gets used.

This method is called by `.ToolManager.trigger_tool`.

Parameters
----------
event : `.Event`
    The canvas event that caused this tool to be called.
sender : object
    Object that requested the tool to be triggered.
data : object
    Extra data.
Nr   r4   sendereventdatas       r   triggerToolBase.trigger   s     	r   )r3   r1   r2   r0   )r   r   r   r   r   default_keymapdescriptionimager7   propertyr6   r5   r@   rE   rD   rJ   rQ   r   r   r   r   r-   r-   I   s     N K E	
 NPD &9;K NFHF ! 	58:F3r   r-   c                   x   ^  \ rS rSrSrSr Sr Sr U 4S jrSS jr	SS jr
SS jr\S	 5       rU 4S
 jrSrU =r$ )ToolToggleBase   a;  
Toggleable tool.

Every time it is triggered, it switches between enable and disable.

Parameters
----------
``*args``
    Variable length argument to be used by the Tool.
``**kwargs``
    `toggled` if present and True, sets the initial state of the Tool
    Arbitrary keyword arguments to be consumed by the Tool
NFc                 h   > UR                  SU R                  5      U l        [        TU ]  " U0 UD6  g )Ntoggled)popdefault_toggled_toggledsuperr7   r4   argskwargs	__class__s      r   r7   ToolToggleBase.__init__   s-    

9d.B.BC$)&)r   c                     U R                   (       a  U R                  U5        OU R                  U5        U R                   (       + U l         g)z5Calls `enable` or `disable` based on `toggled` value.N)r^   disableenablerM   s       r   rQ   ToolToggleBase.trigger   s/    ==LLKK MM)r   c                     g)zO
Enable the toggle tool.

`trigger` calls this method when `toggled` is False.
Nr   r4   rO   s     r   rg   ToolToggleBase.enable        	r   c                     g)a9  
Disable the toggle tool.

`trigger` call this method when `toggled` is True.

This can happen in different circumstances.

* Click on the toolbar tool button.
* Call to `matplotlib.backend_managers.ToolManager.trigger_tool`.
* Another `ToolToggleBase` derived tool is triggered
  (from the same `.ToolManager`).
Nr   rj   s     r   rf   ToolToggleBase.disable   s     	r   c                     U R                   $ )zState of the toggled tool.r^   r:   s    r   r[   ToolToggleBase.toggled   s     }}r   c                    > U R                   nU(       a+  U R                  (       a  U R                  U S 5        OSU l        [        TU ]  U5        U(       a"  U(       a  U R                  U S 5        g SU l        g g )NFT)r[   rD   rQ   r^   r_   rE   )r4   rD   r[   rc   s      r   rE   ToolToggleBase.set_figure   s\    ,,{{T4( !&6"T4( !% r   rp   r0   )r   r   r   r   r   radio_groupcursorr]   r7   rQ   rg   rf   rV   r[   rE   r   __classcell__rc   s   @r   rX   rX      sX     K F0O#**  % %r   rX   c                   J   ^  \ rS rSrSrU 4S jrU 4S jrS rS rS r	Sr
U =r$ )	ToolSetCursor   z
Change to the current cursor while inaxes.

This tool, keeps track of all `ToolToggleBase` derived tools, and updates
the cursor when a tool gets triggered.
c                   > [         TU ]  " U0 UD6  S U l        S U l        [        R
                  U l        U R                  U l        U R                  R                  SU R                  5        U R                  R                  R                  5        H=  nU R                  [        R                  R                  SU R                  U5      5        M?     g )Ntool_added_event)r_   r7   _id_drag_current_toolcursorsr   _default_cursor_last_cursorr5   toolmanager_connect_add_tool_cbktoolsvaluesmplbackend_managers	ToolEvent)r4   ra   rb   toolrc   s       r   r7   ToolSetCursor.__init__   s    $)&)!& 00,,-?-1-?-?	A$$**113Ds33=="D$4$4d < = 4r   c                    > U R                   (       a%  U R                  R                  U R                   5        [        TU ]  U5        U(       a,  U R                  R                  SU R                  5      U l         g g Nmotion_notify_event)r}   r@   mpl_disconnectr_   rE   mpl_connect_set_cursor_cbkr4   rD   rc   s     r   rE   ToolSetCursor.set_figure  sV    ==KK&&t}}56" KK33%t';';=DM r   c                     [        UR                  SS5      b>  U R                  R                  SUR                  R                   3U R
                  5        gg)zProcess every newly added tool.ru   Ntool_trigger_)getattrr   r5   r   r6   _tool_trigger_cbkrj   s     r   r   ToolSetCursor._add_tool_cbk  sJ    5::x.:00

0143I3IK ;r   c                     UR                   R                  (       a  UR                   OS U l        U R                  UR                  5        g r0   )r   r[   r~   r   canvaseventrj   s     r   r   ToolSetCursor._tool_trigger_cbk  s0    +0::+=+=UZZ4U../r   c                 <   U(       a  U R                   (       d  g U R                  (       a  [        USS 5      (       a  UR                  R	                  5       (       ap  U R
                  U R                  R                  :w  aK  U R                   R                  U R                  R                  5        U R                  R                  U l        g g U R
                  U R                  :w  a7  U R                   R                  U R                  5        U R                  U l        g g )Ninaxes)	r@   r~   r   r   get_navigater   ru   
set_cursorr   rj   s     r   r   ToolSetCursor._set_cursor_cbk  s    DKK75(D#A#ALL--//  D$6$6$=$==&&t'9'9'@'@A$($6$6$=$=! > $"6"66KK""4#7#78 $ 4 4D 7r   )r~   r   r}   r   )r   r   r   r   r   r7   rE   r   r   r   r   rv   rw   s   @r   ry   ry      s'    
==K0
5 
5r   ry   c                   >   ^  \ rS rSrSrU 4S jrU 4S jrS rSrU =r	$ )ToolCursorPositioni+  zy
Send message with the current pointer position.

This tool runs in the background reporting the position of the cursor.
c                 4   > S U l         [        TU ]  " U0 UD6  g r0   )r}   r_   r7   r`   s      r   r7   ToolCursorPosition.__init__1  s    $)&)r   c                    > U R                   (       a%  U R                  R                  U R                   5        [        TU ]  U5        U(       a,  U R                  R                  SU R                  5      U l         g g r   )r}   r@   r   r_   rE   r   send_messager   s     r   rE   ToolCursorPosition.set_figure5  sV    ==KK&&t}}56" KK33%t'8'8:DM r   c                     U R                   R                  R                  5       (       a  gSSKJn  UR                  U5      nU R                   R                  X05        g)z=Call `matplotlib.backend_managers.ToolManager.message_event`.Nr   )NavigationToolbar2)r5   messagelocklockedmatplotlib.backend_basesr   _mouse_event_to_messagemessage_event)r4   rO   r   messages       r   r   ToolCursorPosition.send_message=  sG    ''..00?$<<UC&&w5r   )r}   )
r   r   r   r   r   r7   rE   r   r   rv   rw   s   @r   r   r   +  s    
*:6 6r   r   c                   .    \ rS rSrSrSS jrS rS rSrg)	RubberbandBaseiG  zDraw and remove a rubberband.Nc                     U R                   R                  R                  R                  U5      (       d  gUb  U R                  " U6   gU R                  5         g)z<Call `draw_rubberband` or `remove_rubberband` based on data.N)rD   r@   
widgetlock	availabledraw_rubberbandremove_rubberbandrM   s       r   rQ   RubberbandBase.triggerI  sF    {{!!,,66v>>  $'""$r   c                     [         e)zA
Draw rubberband.

This method must get implemented per backend.
)NotImplementedError)r4   rP   s     r   r   RubberbandBase.draw_rubberbandR  s
     "!r   c                     g)zE
Remove rubberband.

This method should get implemented per backend.
Nr   r:   s    r   r    RubberbandBase.remove_rubberbandZ  rl   r   r   r0   )	r   r   r   r   r   rQ   r   r   r   r   r   r   r   r   G  s    '%"r   r   c                   8    \ rS rSrSrSr\" S 5      rSS jrSr	g)	ToolQuitic  /Tool to call the figure manager destroy method.zQuit the figurec                 (    [         R                  S   $ )Nzkeymap.quitr   rcParamsr:   s    r   r;   ToolQuit.<lambda>g      3<<+Fr   Nc                 D    [         R                  " U R                  5        g r0   )r   destroy_figrD   rM   s       r   rQ   ToolQuit.triggeri  s    $r   r   r0   
r   r   r   r   r   rT   rV   rS   rQ   r   r   r   r   r   r   c  s    9#KFGN%r   r   c                   8    \ rS rSrSrSr\" S 5      rSS jrSr	g)	ToolQuitAllim  r   zQuit all figuresc                 (    [         R                  S   $ )Nzkeymap.quit_allr   r:   s    r   r;   ToolQuitAll.<lambda>q  s    3<<8I+Jr   Nc                 .    [         R                  " 5         g r0   )r   destroy_allrM   s       r   rQ   ToolQuitAll.triggers  s    r   r   r0   r   r   r   r   r   r   m  s    9$KJKNr   r   c                   8    \ rS rSrSrSr\" S 5      rSS jrSr	g)	ToolGridiw  z-Tool to toggle the major grids of the figure.zToggle major gridsc                 (    [         R                  S   $ )Nkeymap.gridr   r:   s    r   r;   ToolGrid.<lambda>{  r   r   Nc                 f   [        [        R                  " 5       5      n[        R                  " X$S9   [
        R                  " SU05         [
        R                  R                  X R                  R                  5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nkeyr   struuiduuid4r   _setattr_cmr   
rc_contextbackend_baseskey_press_handlerrD   r@   r4   rN   rO   rP   sentinels        r   rQ   ToolGrid.trigger}  sn    tzz|$ 4nnmX67//{{7I7IJ 8 5477 54#   B"4B B"
B	B""
B0r   r0   r   r   r   r   r   r   w  s    7&KFGNKr   r   c                   8    \ rS rSrSrSr\" S 5      rSS jrSr	g)	ToolMinorGridi  z7Tool to toggle the major and minor grids of the figure.zToggle major and minor gridsc                 (    [         R                  S   $ )Nkeymap.grid_minorr   r:   s    r   r;   ToolMinorGrid.<lambda>      3<<8K+Lr   Nc                 f   [        [        R                  " 5       5      n[        R                  " X$S9   [
        R                  " SU05         [
        R                  R                  X R                  R                  5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr   r   r   r   s        r   rQ   ToolMinorGrid.trigger  so    tzz|$ 4nn18<=//{{7I7IJ > 54== 54r   r   r0   r   r   r   r   r   r     s    A0KLMNKr   r   c                   8    \ rS rSrSrSr\" S 5      rSS jrSr	g)	ToolFullScreeni  zTool to toggle full screen.zToggle fullscreen modec                 (    [         R                  S   $ )Nzkeymap.fullscreenr   r:   s    r   r;   ToolFullScreen.<lambda>  r   r   Nc                 `    U R                   R                  R                  R                  5         g r0   )rD   r@   managerfull_screen_togglerM   s       r   rQ   ToolFullScreen.trigger  s    ""557r   r   r0   r   r   r   r   r   r     s    %*KLMN8r   r   c                   D   ^  \ rS rSrSrSU 4S jjrSS jrSS jrSrU =r	$ )AxisScaleBasei  z3Base Tool to toggle between linear and logarithmic.c                 B   > UR                   c  g [        TU ]	  XU5        g r0   )r   r_   rQ   )r4   rN   rO   rP   rc   s       r   rQ   AxisScaleBase.trigger  s    <<t,r   c                     U R                  UR                  S5        U R                  R                  R	                  5         g )Nlog	set_scaler   rD   r@   	draw_idlerj   s     r   rg   AxisScaleBase.enable  s*    u||U+$$&r   c                     U R                  UR                  S5        U R                  R                  R	                  5         g )Nlinearr   rj   s     r   rf   AxisScaleBase.disable  s*    u||X.$$&r   r   r0   )
r   r   r   r   r   rQ   rg   rf   r   rv   rw   s   @r   r   r     s    =-
'' 'r   r   c                   4    \ rS rSrSrSr\" S 5      rS rSr	g)
ToolYScalei  zCTool to toggle between linear and logarithmic scales on the Y axis.zToggle scale Y axisc                 (    [         R                  S   $ )Nzkeymap.yscaler   r:   s    r   r;   ToolYScale.<lambda>      3<<+Hr   c                 &    UR                  U5        g r0   )
set_yscaler4   axscales      r   r   ToolYScale.set_scale      
er   r   N
r   r   r   r   r   rT   rV   rS   r   r   r   r   r   r  r        M'KHINr   r  c                   4    \ rS rSrSrSr\" S 5      rS rSr	g)
ToolXScalei  zCTool to toggle between linear and logarithmic scales on the X axis.zToggle scale X axisc                 (    [         R                  S   $ )Nzkeymap.xscaler   r:   s    r   r;   ToolXScale.<lambda>  r  r   c                 &    UR                  U5        g r0   )
set_xscaler  s      r   r   ToolXScale.set_scale  r  r   r   Nr  r   r   r   r  r    r  r   r  c                   j   ^  \ rS rSrSrU 4S jrS rS rS rSS jr	S r
SS	 jrS
 rS rS rSrU =r$ )ToolViewsPositionsi  a  
Auxiliary Tool to handle changes in views and positions.

Runs in the background and should get used by all the tools that
need to access the figure's history of views and positions, e.g.

* `ToolZoom`
* `ToolPan`
* `ToolHome`
* `ToolBack`
* `ToolForward`
c                    > [        5       U l        [        5       U l        [        5       U l        [        TU ]  " U0 UD6  g r0   )r   views	positions
home_viewsr_   r7   r`   s      r   r7   ToolViewsPositions.__init__  s3    &(
*,+-$)&)r   c                 *  ^  UT R                   ;  a  [        R                  " 5       T R                   U'   [        R                  " 5       T R                  U'   [	        5       T R
                  U'   T R                  U5        UR                  U 4S j5        gg)z;Add the current figure to the stack of views and positions.c                 &   > TR                  U 5      $ r0   )update_home_views)figr4   s    r   r;   /ToolViewsPositions.add_figure.<locals>.<lambda>  s    d.D.DS.Ir   N)r  r   _Stackr  r   r  push_currentadd_axobserverrC   s   ` r   
add_figureToolViewsPositions.add_figure  sl     #!&DJJv%*\\^DNN6"&7&9DOOF#f%!!"IJ $r   c                     XR                   ;   ah  U R                   U   R                  5         U R                  U   R                  5         U R                  U   R                  5         U R	                  5         gg)zReset the Axes stack.N)r  clearr  r  r  rC   s     r   r(  ToolViewsPositions.clear  s\    ZZJJv$$&NN6"((*OOF#))+""$	  r   c                 6   U R                   U R                     " 5       nUc  gU R                  U R                     " 5       nUc  gU R                  U R                     nU R                  R	                  5       nU H"  nXQ;   a  X   nOX5   nUR                  U5        M$     [        U5      R                  U5      (       a7  U H1  nUR                  X%   S   S5        UR                  X%   S   S5        M3     U R                  R                  R                  5         g)z
Update the view limits and position for each Axes from the current
stack position. If any Axes are present in the figure that aren't in
the current stack position, use the home view limits for those Axes and
don't update *any* positions.
Nr   original   active)r  rD   r  r  get_axes	_set_viewsetissubset_set_positionr@   r   )r4   r  posr  all_axesacur_views          r   update_viewToolViewsPositions.update_view  s     

4;;')=nnT[[)+;__T[[1
;;'')Az 8%=KK!  x=!!#&&q	:6q	84 
 	$$&r   c                 B   U(       d  U R                   n[        5       n[        5       nUR                  5        H(  nUR                  5       X$'   U R	                  U5      X4'   M*     U R
                  U   R                  U5        U R                  U   R                  U5        g)zI
Push the current view limits and position onto their respective stacks.
N)rD   r   r.  	_get_view	_axes_posr  pushr  )r4   rD   r  r3  r5  s        r   r#  ToolViewsPositions.push_current  s~     [[F!#!"A{{}EH^^A&CF # 	

6&v##C(r   c                 |    UR                  S5      R                  5       UR                  5       R                  5       4$ )a	  
Return the original and modified positions for the specified Axes.

Parameters
----------
ax : matplotlib.axes.Axes
    The `.Axes` to get the positions for.

Returns
-------
original_position, modified_position
    A tuple of the original and modified positions.
T)get_positionfrozen)r4   r	  s     r   r;  ToolViewsPositions._axes_pos  s6     %,,.!((*, 	,r   c                     U(       d  U R                   nUR                  5        H7  nX R                  U   ;  d  M  UR                  5       U R                  U   U'   M9     g)zU
Make sure that ``self.home_views`` has an entry for all Axes present
in the figure.
N)rD   r.  r  r:  )r4   rD   r5  s      r   r  $ToolViewsPositions.update_home_views+  sI     [[F"A//-.[[]'* #r   c                     U R                   U R                     R                  5         U R                  U R                     R                  5         g)z2Recall the first view and position from the stack.N)r  rD   homer  r:   s    r   rE  ToolViewsPositions.home7  4    

4;;$$&t{{#((*r   c                     U R                   U R                     R                  5         U R                  U R                     R                  5         g)z2Back one step in the stack of views and positions.N)r  rD   backr  r:   s    r   rI  ToolViewsPositions.back<  rG  r   c                     U R                   U R                     R                  5         U R                  U R                     R                  5         g)z5Forward one step in the stack of views and positions.N)r  rD   forwardr  r:   s    r   rL  ToolViewsPositions.forwardA  s4    

4;;'')t{{#++-r   )r  r  r  r0   )r   r   r   r   r   r7   r%  r(  r7  r#  r;  r  rE  rI  rL  r   rv   rw   s   @r   r  r    s@    *
K%'>),$
;+
+
. .r   r  c                   &    \ rS rSrSrSrSS jrSrg)ViewsPositionsBaseiG  z8Base class for `ToolHome`, `ToolBack` and `ToolForward`.Nc                 >   U R                   R                  [        5      R                  U R                  5        [        U R                   R                  [        5      U R                  5      " 5         U R                   R                  [        5      R                  5         g r0   )r5   get_tool_views_positionsr%  rD   r   _on_triggerr7  rM   s       r   rQ   ViewsPositionsBase.triggerL  sn    !!"23>>t{{K  ))*:;  	" 	$!!"23??Ar   r   r0   )r   r   r   r   r   rS  rQ   r   r   r   r   rO  rO  G  s    BKBr   rO  c                   6    \ rS rSrSrSrSr\" S 5      rSr	Sr
g)	ToolHomeiS  z!Restore the original view limits.zReset original viewzmpl-data/images/homec                 (    [         R                  S   $ )Nzkeymap.homer   r:   s    r   r;   ToolHome.<lambda>X  r   r   rE  r   Nr   r   r   r   r   rT   rU   rV   rS   rS  r   r   r   r   rV  rV  S  s    +'K"EFGNKr   rV  c                   6    \ rS rSrSrSrSr\" S 5      rSr	Sr
g)	ToolBacki\  z#Move back up the view limits stack.zBack to previous viewzmpl-data/images/backc                 (    [         R                  S   $ )Nzkeymap.backr   r:   s    r   r;   ToolBack.<lambda>a  r   r   rI  r   NrY  r   r   r   r[  r[  \  s    -)K"EFGNKr   r[  c                   6    \ rS rSrSrSrSr\" S 5      rSr	Sr
g)	ToolForwardie  z#Move forward in the view lim stack.zForward to next viewzmpl-data/images/forwardc                 (    [         R                  S   $ )Nzkeymap.forwardr   r:   s    r   r;   ToolForward.<lambda>j  s    3<<8H+Ir   rL  r   NrY  r   r   r   r_  r_  e  s    -(K%EIJNKr   r_  c                        \ rS rSrSrSrSrSrg)ConfigureSubplotsBasein  z,Base tool for the configuration of subplots.zConfigure subplotszmpl-data/images/subplotsr   N)r   r   r   r   r   rT   rU   r   r   r   r   rc  rc  n  s    6&K&Er   rc  c                   2    \ rS rSrSrSrSr\" S 5      rSr	g)SaveFigureBaseiu  zBase tool for figure saving.zSave the figurezmpl-data/images/filesavec                 (    [         R                  S   $ )Nzkeymap.saver   r:   s    r   r;   SaveFigureBase.<lambda>z  r   r   r   N)
r   r   r   r   r   rT   rU   rV   rS   r   r   r   r   re  re  u  s    &#K&EFGNr   re  c                   V   ^  \ rS rSrSrU 4S jrS	S jrS	S jrS	U 4S jjrS r	Sr
U =r$ )
ZoomPanBasei}  z(Base class for `ToolZoom` and `ToolPan`.c                    > [         TU ]  " U6   S U l        S U l        S U l        S U l        S U l        SU l        SU l        [        R                  " 5       U R                  -
  U l
        g )Ng       @g      ?)r_   r7   _button_pressed_xypress_idPress
_idRelease	_idScroll
base_scalescrollthreshtime
lastscrollr4   ra   rc   s     r   r7   ZoomPanBase.__init__  s[    $#))+d&7&77r   c                    U R                   R                  R                  U 5        U R                   R                  R                  SU R                  5      U l        U R                   R                  R                  SU R                  5      U l        U R                   R                  R                  SU R                  5      U l	        g)z1Connect press/release events and lock the canvas.button_press_eventbutton_release_eventscroll_eventN)
rD   r@   r   r   _pressrm  _releasern  scroll_zoomro  rj   s     r   rg   ZoomPanBase.enable  s    %%d+**66 $++/++,,88"DMM3++77D,,.r   c                    U R                  5         U R                  R                  R                  R	                  U 5        U R                  R                  R                  U R                  5        U R                  R                  R                  U R                  5        U R                  R                  R                  U R                  5        g)z7Release the canvas and disconnect press/release events.N)	_cancel_actionrD   r@   r   releaser   rm  rn  ro  rj   s     r   rf   ZoomPanBase.disable  s    %%--d3))$--8))$//:))$..9r   c                 L  > U R                   R                  [        5      R                  U R                  5        [
        TU ]  XU5        U R                  (       a  U R                  R                  5       OS nU R                  R                   H  nUR                  U5        M     g r0   )r5   rQ  rR  r%  rD   r_   rQ   r[   r6   upperaxesset_navigate_mode)r4   rN   rO   rP   new_navigate_moder	  rc   s         r   rQ   ZoomPanBase.trigger  sq    !!"23>>t{{Kt,15DIIOO-4++""B  !23 #r   c                    UR                   c  g UR                  S:X  a  U R                  nO"UR                  S:X  a  SU R                  -  nOSnUR                   nUR                  UR                  UR
                  U/5        [        R                  " 5       U R                  -
  U R                  :  a-  U R                  R                  [        5      R                  5         U R                  R                  R                  5         [        R                  " 5       U l        U R                  R                  [        5      R!                  5         g )Nupdownr,  )r   buttonrp  _set_view_from_bboxxyrr  rs  rq  r5   rQ  rR  rI  rD   r@   r   r#  )r4   rO   sclr	  s       r   r|  ZoomPanBase.scroll_zoom  s    <<<<4//C\\V#DOO#C C\\
#67 IIK'4+<+<<%%&67<<>$$&))+!!"23@@Br   )rk  rm  rn  ro  rl  rp  rs  rq  r0   )r   r   r   r   r   r7   rg   rf   rQ   r|  r   rv   rw   s   @r   ri  ri  }  s&    2	8.:4C Cr   ri  c                      ^  \ rS rSrSrSrSr\" S 5      r\	R                  rSrU 4S jrS rS	 rS
 rS rS rS rSrU =r$ )ToolZoomi  z.A Tool for zooming using a rectangle selector.zZoom to rectanglezmpl-data/images/zoom_to_rectc                 (    [         R                  S   $ )Nzkeymap.zoomr   r:   s    r   r;   ToolZoom.<lambda>  r   r   defaultc                 .   > [         TU ]  " U6   / U l        g r0   )r_   r7   	_ids_zoomrt  s     r   r7   ToolZoom.__init__  s    $r   c                    U R                    H(  nU R                  R                  R                  U5        M*     U R                  R                  SU 5        U R                  R                  R                  5         S U l        S U l        / U l         g )N
rubberband)	r  rD   r@   r   r5   trigger_toolr   rl  rk  )r4   zoom_ids     r   r  ToolZoom._cancel_action  sm    ~~GKK--g6 &%%lD9$$&#r   c           	         U R                   (       a  U R                  5         UR                  S:X  a  SU l        O)UR                  S:X  a  SU l        OU R                  5         gUR                  UR
                  p2/ U l        [        U R                  R                  5       5       H  u  pEUc  M
  Uc  M  UR                  U5      (       d  M'  UR                  5       (       d  M>  UR                  5       (       d  MU  U R                  R                  X#XTUR                  5       45        M     U R                  R                  R!                  SU R"                  5      nU R                  R                  R!                  SU R$                  5      nU R                  R                  R!                  SU R&                  5      nXgU4U l         UR(                  U l        g)z<Callback for mouse button presses in zoom-to-rectangle mode.r,     Nr   key_press_eventkey_release_event)r  r  r  rk  r  r  rl  	enumeraterD   r.  in_axesr   can_zoomappendr:  r@   r   _mouse_move_switch_on_zoom_mode_switch_off_zoom_moder   
_zoom_mode)	r4   rO   r  r  ir5  id1id2id3s	            r   rz  ToolZoom._press  sX   
 >>!<<1#$D \\Q#$D !ww1dkk2245DA!-AIIe4D4DNN$$$$aA!++-%@A 6
 kk  ,,!4#3#35kk  ,,t88:kk  ,,!;!;= 3))r   c                 H    UR                   U l        U R                  U5        g r0   )r   r  r  rj   s     r   r  ToolZoom._switch_on_zoom_mode  s    ))r   c                 4    S U l         U R                  U5        g r0   )r  r  rj   s     r   r  ToolZoom._switch_off_zoom_mode  s    r   c                    U R                   (       a  UR                  UR                  p2U R                   S   u  pEpgn[        R                  " XE/X#//UR
                  R                  UR
                  R                  5      u  u  pu  pU R                  S:X  a  UR
                  R                  u  pO(U R                  S:X  a  UR
                  R                  u  pU R                  R                  SX	XU4S9  gg)z3Callback for mouse moves in zoom-to-rectangle mode.r   r  r  r  )rP   N)rl  r  r  npclipbboxminmaxr  	intervaly	intervalxr5   r  )r4   rO   r  r  lastxlastyr5  indviewx1y1x2y2s                r   r  ToolZoom._mouse_move  s     ==77EGGq)-q)9&E!$!#!(!&&**affjj"BHRhr#%))BC'))))dbb)9 * ; r   c                 "  ^ U R                    H(  nU R                  R                  R                  U5        M*     / U l         U R                  (       d  U R                  5         g/ nU R                   H  nUR                  UR                  peUu  pxmp[        XW-
  5      S:  d  [        Xh-
  5      S:  a  U R                  5           g[        U4S jU 5       5      n[        U4S jU 5       5      nUR                  T5        U R                  S:X  a  SnOU R                  S:X  a  SnOM  TR                  XxXV4UU R                  X5        M     SU l        U R                  R                  [         5      R#                  5         U R                  5         g)	z=Callback for mouse button releases in zoom-to-rectangle mode.N   c              3   d   >#    U  H%  nTR                  5       R                  TU5      v   M'     g 7fr0   )get_shared_x_axesjoined.0a1r5  s     r   	<genexpr>$ToolZoom._release.<locals>.<genexpr>&  *     Ng++-44Q;;g   -0c              3   d   >#    U  H%  nTR                  5       R                  TU5      v   M'     g 7fr0   )get_shared_y_axesr  r  s     r   r  r  '  r  r  r,  inr  out)r  rD   r@   r   rl  r  r  r  absanyr  rk  r  r  r5   rQ  rR  r#  )r4   rO   r  done_axcur_xypressr  r  r  r  _indr  twinxtwiny	directionr5  s                 @r   r{  ToolZoom._release  sK    ~~GKK--g6 &}}!==K77EGGq*5'E!T19~!S^a%7##% NgNNENgNNENN1##q( 	%%*!	!!5"6	"&//5A) ). !!"23@@Br   )rk  r  rl  r  )r   r   r   r   r   rT   rU   rV   rS   r   r   ru   rt   r7   r  rz  r  r  r  r{  r   rv   rw   s   @r   r  r    sT    8%K*EFGN""FK $D  ;& &r   r  c                   z   ^  \ rS rSrSr\" S 5      rSrSr\	R                  rSrU 4S jrS rS	 rS
 rS rSrU =r$ )ToolPani9  z*Pan Axes with left mouse, zoom with right.c                 (    [         R                  S   $ )Nz
keymap.panr   r:   s    r   r;   ToolPan.<lambda><  s    3<<+Er   z)Pan axes with left mouse, zoom with rightzmpl-data/images/mover  c                 .   > [         TU ]  " U6   S U l        g r0   )r_   r7   r}   rt  s     r   r7   ToolPan.__init__B  s    $r   c                    S U l         / U l        U R                  R                  R	                  U R
                  5        U R                  R                  R                  U 5        U R                  R                  R                  5         g r0   )
rk  rl  rD   r@   r   r}   r5   r   r  r   r:   s    r   r  ToolPan._cancel_actionF  s]    #))$--8$$,,T2$$&r   c                    UR                   S:X  a  SU l        O)UR                   S:X  a  SU l        OU R                  5         g UR                  UR                  p2/ U l        [        U R                  R                  5       5       H  u  pEUc  M
  Uc  M  UR                  U5      (       d  M'  UR                  5       (       d  M>  UR                  5       (       d  MU  UR                  X#UR                   5        U R
                  R                  XT45        U R                  R                  U 5        U R                  R                   R#                  SU R$                  5      U l        M     g )Nr,  r  r   )r  rk  r  r  r  rl  r  rD   r.  r  r   can_pan	start_panr  r5   r   r@   r   r  r}   )r4   rO   r  r  r  r5  s         r   rz  ToolPan._pressM  s    <<1#$D \\Q#$D !ww1dkk2245DA!-AIIe4D4DNN$$A%,,/$$aV,  ,,T2 $ 2 2 > >)4+;+;!= 6r   c                    U R                   c  U R                  5         g U R                  R                  R	                  U R
                  5        U R                  R                  R                  U 5        U R                   H  u  p#UR                  5         M     U R                  (       d  U R                  5         g U R                  R                  [        5      R                  5         U R                  5         g r0   )rk  r  rD   r@   r   r}   r5   r   r  rl  end_panrQ  rR  r#  r4   rO   r5  r  s       r   r{  ToolPan._releaseb  s    '!))$--8$$,,T2}}GAIIK %}}!!!"23@@Br   c                     U R                    HA  u  p#UR                  U R                  UR                  UR                  UR
                  5        MC     U R                  R                  R                  5         g r0   )	rl  drag_panrk  r   r  r  r5   r@   r   r  s       r   r  ToolPan._mouse_moves  sR    }}GA JJt++UYYI % 	))+r   )rk  r}   rl  )r   r   r   r   r   rV   rS   rT   rU   r   r   ru   rt   r7   r  rz  r{  r  r   rv   rw   s   @r   r  r  9  sG    4EFN=K"E\\FK'=*", ,r   r  c                   V    \ rS rSrSr\" S 5      rSr\S 5       r	S r
S rS rS	 rS
rg)ToolHelpBasei{  z*Print tool list, shortcuts and descriptionc                 (    [         R                  S   $ )Nzkeymap.helpr   r:   s    r   r;   ToolHelpBase.<lambda>}  r   r   zmpl-data/images/helpc                 p    [        U 5      S:X  a  U $ [        R                  " SSU 5      R                  5       $ )z
Convert a shortcut string from the notation used in rc config to the
standard notation for displaying shortcuts, e.g. 'ctrl+a' -> 'Ctrl+A'.
r,  z\+[A-Z]z+Shift\g<0>)lenresubtitle)key_sequences    r   format_shortcutToolHelpBase.format_shortcut  s8     !$L 1Q 6 	Jz><@FFH	Jr   c                 p   ^  T R                   R                  U5      nSR                  U 4S jU 5       5      $ )Nz, c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr0   )r  )r  keymapr4   s     r   r  3ToolHelpBase._format_tool_keymap.<locals>.<genexpr>  s     LG&--f55Gs   !)r5   get_tool_keymapjoin)r4   r6   keymapss   `  r   _format_tool_keymap ToolHelpBase._format_tool_keymap  s.    ""2248yyLGLLLr   c                     [        U R                  R                  R                  5       5       VVs/ s H5  u  pUR                  (       d  M  XR                  U5      UR                  4PM7     snn$ s  snnf r0   )sortedr5   r   itemsrT   r  )r4   r6   r   s      r   _get_help_entriesToolHelpBase._get_help_entries  se    "()9)9)?)?)E)E)G"H%"HJD## I//5t7G7GH"H% 	% %s   A1!A1c                     U R                  5       nU Vs/ s H  nSR                  " U6 PM     nnSR                  U5      $ s  snf )Nz
{}: {}
	{}
)r  formatr  )r4   entriesentrys      r   _get_help_textToolHelpBase._get_help_text  sD    ((*>EFgU>((%0gFyy!! Gs   Ac                     SnUR                  SSS5      /nX R                  5        Vs/ s H  o1R                   " U6 PM     sn-  nSUS   -   SR                  USS  5      -   S	-   $ s  snf )
Nz*<tr><td>{}</td><td>{}</td><td>{}</td></tr>z<b>Action</b>z<b>Shortcuts</b>z<b>Description</b>z2<style>td {padding: 0px 4px}</style><table><thead>r   z</thead><tbody>r,  z</tbody></table>)r  r  r  )r4   fmtrowsrows       r   _get_help_htmlToolHelpBase._get_help_html  s    :

/1EG H-C-C-EF-EcS!-EFF!#'7+.$tABx.)+=> 	? Gs   A&r   N)r   r   r   r   rT   rV   rS   rU   staticmethodr  r  r  r  r  r   r   r   r   r  r  {  s@    >KFGN"EJ JM%
"
?r   r  c                   4    \ rS rSrSrSr\" S 5      rS rSr	g)ToolCopyToClipboardBasei  z)Tool to copy the figure to the clipboard.z#Copy the canvas figure to clipboardc                 (    [         R                  S   $ )Nzkeymap.copyr   r:   s    r   r;    ToolCopyToClipboardBase.<lambda>  r   r   c                 >    SnU R                   R                  X05        g )NzCopy tool is not available)r5   r   )r4   ra   rb   r   s       r   rQ   ToolCopyToClipboardBase.trigger  s    .&&w5r   r   Nr   r   r   r   r  r    s    37KFGN6r   r  rE  rI  rL  zoompansubplotssavegrid
grid_minor
fullscreenquitquit_allxscaleyscalepositionru   )r  helpcopy
navigation)rE  rI  rL  zoompan)r  r  r   ior*  c                 X    UR                  5        H  u  p#U R                  X#5        M     g)a)  
Add multiple tools to a `.ToolManager`.

Parameters
----------
toolmanager : `.backend_managers.ToolManager`
    Manager to which the tools are added.
tools : {str: class_like}, optional
    The tools to add in a {name: tool} dict, see
    `.backend_managers.ToolManager.add_tool` for more info.
N)r  add_tool)r5   r   r6   r   s       r   add_tools_to_managerr1    s$     kkm
T( $r   c                 f    U H+  u  p#[        U5       H  u  pEU R                  XRU5        M     M-     g)a  
Add multiple tools to the container.

Parameters
----------
container : Container
    `.backend_bases.ToolContainerBase` object that will get the tools
    added.
tools : list, optional
    List in the form ``[[group1, [tool1, tool2 ...]], [group2, [...]]]``
    where the tools ``[tool1, tool2, ...]`` will display in group1.
    See `.backend_bases.ToolContainerBase.add_tool` for details.
N)r  r0  )	containerr   group
grouptoolsr)  r   s         r   add_tools_to_containerr6    s2     #'
3NHtH5 4 #r   r0   )7r   r   r   r  rr  typesr   r   weakrefr   numpyr  
matplotlibr   matplotlib._pylab_helpersr   r   r   IntEnumr	   r   r0  r!   r    r*   rR  r-   rX   ry   r   r   r   r   r   r   r   r   r  r  r  rO  rV  r[  r_  rc  re  ri  r  r  r  r  default_toolsdefault_toolbar_toolsr1  r6  r   r   r   <module>r?     s     	  !  %   ) ""dll "    V VrT%X T%n/5H /5d6 68X 8%x %( Kx KKH K8X 8'N '"  @. @.F	B 	B! ! $ 'H 'HX H@C. @CFv{ vr?,k ?,D#?8 #?L6h 6 68 Y #('2  	
 } ~  [ : : / "#5 =  .%0!& '(CD#%@A 013 
 -: )" -B 6r   