3
ÌœŸW,  ã               @   sp   d Z ddlmZmZmZ ddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ G dd	„ d	eƒZd
S )z6A simple ImagePlaneWidget module to view image data.

é    )ÚInstanceÚBoolÚon_trait_change)ÚViewÚGroupÚItem)Útvtk)ÚModule)Úerror)ÚPipelineInfoc               @   s”   e Zd ZdZeejddd�Zeddd�Z	e
dgdgd	gd
�Zeeedddd�dd�ddddd�Zdd„ Zdd„ Zdd„ Zedƒdd„ ƒZdd„ ZdS )ÚImagePlaneWidgetr   FT)Ú
allow_noneÚrecordz1Use a lookup table to map input scalars to colors)ÚhelpÚ
image_dataÚanyÚscalars)ÚdatasetsÚattribute_typesÚ
attributesÚipwÚcustom)ÚnameÚstyleÚ	resizable)Úshow_labelsiX  )ÚwidthÚheightr   Ú
scrollablec             C   s"   t jdddddd�| _| jƒ  dS )a  Override this method so that it *creates* the tvtk
        pipeline.

        This method is invoked when the object is initialized via
        `__init__`.  Note that at the time this method is called, the
        tvtk data pipeline will *not* yet be setup.  So upstream data
        will not be available.  The idea is that you simply create the
        basic objects and setup those parts of the pipeline not
        dependent on upstream sources and filters.  You should also
        set the `actors` attribute up at this point.
        é   r   T)Zdisplay_textZkey_press_activationZleft_button_actionZmiddle_button_actionZuser_controlled_lookup_tableN)r   r   r   Ú	setup_lut)Úself© r"   úd/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/modules/image_plane_widget.pyÚsetup_pipeline0   s    
zImagePlaneWidget.setup_pipelinec             C   sj   | j }|dkrdS |jjd }|jjƒ }|jdƒp:|jdƒsPd}t|ƒ t|ƒ‚| j| j|ƒ | j	ƒ  dS )zêOverride this method so that it *updates* the tvtk pipeline
        when data upstream is known to have changed.

        This method is invoked (automatically) when any of the inputs
        sends a `pipeline_changed` event.
        Nr   ÚvtkStructuredPointsÚvtkImageDataz?ImagePlaneWidget only supports structured points or image data.)
Úmodule_managerÚsourceÚoutputsZget_output_datasetÚis_ar
   Ú	TypeErrorÚconfigure_inputr   r    )r!   Zmod_mgrÚinputÚdatasetÚmsgr"   r"   r#   Úupdate_pipelineE   s    


z ImagePlaneWidget.update_pipelinec             C   s
   d| _ dS )zÌOverride this method so that it flushes the vtk pipeline if
        that is necessary.

        This method is invoked (automatically) when any of the inputs
        sends a `data_changed` event.
        TN)Zdata_changed)r!   r"   r"   r#   Úupdate_data]   s    zImagePlaneWidget.update_dataÚuse_lookup_tablec             C   s6   | j r | jd k	r*| jjj| j_n
d | jj_| jƒ  d S )N)r2   r'   Zscalar_lut_managerZlutr   Zlookup_tableZ	color_mapÚrender)r!   r"   r"   r#   r    h   s
    

zImagePlaneWidget.setup_lutc             C   sV   |d k	r$|j | jdd� | jj|ƒ |j | jƒ | jj|ƒ |d k	rL| jƒ  d| _d S )NT)Úremove)r   r3   Zwidgetsr4   Úappendr0   Zpipeline_changed)r!   ÚoldÚnewr"   r"   r#   Ú_ipw_changedv   s    zImagePlaneWidget._ipw_changedN)Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r   r   r   r2   r   Ú
input_infor   r   r   Úviewr$   r0   r1   r   r    r8   r"   r"   r"   r#   r      s$   
r   N)Ú__doc__Ú
traits.apir   r   r   Útraitsui.apir   r   r   Útvtk.apir   Zmayavi.core.moduler	   Úmayavi.core.commonr
   Úmayavi.core.pipeline_infor   r   r"   r"   r"   r#   Ú<module>   s   