3
îÈ‘[R  ã               @   sh   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 G dd	„ d	e
ƒZd
S )a†   A module that integrates through a tensor field to generate a
     hyperstreamline. The integration is along the maximum
     eigenvector and the cross section of the hyperstreamline is
     defined by the two other eigenvectors. Thus the shape of the
     hyperstreamline is "tube-like", with the cross section being
     elliptical. Hyperstreamlines are used to visualize tensor fields.
é    )ÚInstance)ÚViewÚGroupÚItem)Útvtk)ÚModule)ÚPipelineInfo)ÚActorc            	   @   sØ   e Zd ZdZeejddd�Zeeddd�Z	eej
f dddd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�dd�Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"S )#ÚHyperStreamliner   FT)Ú
allow_noneÚrecord)ÚoutlineZ	x_shadowsZ	y_shadowsZ	z_shadows)ÚargsÚkwr   ÚanyÚtensors)ÚdatasetsÚattribute_typesÚ
attributesÚactorÚcustom)ÚnameÚstyler	   )Úshow_labelsÚlabelÚwidget)r   r   Ú	resizableÚPointWidgetÚ
streamlineZ
Streamline)r   r   )r   c             C   s†   | j j| jƒ tjƒ | _| j j| j_| jjƒ  d| j_	d| j_
d| j_d| j_d| j_d| j_| jj| jƒ tƒ | _| j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.
        g      $@gš™™™™™¹?g{®Gáz„?g      Ð?é   é   N)r   Úon_trait_changeÚ_start_position_changedr   r
   r   ÚpositionÚstart_positionZintegrate_minor_eigenvectorZmaximum_propagation_distanceZintegration_step_lengthZstep_lengthÚradiusZnumber_of_sidesZintegration_directionÚrenderr	   r   ZwidgetsÚappend)Úself© r)   úb/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/modules/hyper_streamline.pyÚsetup_pipeline?   s    

zHyperStreamline.setup_pipelinec             C   s|   | j }|dkrdS |jjd }| j| j|jƒ | j}|j}| j||ƒ |dksV||kr^|jƒ  | jj	ƒ  | jg| _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.
        Nr   T)Úmodule_managerÚsourceÚoutputsÚconfigure_connectionr   r   ÚinputÚconfigure_input_dataZplace_widgetÚupdateZpipeline_changed)r(   ÚmmÚsrcÚwZold_inpr)   r)   r*   Úupdate_pipeline[   s    

zHyperStreamline.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HyperStreamline.update_datac             C   sT   |d k	r|j | jdd� |j | jƒ | j}|d k	r@| j||jƒ |g| _| jƒ  d S )NT)Úremove)r!   r&   r,   r/   r-   r.   r6   )r(   ÚoldÚnewr3   r)   r)   r*   Ú_streamline_changed}   s    z#HyperStreamline._streamline_changedc             C   s   | j j| j_d S )N)r   r#   r   r$   )r(   Úvaluer)   r)   r*   r"   ‰   s    z'HyperStreamline._start_position_changedc             C   s    | j |_ | g|_| j||ƒ d S )N)ÚsceneÚinputsZ_change_components)r(   r9   r:   r)   r)   r*   Ú_actor_changedŒ   s    zHyperStreamline._actor_changedN)Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r
   r   r	   r   r   r   r   Ú
input_infor   r   r   Úviewr+   r6   r7   r;   r"   r?   r)   r)   r)   r*   r
      s8   
r
   N)Ú__doc__Ú
traits.apir   Útraitsui.apir   r   r   Útvtk.apir   Zmayavi.core.moduler   Úmayavi.core.pipeline_infor   Zmayavi.components.actorr	   r
   r)   r)   r)   r*   Ú<module>   s   