o
    Õj˜  ã                   @   sN   d Z ddlmZ ddlmZ dd„ Zdd„ Zdd	d
„Zddd„Z	ddd„Z
dS )z|
========================
Widget testing utilities
========================

See also :mod:`matplotlib.tests.test_widgets`.
é    )ÚmockNc                  C   s<   t  dd¡\} }| ddgddg¡ | d¡ | j ¡  |S )z"Create a plot and return its Axes.é   r   éÈ   g      ð?)ÚpltZsubplotsZplotZ
set_aspectÚcanvasZdraw)ZfigÚax© r   ú[/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/matplotlib/testing/widgets.pyÚget_ax   s
   

r
   c                  O   s   d S ©Nr   )ÚargsÚkwargsr   r   r	   Únoop   s   r   r   c                 C   sr   t  ¡ }||_| j ||f||fg¡d \|_|_|||_|_| |_	| j
ddj|_||_||_d|_d|_|S )a  
    Create a mock event that can stand in for `.Event` and its subclasses.

    This event is intended to be used in tests where it can be passed into
    event handling functions.

    Parameters
    ----------
    ax : `~matplotlib.axes.Axes`
        The Axes the event will be in.
    xdata : float
        x coord of mouse in data coords.
    ydata : float
        y coord of mouse in data coords.
    button : None or `MouseButton` or {'up', 'down'}
        The mouse button pressed in this event (see also `.MouseEvent`).
    key : None or str
        The key pressed when the mouse event triggered (see also `.KeyEvent`).
    step : int
        Number of scroll steps (positive for 'up', negative for 'down').

    Returns
    -------
    event
        A `.Event`\-like Mock instance.
    r   T)ÚrootNZCustom)r   ZMockÚbuttonZ	transDataÚ	transformÚxÚyÚxdataÚydataZinaxesZ
get_figurer   ÚkeyÚstepZguiEventÚname)r   r   r   r   r   r   Úeventr   r   r	   Ú
mock_event   s   ÿÿr   c           	      C   s*   t | j|||||ƒ}t| |ƒ}||ƒ dS )aT  
    Trigger an event on the given tool.

    Parameters
    ----------
    tool : matplotlib.widgets.AxesWidget
    etype : str
        The event to trigger.
    xdata : float
        x coord of mouse in data coords.
    ydata : float
        y coord of mouse in data coords.
    button : None or `MouseButton` or {'up', 'down'}
        The mouse button pressed in this event (see also `.MouseEvent`).
    key : None or str
        The key pressed when the mouse event triggered (see also `.KeyEvent`).
    step : int
        Number of scroll steps (positive for 'up', negative for 'down').
    N)r   r   Úgetattr)	ÚtoolÚetyper   r   r   r   r   r   Úfuncr   r   r	   Údo_eventD   s   
r   c                 C   sž   |durt | d|d |d d|d t | d|d |d dd t | d|d |d dd t | d	|d |d dd |durMt | d
|d |d d|d dS dS )a}  
    Helper to simulate a mouse drag operation.

    Parameters
    ----------
    tool : `~matplotlib.widgets.Widget`
    start : [float, float]
        Starting point in data coordinates.
    end : [float, float]
        End point in data coordinates.
    key : None or str
         An optional key that is pressed during the whole operation
         (see also `.KeyEvent`).
    NZon_key_pressr   r   )r   r   r   r   Zpress)r   r   r   ZonmoveÚreleaseZon_key_release)r   )r   ÚstartÚendr   r   r   r	   Úclick_and_drag]   s   ÿ
ÿþr#   )r   r   r   Nr   r   )Ú__doc__Zunittestr   Zmatplotlib.pyplotZpyplotr   r
   r   r   r   r#   r   r   r   r	   Ú<module>   s    	

)