3
©f‘[t  ã               @   sd   d Z ddlmZmZ ddl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 )z@Draws a surface for any input dataset with optional contouring.
é    )ÚInstanceÚBool)Útvtk)ÚPipelineInfo)ÚModule)ÚContour)ÚActorc               @   s„   e Zd ZdZeddd�Zeeddd�Zee	ddd�Z
edgdgdgd�Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚSurfacer   Fzif contours are generated)ÚdescT)Ú
allow_noneÚrecordÚany)ÚdatasetsÚattribute_typesÚ
attributesc             C   s$   t ddd�| _tƒ | _d| j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.
        Té
   )Zauto_contoursZnumber_of_contoursg       @N)r   Úcontourr   ÚactorÚpropertyÚ
line_width)Úself© r   úY/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/modules/surface.pyÚsetup_pipeline*   s    zSurface.setup_pipelinec             C   s8   | j }|dkrdS | j| jƒ | jj|jjƒ d| _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.
        NT)Úmodule_managerÚ_enable_contours_changedÚenable_contoursr   Zset_lutZscalar_lut_managerZlutZpipeline_changed)r   Úmmr   r   r   Úupdate_pipeline<   s    zSurface.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_dataP   s    	zSurface.update_datac             C   s&   |rd| j j_n
d| j j_| jƒ  dS )z”When filled contours are enabled, the mapper should use the
        the cell data, otherwise it should use the default scalar
        mode.
        Úuse_cell_dataÚdefaultN)r   ÚmapperÚscalar_modeÚrender)r   Úvaluer   r   r   Ú_filled_contours_changed^   s    
z Surface._filled_contours_changedc             C   sl   | j dkrdS |r@| j jg| j_| jg| j_| jjr`d| jj_n | jj}| j jg| j_d| jj_| jƒ  dS )zTurns on and off the contours.Nr    r!   )	r   Úsourcer   Úinputsr   Úfilled_contoursr"   r#   r$   )r   r%   Z
old_inputsr   r   r   r   i   s    

z Surface._enable_contours_changedc             C   s8   |d k	r|j | jddd� |j | jdƒ | j||ƒ d S )Nr)   T)Úremove)Úon_trait_changer&   Ú_change_components)r   ÚoldÚnewr   r   r   Ú_contour_changedx   s    zSurface._contour_changedc             C   sF   |d krt jdd�|_| j|_| j}|d k	r6|jg|_| j||ƒ d S )Né   )Zuse_lookup_table_scalar_range)r   ZDataSetMapperr"   Úscener   r'   r(   r,   )r   r-   r.   r   r   r   r   Ú_actor_changed�   s    
zSurface._actor_changedN)Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r   r   r   r   r   r   Ú
input_infor   r   r   r&   r   r/   r2   r   r   r   r   r	      s   
	r	   N)Ú__doc__Ú
traits.apir   r   Útvtk.apir   Úmayavi.core.pipeline_infor   Zmayavi.core.moduler   Zmayavi.components.contourr   Zmayavi.components.actorr   r	   r   r   r   r   Ú<module>   s   