3
ÐÆ‘[R-  ã               @   sš   d Z ddlmZ ddlmZmZmZ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 eejƒ jƒZG d	d
„ d
eƒZdS )z:This module allows the user to place text on the screen.

é    )ÚStrictVersion)ÚInstanceÚRangeÚStrÚBoolÚPropertyÚFloat)ÚViewÚGroupÚItemÚInstanceEditor)Útvtk)Ústate_pickler)ÚModule)ÚPipelineInfoc                   sv  e Zd ZdZeejddd�Zedd�Z	e
d dd�Zedd	d�Zedd
d�Ze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�Zeddddddd�Zedgdgdgd�Zedkrðeedd�edd�edd�edd�edd�ddd�Zn4eedd�edd�edd�edd�edd�ddd�Zeeddd�ed d!d�d"d#�Zeed$d%dd&�ed'd(dd&�ed)d*dd&�dd+d,d-d.�Zeeeed/d�ed-d�eeed0d1d2�ƒeed3d4eeeƒd5�d6�dd7�d8dd9�eed:d4dd;�d<dd9�ƒZ edƒZ!eej"ƒZ#d=d>„ Z$d?d@„ Z%dAdB„ Z&dCdD„ Z'dEdF„ Z(dGdH„ Z)dIdJ„ Z*dKdL„ Z+e+Z,e+Z-e+Z.dMdN„ Z/dOdP„ Z0dQdR„ Z1dSdT„ Z2dUdV„ Z3‡ fdWdX„Z4‡  Z5S )YÚTextr   FT)Ú
allow_noneÚrecord)r   zthe text to be displayed)Údescg        zthe x-coordinate of the textzthe y-coordinate of the textzthe z-coordinate of the textg      ð?)Ú	enter_setÚauto_setr   z:whether the position of the object is given in 2D or in 3Dgš™™™™™Ù?z3the width of the text as a fraction of the viewportÚany)ÚdatasetsÚattribute_typesÚ
attributesz5.1Z
visibility)ÚnameÚtext_scale_modeZalignment_pointZminimum_sizeZmaximum_line_heightz
Text Actor)Úshow_borderÚlabelÚscaled_textÚ_x_position_2dz
X position)r   r   Ú_y_position_2dz
Y positionznot position_in_3d)Úvisible_whenÚ
x_positionÚX)r   r   ÚspringyÚ
y_positionÚYÚ
z_positionÚZÚPositionÚ
horizontalÚposition_in_3d)r   r   Úorientationr"   ÚtextÚwidthzobject.actor.scaled_text)r   Úenabled_whenÚactorÚcustom)Úview)r   ÚstyleÚeditor)Úshow_labelsÚ	TextActor)r   r6   Ú	_property)r   r4   Ú	resizableÚTextPropertyc             C   s&   d| _ tj| |dgdgd� d| _ d S )NTr1   Ú	_updating)ÚfirstÚignoreF)r;   r   Ú	set_state)ÚselfÚstate© rA   úV/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/modules/text.pyÚ__set_pure_state__‡   s    
zText.__set_pure_state__c             C   s    t jt| jƒd� }| _tdkr2|jdddd� n|jdddd� |j}|jd	| j| j	d
fd� |j
}|jd	d� d| j_| j| jƒ | j| jƒ | jdƒ dS )a  Override this method so that it *creates* the tvtk
        pipeline.

        This method is invoked when the object is initialized via
        `__init__`.  Note that at the time this method is called, the
        tvtk data pipeline will *not* yet be setup.  So upstream data
        will not be available.  The idea is that you simply create the
        basic objects and setup those parts of the pipeline not
        dependent on upstream sources and filters.  You should also
        set the `actors` attribute up at this point.
        )Úinputz5.1Úpropgš™™™™™Ù?g      ð?)r   r/   ÚheightT)r   r/   rF   Únormalized_viewportg        )Úcoordinate_systemÚvalue)rH   N)r   r7   Ústrr.   r1   ÚVTK_VERÚ	trait_setÚposition_coordinater#   r&   Úposition2_coordinater8   ZopacityÚ_text_changedÚ_width_changedr/   Ú_shadow_positions)r?   r1   ÚcrA   rA   rB   Úsetup_pipeline�   s    zText.setup_pipelinec             C   s
   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 any of the inputs
        sends a `pipeline_changed` event.
        TN)Úpipeline_changed)r?   rA   rA   rB   Úupdate_pipeline®   s    zText.update_pipelinec             C   s
   d| _ dS )zÌOverride this method so that it flushes the vtk pipeline if
        that is necessary.

        This method is invoked (automatically) when any of the inputs
        sends a `data_changed` event.
        TN)Zdata_changed)r?   rA   rA   rB   Úupdate_data·   s    zText.update_datac             C   s2   | j }|d krd S | jrd S t|ƒ|_| jƒ  d S )N)r1   r;   rJ   rD   Úrender)r?   rI   r1   rA   rA   rB   rO   Ä   s    
