3
P„-]Ò  ã               @   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 PolyData file reader object.
é    )Úbasename)ÚInstanceÚStrÚDict)ÚViewÚItemÚGroupÚInclude)Útvtk)ÚFileDataSource)ÚPipelineInfo)Úerrorc            	       sÀ   e Zd ZdZdZeejdd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edgdgdgd�Z‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd „ ƒZ‡  ZS )!ÚPolyDataReaderz`A PolyData file reader. The reader supports all the
    different types of poly data files.
    r   FT)Ú
allow_noneÚrecordZtime_step_groupZbase_file_name)ÚnameÚreaderÚcustom)r   ÚstyleÚ	resizable)Úshow_labels)r   Ú	poly_dataÚany)ÚdatasetsÚattribute_typesÚ
attributesc                s    |j j|j_tt| ƒj|ƒ d S )N)Ú	file_pathÚabs_pthr   Ú	file_nameÚsuperr   Ú__set_pure_state__)ÚselfÚstate)Ú	__class__© úb/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/sources/poly_data_reader.pyr    ;   s    z!PolyDataReader.__set_pure_state__c             C   s,   | j jƒ  t| jjƒ ƒdkr d S | jƒ  d S )Nr   )r   ÚupdateÚlenr   ÚgetÚrender)r!   r$   r$   r%   r&   D   s    
zPolyDataReader.updatec             C   s   dS )z+ Return True as the reader has output port.Tr$   )r!   r$   r$   r%   Úhas_output_portJ   s    zPolyDataReader.has_output_portc             C   s   | j jS )z Return the reader output port.)r   Úoutput_port)r!   r$   r$   r%   Úget_output_objectN   s    z PolyDataReader.get_output_objectc             C   sÔ   |j ƒ }t|ƒdkrd S |jƒ jdƒ}|d jƒ }| j}|| jkrP| j| | _ntd| ƒ d S | jj}|jƒ | j_| jj	ƒ  | jj
ƒ  |d k	r |j| jdd� | jj| jƒ | jg| _||krÆd| _| jƒ | _d S )Nr   Ú.é   zInvalid extension for file: %sT)Úremoveéÿÿÿÿ)r(   r'   ÚstripÚsplitÚlowerr   Ú_reader_dictr   r   r&   Zupdate_informationÚon_trait_changer)   ÚoutputsZdata_changedÚ	_get_namer   )r!   ZfpathÚvalueÚ	splitnameÚ	extensionZ
old_readerZ	old_fnamer$   r$   r%   Ú_file_path_changedU   s*    



z!PolyDataReader._file_path_changedc             C   sB   t | jjƒ ƒ}d| }t| jƒdkr,|d7 }d| jk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'   Z	file_listr   )r!   ÚfnameÚretr$   r$   r%   r7   u   s    
zPolyDataReader._get_namec             C   sX   t jƒ t jƒ t jƒ t jƒ t jƒ t jƒ t jƒ t jƒ t jƒ t jƒ t j	ƒ t j
ƒ t jƒ dœ}|S )zDefault value for reader dict.)ZstlZstlaZstlbÚtxtÚrawZplyÚpdbZslcÚxyzÚobjZfacetZcubeÚg)r
   Z	STLReaderZSimplePointsReaderZParticleReaderZ	PLYReaderZ	PDBReaderZ	SLCReaderÚXYZMolReaderZ	OBJReaderZFacetReaderZGaussianCubeReaderZ	BYUReader)r!   Zrdr$   r$   r%   Z__reader_dict_default‚   s    z$PolyDataReader.__reader_dict_defaultc             C   s€   |j ƒ jdƒ}|d	 jƒ }|dkr|ddlm} |}|jƒ }|jdƒ tjƒ }||_	|j
ƒ  |j|ƒ t|jjƒdkrxdS dS dS )
z“ Class method to check if the reader can actually
        read the file. Returns 'True' if it can read it succesfully
        else 'False'
        r-   r.   rA   r   )Ú	vtkObjectTFNr0   )r1   r2   r3   ÚvtkrE   ÚGetGlobalWarningDisplayÚSetGlobalWarningDisplayr
   rD   r   r&   r'   ÚoutputÚpoints)ÚclsÚfilenamer9   r:   rE   ÚoÚwÚrr$   r$   r%   Úcan_read•   s    

zPolyDataReader.can_read)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__version__r   r
   ÚObjectr   r   r   r4   r   r   r	   r   Úviewr   Úoutput_infor    r&   r*   r,   r;   r7   Z$_PolyDataReader__reader_dict_defaultÚclassmethodrP   Ú__classcell__r$   r$   )r#   r%   r      s.   

	 r   N)rT   Úos.pathr   Ú
traits.apir   r   r   Útraitsui.apir   r   r   r	   Útvtk.apir
   Zmayavi.core.file_data_sourcer   Úmayavi.core.pipeline_infor   Úmayavi.core.commonr   r   r$   r$   r$   r%   Ú<module>   s   