a
    «ˆcÏ  ã                   @   s€   d Z ddl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 ddlmZ dd	lmZ G d
d„ de
ƒZdS )znThis module takes a slice of the unstructured grid data and shows
the cells that intersect or touch the slice.é    )ÚInstance)ÚViewÚGroupÚItem)Útvtk)ÚModule)ÚPipelineInfo)ÚImplicitPlane)ÚActor)Úerrorc                	   @   sö   e Zd ZdZdZeeddd�Zeej	ddd�Z
eejddd�Zeeddd�Zedgdgdgd�Zeeed	d
d�ddd�eedd
dd�ddd�eedd
dd�ddd�eedd
d�dd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 )$ÚSliceUnstructuredGridzrThis module takes a slice of the unstructured grid data and
    shows the cells that intersect or touch the slice.r   FT)Ú
allow_noneÚrecordZunstructured_gridÚany)ZdatasetsZattribute_typesÚ
attributesÚimplicit_planeZcustom)ÚnameÚstyler	   )ÚlabelZshow_labelsÚextract_geometry)r   r   Z	resizablezExtract GeometryÚgeom_filterzGeometry FilterÚactorr
   c                 C   s<   t ƒ | _tjddd�}|| _t ¡ | _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.
        é   )Zextract_only_boundary_cellsZextract_boundary_cellsÚwN)r	   r   r   ÚExtractGeometryr   ÚGeometryFilterr   r
   r   ÚpropertyZrepresentation)ÚselfÚex© r   úi/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/modules/slice_unstructured_grid.pyÚsetup_pipelineD   s    ÿ
z$SliceUnstructuredGrid.setup_pipelinec                 C   sl   | j }|du rdS |j ¡ }| d¡s.tdƒ |jg| j_| j 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.
        NZvtkUnstructuredGridz>SliceUnstructuredGrid only works with input unstructured gridsT)Úmodule_managerÚsourceZget_output_datasetZis_ar   r   ÚinputsÚconfigure_connectionr   r   Zset_lutZscalar_lut_managerZlutZpipeline_changed)r   Zmod_mgrÚinputÚsrcr   r   r    Úupdate_pipeline[   s    

z%SliceUnstructuredGrid.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_datau   s    	z!SliceUnstructuredGrid.update_datac                 C   s&   | j }|d ur|j|_|  ||¡ d S ©N)r   ÚplaneÚimplicit_functionÚ_change_components©r   ÚoldÚnewr   r   r   r    Ú_implicit_plane_changedƒ   s    z-SliceUnstructuredGrid._implicit_plane_changedc                 C   s|   |d ur|j | jdd� | j}|d ur8|j}|  ||¡ | j}|d urN|j|_| j}|d urd|j	|_
|  | j¡ |  ¡  d S ©NT)Úremove)Úon_trait_changeÚrenderr"   r#   r%   r   r+   r,   r   Úoutput_portÚinput_connectionr(   )r   r/   r0   Úmmr'   ÚipZgfr   r   r    Ú_extract_geometry_changed‰   s    z/SliceUnstructuredGrid._extract_geometry_changedc                 C   sH   |d ur|j | jdd� | j}|d ur.|j|_|  | j¡ |jg| _d S r2   )r4   r5   r   r6   r7   Úoutputsr.   r   r   r    Ú_geom_filter_changed›   s    z*SliceUnstructuredGrid._geom_filter_changedc                 C   s    | j |_ | g|_|  ||¡ d S r*   )Zscener$   r-   )r   r/   r0   r   r   r    Ú_actor_changed¦   s    z$SliceUnstructuredGrid._actor_changedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__version__r   r	   r   r   r   r   r   r   r
   r   r   Z
input_infor   r   r   Úviewr!   r(   r)   r1   r:   r<   r=   r   r   r   r    r      sX   ÿÿÿþþÿýÿýþõr   N)rA   Z
traits.apir   Ztraitsui.apir   r   r   Ztvtk.apir   Zmayavi.core.moduler   Zmayavi.core.pipeline_infor   Z mayavi.components.implicit_planer	   Zmayavi.components.actorr
   Zmayavi.core.commonr   r   r   r   r   r    Ú<module>   s   