
    h.                     n    S SK JrJrJrJr   " S S5      r " S S\5      r " S S5      r " S S	5      rg
)    )_apibackend_toolscbookwidgetsc                   "    \ rS rSrSrSS jrSrg)	ToolEvent   z)Event for tool manipulation (add/remove).Nc                 4    Xl         X l        X0l        X@l        g N)namesendertooldata)selfr   r   r   r   s        M/var/www/html/env/lib/python3.13/site-packages/matplotlib/backend_managers.py__init__ToolEvent.__init__   s    			    )r   r   r   r   r   __name__
__module____qualname____firstlineno____doc__r   __static_attributes__ r   r   r   r      s
    3r   r   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )ToolTriggerEvent   z/Event to inform that a tool has been triggered.c                 2   > [         TU ]  XX55        X@l        g r   )superr   canvasevent)r   r   r   r   r"   r   	__class__s         r   r   ToolTriggerEvent.__init__   s    t2&r   r"   )NN)r   r   r   r   r   r   r   __classcell__)r#   s   @r   r   r      s    9' 'r   r   c                       \ rS rSrSrS rSrg)ToolManagerMessageEvent   zg
Event carrying messages from toolmanager.

Messages usually get displayed to the user by the toolbar.
c                 (    Xl         X l        X0l        g r   )r   r   message)r   r   r   r+   s       r   r    ToolManagerMessageEvent.__init__   s    	r   )r+   r   r   Nr   r   r   r   r(   r(      s    
r   r(   c                       \ rS rSrSrSS jr\S 5       r\S 5       r\R                  S 5       rSS jr
S	 rS
 rSS jr\S 5       rS rS rS rS rS rS rSS jrS r\S 5       rSS jrSrg)ToolManager    av  
Manager for actions triggered by user interactions (key press, toolbar
clicks, ...) on a Figure.

Attributes
----------
figure : `.Figure`
keypresslock : `~matplotlib.widgets.LockDraw`
    `.LockDraw` object to know if the `canvas` key_press_event is locked.
messagelock : `~matplotlib.widgets.LockDraw`
    `.LockDraw` object to know if the message is available to write.
Nc                    S U l         0 U l        0 U l        0 U l        [        R
                  " 5       U l        [        R                  " 5       U l	        [        R                  " 5       U l
        S U l        U R                  U5        g r   )_key_press_handler_id_tools_keys_toggledr   CallbackRegistry
_callbacksr   LockDrawkeypresslockmessagelock_figure
set_figurer   figures     r   r   ToolManager.__init__.   sf    %)"
002 $,,."++-r   c                 R    U R                   (       d  gU R                   R                  $ )z Canvas managed by FigureManager.N)r:   canvasr   s    r   r@   ToolManager.canvas>   s     ||||"""r   c                     U R                   $ )zFigure that holds the canvas.)r:   rA   s    r   r=   ToolManager.figureE   s     ||r   c                 &    U R                  U5        g r   )r;   r<   s     r   r=   rD   J   s    r   c                 >   U R                   (       a%  U R                  R                  U R                   5        Xl        U(       a+  U R                  R	                  SU R
                  5      U l         U(       a(  U R                  R                  5        H	  nXl        M     gg)z
Bind the given figure to the tools.

Parameters
----------
figure : `.Figure`
update_tools : bool, default: True
    Force tools to update figure.
key_press_eventN)	r1   r@   mpl_disconnectr:   mpl_connect
_key_pressr2   valuesr=   )r   r=   update_toolsr   s       r   r;   ToolManager.set_figureN   sq     %%KK&&t'A'AB)-)@)@!4??*4D&**,$ - r   c                 8    U R                   R                  X5      $ )a=  
Connect event with string *s* to *func*.

Parameters
----------
s : str
    The name of the event. The following events are recognized:

    - 'tool_message_event'
    - 'tool_removed_event'
    - 'tool_added_event'

    For every tool added a new event is created

    - 'tool_trigger_TOOLNAME', where TOOLNAME is the id of the tool.

