a
    «ˆc4+  ã                   @   sˆ   d Z ddlmZmZm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 G d
d„ deƒZdS )zTA component that allows one to place colored and scaled glyphs at
input point data.
é    )ÚInstanceÚTraitÚBool)ÚEnum)ÚViewÚGroupÚItem)Útvtk)ÚRevPrefixMap)Ú	Component)ÚModule)Úglyph_sourcec                       sè  e Zd ZdZedddd�Zeddddd	œd
dd�Zeddddœddd�Zeddddœddd�Z	e
ddd�Zeejdddidd�Zeejddd�Zeejddd�ZeeƒZe
dƒZe
dƒZeeedd�eeddddd�dd �d!d"�eeed#d$d$d%�ed&d'd'd%�ed(d)d)d%�ƒeed*ddd+�dd �d dd,�eed-ddd+�dd.d/�dd0�Z‡ fd1d2„Zd3d4„ Zd5d6„ Zd7d8„ Z‡ fd9d:„Z ‡ fd;d<„Z!‡ fd=d>„Z"d?d@„ Z#dAdB„ Z$dCdD„ Z%dEdF„ Z&dGdH„ Z'dIdJ„ Z(dKdL„ Z)dMdN„ Z*dOdP„ Z+‡ fdQdR„Z,‡  Z-S )SÚGlyphr   ÚvectorÚtensorz if the glyph is vector or tensor)Údescé   é   é   )Zscale_by_vectorZscale_by_vector_componentsZdata_scaling_offÚscale_by_scalarr   z:if scaling is done using scalar or vector/normal magnitude)Údefault_valuer   )Zcolor_by_vectorÚcolor_by_scalarÚno_coloringr   z8if coloring is done by scalar or vector/normal magnitude)ÚscalarsZeigenvaluesr   r   z,if coloring is done by scalar or eigenvaluesFzif input points are masked© Zrandom_modeT)ÚargsÚkwÚrecord)Ú
allow_noner   Úmask_input_points)ÚnameÚmask_pointszobject.mask_input_pointsZcustom)r    Úenabled_whenÚstyleÚ	resizable)Úshow_labelsZMasking)ÚlabelÚ
scale_modeÚshow_scale_mode)r    r"   Zvisible_whenÚ
color_modezglyph_type == "vector"Úcolor_mode_tensorzglyph_type == "tensor"Úglyph)r    r#   r$   )r&   Úselectedr   zGlyph Source)r%   r&   )r$   c                    s(   t t| ƒ ¡ }dD ]}| |d ¡ q|S )N)ÚmoduleÚ	_updating)Úsuperr   Ú__get_pure_state__Úpop)ÚselfÚdÚattr©Ú	__class__r   úZ/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/components/glyph.pyr0   †   s    zGlyph.__get_pure_state__c                 C   s8   |   | j¡ t ¡ | _| j | j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.
        Úpipeline_changedN)Ú_glyph_type_changedÚ
glyph_typer   ÚGlyphSourceÚon_trait_changeÚ_update_sourcer!   Úrender©r2   r   r   r7   Úsetup_pipeline�   s    
zGlyph.setup_pipelinec                 C   sv   t | jƒdks"t | jd jƒdkr&dS |  | j¡ | jdkrJ|  | j¡ n|  | 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.
        r   Nr   T)ÚlenÚinputsÚoutputsÚ_mask_input_points_changedr   r:   Ú_color_mode_changedr)   Ú_color_mode_tensor_changedr*   Ú_scale_mode_changedr'   r+   r8   r?   r   r   r7   Úupdate_pipeline£   s    "

zGlyph.update_pipelinec                 C   s   |   | j¡ 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)rG   r'   Zdata_changedr?   r   r   r7   Úupdate_data¸   s    zGlyph.update_datac                    s   | j stt| ƒ ¡  d S ©N)r.   r/   r   r>   r?   r5   r   r7   r>   Â   s    zGlyph.renderc                    s&   | j r
dS | j ¡  tt| ƒ ¡  dS )zOverridden method.
        N)Úrunningr   Ústartr/   r   r?   r5   r   r7   rL   Æ   s    
