B
    \c                 @   sB   d dl mZ ddlmZ ddlmZmZ dgZG dd deZdS )	   )Plugin   )RectangleTool   )SaveButtonsButtonCropc                   sF   e Zd Zd Zd fdd	Z fddZdd Zdd	 Zd
d Z  Z	S )r   
   c                s4   t t| jf | || _| t  t|   d S )N)superr   __init__maxdist
add_widgetr   printhelp)selfr   kwargs)	__class__ :lib/python3.7/site-packages/skimage/viewer/plugins/crop.pyr      s    zCrop.__init__c                sP   t t| | t|| j| jd| _| j| j t	d| j
| _| | j d S )N)r   Zon_enterZReset)r
   r   attachr   r   crop	rect_toolZartistsappendr   resetZreset_buttonr   )r   image_viewer)r   r   r   r      s    zCrop.attachc             C   s   d}d |S )N)z	Crop toolz2Select rectangular region and press enter to crop.
)join)r   Zhelpstrr   r   r   r      s    z	Crop.helpc             C   sX   |\}}}}||ks||kr d S | j j||d ||d f }|| j _| j j  d S )Nr   )r   imageaxrelim)r   extentsZxminZxmaxZyminZymaxr   r   r   r   r   "   s     z	Crop.cropc             C   s$   d| j _| jj| j_| jj  d S )N)iiii)r   r    r   Zoriginal_imager   r   r   )r   r   r   r   r   *   s    z
Crop.reset)r	   )
__name__
__module____qualname__namer   r   r   r   r   __classcell__r   r   )r   r   r   	   s   N)	baser   Zcanvastoolsr   Zviewer.widgetsr   r   __all__r   r   r   r   r   <module>   s   