func : callable
    Callback function for the toolmanager event with signature::

        def func(event: ToolEvent) -> Any

Returns
-------
cid
    The callback id for the connection. This can be used in
    `.toolmanager_disconnect`.
)r6   connect)r   sfuncs      r   toolmanager_connectToolManager.toolmanager_connectb   s    8 &&q//r   c                 8    U R                   R                  U5      $ )z
Disconnect callback id *cid*.

Example usage::

    cid = toolmanager.toolmanager_connect('tool_trigger_zoom', onpress)
    #...later
    toolmanager.toolmanager_disconnect(cid)
)r6   
disconnect)r   cids     r   toolmanager_disconnect"ToolManager.toolmanager_disconnect   s     ))#..r   c                 `    Uc  U nSn[        X2U5      nU R                  R                  X45        g)z!Emit a `ToolManagerMessageEvent`.Ntool_message_event)r(   r6   process)r   r+   r   rP   events        r   message_eventToolManager.message_event   s/    >F '7;)r   c                     U R                   $ )zCurrently toggled tools.)r4   rA   s    r   active_toggleToolManager.active_toggle   s     }}r   c                 |    U R                   R                  5        VVs/ s H  u  p#X1:X  d  M  UPM     nnnU$ s  snnf )z
Return the keymap associated with the specified tool.

Parameters
----------
name : str
    Name of the Tool.

Returns
-------
list of str
    List of keys associated with the tool.
)r3   items)r   r   kikeyss        r   get_tool_keymapToolManager.get_tool_keymap   s7     #jj..0>0daAI0> ?s   88c                 N    U R                  U5       H  nU R                  U	 M     g r   )rg   r3   )r   r   rd   s      r   _remove_keysToolManager._remove_keys   s"    %%d+A

