3
ËœŸW“  ã               @   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ÚhighÚ	enter_setÚ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)Ú	resizablec                sr   t t| ƒjƒ }xRd
D ]J}xdD ]}|j|| d ƒ qW |jd| d d ƒ |jd| d d ƒ qW |jd	d ƒ |S )NÚxÚyÚzÚ_minÚ_maxÚ_Ú_lowÚ_highÚplane)r    r!   r"   )r#   r$   )Úsuperr   Ú__get_pure_state__Úpop)ÚselfÚdÚaxisr   )Ú	__class__© úf/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/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 jƒ }d}|jdƒr8tjƒ }nL|jdƒsL|jdƒrVtjƒ }n.|jdƒrjtjƒ }nd|j }t	|ƒ t
|ƒ‚| j|| jd ƒ || _| jƒ  | jƒ  |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   NÚvtkStructuredGridÚvtkStructuredPointsÚvtkImageDataÚvtkRectilinearGridz8The GridPlane component does not support the %s dataset.)ÚlenÚinputsZget_output_datasetÚis_ar   ZStructuredGridGeometryFilterZImageDataGeometryFilterZRectilinearGridGeometryFilterÚ
class_namer
   Ú	TypeErrorÚconfigure_connectionr(   Ú_update_limitsÚ_update_voiÚoutputs)r,   Úinputr(   Úmsgr0   r0   r1   Úupdate_pipelinei   s&    




zCustomGridPlane.update_pipelinec             C   s   | j ƒ  | jƒ  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<   r=   Údata_changed)r,   r0   r0   r1   Úupdate_data†   s    zCustomGridPlane.update_datac             C   s   dS )z' The contour filter has an output port.Tr0   )r,   r0   r0   r1   Úhas_output_port’   s    zCustomGridPlane.has_output_portc             C   s   | j jS )z Returns the output port.)r(   Úoutput_port)r,   r0   r0   r1   Úget_output_object–   s    z!CustomGridPlane.get_output_objectc             C   sJ   | j jj}|d d… \| _| _|dd… \| _| _|dd … \| _| _d S )Né   é   )	r(   r?   Zwhole_extentr   r   r   r   r   r   )r,   Úextentsr0   r0   r1   r<   �   s    
zCustomGridPlane._update_limitsc             C   s   || j kr|| _ n| jƒ  d S )N)r   r=   )r,   Úvalr0   r0   r1   Ú_x_min_changed£   s    
zCustomGridPlane._x_min_changedc             C   s   || j k r|| _ n| jƒ  d S )N)r   r=   )r,   rJ   r0   r0   r1   Ú_x_max_changed©   s    
zCustomGridPlane._x_max_changedc             C   s   || j kr|| _ n| jƒ  d S )N)r   r=   )r,   rJ   r0   r0   r1   Ú_y_min_changed¯   s    
zCustomGridPlane._y_min_changedc             C   s   || j k r|| _ n| jƒ  d S )N)r   r=   )r,   rJ   r0   r0   r1   Ú_y_max_changedµ   s    
zCustomGridPlane._y_max_changedc             C   s   || j kr|| _ n| jƒ  d S )N)r   r=   )r,   rJ   r0   r0   r1   Ú_z_min_changed»   s    
zCustomGridPlane._z_min_changedc             C   s   || j k r|| _ n| jƒ  d S )N)r   r=   )r,   rJ   r0   r0   r1   Ú_z_max_changedÁ   s    
zCustomGridPlane._z_max_changedc             C   s|   t | jƒdkrd S | j}| j| j| j| j| j| jf}y|j	|ƒ W n t
k
r`   t|ƒ|_Y nX |jƒ  |jƒ  d| _d S )Nr   T)r6   r7   r(   r   r   r   r   r   r   Z
set_extentÚAttributeErrorÚtupleÚextentZupdate_whole_extentÚupdaterB   )r,   r(   rI   r0   r0   r1   r=   Ç   s    zCustomGridPlane._update_voi)(Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   ÚObjectr(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úviewr*   rA   rC   rD   rF   r<   rK   rL   rM   rN   rO   rP   r=   Ú__classcell__r0   r0   )r/   r1   r      s\   

r   N)Ú__doc__Ú
traits.apir   r   r   Útraitsui.apir   r   r   Útvtk.apir   Zmayavi.core.componentr	   Úmayavi.core.commonr
   r   r0   r0   r0   r1   Ú<module>   s   