o
    :ήcj                     @   sd  d dl mZ d dlZd dlmZ d dlZed d dlm	Z	 d dl
mZmZ d dlmZmZmZmZ d dlmZ zd d	lmZ W n eyN   d
d ZY nw dd ZdddZeejje dddd Zeejje dddd Zeejje dddd Zeejje ddejde	 e	  gdd Z!eejje dddd Z"dS )    )
namedtupleN)assert_equal
matplotlib)data)ImageViewerhas_qt)LineToolThickLineToolRectangleTool	PaintTool)CanvasToolBase)cleanupc                 C   s   | S )N )funcr   r   F/tmp/pip-target-vg8gfxp4/lib/python/skimage/viewer/tests/test_tools.pyr      s   r   c                 C   sB   | j dd \}}|d d| d g}|d gd }t||gS )Nr         )shapenp	transpose)imagehwxyr   r   r   get_end_points   s   r      c           	      C   s   | j }tdd}||_|j||f\|_|_|||_|_||_	|j
j|_||_d|_d|_d|_t| jd| }|| dS )a  
     *name*
        the event name

    *canvas*
        the FigureCanvas instance generating the event

    *guiEvent*
        the GUI event that triggered the matplotlib event

    *x*
        x position - pixels from left of canvas

    *y*
        y position - pixels from bottom of canvas

    *inaxes*
        the :class:`~matplotlib.axes.Axes` instance if mouse is over axes

    *xdata*
        x coord of mouse in data coords

    *ydata*
        y coord of mouse in data coords

     *button*
        button pressed None, 1, 2, 3, 'up', 'down' (up and down are used
        for scroll events)

    *key*
        the key depressed when the mouse event triggered (see
        :class:`KeyEvent`)

    *step*
        number of scroll steps (positive for 'up', negative for 'down')
    Eventz;name canvas guiEvent x y inaxes xdata ydata button key stepr   NCustomzon_%s)axr   button	transData	transformr   r   xdataydatainaxesfigurecanvaskeystepguiEventnamegetattr_event_manager)	vieweretyper    r#   r$   r(   r   eventr   r   r   r   do_event   s   %
r1   zQt not installed)reasonc                  C   s   t  } t| }t|dtddtddd}t| |_t|jt	ddgd	dgg t
|d
ddd t
|dddd t
|d t|jt	ddgd	dgg t
|d
ddd t
|dddd t
|d t|jt	ddgddgg d S )N
   r   )	linewidth   
markersizemaxdist
line_propshandle_props      iU  mouse_pressr#   r$   move   i  mouse_released   )r   camerar   r   dictr   
end_pointsr   r   arrayr1   geometryimgr.   toolr   r   r   test_line_toolS   s   


"rL   c                  C   s   t  } t| }t|dtddtddd}t| |_t|ddd	 t|j	d
 t|ddd	 t|j	d t|ddd t|j	d
 t|ddd t|j	d d S )Nr3   red)colorr5   r6   r8   scrollup)r    r   downr   	key_press+r(   -)
r   rD   r   r	   rE   r   rF   r1   r   r4   rI   r   r   r   test_thick_line_toolm   s   
rV   c                  C   s   t  } t| }t|dd}d|_t|jd t|jd t|jd t|jd t	|dddd t	|d	d
d
d t	|d t	|dddd t	|d	ddd t	|d t|jg d d S )Nr3   )r9   )rC      rC   rW   ))rC   rW   rW   rC   )rC   rC   rW   rW   ))rC        @_@rW   rX   )rX   rC   rX   rW   r>   rC   r?   r@   x   rB   )r3   rC   r3   rC   )
r   rD   r   r
   extentsr   cornersedge_centersrH   r1   rI   r   r   r   test_rect_tool   s&   

r]   rJ   c                 C   s2  t | }t|| j}d|_t|jd d|_t|jd t|j| jd d  t|dddd t|dddd t|d t|j|jdk jd	 d
|_t|dddd t|dddd t|d t|j|jd
k jd t|j|jdk jd	 t|ddd |jd |_t|j	 d t|j
j|jjj d S )Nr3   r   r>   rC   r?   r@   n   rB   i  r5      (   iq  rR   enterrT   r   )r   r   r   radiusr   labelr1   overlaysizesumcmapN_overlay_plotnormvmaxrI   r   r   r   test_paint_tool   s*   

rl   c                  C   sb   t  } t| }t|}|d |d t|ddd |  |  t|dd}|  d S )NFTrR   ra   rT   )useblit)r   moonr   r   set_visibler1   redrawremoverI   r   r   r   test_base_tool   s   

rr   )r   r   r   N)#collectionsr   numpyr   numpy.testingr   pytestimportorskipskimager   skimage.viewerr   r   skimage.viewer.canvastoolsr   r	   r
   r   skimage.viewer.canvastools.baser   matplotlib.testing.decoratorsr   ImportErrorr   r1   markskipifrL   rV   r]   parametrizern   	astronautrl   rr   r   r   r   r   <module>   s@    

7 