a
    «ˆc™  ã                   @   s€   d Z ddlmZ ddl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 G d	d
„ d
eƒZdS )z'A Unstructred Grid file reader object.
é    )Úbasename)ÚInstanceÚStrÚDict)ÚViewÚGroupÚItemÚInclude)Útvtk)ÚFileDataSource)ÚPipelineInfo)Úerrorc                	       s¨   e Zd ZdZeejddd�Zedgd�Z	e
eeejƒƒZeeedƒedd	�ed
ddd�dd�dd�Z‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚUnstructuredGridReaderr   FT)Ú
allow_noneÚrecordZunstructured_grid)ZdatasetsZtime_step_groupZbase_file_name)ÚnameÚreaderZcustom)r   ÚstyleÚ	resizable)Zshow_labels)r   c                    s    |j j|j_tt| ƒ |¡ d S )N)Ú	file_pathZabs_pthr   Ú	file_nameÚsuperr   Ú__set_pure_state__)ÚselfÚstate©Ú	__class__© új/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/sources/unstructured_grid_reader.pyr   3   s    z)UnstructuredGridReader.__set_pure_state__c                 C   s,   | j  ¡  t| j ¡ ƒdkr d S |  ¡  d S )Nr   )r   ÚupdateÚlenr   ÚgetÚrender©r   r   r   r   r   <   s    
zUnstructuredGridReader.updatec                 C   s   dS )z+ Return True as the reader has output port.Tr   r#   r   r   r   Úhas_output_portB   s    z&UnstructuredGridReader.has_output_portc                 C   s   | j jS )z Return the reader output port.)r   Zoutput_portr#   r   r   r   Úget_output_objectF   s    z(UnstructuredGridReader.get_output_objectc           	      C   s  |  ¡ }t|ƒdkrd S | ¡  d¡}|d  ¡ }| j}|| jv rP| j| | _ntd| ƒ d S | jj}| ¡ | j_| j 	¡  t
| jtjƒr¸t| jjƒD ]}| j |¡}| j |d¡ q˜| j ¡  |d urÚ|j| jdd� | j | j¡ | jg| _||k�rd| _|  ¡ | _d S )Nr   Ú.éÿÿÿÿz#Invalid file extension for file: %sé   T)Úremove)r!   r    ÚstripÚsplitÚlowerr   Ú_reader_dictr   r   Zupdate_informationÚ
isinstancer
   ÚExodusIIReaderÚrangeZnumber_of_point_result_arraysZget_point_result_array_nameZset_point_result_array_statusr   Zon_trait_changer"   ÚoutputsZdata_changedÚ	_get_namer   )	r   ZfpathÚvalueZ	splitnameÚ	extensionZ
old_readerZ	old_fnameÚkZarr_namer   r   r   Ú_file_path_changedM   s2    




z)UnstructuredGridReader._file_path_changedc                 C   sB   t | j ¡ ƒ}d| }t| jƒdkr,|d7 }d| jv r>|d7 }|S )zi Returns the name to display on the tree view.  Note that
        this is not a property getter.
        z%sr(   z (timeseries)z[Hidden]z	 [Hidden])r   r   r!   r    Ú	file_listr   )r   ÚfnameÚretr   r   r   r2   r   s    
z UnstructuredGridReader._get_namec                 C   s   t  ¡ t  ¡ t  ¡ dœ}|S )zDefault value for reader dict.)ÚinpZneuZex2)r
   ZAVSucdReaderZGAMBITReaderr/   )r   Úrdr   r   r   Z__reader_dict_default   s
    þz,UnstructuredGridReader.__reader_dict_default)Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r
   ZObjectr   r   Zoutput_infor   r   r-   r   r   r	   r   Úviewr   r   r$   r%   r6   r2   Z,_UnstructuredGridReader__reader_dict_defaultÚ__classcell__r   r   r   r   r      s*   
þûú	%r   N)Ú__doc__Úos.pathr   Z
traits.apir   r   r   Ztraitsui.apir   r   r   r	   Ztvtk.apir
   Zmayavi.core.file_data_sourcer   Zmayavi.core.pipeline_infor   Zmayavi.core.commonr   r   r   r   r   r   Ú<module>   s   