a
    «ˆcè  ã                   @   sP   d Z ddlmZmZmZmZ ddlmZmZm	Z	 ddl
mZ G dd„ deƒZdS )a  A meta-component that allows a component to be optionally enabled
or disabled.  This component is mostly for illustration and is not
used anywhere.  This is because it is usually much easier to simply
add a trait in the module to enable/disable a particular component.

é    )ÚInstanceÚBoolÚStrÚProperty)ÚViewÚGroupÚItem)Ú	Componentc                	       s¶   e Zd ZdZeZeeƒZe	ddd�Z
eZedd�Zeeeeƒeeddd	d
�dd�ƒƒZdd„ Zdd„ Z‡ f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 )!ÚOptionalr   Tzif the component is enabled)ÚdescÚenabled)ÚnameÚ	componentZcustomzobject.enabled)r   ÚstyleZvisible_whenF)Zshow_labelsc                 C   s$   | j }| j|jkr| 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 the input fires a
        `pipeline_changed` event.
        TN)r   ÚinputsÚpipeline_changed)ÚselfÚcomp© r   ú]/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/components/optional.pyÚupdate_pipeline6   s    zOptional.update_pipelinec                 C   s
   d| _ dS )zÆOverride this method to do what is necessary when upstream
        data changes.

        This method is invoked (automatically) when any of the inputs
        sends a `data_changed` event.
        TN©Údata_changed©r   r   r   r   Úupdate_dataB   s    zOptional.update_datac                    s&   | j r
dS tt| ƒ ¡  | j ¡  dS )z¾This is invoked when this object is added to the mayavi
        pipeline.  Note that when start is invoked, all the other
        information for the pipeline should be already set.
        N)ÚrunningÚsuperr
   Ústartr   r   ©Ú	__class__r   r   r   N   s    zOptional.startc                    s&   | j s
dS | j ¡  tt| ƒ ¡  dS )zNInvoked when this object is removed from the mayavi
        pipeline.
        N)r   r   Ústopr   r
   r   r   r   r   r    Z   s    
zOptional.stopc                 C   s   | j r| jjS | jd jS d S )Nr   )r   r   Úoutputsr   r   r   r   r   Ú_get_outputsg   s    zOptional._get_outputsc                 C   s
   d| _ d S ©NT©r   )r   Úvaluer   r   r   Ú_enabled_changedm   s    zOptional._enabled_changedc                 C   s   |   ¡ jd }||_d S )NÚenabled_item)Ztrait_view_elementsÚcontentÚlabel)r   r%   Úitemr   r   r   Ú_label_changedq   s    zOptional._label_changedc                 C   sL   |d ur,|j | jddd� |j | jddd� |  | jd¡ |  | jd¡ d S )Nr   T)Úremover   )Zon_trait_changeÚ_fire_pipeline_changedÚ_fire_data_changed)r   ÚoldÚnewr   r   r   Ú_component_changedv   s    ÿÿzOptional._component_changedc                 C   s
   d| _ d S r#   r$   r   r   r   r   r-   €   s    zOptional._fire_pipeline_changedc                 C   s
   d| _ d S r#   r   r   r   r   r   r.   ƒ   s    zOptional._fire_data_changed)Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r!   r   r	   r   r   r   r   r)   r   r'   r   r   Úviewr   r   r   r    r"   r&   r+   r1   r-   r.   Ú__classcell__r   r   r   r   r
      s.   

ÿþÿ

r
   N)Ú__doc__Z
traits.apir   r   r   r   Ztraitsui.apir   r   r   Zmayavi.core.componentr	   r
   r   r   r   r   Ú<module>   s   