3
ÌœŸWC-  ã               @   s    d Z ddlmZmZ ddlmZ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 dd
lmZ ddlmZ G dd„ de
ƒZdS )z�Takes a cut plane of any input data set using an implicit plane and
plots the data with optional contouring and scalar warping.

é    )ÚInstanceÚBool)ÚViewÚGroupÚItemÚInstanceEditor)ÚModule)ÚPipelineInfo)ÚImplicitPlane)ÚCutter)Ú
WarpScalar)ÚPolyDataNormals)ÚContour)ÚActorc               @   sê  e Zd ZdZeeddd�Zeeddd�Ze	ddd�Z
eeddd�Ze	ddd�Zeedd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eeddeeedƒƒd�d�dd�Zeeeddd�ddd�eeedd�ƒeedddd�dd�ddd�eedd�eedddeeeƒd�d�dd�edd�ed dd!�ed"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 d0d1„ Z!d2d3„ Z"d4d5„ Z#d6d7„ Z$d8d9„ Z%d:d;„ Z&d<d=„ Z'd>d?„ Z(d@dA„ Z)dBdC„ Z*dDdE„ Z+dFdG„ Z,dHS )IÚScalarCutPlaner   FT)Ú
allow_noneÚrecordzif contours are generated)Údesczif scalar warping is enabledzHif normals are to be computed to make the warped scalar surface smootherÚanyÚscalars)ÚdatasetsÚattribute_typesÚ
attributesÚfilterÚcustomÚscale_factor)Úview)ÚnameÚstyleÚeditor)Úshow_labelsÚimplicit_plane)r   r   r
   )Úlabelr    Úenable_contours)r   Úcontourzobject.enable_contours)r   r   Úenabled_whenZContoursÚenable_warp_scalarÚwarp_scalar)r   r%   r   r   Ú_Úcompute_normals)r   r%   Únormalsz&compute_normals and enable_warp_scalar)r   r   Ú
show_labelr%   r   Úactorr   c             C   sH   t ƒ | _tƒ | _tddd�| _tƒ | _tƒ | _	t
ƒ | _| jj}d|_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
   r!   r   Úcutterr   r$   r   r'   r   r*   r   r,   ÚpropertyÚ
line_width)ÚselfÚprop© r3   úb/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/modules/scalar_cut_plane.pyÚsetup_pipelineq   s    zScalarCutPlane.setup_pipelinec             C   sR   | j }|dkrdS |jg| j_| jj| 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.
        NT)Úmodule_managerÚsourcer!   ÚinputsÚnormalr'   r   Ú_enable_warp_scalar_changedr&   r,   Zset_lutZscalar_lut_managerZlutZpipeline_changed)r1   Úmmr3   r3   r4   Úupdate_pipeline‰   s    zScalarCutPlane.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)r1   r3   r3   r4   Úupdate_data¥   s    	zScalarCutPlane.update_datac             C   s$   | j r| jr| jS | jS n| jS dS )z\Helper function to return the warped (or not) output
        depending on settings.
        N)r&   r)   r*   r'   r.   )r1   r3   r3   r4   Ú_get_warp_output³   s
    zScalarCutPlane._get_warp_outputc             C   s   | j r| jS | jƒ S dS )zlHelper function to return the contoured (and warped (or
        not)) output depending on settings.
        N)r#   r$   r>   )r1   r3   r3   r4   Ú_get_contour_output¿   s    z"ScalarCutPlane._get_contour_outputc             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)r1   Úvaluer3   r3   r4   Ú$_filled_contours_changed_for_contourÈ   s    
z3ScalarCutPlane._filled_contours_changed_for_contourc             C   s@   | j dkrdS |r | jg| j_ng | j_| j| jƒ | jƒ  dS )z$Turns on and off the scalar warping.N)r6   r.   r'   r8   Ú_compute_normals_changedr)   rD   )r1   rE   r3   r3   r4   r:   Ó   s    
z*ScalarCutPlane._enable_warp_scalar_changedc             C   sH   | j d krd S | jr0| j}|r*| jg|_ng |_| j| jƒ | jƒ  d S )N)r6   r&   r*   r'   r8   Ú_enable_contours_changedr#   rD   )r1   rE   r*   r3   r3   r4   rG   ß   s    
z'ScalarCutPlane._compute_normals_changedc             C   sl   | j dkrdS | j}|rD| jƒ g| j_| jƒ g|_| jjr`d|j_ng | j_| jƒ g|_d|j_| j	ƒ  dS )zTurns on and off the contours.Nr@   rA   )
r6   r,   r>   r$   r8   r?   Zfilled_contoursrB   rC   rD   )r1   rE   r,   r3   r3   r4   rH   ì   s    

z'ScalarCutPlane._enable_contours_changedc             C   s2   | j }|d k	r"|g|_| j| jƒ | j||ƒ d S )N)r'   r8   rG   r)   Ú_change_components)r1   ÚoldÚnewr'   r3   r3   r4   Ú_normals_changedý   s
    zScalarCutPlane._normals_changedc             C   sf   | j }|d k	r*|j|_|g|_| j| jƒ |d k	rF|jj| jddd� |jj| jdƒ | j	||ƒ d S )Nr9   T)Úremove)
r.   ÚplaneÚcut_functionr8   r:   r&   ÚwidgetÚon_trait_changeÚ_update_normalrI   )r1   rJ   rK   r.   r3   r3   r4   Ú_implicit_plane_changed  s    z&ScalarCutPlane._implicit_plane_changedc             C   s:   | j }|d k	r*|j|_|g|_| j| jƒ | j||ƒ d S )N)r!   rN   rO   r8   r:   r&   rI   )r1   rJ   rK   Úipr3   r3   r4   Ú_cutter_changed  s    zScalarCutPlane._cutter_changedc             C   s   | j | jƒ | j||ƒ d S )N)rH   r#   rI   )r1   rJ   rK   r3   r3   r4   Ú_contour_changed  s    zScalarCutPlane._contour_changedc             C   s   | j | jƒ | j||ƒ d S )N)r:   r&   rI   )r1   rJ   rK   r3   r3   r4   Ú_warp_scalar_changed  s    z#ScalarCutPlane._warp_scalar_changedc             C   s   | j | jƒ | j||ƒ d S )N)rH   r#   rI   )r1   rJ   rK   r3   r3   r4   Ú_actor_changed$  s    zScalarCutPlane._actor_changedc             C   s    | j }|dk	r| jjj|j_dS )zDInvoked when the orientation of the implicit plane changes.
        N)r'   r!   rP   r9   r   )r1   Úwsr3   r3   r4   rR   )  s    zScalarCutPlane._update_normalN)-Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r
   r!   r   r.   r   r#   r   r$   r&   r   r'   r)   r   r*   r   r,   r	   Ú
input_infor   r   r   r   Z_warp_groupr   r5   r<   r=   r>   r?   rF   r:   rG   rH   rL   rS   rU   rV   rW   rX   rR   r3   r3   r3   r4   r      s„   


		r   N)Ú__doc__Ú
traits.apir   r   Útraitsui.apir   r   r   r   Zmayavi.core.moduler   Úmayavi.core.pipeline_infor	   Z mayavi.components.implicit_planer
   Zmayavi.components.cutterr   Zmayavi.filters.warp_scalarr   Z#mayavi.components.poly_data_normalsr   Zmayavi.components.contourr   Zmayavi.components.actorr   r   r3   r3   r3   r4   Ú<module>   s   