1 ,r   c           	      6   XR                   ;  a  [        U< S35      eU R                  U5        [        U[        5      (       a  U/nU HL  nX0R
                  ;   a,  [        R                  " SU SU R
                  U    SU 35        XR
                  U'   MN     g)z
Set the keymap to associate with the specified tool.

Parameters
----------
name : str
    Name of the Tool.
key : str or list of str
    Keys to associate with the tool.
z not in ToolszKey z changed from z to N)r2   KeyErrorrj   
isinstancestrr3   r   warn_external)r   r   keyrd   s       r   update_keymapToolManager.update_keymap   s     {{"dX]344$c3%CAJJ""1#^DJJqM?$tfEG JJqM	 r   c                    U R                  U5      n[        USS5      (       a  U R                  US5        U R                  U5        [	        SX5      nU R
                  R                  UR                  U5        U R                  U	 g)zS
Remove tool named *name*.

Parameters
----------
name : str
    Name of the tool.
toggledFtoolmanagertool_removed_eventN)	get_toolgetattrtrigger_toolrj   r   r6   r[   r   r2   )r   r   r   r\   s       r   remove_toolToolManager.remove_tool   sp     }}T"4E**dM2$.;

E2KKr   c                 R   [         R                  " [        U R                  5      U5      nU(       d  [	        S[        U5      -  5      eXR                  ;   a%  [        R                  " S5        U R                  U   $ U" X/UQ70 UD6nX`R                  U'   UR                  b  U R                  XR                  5        [        U[         R                  5      (       a|  UR                  c%  U R                  R                  S[!        5       5        O&U R                  R                  UR                  S5        UR"                  (       a  U R%                  USS5        UR'                  U R(                  5        [+        SX5      nU R,                  R/                  UR0                  U5        U$ )a&  
Add *tool* to `ToolManager`.

If successful, adds a new event ``tool_trigger_{name}`` where
``{name}`` is the *name* of the tool; the event is fired every time the
tool is triggered.

Parameters
----------
name : str
    Name of the tool, treated as the ID, has to be unique.
tool : type
    Class of the tool to be added.  A subclass will be used
    instead if one was registered for the current canvas class.
*args, **kwargs
    Passed to the *tool*'s constructor.

See Also
--------
matplotlib.backend_tools.ToolBase : The base class for tools.
zImpossible to find class for %sz;A "Tool class" with the same name already exists, not addedNtool_added_event)r   _find_tool_classtyper@   
ValueErrorro   r2   r   rp   default_keymaprr   rn   ToolToggleBaseradio_groupr4   
setdefaultsetru   _handle_toggler;   r=   r   r6   r[   r   )r   r   r   argskwargstool_clstool_objr\   s           r   add_toolToolManager.add_tool   sO   . !11$t{{2CTJ>TJKK;;  3 4;;t$$D888$D"".t%<%<= h < <== ##+((su5(()=)=tD ##HdD9DKK(,d=

E2r   c                    UR                   nUco  UR                  U R                  S   ;   a)  U R                  S   R                  UR                  5        gU R                  S   R	                  UR                  5        gU R                  U   UR                  :X  a  SnOJU R                  U   c  UR                  nO-U R                  U R                  U   U UU5        UR                  nXPR                  U'   g)z
Toggle tools, need to untoggle prior to using other Toggle tool.
Called from trigger_tool.

Parameters
----------
tool : `.ToolBase`
canvasevent : Event
    Original Canvas event or None.
data : object
    Extra data to pass to the tool when triggering.
N)r   r   r4   removeaddrz   )r   r   r"   r   r   ru   s         r   r   ToolManager._handle_toggle  s     && yyDMM$//d#**4995  d#''		2 ==%2G ]];'/iiG dmmK8")"$ iiG &-k"r   c                    U R                  U5      nUc  gUc  U n[        U[        R                  5      (       a  U R	                  XSU5        UR                  X#U5        SU-  n[        XbXSU5      nU R                  R                  Xg5        g)a)  
Trigger a tool and emit the ``tool_trigger_{name}`` event.

Parameters
----------
name : str
    Name of the tool.
sender : object
    Object that wishes to trigger the tool.
canvasevent : Event
    Original Canvas event or None.
data : object
    Extra data to pass to the tool when triggering.
Nztool_trigger_%s)	rx   rn   r   r   r   triggerr   r6   r[   )r   r   r   r"   r   r   rP   r\   s           r   rz   ToolManager.trigger_tool;  s     }}T"<>FdM889948V$/$ DtD)r   c                     UR                   b  U R                  R                  5       (       a  g U R                  R	                  UR                   S 5      nUc  g U R                  X!S9  g )Nr%   )rq   r8   lockedr3   getrz   )r   r\   r   s      r   rJ   ToolManager._key_pressZ  sT    99 1 1 8 8 : :zz~~eii.<$2r   c                     U R                   $ )z,A dict mapping tool name -> controlled tool.)r2   rA   s    r   toolsToolManager.toolsc  s     {{r   c                     [        U[        R                  5      (       a  UR                  U R                  ;   a  U$ XR                  ;  a"  U(       a  [
        R                  " SU< 35        gU R                  U   $ )a  
Return the tool object with the given name.

For convenience, this passes tool objects through.

Parameters
----------
name : str or `.ToolBase`
    Name of the tool, or the tool itself.
warn : bool, default: True
    Whether a warning should be emitted it no tool with the given name
    exists.

Returns
-------
`.ToolBase` or None
    The tool or None if no tool with the given name exists.
z"ToolManager does not control tool N)rn   r   ToolBaser   r2   r   rp   )r   r   warns      r   rx   ToolManager.get_toolh  sd    & t]3344II,K{{"""8AC{{4  r   )r6   r:   r1   r3   r4   r2   r8   r9   r   )T)NNN)r   r   r   r   r   r   propertyr@   r=   setterr;   rR   rW   r]   r`   rg   rj   rr   r{   r   r   rz   rJ   r   rx   r   r   r   r   r.   r.       s       # #   ]]   %(0<
/*  $!,"7r)-V*>3  !r   r.   N)	
matplotlibr   r   r   r   r   r   r(   r.   r   r   r   <module>r      s7    : : 'y '	 	c! c!r   