o
    :ήce	                     @   sV   d dl ZddlmZ ddlmZ ddlmZmZ ddl	m
Z
 dgZG d	d de
ZdS )
    N   )QtGui)new_plot)BlitManagerEventManager   )Plugin
PlotPluginc                       sZ   e Zd ZdZd fdd	Z fddZd	d
 Zdd Z fddZdd Z	dd Z
  ZS )r	   zPlugin for ImageViewer that contains a plot canvas.

    Base class for plugins that contain a Matplotlib plot canvas, which can,
    for example, display an image histogram.

    See base Plugin class for additional details.
    N     c                    s@   t t| jd|||d| || _|| _d | _g | _d | _d S )N)image_filterheightwidth )superr	   __init___height_width_blit_manager_tools_event_manager)selfr   r   r   kwargs	__class__r   H/tmp/pip-target-vg8gfxp4/lib/python/skimage/viewer/plugins/plotplugin.pyr      s   
zPlotPlugin.__init__c                    s:   t t| | |   |jrt| j| _t| j| _	d S N)
r   r	   attachadd_plotuseblitr   axr   r   r   )r   image_viewerr   r   r   r      s
   zPlotPlugin.attachc                 C   s   | j   dS )zRedraw plot.N)canvas	draw_idle)r   r   r   r   redraw'   s   zPlotPlugin.redrawc                 C   s   t  \| _| _| j| jt| jj  | j| jt| jj  | jj	| _	t
 }|t
jj}|  }t|rBt|d }| jj| | j| j	| jd d S )Ng     o@r   )r   figr    set_figwidthr   floatdpiset_figheightr   r"   r   QPalettecolorWindowtoRgbvaluenpisscalarstrpatchset_facecolorlayout	addWidgetrow)r   qpaletteqcolorbgcolorr   r   r   r   +   s   

zPlotPlugin.add_plotc                    s   t t| | |   d S r   )r   r	   _update_original_imager$   )r   imager   r   r   r:   :   s   z!PlotPlugin._update_original_imagec                 C   s0   | j r
| j |j | j| | j| d S r   )r   add_artistsartistsr   appendr   r   r   toolr   r   r   add_tool>   s   zPlotPlugin.add_toolc                 C   s>   || j vrd S | jr| j|j | j | | j| d S r   )r   r   remove_artistsr=   remover   detachr?   r   r   r   remove_toolD   s   
zPlotPlugin.remove_tool)Nr
   r   )__name__
__module____qualname____doc__r   r   r$   r   r:   rA   rE   __classcell__r   r   r   r   r	      s    
)numpyr/   qtr   utilsr   utils.canvasr   r   baser   __all__r	   r   r   r   r   <module>   s    