a
    «ˆc“  ã                   @   sd   d Z ddlmZ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 G dd„ deƒZd	S )
zA grid plane component.

é    )ÚInstanceÚIntÚRange)ÚViewÚGroupÚItem)Útvtk)Ú	Component)Úerrorc                
       sp  e Zd ZdZeejƒZe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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ƒZedƒZedƒZedƒZedƒZedƒZeeedd�edd�edd�edd�edd�e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 d(d)„ Z!d*d+„ Z"d,d-„ Z#d.d/„ Z$d0d1„ Z%d2d3„ Z&‡  Z'S )4ÚCustomGridPlaner   Ú_x_lowÚ_x_highTFzminimum x value of the domain)ÚvalueÚlowÚhighZ	enter_setZauto_setÚdesci'  zmaximum x value of the domainÚ_y_lowÚ_y_highzminimum y value of the domainzmaximum y value of the domainÚ_z_lowÚ_z_highzminimum z value of the domainzmaximum z value of the domainÚx_min)ÚnameÚx_maxÚy_minÚy_maxÚz_minÚz_max)Z	resizablec                    sj   t t| ƒ ¡ }dD ]F}dD ]}| || d ¡ q| d| d d ¡ | d| d d ¡ q| dd ¡ |S )N)ÚxÚyÚz)Z_minZ_maxÚ_Z_lowZ_highÚplane)Úsuperr   Ú__get_pure_state__Úpop)ÚselfÚdZaxisr   ©Ú	__class__© úf/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/components/custom_grid_plane.pyr#   Y   s    z"CustomGridPlane.__get_pure_state__c                 C   s¸   t | jƒdkrdS | jd  ¡ }d}| d¡r8t ¡ }nL| d¡sL| d¡rVt ¡ }n.| d¡rjt ¡ }nd|j }t	|ƒ t
|ƒ‚|  || jd ¡ || _|  ¡  |  ¡  |g| _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.
        r   NZvtkStructuredGridZvtkStructuredPointsZvtkImageDataZvtkRectilinearGridz8The GridPlane component does not support the %s dataset.)ÚlenÚinputsZget_output_datasetZis_ar   ZStructuredGridGeometryFilterZImageDataGeometryFilterZRectilinearGridGeometryFilterÚ
class_namer
   Ú	TypeErrorZconfigure_connectionr!   Ú_update_limitsÚ_update_voiÚoutputs)r%   Úinputr!   Úmsgr)   r)   r*   Úupdate_pipelinei   s(    




ÿzCustomGridPlane.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)r/   r0   Údata_changed©r%   r)   r)   r*   Úupdate_data†   s    zCustomGridPlane.update_datac                 C   s   dS )z' The contour filter has an output port.Tr)   r6   r)   r)   r*   Úhas_output_port’   s    zCustomGridPlane.has_output_portc                 C   s   | j jS )z Returns the output port.)r!   Zoutput_portr6   r)   r)   r*   Úget_output_object–   s    z!CustomGridPlane.get_output_objectc                 C   sJ   | j jj}|d d… \| _| _|dd… \| _| _|dd … \| _| _d S )Né   é   )	r!   r2   Zwhole_extentr   r   r   r   r   r   )r%   Úextentsr)   r)   r*   r/   �   s    
zCustomGridPlane._update_limitsc                 C   s   || j kr|| _ n|  ¡  d S ©N)r   r0   ©r%   Úvalr)   r)   r*   Ú_x_min_changed£   s    
zCustomGridPlane._x_min_changedc                 C   s   || j k r|| _ n|  ¡  d S r=   )r   r0   r>   r)   r)   r*   Ú_x_max_changed©   s    
zCustomGridPlane._x_max_changedc                 C   s   || j kr|| _ n|  ¡  d S r=   )r   r0   r>   r)   r)   r*   Ú_y_min_changed¯   s    
zCustomGridPlane._y_min_changedc                 C   s   || j k r|| _ n|  ¡  d S r=   )r   r0   r>   r)   r)   r*   Ú_y_max_changedµ   s    
zCustomGridPlane._y_max_changedc                 C   s   || j kr|| _ n|  ¡  d S r=   )r   r0   r>   r)   r)   r*   Ú_z_min_changed»   s    
zCustomGridPlane._z_min_changedc                 C   s   || j k r|| _ n|  ¡  d S r=   )r   r0   r>   r)   r)   r*   Ú_z_max_changedÁ   s    
zCustomGridPlane._z_max_changedc                 C   sz   t | jƒdkrd S | j}| j| j| j| j| j| jf}z| 	|¡ W n t
y^   t|ƒ|_Y n0 | ¡  | ¡  d| _d S )Nr   T)r+   r,   r!   r   r   r   r   r   r   Z
set_extentÚAttributeErrorÚtupleZextentZupdate_whole_extentÚupdater5   )r%   r!   r<   r)   r)   r*   r0   Ç   s    þzCustomGridPlane._update_voi)(Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   ZObjectr!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úviewr#   r4   r7   r8   r9   r/   r@   rA   rB   rC   rD   rE   r0   Ú__classcell__r)   r)   r'   r*   r      sl   
þþþþþþ	ûùr   N)Ú__doc__Z
traits.apir   r   r   Ztraitsui.apir   r   r   Ztvtk.apir   Zmayavi.core.componentr	   Zmayavi.core.commonr
   r   r)   r)   r)   r*   Ú<module>   s   