a
    «ˆc(  ã                   @   s¬   d Z ddlmZ ddlmZmZmZ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 G dd„ deƒZdS )a  Allows the user to draw streamlines for given vector data.  This
supports various types of seed objects (line, sphere, plane and point
seeds).  It also allows the user to draw ribbons or tubes and further
supports different types of interactive modes of calculating the
streamlines.
é    )Úsqrt)ÚInstanceÚBoolÚTraitÚDelegateÚButton)ÚViewÚGroupÚItemÚInstanceEditor)Útvtk)Ú
PrefixList)ÚModule)ÚPipelineInfo)ÚActor)ÚSourceWidget)ÚDataSetHelperc                   @   s  e Zd ZdZeejddd�Zeeddd�Z	e
ddd�Zeg d¢dd	d
�Zeej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dƒZedƒZeedd�edd�edd�edd�edd�edd�edd�edd�ƒZeedd�edd�edd�edd�ƒZe eeedd�ƒeedd�dd�eedd�ed d!d"e!e eƒd#�d$�ed%d!d&e!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d+�eed.d!d/�d0dd+�dd1�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,dFS )GÚ
Streamliner   FT)Ú
allow_noneÚrecordÚseed)Úmodify)ÚlineÚribbonÚtuber   z'draw streamlines as lines/ribbons/tubes)Údefault_valueÚdescÚanyZvectors)ZdatasetsZattribute_typesÚ
attributeszUpdate StreamlinesZcapping)ÚnameZsides_share_verticesZvary_radiusZnumber_of_sidesÚradiusZradius_factorÚoffsetZon_ratioZ
vary_widthÚwidthZwidth_factorZangleÚupdate_modeÚupdate_streamlines)Úshow_labelsÚstreamline_typeÚribbon_filterZcustomz"object.streamline_type == "ribbon")Úview)r   ÚstyleZvisible_whenZeditorÚtube_filterz object.streamline_type == "tube")r%   Úlabel)r+   )r   r)   Ú	resizableZSeed)r+   r%   Ústream_tracerÚStreamTracerÚactor)r   r)   r   )r,   c                 C   sP   t ƒ | _tjddddd�| _t ¡ | _t ¡ | _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.
        é2   ZforwardTZrunge_kutta4)Zmaximum_propagationZintegration_directionZcompute_vorticityZintegrator_typeg       @N)r   r   r   r.   r-   ÚRibbonFilterr'   Ú
TubeFilterr*   ÚCleanPolyDataÚclean_filterr   r/   ÚpropertyÚ
line_width©Úself© r9   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/modules/streamline.pyÚsetup_pipelineƒ   s    ý


zStreamline.setup_pipelinec                 C   sø   | j }|du rdS |j}|  | j|jd ¡ |g| j_| jrÒt|jd ƒ}| 	¡ }|d |d  |d |d  |d |d  g}t
|d |d  |d |d   |d |d   ƒ}|d | j_|d | j_d	| _|  | 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.
        Nr   é   é   é   é   é   g¸…ëQ¸~?FT)Úmodule_managerÚsourceÚconfigure_connectionr-   Úoutputsr   ÚinputsÚ_firstr   Z
get_boundsr   r'   r"   r*   r    Ú_streamline_type_changedr&   r/   Zset_lutZscalar_lut_managerZlutZpipeline_changed)r8   ÚmmÚsrcZdshÚbÚlÚlengthr9   r9   r:   Úupdate_pipelinež   s"    
.4zStreamline.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_changedr7   r9   r9   r:   Úupdate_data¾   s    	zStreamline.update_datac                 C   sŠ   | j d u rd S | j}| j}| j}|dkr2|g| _nL|dkrP|  ||¡ |g| _n.|dkr~| j}|  ||¡ |  ||¡ |g| _|  ¡  d S )Nr   r   r   )rA   r-   r'   r*   rD   rC   r4   Úrender)r8   ÚvalueÚstÚrfÚtfÚcfr9   r9   r:   rG   Ì   s     


z#Streamline._streamline_type_changedc                 C   s    | j  ¡  | j ¡  |  ¡  d S ©N)r   Zupdate_poly_datar-   ÚupdaterO   r7   r9   r9   r:   Ú_update_streamlines_firedà   s    

z$Streamline._update_streamlines_firedc                 C   sz   |d ur|j | jdd� | j}|d ur4|  ||j¡ |  | j¡ | j}|d urf|j}|  ||jd ¡ |g| _|  	¡  d S )NT©Úremover   )
Úon_trait_changerO   r   Úconfigure_source_dataÚ	poly_datarA   rB   rC   rD   rM   )r8   ÚoldÚnewr   rH   rI   r9   r9   r:   Ú_stream_tracer_changedå   s    z!Streamline._stream_tracer_changedc                 C   s,   | j }|d ur|  ||j¡ |  ||¡ d S rU   )r-   r[   r\   Ú_change_components)r8   r]   r^   rQ   r9   r9   r:   Ú_seed_changed÷   s    zStreamline._seed_changedc                 C   s4   |d ur|j | jdd� |  | j¡ |  | j¡ d S ©NTrX   ©rZ   rO   rG   r&   ©r8   r]   r^   r9   r9   r:   Ú_ribbon_filter_changedý   s    z!Streamline._ribbon_filter_changedc                 C   s4   |d ur|j | jdd� |  | j¡ |  | j¡ d S rb   rc   rd   r9   r9   r:   Ú_tube_filter_changed  s    zStreamline._tube_filter_changedc                 C   s    | j |_ | g|_|  ||¡ d S rU   )ZscenerE   r`   rd   r9   r9   r:   Ú_actor_changed	  s    zStreamline._actor_changedN)-Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r.   r-   r   r   r   r#   r   r&   r1   r'   r2   r*   r3   r4   r   r/   r   Z
input_infor   rF   r   r$   r	   r
   Z_tube_groupZ_ribbon_groupr   r   r(   r;   rM   rN   rG   rW   r_   ra   re   rf   rg   r9   r9   r9   r:   r      s¦   ÿýÿÿÿþ
ù

ý
ÿ
þþø
ñþþþæ  r   N)Ú__doc__Úmathr   Z
traits.apir   r   r   r   r   Ztraitsui.apir   r	   r
   r   Ztvtk.apir   Ztvtk.tvtk_baser   Zmayavi.core.moduler   Zmayavi.core.pipeline_infor   Zmayavi.components.actorr   Zmayavi.components.source_widgetr   Zmayavi.core.utilsr   r   r9   r9   r9   r:   Ú<module>   s   