zText._text_changedc             C   s@   | j d| d| d� | j d| d| d� |s<| j| _| j| _d S )Nr#   r    )Úremover&   r!   )Ú
sync_traitr#   r    r&   r!   )r?   rI   rA   rA   rB   rQ   Í   s    



zText._shadow_positionsc             C   s®   |rd| j j_d| j j_ndd| j j_d| j j_| j}| j}|dk rHd}n|dkrTd}|dk rbd}n|dkrnd}| j||dd� | j| ƒ | jƒ  | j j	| j
| j
ƒ d| _d S )NZworldrG   r   é   F)r#   r&   Útrait_change_notifyT)r1   rM   rH   rN   r#   r&   rL   rQ   Ú_change_positionrP   r/   rT   )r?   rI   ÚxÚyrA   rA   rB   Ú_position_in_3d_changedÖ   s*    


zText._position_in_3d_changedc             C   sZ   | j }|dkrdS | jrdS | j}| j}| j}| jrD|||f|j_n
||f|_| j	ƒ  dS )z@ Callback for _x_position, _y_position, and z_position.
        N)
r1   r;   r#   r&   r(   r,   rM   rI   ÚpositionrW   )r?   r1   r]   r^   ÚzrA   rA   rB   r\   ð   s    
zText._change_positionc             C   s.   | j }|d krd S | jrd S ||_| jƒ  d S )N)r1   r;   r/   rW   )r?   rI   r1   rA   rA   rB   rP     s    zText._width_changedc             C   s@   d| _ z,| j}|j| _|j}|\| _| _|j| _W d d| _ X d S )NTF)r;   r1   rD   r.   r`   r#   r&   r/   )r?   r1   ÚposrA   rA   rB   Ú_update_traits  s    zText._update_traitsc             C   s   | j S )N)r8   )r?   rA   rA   rB   Ú_get_property  s    zText._get_propertyc             C   s„   |d k	r<x"|| j fD ]}|j| jdd� qW |j| jdd� |j| _ x|| j fD ]}|j| jƒ qPW |j| jƒ |g| _| jƒ  d S )NT)rX   )r8   Úon_trait_changerW   rc   Ztext_propertyZactors)r?   ÚoldÚnewÚobjrA   rA   rB   Ú_actor_changed  s    zText._actor_changedc             C   s   || j _| jƒ  d S )N)ÚpropertyÚcolorrW   )r?   rf   rg   rA   rA   rB   Ú_foreground_changed_for_scene,  s    z"Text._foreground_changed_for_scenec                s$   t t| ƒj||ƒ | jd |jƒ d S )N)Úsuperr   Ú_scene_changedrl   Ú
foreground)r?   rf   rg   )Ú	__class__rA   rB   rn   1  s    zText._scene_changed)6Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r7   r1   r   rj   r   r.   r   r#   r&   r(   r   r    r!   r   r,   r/   r   Ú
input_inforK   r
   r   Z_text_actor_groupZ_position_group_2dZ_position_group_3dr	   r   r3   r;   r:   r8   rC   rS   rU   rV   rO   rQ   r_   r\   Z_x_position_changedZ_y_position_changedZ_z_position_changedrP   rc   rd   ri   rl   rn   Ú__classcell__rA   rA   )rp   rB   r      s¢   






					r   N)Ú__doc__Údistutils.versionr   Ú
traits.apir   r   r   r   r   r   Útraitsui.apir	   r
   r   r   Útvtk.apir   Zapptools.persistencer   Zmayavi.core.moduler   Úmayavi.core.pipeline_infor   ÚVersionÚvtk_versionrK   r   rA   rA   rA   rB   Ú<module>   s    