a
    «ˆcC  ã                   @   s„   d Z ddlmZ ddlmZ ddlmZ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 )zAn importer for VRML files.

é    )Úbasename)Útvtk)ÚInstanceÚStr)ÚViewÚItemÚ
FileEditor)ÚFilePath)Ú	set_state)ÚSource)ÚPipelineInfoc                       sÐ   e Zd ZdZeddddd�Zeejdddd�Z	e
d	gd
�Zeedd�Zeedeƒ d�ƒZ‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Z‡ fd&d'„Z‡  ZS )(ÚVRMLImporterr   Ú TFzthe VRML file name)Z	enter_setZauto_setÚdesc© )ÚargsÚ
allow_noneÚrecordÚnone)Zdatasets)r   Ú	file_name)ÚnameZeditorc                    s&   t t| ƒ ¡ }dD ]}| |¡ q|S )N)Úreaderr   )Úsuperr   Ú__get_pure_state__Úpop)ÚselfÚdr   ©Ú	__class__r   ú_/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/sources/vrml_importer.pyr   3   s    zVRMLImporter.__get_pure_state__c                 C   s&   |j j}|  |¡ t| |dgd� d S )NÚ
_file_path)Úignore)r    Zabs_pthÚ
initializer
   )r   ÚstateÚfnamer   r   r   Ú__set_pure_state__:   s    
zVRMLImporter.__set_pure_state__c                 C   s
   || _ d S ©N)r   )r   r   r   r   r   r"   B   s    zVRMLImporter.initializec                 C   s@   | j s<| jj| j_|  ¡  d| _ | js2|  | j¡ | j ¡  dS )z)Adds `self.actors` to the scene.
        TN)Ú_actors_addedÚsceneÚrender_windowr   Ú_update_readerZvisibleÚ_visible_changedÚrender©r   r   r   r   Ú
add_actorsH   s    zVRMLImporter.add_actorsc                 C   s(   | j r$| j | j¡ d| _ | j ¡  dS )z.Removes `self.actors` from the scene.
        FN)r'   r(   Úremove_actorsÚactorsr,   r-   r   r   r   r/   S   s    zVRMLImporter.remove_actorsc                 C   s   dS )z+ Return True as the reader has output port.Tr   r-   r   r   r   Úhas_output_port[   s    zVRMLImporter.has_output_portc                 C   s   | j jS )z Return the reader output port.)r   Zoutput_portr-   r   r   r   Úget_output_object_   s    zVRMLImporter.get_output_objectc                 C   sR   | j }||_| j |¡ |  ¡  |  ¡  dt| jƒ }d| jv rH|d7 }|| _d S )NzVRML file (%s)z[Hidden]z	 [Hidden])r   r   r    Úsetr*   r,   r   r   )r   Úvaluer   r   r   r   r   Ú_file_name_changedf   s    
zVRMLImporter._file_name_changedc                    s”   | j }| jd u s(|jd u s(t|jƒdkr,d S dd„ | jjjD ƒ‰ | ¡  | j ¡  dd„ | jjjD ƒ}‡ fdd„|D ƒ| _tˆ ƒdkr�| j ¡  d S )Nr   c                 S   s   g | ]}|‘qS r   r   ©Ú.0Úxr   r   r   Ú
<listcomp>v   ó    z/VRMLImporter._update_reader.<locals>.<listcomp>c                 S   s   g | ]}|‘qS r   r   r6   r   r   r   r9   y   r:   c                    s   g | ]}|ˆ vr|‘qS r   r   r6   ©Zactors1r   r   r9   z   r:   )	r   r(   r   ÚlenZrendererr0   Úreadr,   Z
reset_zoom)r   r   Zactors2r   r;   r   r*   q   s    ÿ
zVRMLImporter._update_readerc                 C   s,   | j r(| | j¡ | j}|j|_|  ¡  d S r&   )r'   r/   r0   r   r)   r*   )r   ÚoldÚnewr   r   r   r   Ú_scene_changed   s
    zVRMLImporter._scene_changedc                 C   s    | j r| j |¡ | j ¡  d S r&   )r'   r(   r/   r,   )r   r>   r?   r   r   r   Ú_actors_changed†   s    zVRMLImporter._actors_changedc                 C   s"   | j r| j |j¡ | j ¡  d S r&   )r'   r(   r/   Úremovedr,   )r   Z
list_eventr   r   r   Ú_actors_items_changed�   s    z"VRMLImporter._actors_items_changedc                    s2   |r| j s| j | j¡ d| _ tt| ƒ |¡ d S )NT)r'   r(   r.   r0   r   r   r+   )r   r4   r   r   r   r+   ”   s
    zVRMLImporter._visible_changed) Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r   r   r   r   r   Zoutput_infor	   r    r   r   r   Úviewr   r%   r"   r.   r/   r1   r2   r5   r*   r@   rA   rC   r+   Ú__classcell__r   r   r   r   r      s.   ÿ
ÿr   N)Ú__doc__Úos.pathr   Ztvtk.apir   Z
traits.apir   r   Ztraitsui.apir   r   r   Zapptools.persistence.file_pathr	   Z"apptools.persistence.state_picklerr
   Zmayavi.core.sourcer   Zmayavi.core.pipeline_infor   r   r   r   r   r   Ú<module>   s   