zGlyph.startc                    s&   | j s
d S | j ¡  tt| ƒ ¡  d S rJ   )rK   r   Ústopr/   r   r?   r5   r   r7   rM   Î   s    
z
Glyph.stopc                 C   s   dS )z The filter has an output port.Tr   r?   r   r   r7   Úhas_output_portÔ   s    zGlyph.has_output_portc                 C   s   | j jS )z Returns the output port.)r+   Zoutput_portr?   r   r   r7   Úget_output_objectØ   s    zGlyph.get_output_objectc                 C   s   |   | j| jjd ¡ d S ©Nr   )Úconfigure_source_datar+   r   rC   r?   r   r   r7   r=   ß   s    zGlyph._update_sourcec                 C   s   |   | j|jd ¡ d S rP   )rQ   r+   rC   ©r2   Úvaluer   r   r7   Ú_glyph_source_changedâ   s    zGlyph._glyph_source_changedc                 C   s&   t | jƒdkrd S |dkr"|| j_d S )Nr   r   )rA   rB   r+   r)   rR   r   r   r7   rE   å   s    zGlyph._color_mode_changedc                 C   sL   t | jƒdkrd S d| _|dkr2|| j_d| j_nd| j_d| _|  ¡  d S )Nr   Tr   F)rA   rB   r.   r+   r)   Zcolor_glyphsr>   rR   r   r   r7   rF   ë   s    
z Glyph._color_mode_tensor_changedc                 C   s�   | j d u s"t| jƒdks"| jdkr&d S d| _zN| j}||_| j j}|jdkr\t|j	j
ƒ|_nt|jj
ƒ|_W d| _|  ¡  nd| _|  ¡  0 d S )Nr   r   Tr   F)r-   rA   rB   r:   r.   r+   r'   Zmodule_managerÚtupleZscalar_lut_managerZ
data_rangeÚrangeZvector_lut_managerr>   )r2   rS   r+   Úmmr   r   r7   rG   ÷   s     ÿ

ÿzGlyph._scale_mode_changedc                 C   sf   | j }t|ƒdkrd S |rF| j}|  ||d jd ¡ |  | j|¡ n|  | j|d ¡ | j ¡  d S rP   )rB   rA   r!   Zconfigure_connectionrC   r+   Úupdate)r2   rS   rB   Úmaskr   r   r7   rD   
  s    z Glyph._mask_input_points_changedc                 C   s@   | j dkrtjdd�| _ntjdd�| _d| _| j | j¡ d S )Nr   T)Zclampinggš™™™™™¹?)Zscale_factorF)r:   r	   ZGlyph3Dr+   ZTensorGlyphr(   r<   r>   rR   r   r   r7   r9     s
    
zGlyph._glyph_type_changedc                    s   t t| ƒ ||¡ || j_d S rJ   )r/   r   Ú_scene_changedr   Zscene)r2   ÚoldÚnewr5   r   r7   rZ     s    zGlyph._scene_changed).Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r:   r
   r'   r)   r*   r   r   r   r	   Z
MaskPointsr!   ZObjectr+   r   r;   r   r-   r(   r.   r   r   r   Úviewr0   r@   rH   rI   r>   rL   rM   rN   rO   r=   rT   rE   rF   rG   rD   r9   rZ   Ú__classcell__r   r   r5   r7   r      s¸   ÿýûþüþü	ÿÿþýúþþþú
ÿþòÿýã#

r   N)Ú__doc__Z
traits.apir   r   r   r   Ztraitsui.apir   r   r   Ztvtk.apir	   Ztvtk.tvtk_baser
   Zmayavi.core.componentr   Zmayavi.core.moduler   Zmayavi.componentsr   r   r   r   r   r7   Ú<module>   s   
