3
5Ad]?  ã               @   st   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 ddlmZ ddlmZ ddlmZ G dd	„ d	eƒZd
S )a   This module allows the user to place text in 3D at a location on the
scene.

Unlike the 'Text' module, this module positions text in 3D in the scene,
and in 2D on the screen. As a result the text resizes with the figure,
and can be masked by objects in the foreground.
é    )ÚInstanceÚStrÚCArrayÚBool)ÚViewÚGroupÚItem)Útvtk)ÚModule)ÚPipelineInfo)ÚActorc                   sT  e Zd ZdZeeddd�Zeejddd�Z	e
ddddd�Zed8d	d
ddd�Zed9d	dddd�Zed:d	dddd�Zeddd�Zedgdgdgd�Zeeedd�eedd�dddd�eedd�dddd�eedd�eddd�ddd�dd �eed!d"dd#�d$d �ƒZd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd;d4d5„Z‡ fd6d7„Z ‡  Z!S )<ÚText3Dr   FT)Ú
allow_noneÚrecordÚTextzthe text to be displayed)ÚdescÚ	enter_setÚauto_setç        é   z!the world coordinates of the text)ÚvalueÚcolsr   r   r   ç      ð?zthe scale of the textz"the orientation angles of the textz%if the text is kept facing the camera)r   Úany)ZdatasetsZattribute_typesZ
attributesÚtext)ÚnameÚpositionZPosition)Zshow_labelsÚshow_borderÚlabelÚscaleÚScaleÚorient_to_cameraÚorientationZAngles)r   r   ZOrientation)r   r   )r   ÚactorZcustom)r   ÚstyleZ
show_labelr   c             C   s2   t j| jd�| _| jg| _tƒ | _| j| jƒ 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.
        )r   N)r	   Ú
VectorTextr   Úvector_textÚoutputsr   r#   Ú_text_changed)Úself© r*   ú|/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/mayavi-4.7.1-py3.6-linux-x86_64.egg/mayavi/modules/text3d.pyÚsetup_pipelineY   s    
zText3D.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)Zpipeline_changed)r)   r*   r*   r+   Úupdate_pipelinej   s    zText3D.update_pipelinec             C   s   dS )z, Return True as the text3d has output port. Tr*   )r)   r*   r*   r+   Úhas_output_ports   s    zText3D.has_output_portc             C   s   | j jS )N)r&   Zoutput_port)r)   r*   r*   r+   Úget_output_objectw   s    zText3D.get_output_objectc             C   s(   | j }|d krd S t|ƒ|_| jƒ  d S )N)r&   Ústrr   Úrender)r)   r   r&   r*   r*   r+   r(   }   s
    
zText3D._text_changedc             C   sP   | j |_ | g|_| j||ƒ d }|d k	r.|j}| j|d�|_|j| _| jƒ  d S )N)Úold)ÚsceneÚinputsZ_change_componentsr#   Ú_get_actor_or_followerZactorsr1   )r)   r2   ÚnewZ	old_actorr*   r*   r+   Ú_actor_changed„   s    zText3D._actor_changedc             C   s   | j | jjd�| j_d S )N)r2   )r5   r#   )r)   r*   r*   r+   Ú_orient_to_camera_changed�   s    z Text3D._orient_to_camera_changedNc             C   s˜   | j r$tjƒ }| jdk	r,| jj|_ntjƒ }|dk	rj| jd|ddd� | jd|ddd� | jd|ddd� | jd|dƒ | jd|dƒ | jd|dƒ |S )zÊ Get a tvtk.Actor or a tvtk.Follower for the actor of the
            object and wire the callbacks to it.
            If old is given, it is the old actor, to remove its
            callbacks.
        Nr   T)Úremover   r"   )r!   r	   ZFollowerr3   Úcamerar   Z
sync_trait)r)   r2   r6   r*   r*   r+   r5   ”   s    
zText3D._get_actor_or_followerc                s0   t t| ƒj||ƒ |d k	r,| jr,|j| jj_d S )N)Úsuperr   Ú_scene_changedr!   r:   r#   )r)   r2   r6   )Ú	__class__r*   r+   r<   ª   s    zText3D._scene_changed)r   r   r   )r   r   r   )r   r   r   )N)"Ú__name__Ú
__module__Ú__qualname__Ú__version__r   r   r#   r	   r%   r&   r   r   r   r   r   r"   r   r!   r   Z
input_infor   r   r   Úviewr,   r-   r.   r/   r(   r7   r8   r5   r<   Ú__classcell__r*   r*   )r=   r+   r      sZ   







	
r   N)Ú__doc__Z
traits.apir   r   r   r   Ztraitsui.apir   r   r   Ztvtk.apir	   Zmayavi.core.moduler
   Zmayavi.core.pipeline_infor   Zmayavi.components.actorr   r   r*   r*   r*   r+   Ú<module>   s   