a
    «ˆcrE ã                   @   s‚  d Z ddlZddlZddlZddlmZmZmZmZm	Z	 ddl
mZmZmZmZmZmZmZmZ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" dd
l#m$Z$ ddl%m&Z& da'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„ Z0dd„ Z1d d!„ Z2d"d#„ Z3d$d%„ Z4d&d'„ Z5G d(d)„ d)e$ƒZ6G d*d+„ d+eƒZ7G d,d-„ d-ej8ƒZ9G d.d/„ d/eƒZ:G d0d1„ d1eƒZ;G d2d3„ d3eƒZ<G d4d5„ d5eƒZ=G d6d7„ d7eƒZ>G d8d9„ d9eƒZ?G d:d;„ d;eƒZ@G d<d=„ d=eƒZAG d>d?„ d?eƒZBG d@dA„ dAeƒZCe>ZDe9ZEe:ZFe;ZGe<ZHe=ZIe?ZJe@ZKeAZLeBZMeCZNejOjPZQdBdC„ ZRdDdE„ ZSdFdG„ ZTdHdI„ ZUdJdK„ ZVdLdM„ ZWdNdO„ ZXdS )Pa~  A module that provides VPython like capabilities.  For more
details about VPython, refer the official website.
VPython : http://www.vpython.org/index.html

The API is based on VPython, but instead of using OpenGL and other C
libraries, this is based completly on TVTK, and Traits and Numpy.
All of the demos are also translated from VPython examples.

The implementation is done using object oriented design, and each
visualization capability is implemented as a seperate traits class.
The attributes of each class could be independently edited.

The API is kept as similar to VPython as much as possible.

This module offers the following classes :

 Display actors
 sphere, cylinder, cone, box, arrow, curve, ring, helix, ellipsoid

 Functionality classes
 frame, vector, animator

 Utility functions
 iterator, remove_actor, show

To see examples of classes and functions look at the `test_*`
functions at the end of this file. Here is a quick example
demonstrating how to use visual.

Note: The visual module should be interactively used in ipython only when
--gui=qt is enabled. `visual` will not work properly in an interactive mode
with the vanilla python interpretor.  ::

    $ ipython --gui=qt

    In [1]: from tvtk.tools import visual
    In [2]: visual.test_sphere()
    In [3]: s = visual.sphere() # Create a sphere actor
    In [4]: s.edit_traits() # Edit sphere actor's properties via GUI

é    N)ÚsinÚcosÚpiÚsqrtÚacos)Ú	HasTraitsÚTraitÚInstanceÚTupleÚIntÚRangeÚButtonÚArrayÚBoolÚAnyÚListÚEnum)ÚViewÚItemÚGroup)Útvtk)Úivtk)Úconfigure_input)ÚGUI)ÚTimer)Úvtk_color_traitc                  C   s    t jdd�} d| j_t ¡  | S )z<Creates and retunrs the ivtk viewer to get_viewer() functionF)Zbrowser©r   r   r   )r   ÚviewerÚsceneZ
backgroundr   Zprocess_events)Úv© r    úT/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/tvtk/tools/visual.pyÚ_create_viewerK   s    r"   c                 C   s   | a dS )z¥Set the global viewer.  Handy if you need to use visual from your
    own viewer.  Pass an object that has a `scene` trait containing a
    tvtk scene instance.
    N)Ú_viewer)r   r    r    r!   Ú
set_viewerR   s    r$   c                   C   s6   t du rtƒ a n"zt j ¡  W n   tƒ a Y n0 t S )zî Creates and returns an ivtk viewer. If the fuction is called
    1st time than creates and returns the viewer, otherwise the
    originally created viewer itself is returned. Checking is done
    through the global variable _viewer.
    N)r#   r"   r   Úrenderr    r    r    r!   Ú
get_viewerZ   s    r&   c                  G   s    t ƒ }|j | ¡ |j ¡  dS )zn Gets an ivtk viewer from the function get_viewer() and adds
    all the actors given, to the ivtk scene.
    N)r&   r   Z
add_actorsÚ
reset_zoom)Útvtk_actorsr   r    r    r!   Ú
show_actoro   s    r)   c                  G   s,   t ƒ }| D ]}|j |j¡ |j ¡  q
dS )zo Gets the ivtk viewer from the function get_viewer() and
    removes all the actors given, from the ivtk scene.N)r&   r   Zremove_actorsÚactorr'   )r(   r   Úxr    r    r!   Úremove_actorw   s    r,   c                  C   s(   dt jv s$dt jv rntƒ } |  ¡  dS )zºThis function has to be called at the end in a stand alone
    visual program. Note - Don't call this function when running
    visual from ipython iterpretor in an interactive mode
    z-wthreadz--guiN)ÚsysÚargvr   Zstart_event_loop)Úguir    r    r!   Úshow   s    r0   c                 O   s   t | |g|¢R i |¤ŽS )zˆCreates an instance of utility class Animator and returns it,
    used for programs with animations, see examples for demonstration
    )ÚAnimator)ÚmillisecÚcallableÚargsÚkwargsr    r    r!   ÚiterateŠ   s    r6   c                 C   s   ||  }|| |dd…< |S )z±Translate function takes 3 arguments the old position, new
    position and the points. The function translates all the points to
    the new position and returns the new pointsNr    )ÚoldÚnewÚpointsÚdiffr    r    r!   Ú	translate�   s    r;   c                 C   s   ||  |dd…< |S )zÎTranslate function takes 2 arguments the with which the points
    are required to be translated and the points. The function
    translates all the points to the new position and returns the new
    pointsNr    )r:   r9   r    r    r!   Útranslate_points˜   s    r<   c           	      C   sz  t j| td�} | tt  | | ¡ƒ } | d }| d }| d }|t d }t|ƒ}t|ƒ}t  dt¡}|d| ||   |d d< d| | | ||  |d d< d| | | ||  |d d< d| | | ||  |d d< |d| ||   |d d< d| | | ||  |d d< d| | | ||  |d d< d| | | ||  |d d< |d| ||   |d d< |S )zWCreate a rotation matrix given an axis and an angle (in
    degrees) to rotate by.
    ©Údtyper   é   é   é´   )é   rB   )	ÚnumpyÚasarrayÚfloatr   Úinnerr   r   r   Úzeros)	ÚaxisÚangler+   ÚyÚzÚtZcostZsintÚrotatorr    r    r!   Ú_create_rotation_matrix    s&          rN   c                 C   s  | t tt | | ¡ƒƒ }|tt ||¡ƒ }t ||¡}tt|ƒd ƒdk rˆ|dk r„| }t||ƒ}| |dd…< |}t||ƒ}|S |S t|ƒ}t ||¡}	t	|	d| t
 ƒ}
t |d¡rÔt ||
j¡|dd…< |S | }t||ƒ}t ||
j¡|dd…< |}t||ƒ}|S dS )a  The function takes 4 arguments, the old and the new axis, the
    position and points. All arguments should be given as a numpy
    array, The first 3 can also be given in form of a tuple. The
    function rotates all the points so that they become aligned with
    the new axisç      ð?g»½×Ùß|Û=r   Nç     €f@ç        )rE   r   rC   rF   ÚdotÚabsr<   r   ÚcrossrN   r   ÚallcloseÚT)r7   r8   Úposr9   ÚoÚnZdpdtr:   ÚalphaÚraxisÚdatar    r    r!   Úaxis_changedº   s0    



r]   c           	      C   sì   t | |ƒ}t |d¡rPt |d¡rPt ||j¡|dd…< t ||j¡}|||fS d|d  d|d  d|d  f}|| }t||ƒ}t ||j¡|dd…< t ||j¡}|d |d |d f}t||ƒ}|| }t ||j¡}|||fS dS )a]  Rotate function takes 6 arguments the axis about which the
    actor has to be rotated, the angle with which the actor has to be
    rotated, the point (origin) about which actor has to be rotated
    and posistion, points and current axis of the actor. The function
    returns the new position, points and axis of the actor after the
    rotation.rQ   Néÿÿÿÿr   r?   r@   )rN   rC   rU   rR   rV   r<   )	rH   rI   ÚoriginrW   r9   Úmaxisr\   r[   r:   r    r    r!   Úrotateä   s    

"

ra   c                 C   sx   t j| td�} t| |ƒ}t  |d¡r:t  ||j¡}||fS || }t  ||j¡}|| }|tt  ||¡ƒ }||fS dS )aN  Rotate function takes 5 arguments the axis about which the
    actor has to be rotated, the angle with which the actor has to be
    rotated, the point (origin) about which actor has to be rotated
    and posistion, and current axis of the actor. The function returns
    the new position and new axis of the actor after the rotation.r=   rQ   N)	rC   rD   rE   rN   rU   rR   rV   r   rF   )rH   rI   r_   rW   r`   r\   r[   r    r    r!   Úrotate_single_pointý   s    
rb   c                 C   s¨   t j| td�}t  |¡}t  |d¡r>t  ||j¡|dd…< |S d|d  d|d  d|d  f}t||ƒ}t  ||j¡|dd…< |d |d |d f}t||ƒ}|S dS )zÇScale function takes 2 arguments the scaling_factor in a form
    of list, or a tuple giving the scale factor for x,y and z
    axis. The function returns the new points ofthe actor after
    scalingr=   rQ   Nr^   r   r?   r@   )rC   rD   rE   ZdiagrU   rR   rV   r<   )Zscale_factorr9   rW   Zscr\   r:   r    r    r!   Úscale  s    
"

rc   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚVTimerc                 O   s8   t j| ||g|¢R i |¤Ž tƒ | _| j | jd¡ d S )NÚclosing)r   Ú__init__r&   r   Úon_trait_changeÚ_close)ÚselfZ	millisecsr3   r4   Úkw_argsr    r    r!   rf   )  s    zVTimer.__init__c                 C   s   |   ¡  tdƒ d S )Nz5Stopping iterations since the viewer has been closed.)ÚStopÚprint©ri   r    r    r!   rh   /  s    zVTimer._closec                 C   sL   z| j | ji | j¤Ž W n. ty2   |  ¡  Y n   |  ¡  ‚ Y n0 dS )z/Overridden to call the given callable.
        N)r3   r4   rj   ÚStopIterationrk   rm   r    r    r!   ÚNotify3  s    zVTimer.NotifyN)Ú__name__Ú
__module__Ú__qualname__rf   rh   ro   r    r    r    r!   rd   (  s   rd   c                   @   s˜   e Zd ZedƒZedƒZeddddd�Zee	ƒZ
eedd	d
�edƒedd	d
�edƒdd�Zeeedd�ddgdd�Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r1   zStart AnimationzStop Animationr?   i † éd   z.Specifies frequency with which timer is called©ÚdescÚstart_animationÚsimple)ÚstyleÚ_Ústop_animationF)Zshow_labelsÚtime_period©ÚnamezAnimation ControlerÚOKéú   )ÚtitleÚbuttonsÚwidthc                 O   s$   || _ t||g|¢R i |¤Ž| _d S ©N)r{   rd   Úitimer)ri   r2   r3   r4   r5   r    r    r!   rf   Y  s    zAnimator.__init__c                 C   s   | j  ¡  d S rƒ   )r„   ÚStartrm   r    r    r!   Ú_start_animation_fired_  s    zAnimator._start_animation_firedc                 C   s   | j  ¡  d S rƒ   )r„   rk   rm   r    r    r!   Ú_stop_animation_firedb  s    zAnimator._stop_animation_firedc                 C   s6   | j }|d u rd S ||_| ¡ r2| ¡  | |¡ d S rƒ   )r„   r2   Z	IsRunningrk   r…   )ri   ÚvaluerL   r    r    r!   Ú_time_period_changede  s    zAnimator._time_period_changedN)rp   rq   rr   r   rv   rz   r   r{   r	   rd   r„   r   r   Zevent_groupr   Útraits_viewrf   r†   r‡   r‰   r    r    r    r!   r1   >  s(   ÿ
üþr1   c                   @   sˆ   e Zd ZdZddd„Zdd„ Zdd„ ZeeeƒZd	d
„ Z	dd„ Z
ee	e
ƒZdd„ Zdd„ ZeeeƒZdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚMVectorzNMVector class gives many of the functionalities given by Vector
    of VPythonrQ   c                 C   s0   t  |||ft¡}t jj| d|tdd�}| ¡ S )N)rB   F)ÚshapeÚbufferr>   Úorder)rC   ÚarrayrE   ÚndarrayÚ__new__Úcopy)Úsubtyper+   rJ   rK   r\   Úretr    r    r!   r‘   q  s    
þzMVector.__new__c                 C   s   | d S ©Nr   r    rm   r    r    r!   Ú_get_xx  s    zMVector._get_xc                 C   s   || d< d S r•   r    ©ri   Úvalr    r    r!   Ú_set_x{  s    zMVector._set_xc                 C   s   | d S ©Nr?   r    rm   r    r    r!   Ú_get_y€  s    zMVector._get_yc                 C   s   || d< d S rš   r    r—   r    r    r!   Ú_set_yƒ  s    zMVector._set_yc                 C   s   | d S ©Nr@   r    rm   r    r    r!   Ú_get_zˆ  s    zMVector._get_zc                 C   s   || d< d S r�   r    r—   r    r    r!   Ú_set_z‹  s    zMVector._set_zc                 C   s4   | j |j  }| j|j }| j|j }|| | }|S )z¤ Function performs the dot vector multiplication of 2
        vector instances and returning a new vector instance equal to
        the dot product of given vectors)r+   rJ   rK   )Úvec1Úvec2ÚiÚjÚkrR   r    r    r!   rR   �  s
    zMVector.dotc                 C   sX   | j |j | j|j   }| j|j | j|j  }| j|j  | j |j  }t|||ƒ}|S )zª Function performing the cross vector multiplication of 2
        vector instances and returning a new vector instance equal to
        the cross product of given vectors)rJ   rK   r+   r‹   )r    r¡   r¢   r£   r¤   rT   r    r    r!   rT   š  s
    zMVector.crossc                 C   s,   t | d d | d d  | d d  ƒ}|S )z8 Function computes and returns the magnitude of a vectorr   r@   r?   )r   )ÚvecÚmagr    r    r!   r¦   ¤  s    (zMVector.magc                 C   s   | t t | | ¡ƒ }|S )zL Function computes and returns the normalized form of a
        given vector)r   rC   rF   )r¥   Únormr    r    r!   r§   ©  s    zMVector.normN)rQ   rQ   rQ   )rp   rq   rr   Ú__doc__r‘   r–   r™   Úpropertyr+   r›   rœ   rJ   rž   rŸ   rK   rR   rT   r¦   r§   r    r    r    r!   r‹   n  s   





r‹   c                	   @   sò   e Zd ZdZeddd�Zeddddd	�Zedddd
d	�Zeddddd	�Z	eddd�Z
eZedƒZeZeeeddd�eddd�eddd�edd�ddd�dgd�Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Ze g d¢¡fd*d+„Zd,S )-ÚFramez~Frame groups together all the actors given to it into a single
    unit, so that they can be manipulated as a combined entity.©rO   rQ   rQ   zthe frame axis©rˆ   ru   ç°÷™9ýþç°÷™9ý~rQ   z!the X coordinate of frame objectsrt   z!the Y coordinate of frame objectsz!the Z coordinate of frame objects©rQ   rQ   rQ   zthe frame posTr+   úPos X©r}   ÚlabelrJ   úPos YrK   úPos ZÚ
visibilityr|   zFrame Properties©r²   Zshow_borderr~   ©r�   c                 O   sp   t |ƒ| _tj| fi |¤Ž t | ¡ ƒ| _|  t g d¢¡| j¡ |  	d| j
¡ |  d| j¡ |  d| j¡ d S )Nr¯   rQ   )ÚlistÚargr   rf   ÚkeysÚ_pos_changedrC   r�   rW   Ú
_x_changedr+   Ú
_y_changedrJ   Ú
_z_changedrK   )ri   Ú	argumentsÚtraitsr    r    r!   rf   Ê  s    
zFrame.__init__c                 C   s$   || }| j D ]}|j| |_qd S rƒ   )r¹   rW   ©ri   r7   r8   r:   Úar    r    r!   r»   Ø  s    
zFrame._pos_changedc                 C   s$   || }| j D ]}|j| |_qd S rƒ   )r¹   r+   rÁ   r    r    r!   r¼   Ý  s    
zFrame._x_changedc                 C   s$   || }| j D ]}|j| |_qd S rƒ   )r¹   rJ   rÁ   r    r    r!   r½   â  s    
zFrame._y_changedc                 C   s$   || }| j D ]}|j| |_qd S rƒ   )r¹   rK   rÁ   r    r    r!   r¾   ç  s    
zFrame._z_changedc                 C   s~   t  ||¡rnl|tt  ||¡ƒ }|tt  ||¡ƒ }t  ||¡}tt  ||¡ƒ}d| t }| jD ]}| 	||| j
¡ qdd S )NrP   )rC   rU   r   rF   rT   r   rR   r   r¹   ra   rW   )ri   r7   r8   rX   rY   r[   rZ   rÂ   r    r    r!   Ú_axis_changedì  s    
zFrame._axis_changedc                 C   s>   t |ƒ}|dkr&| jD ]}d|j_qn| jD ]}d|j_q,d S ©Nr?   r   )Úintr¹   r*   rµ   )ri   rˆ   r˜   rÂ   r    r    r!   Ú_visibility_changedû  s    

zFrame._visibility_changedc                 C   sX   | j D ]}| |||¡ qt g d¢¡}t|||| j|| jƒ\}}}| j||dd� d S )Nr«   F)rW   rH   Útrait_change_notify)r¹   ra   rC   r�   rW   rH   Ú	trait_set)ri   rI   rH   r_   rÂ   ÚptsrW   Zfaxisr    r    r!   ra     s
    
zFrame.rotateN)rp   rq   rr   r¨   r   rH   r   r+   rJ   rK   rW   r   Zobjectsr   rµ   r   r   r   r   r   rŠ   rf   r»   r¼   r½   r¾   rÃ   rÆ   rC   r�   ra   r    r    r    r!   rª   ¯  s4   

ûú	rª   c                   @   sº  e Zd ZdZeeddd�Zeddd�Zedd	d
dd�Z	eddd�Z
edd	ddd�Zedd	ddd�Zedd	ddd�ZedƒZedddƒZedƒZeejdd�ZeejƒZeejdd�Zeejdd�Zeejdd�Ze Z!e"e#e$dd�e$dd�e$dd�e$ddd �e$d!d"d �e$d#d$d �e$d%d�d&dd'�	d(gd)�Z%d*d+„ Z&d,d-„ Z'd.d/„ Z(d0d1„ Z)e* +g d¢¡fd2d3„Z,d4d5„ Z-d6d7„ Z.d8d9„ Z/d:d;„ Z0d<d=„ Z1d>d?„ Z2d@dA„ Z3dBdC„ Z4dDdE„ Z5dFdG„ Z6dHdI„ Z7dJS )KÚCurvez”Curve class creates a polydata source using point and
    connectivity arrays given by the user, which inturn is used to
    create a polydata actor©NrB   zthe points of the curve)r>   rŒ   ru   r¯   zthe curve posr¬   rQ   r®   ç{®Gáz„?zthe radius of curve tuber«   zthe curve axisr­   zthe X coordinate of curvert   zthe Y coordinate of curvezthe Z coordinate of curve©rO   rO   rO   ÚsÚwÚpTr    )r4   Úcolorr|   rµ   Úradiusr+   r°   r±   rJ   r³   rK   r´   ÚrepresentationzCurve Propertiesr¶   r~   r·   c                 K   s:  | j j| _t| j| jƒ t| j| jƒ d| j_d| j_t 	¡ }t|| jƒ || j _
| j ¡  | j ¡  | j j| _| j| j_t| j ƒ tƒ | _| j | jjj¡ | j  | jjj¡ | j | jjj¡ | dd ¡}tj| fi |¤Ž |  | j¡ |  | j¡ |  | j¡ |  | j¡ |d u�r6|  t  d¡tj!|t"d�¡ d S )Né   r?   rH   r«   r=   )#r*   r©   r   ÚstripperÚpolydataÚtubeÚnumber_of_sidesÚcappingr   ÚPolyDataMapperÚmapperÚupdaterÓ   r)   r&   r   rg   r   r%   Úpopr   rf   Ú_points_changedr9   Ú_color_changedrÑ   rÆ   rµ   Ú_radius_changedrÒ   rÃ   rC   r�   rD   rE   )ri   rÀ   ÚmrH   r    r    r!   rf   ;  s6    






ÿzCurve.__init__c                 C   s   |   |g¡ dS )zMFunction appeneds new points given as arguments to the
        current pointsN)Úextend)ri   Zpntr    r    r!   Úappend_  s    zCurve.appendc                 C   sb   | j d u r|}n@| j jd }t | j |t|ƒ df¡}| j |d |…< |||d …< || _ |  ¡  d S )Nr   rB   )r9   rŒ   rC   ÚresizeÚlenrÜ   )ri   rÉ   rÐ   rY   r    r    r!   râ   d  s    
zCurve.extendc                 C   s.   | j  ¡  | j ¡  | j ¡  | jj ¡  d S rƒ   )rÖ   ÚmodifiedrÕ   rÜ   r×   r   r   r%   rm   r    r    r!   rÜ   o  s    


zCurve.updatec              
   C   s„   t |||| j| jt g d¢¡ƒ\}}}| j|dd� | j|dd� | j|dd� | j| j_| j ¡  | j 	¡  | j
 	¡  |  ¡  dS )úÿFunction takes atleast 2 arguments: axis about which to
        rotate the actor and angle with which to rotate the actor, the
        3rd agrument is origin i.e. the point about which to rotate
        the actor, by default it is set to the global originr¯   F©rW   rÇ   ©r9   rÇ   ©rH   rÇ   N)ra   rW   r9   rC   r�   rÈ   rÖ   ræ   rÕ   rÜ   r×   r%   ©ri   rI   rH   r_   rÐ   r   Úaxr    r    r!   ra   u  s    &



zCurve.rotatec                 C   s   | j }|dur|j ¡  dS )z1Function redraws/refreshs the ivtk viewer's sceneN©r   r   r%   ©ri   r   r    r    r!   r%   „  s    zCurve.renderc                 C   sÂ   d | j _|| j _|d u r"d}d }n^t| jƒd }t |dfd¡}t d|d dd¡|d d …df< t d|d dd¡|d d …df< || j _| j  ¡  | j 	¡  | j
 	¡  | j}|d ur¾|j ¡  d S )Nr   r?   r@   Úlç      à?)rÖ   Úlinesr9   rå   rC   rG   Úarangeræ   rÕ   rÜ   r×   r   r   r%   )ri   rˆ   Únprñ   r   r    r    r!   rÞ   Œ  s       


zCurve._points_changedc                 C   s$   || _ | j | jd | jd f| _d S ©Nr?   r@   ©r+   rW   ©ri   rˆ   r    r    r!   r¼   Ÿ  s    zCurve._x_changedc                 C   s$   || _ | jd | j | jd f| _d S ©Nr   r@   ©rJ   rW   rö   r    r    r!   r½   £  s    zCurve._y_changedc                 C   s$   || _ | jd | jd | j f| _d S ©Nr   r?   ©rK   rW   rö   r    r    r!   r¾   §  s    zCurve._z_changedc                 C   s†   | j |d dd� | j |d dd� | j |d dd� t||| jƒ}| j |dd� | j| j_| j ¡  | j ¡  | j ¡  |  ¡  d S )	Nr   F©r+   rÇ   r?   ©rJ   rÇ   r@   ©rK   rÇ   ré   )	rÈ   r;   r9   rÖ   ræ   rÕ   rÜ   r×   r%   )ri   r7   r8   rÐ   r    r    r!   r»   «  s    



zCurve._pos_changedc                 C   s    t ||| j| jƒ}| ¡ | _d S rƒ   )r]   rW   r9   r’   )ri   r7   r8   rÉ   r    r    r!   rÃ   ·  s    zCurve._axis_changedc                 C   s   || j j_d S rƒ   ©r*   r©   rÑ   rö   r    r    r!   rß   »  s    zCurve._color_changedc                 C   s   | j | j_ d S rƒ   )rÒ   r×   rö   r    r    r!   rà   ¾  s    zCurve._radius_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   ©rÓ   r©   ræ   r%   rö   r    r    r!   Ú_representation_changedÁ  s    

zCurve._representation_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   ©rÅ   r*   rµ   ©ri   rˆ   r˜   r    r    r!   rÆ   Æ  s    
zCurve._visibility_changedN)8rp   rq   rr   r¨   r   rE   r9   rW   r   rÒ   rH   r+   rJ   rK   r   rÑ   r   rÓ   r   rµ   r	   r   ÚPolyDatarÖ   ÚPropertyr©   ZStripperrÕ   Ú
TubeFilterr×   ÚActorr*   r   r   r   r   r   rŠ   rf   rã   râ   rÜ   rC   r�   ra   r%   rÞ   r¼   r½   r¾   r»   rÃ   rß   rà   r   rÆ   r    r    r    r!   rÊ     sZ   



ø	÷$rÊ   c                   @   sº  e Zd ZdZeddd�Zeddddd	�Zed
dd	�Zeddd	�Z	e
dƒZeddddd�Zeddddd�Zeddddd�ZedddƒZeddddd	�ZedƒZeZeejdƒZeejƒZeejdƒZeejdƒZee  ¡ dƒZ!e"e#e$dd�e$dd�e$dd d!�e$d"d#d!�e$d$d%d!�e$d&d�e$d'd�e$d(d�d)dd*�
d+gd,�Z%d-d.„ Z&d/d0„ Z'd1d2„ Z(d3d4„ Z)d5d6„ Z*d7d8„ Z+d9d:„ Z,d;d<„ Z-d=d>„ Z.d?d@„ Z/dAdB„ Z0dCdD„ Z1e2 3g d
¢¡fdEdF„Z4dGdH„ Z5dIS )JÚRingzjRing class creates a Ring form tvtk polydata, follows
    the usual VTK pipeline and creates a ring actor.Úd)éh  rB   ©rŒ   r­   r®   rð   zthe ring radiusr¬   r¯   zthe ring posr«   zthe ring axisrÍ   rQ   zthe X coordinate of ring centerrt   zthe Y coordinate of ring centerzthe Z coordinate of ring centerrÎ   rÏ   rÐ   r   rÌ   zthe ring thicknessTr    rÒ   r|   Ú	thicknessr+   r°   r±   rJ   r³   rK   r´   rÑ   rµ   rÓ   zRing Propertiesr¶   r~   r·   c                 K   s4  | j j| _t ¡ | _t| j| jƒ t| j| jƒ | j ¡  | j ¡  d| j_	d| j_
t ¡ }t|| jƒ || j _| j j| _| j| j_tƒ | _| j | jjj¡ | j  | jjj¡ | j | jjj¡ tj| fi |¤Ž |  ¡  |  g d¢| j¡ |  | j¡ |  | j¡ |  | j¡ |  t  d¡| j!¡ t"| j ƒ d S ©NrÔ   r?   r¯   r«   )#r*   r©   r   ÚPolyDataNormalsÚnormalsr   rÖ   r×   rÜ   rØ   rÙ   rÚ   rÛ   rÓ   r&   r   rg   r   r%   r   rf   Ú_create_pointsr»   rW   rß   rÑ   rÆ   rµ   Ú_thickness_changedr  rÃ   rC   r�   rH   r)   ©ri   rÀ   rá   r    r    r!   rf   ö  s2    





zRing.__init__c                 C   sè   t dddƒD ]N}|t d }d| j| d< | jt|ƒ | j| d< | jt|ƒ | j| d< qt| jƒd }t |dfd¡}t 	d|d dd¡|d d …df< t 	d|d dd¡|d d …df< | j| j
_|| j
_| j}|d urä|j ¡  d S )	Nr   r	  r?   rA   rQ   r@   rï   rð   )Úranger   r9   rÒ   r   r   rå   rC   rG   rò   rÖ   rñ   r   r   r%   )ri   r¢   Úthetaró   rñ   r   r    r    r!   r    s      
zRing._create_pointsc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   *  s    zRing._color_changedc                 C   sØ   || }t  | jd¡rZ|| jd d …  | jd d …< | j ¡  | j ¡  | j ¡  |  	¡  nz| j}d| }t
|| jƒ| _|| jd d …  | jd d …< |}t
|| jƒ| _| j| j_| j ¡  | j ¡  | j ¡  |  	¡  d S )NrQ   r¯   )rC   rU   rW   r9   rÖ   ræ   r  rÜ   r×   r%   r<   )ri   r7   r8   ZfactorÚcr:   r    r    r!   rà   -  s$    







zRing._radius_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   C  s    zRing._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   G  s    zRing._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   K  s    zRing._z_changedc                 C   sz   | j |d dd� | j |d dd� | j |d dd� t||| jƒ| _| j| j_| j ¡  | j ¡  | j ¡  |  ¡  d S ©Nr   Frû   r?   rü   r@   rý   ©	rÈ   r;   r9   rÖ   ræ   r  rÜ   r×   r%   ©ri   r7   r8   r    r    r!   r»   O  s    



zRing._pos_changedc                 C   sH   t ||| j| jƒ| _| j| j_| j ¡  | j ¡  | j ¡  |  ¡  d S rƒ   ©	r]   rW   r9   rÖ   ræ   r  rÜ   r×   r%   r  r    r    r!   rÃ   Z  s    



zRing._axis_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   b  s    

zRing._representation_changedc                 C   s   || j _d S rƒ   )r*   rµ   rö   r    r    r!   rÆ   g  s    zRing._visibility_changedc                 C   s   || j _d S rƒ   ©r×   rÒ   rö   r    r    r!   r  j  s    zRing._thickness_changedc                 C   st   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  | j ¡  | j	 ¡  |  
¡  dS )a  Function takes atleast 2 arguments: angle with which to
        rotate the actor, and the axis about which to rotate the
        actor, the 3rd agrument is origin i.e. the point about which
        to rotate the actor, by default it is set to the global originFrè   rê   N©ra   rW   r9   rH   rÈ   rÖ   ræ   r  rÜ   r×   r%   rë   r    r    r!   ra   o  s    



zRing.rotatec                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%   ~  s    zRing.renderN)6rp   rq   rr   r¨   r   r9   r   rÒ   rW   rH   r   rÑ   r+   rJ   rK   r   rÓ   r  r   rµ   r   r   r	   r   r  rÖ   r  r©   r  r×   r  r*   r  r  r   r   r   rŠ   rf   r  rß   rà   r¼   r½   r¾   r»   rÃ   r   rÆ   r  rC   r�   ra   r%   r    r    r    r!   r  Í  sZ   



÷
ö#r  c                   @   s   e Zd ZdZeddd�Zeddddd	�Zeddd
dd	�Zeddd	�Z	eddd	�Z
edƒZeddddd�Zeddddd�Zeddddd�ZedddƒZedƒZeZeejdƒZeejƒZeejdƒZeee dd�e dd�e dd d!�e d"d#d!�e d$d%d!�e d&d�e d'd�e d(d�d)dd*�
d+gd,�Z!d-d.„ Z"d/d0„ Z#d1d2„ Z$d3d4„ Z%d5d6„ Z&d7d8„ Z'd9d:„ Z(d;d<„ Z)d=d>„ Z*d?d@„ Z+dAdB„ Z,dCdD„ Z-e. /g d¢¡fdEdF„Z0dGdH„ Z1dIS )JÚConezËCone class creates Cone from polydata obtained from tvtk
    ConeSource, follows the usual VTK pipeline and creates a Cone
    actor, which is passed to the show_actor() function as an
    argument.
    r  )é   rB   r
  rQ   g      Y@rð   zthe cone radiusr¬   rO   zthe cone heightr¯   zthe cone posr«   zthe cone axisrÍ   r­   r®   zthe X coordinate of cone centerrt   zthe Y coordinate of cone centerzthe Z coordinate of cone centerrÎ   rÏ   rÐ   Tr    rÒ   r|   Úheightr+   r°   r±   rJ   r³   rK   r´   rÑ   rµ   rÓ   zCone Propertiesr¶   r~   r·   c                 K   sÂ   | j j| _t ¡ }t|| jƒ || j _| j j| _| j| j_tƒ | _	| j 
| j	jj¡ | j  
| j	jj¡ tj| fi |¤Ž |  | j| j| j| j¡ |  t g d¢¡| j¡ |  | j¡ t| j ƒ d S )Nr¯   )r*   r©   r   rÚ   r   rÖ   rÛ   rÓ   r&   r   rg   r   r%   r   rf   r  rÒ   r  rW   rH   r»   rC   r�   rß   rÑ   r)   r  r    r    r!   rf   ®  s    


zCone.__init__c                 C   sV   t j||t|ƒt|ƒd�}| ¡  |j}|j ¡ }|| _| j| j_|j| j_||jfS )N)rÒ   r  ÚcenterÚ	direction)	r   Z
ConeSourceÚtuplerÜ   Úoutputr9   Úto_arrayrÖ   Úpolys)ri   ÚrÚhr  r  ÚcsÚpsr9   r    r    r!   r  Å  s    ÿ


zCone._create_pointsc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   Ñ  s    zCone._color_changedc                 C   s:   |   | j| j| j| j¡\}}|| j_| j ¡  |  ¡  d S rƒ   ©	r  rÒ   r  rW   rH   rÖ   r9   ræ   r%   ©ri   r9   rñ   r    r    r!   rà   Ô  s    
zCone._radius_changedc                 C   s:   |   | j| j| j| j¡\}}|| j_| j ¡  |  ¡  d S rƒ   r(  r)  r    r    r!   Ú_height_changedÚ  s    
zCone._height_changedc                 C   sn   | j |d dd� | j |d dd� | j |d dd� |  | j| j| j| j¡\}}|| _| j ¡  |  	¡  d S r  )
rÈ   r  rÒ   r  rW   rH   r9   rÖ   ræ   r%   ©ri   r7   r8   r9   rñ   r    r    r!   r»   à  s    
zCone._pos_changedc                 C   s:   |   | j| j| j| j¡\}}|| j_| j ¡  |  ¡  d S rƒ   r(  r)  r    r    r!   rÃ   é  s    
zCone._axis_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   ï  s    zCone._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   ó  s    zCone._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   ÷  s    zCone._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   û  s    

zCone._representation_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ      s    
zCone._visibility_changedc                 C   s`   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  |  ¡  dS ©rç   Frè   rê   N©ra   rW   r9   rH   rÈ   rÖ   ræ   r%   rë   r    r    r!   ra   	  s    

zCone.rotatec                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%     s    zCone.renderN)2rp   rq   rr   r¨   r   r9   r   rÒ   r  rW   rH   r   rÑ   r+   rJ   rK   r   rÓ   r   rµ   r   r   r	   r   r  rÖ   r  r©   r  r*   r   r   r   rŠ   rf   r  rß   rà   r*  r»   rÃ   r¼   r½   r¾   r   rÆ   rC   r�   ra   r%   r    r    r    r!   r  „  sV   



÷
ö		r  c                   @   s‚  e Zd ZdZeddddd�Zeddd�Zed	d
d�Ze	dƒZ
eddddd�Zeddddd�Zeddddd�ZedddƒZedƒZeZeejdƒZeejƒZeejdƒZeejdƒZeee ddd�e ddd�e ddd�e ddd�e d d!�e d"d!�e d#d!�d$dd%�	d&gd'�Z!d(d)„ Z"d*d+„ Z#d,d-„ Z$d.d/„ Z%d0d1„ Z&d2d3„ Z'd4d5„ Z(d6d7„ Z)d8d9„ Z*d:d;„ Z+d<d=„ Z,d>d?„ Z-e. /g d¢¡fd@dA„Z0dBS )CÚSpherez¸Sphere class creates Sphere from tvtk SphereSource, follows the
    usual VTK pipeline and creates a Sphere actor, which is passed to
    the show_actor() function as an argument.
    rQ   r®   rð   zthe sphere radiusr¬   r¯   zthe sphere posr«   zthe sphere axisrÍ   r­   z!the X coordinate of sphere centerrt   z!the Y coordinate of sphere centerz!the Z coordinate of sphere centerrÎ   rÏ   rÐ   Tr    rÒ   rw   ©r}   rx   r+   r°   r±   rJ   r³   rK   r´   rÑ   r|   rµ   rÓ   zSphere Propertiesr¶   r~   r·   c                 K   sô   | j j| _t ¡ | _t| j| jƒ | j ¡  t ¡ }t|| jƒ || j _	| j j| _| j
| j_
t| j ƒ tƒ | _| j | jjj¡ | j  | jjj¡ tj| fi |¤Ž |  | j| j¡ |  | j¡ |  | j¡ |  | j¡ |  | j¡ |  | j¡ d S rƒ   ) r*   r©   r   r  r  r   rÖ   rÜ   rÚ   rÛ   rÓ   r)   r&   r   rg   r   r%   r   rf   r  rÒ   rW   rß   rÑ   rÆ   rµ   r¼   r+   r½   rJ   r¾   rK   r  r    r    r!   rf   B  s(    





zSphere.__init__c                 C   sR   t j|t|ƒddd�}| ¡  |j}|j ¡ }|| _| j| j_|j| j_||jfS ©Né   )rÒ   r  Zphi_resolutionZtheta_resolution)	r   ÚSphereSourcer   rÜ   r!  r9   r"  rÖ   r#  ©ri   r$  r  Úspr'  r9   r    r    r!   r  _  s    þ


zSphere._create_pointsc                 C   s2   |   | j| j¡\}}|| j_| j ¡  |  ¡  d S rƒ   )r  rÒ   rW   rÖ   r9   ræ   r%   ©ri   rˆ   r9   r#  r    r    r!   rà   l  s    
zSphere._radius_changedc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   r  s    zSphere._color_changedc                 C   sr   | j |d dd� | j |d dd� | j |d dd� |  | j| j¡\}}|| j_| j ¡  | j ¡  |  	¡  d S r  ©
rÈ   r  rÒ   rW   rÖ   r9   ræ   r  rÜ   r%   r+  r    r    r!   r»   u  s    

zSphere._pos_changedc                 C   s>   t ||| j| jƒ| _| j| j_| j ¡  | j ¡  |  ¡  d S rƒ   ©r]   rW   r9   rÖ   ræ   r  rÜ   r%   r  r    r    r!   rÃ     s
    


zSphere._axis_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   †  s    zSphere._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   Š  s    zSphere._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   Ž  s    zSphere._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   ’  s    

zSphere._representation_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ   —  s    
zSphere._visibility_changedc                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%      s    zSphere.renderc                 C   s`   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  |  ¡  dS r,  r-  rë   r    r    r!   ra   ¥  s    

zSphere.rotateN)1rp   rq   rr   r¨   r   rÒ   r   rW   rH   r   rÑ   r+   rJ   rK   r   rÓ   r   rµ   r   r   r	   r   r  rÖ   r  r©   r  r*   r  r  r   r   r   rŠ   rf   r  rà   rß   r»   rÃ   r¼   r½   r¾   r   rÆ   r%   rC   r�   ra   r    r    r    r!   r.    sP   



ø	÷
	r.  c                   @   s²  e Zd ZdZeddddd�Zeddddd�Zedd	d�Zed
dd�Z	eddd�Z
edƒZeddddd�Zeddddd�Zeddddd�ZedddƒZedƒZeZeejdƒZeejdƒZeejƒZee ¡ dƒZe e!e"ddd�e"ddd�e"ddd �e"d!d"d �e"d#d$d �e"d%d&�e"d'd&�e"d(d&�d)dd*�
d+gd,�Z#d-d.„ Z$d/d0„ Z%d1d2„ Z&d3d4„ Z'd5d6„ Z(d7d8„ Z)d9d:„ Z*d;d<„ Z+d=d>„ Z,d?d@„ Z-dAdB„ Z.dCdD„ Z/e0 1g d¢¡fdEdF„Z2dGdH„ Z3dIS )JÚCylinderz¾Cylinder class creates Cylinder from tvtk CylinderSource,
    follows the usual VTK pipeline and creates a Sphere actor, which
    is passed to the show_actor() function as an argument.
    rQ   r®   rO   zthe cylinder radiusr¬   zthe cylinder lengthr¯   zthe cylinder posr«   zthe cylinder axisr  )é<   rB   r
  rÍ   r­   z#the X coordinate of cylinder centerrt   z#the Y coordinate of cylinder centerz#the Z coordinate of cylinder centerrÎ   rÏ   rÐ   Tr    rÒ   rw   r/  Úlengthr+   r°   r±   rJ   r³   rK   r´   rÑ   r|   rµ   rÓ   zCylinder Propertiesr¶   r~   r·   c                 K   s  | j j| _t ¡ | _t| j| jƒ t ¡ }t|| jƒ || j _| j j| _| j	| j_	t
| j ƒ tƒ | _| j | jjj¡ | j  | jjj¡ tj| fi |¤Ž |  | j| j| j¡ |  | j¡ |  | j¡ |  t g d¢¡| j¡ |  | j¡ |   | j!¡ |  "| j#¡ d S ©Nr«   )$r*   r©   r   r  r  r   rÖ   rÚ   rÛ   rÓ   r)   r&   r   rg   r   r%   r   rf   r  rÒ   rW   r:  rß   rÑ   rÆ   rµ   rÃ   rC   r�   rH   r¼   r+   r½   rJ   r¾   rK   r  r    r    r!   rf   Ý  s(    




zCylinder.__init__c           	      C   sÆ   t j||dd�}| ¡  |j}|j ¡ }t|ƒ}td|dƒD ] }|| d |d  || d< q<tt	 
g d¢¡t	 
g d¢¡t	 
g d¢¡|ƒ}tt	 
g d¢¡| j|ƒ}|| _| j| j_|j| j_||jfS )	Né   )rÒ   r  Ú
resolutionr   r?   g       @©rQ   rO   rQ   r«   r¯   )r   ZCylinderSourcerÜ   r!  r9   r"  rå   r  r]   rC   r�   r;   rW   rÖ   r#  )	ri   r$  r  r%  Úcpr'  r9   rï   r¢   r    r    r!   r  ù  s    
,

zCylinder._create_pointsc                 C   sD   |   | j| j| j¡\| _}| j| j_| j ¡  | j ¡  |  	¡  d S rƒ   ©
r  rÒ   rW   r:  r9   rÖ   ræ   r  rÜ   r%   ©ri   r7   r8   r#  r    r    r!   rà     s
    


zCylinder._radius_changedc                 C   sD   |   | j| j| j¡\| _}| j| j_| j ¡  | j ¡  |  	¡  d S rƒ   r@  )ri   rˆ   r#  r    r    r!   Ú_length_changed  s
    


zCylinder._length_changedc                 C   s>   t ||| j| jƒ| _| j| j_| j ¡  | j ¡  |  ¡  d S rƒ   r7  r  r    r    r!   rÃ     s
    


zCylinder._axis_changedc                 C   sp   | j |d dd� | j |d dd� | j |d dd� t||| jƒ| _| j| j_| j ¡  | j ¡  |  ¡  d S r  ©rÈ   r;   r9   rÖ   ræ   r  rÜ   r%   r  r    r    r!   r»     s    


zCylinder._pos_changedc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   '  s    zCylinder._color_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   *  s    zCylinder._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   .  s    zCylinder._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   2  s    zCylinder._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   6  s    

z Cylinder._representation_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ   ;  s    
zCylinder._visibility_changedc                 C   sj   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  | j ¡  |  	¡  dS r,  ©
ra   rW   r9   rH   rÈ   rÖ   ræ   r  rÜ   r%   rë   r    r    r!   ra   D  s    


zCylinder.rotatec                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%   R  s    zCylinder.renderN)4rp   rq   rr   r¨   r   rÒ   r:  r   rW   rH   r9   r   rÑ   r+   rJ   rK   r   rÓ   r   rµ   r   r   r	   r   r  rÖ   r  r*   r  r©   r  r  r   r   r   rŠ   rf   r  rà   rB  rÃ   r»   rß   r¼   r½   r¾   r   rÆ   rC   r�   ra   r%   r    r    r    r!   r8  ²  sX   




÷
ö
	r8  c                   @   sÔ  e Zd ZdZeddd�Zeddd�ZedƒZ	e
dd	d
dd�Ze
dd	d
dd�Ze
dd	d
dd�ZedddƒZe
dd	ddd�Ze
dd	ddd�Ze
dd	ddd�Zeddd�Zeddd�ZedƒZeZeejdƒZeejdƒZeejƒZ e!e"e#dd�e#dd�e#d d�e#d!d"d#�e#d$d%d#�e#d&d'd#�e#d(d�e#d)d�e#d*d�d+dd,�d-gd.�Z$d/d0„ Z%d1d2„ Z&d3d4„ Z'd5d6„ Z(d7d8„ Z)d9d:„ Z*d;d<„ Z+d=d>„ Z,d?d@„ Z-dAdB„ Z.dCdD„ Z/dEdF„ Z0dGdH„ Z1dIdJ„ Z2e3 4g d¢¡fdKdL„Z5dMdN„ Z6dOS )PÚBoxz®Box class creates Box from tvtk CubeSource, follows the usual
    VTK pipeline and creates a Cube actor, which is passed to the
    show_actor() function as an argument.
    rÍ   zthe box sizert   r¯   zthe Box posr¬   r­   r®   rQ   zthe X coordinate of box centerzthe Y coordinate of box centerzthe Z coordinate of box centerrÎ   rÏ   rÐ   r   rO   zthe box lengthzthe box heightzthe box widthr«   zthe box axisr  )é   rB   r
  Tr    r:  r|   r  r‚   r+   r°   r±   rJ   r³   rK   r´   rÑ   rµ   rÓ   zBox Propertiesr¶   r~   r·   c                 K   s  | j j| _t ¡ }t|| jƒ || j _| j j| _| j| j_t| j ƒ t	ƒ | _
| j | j
jj¡ | j  | j
jj¡ tj| fi |¤Ž |  | j| j¡ |  | j¡ |  | j¡ |  t g d¢¡| j¡ |  | j¡ |  | j¡ |  | j ¡ |  !| j"¡ |  #| j$¡ |  %| j&¡ d S r;  )'r*   r©   r   rÚ   r   rÖ   rÛ   rÓ   r)   r&   r   rg   r   r%   r   rf   r  ÚsizerW   rß   rÑ   rÆ   rµ   rÃ   rC   r�   rH   r¼   r+   r½   rJ   r¾   rK   rB  r:  r*  r  Ú_width_changedr‚   r  r    r    r!   rf   ƒ  s*    



zBox.__init__c                 C   s^   t j|d |d |d t|ƒd�}| ¡  |j}|j ¡ }|| _| j| j_|j| j_||jfS )Nr   r?   r@   )Zx_lengthZy_lengthZz_lengthr  )	r   Z
CubeSourcer   rÜ   r!  r9   r"  rÖ   r#  )ri   rÎ   r  r?  r'  r9   r    r    r!   r     s    "


zBox._create_pointsc                 C   sl   | j |d dd� | j |d dd� | j |d dd� |  | j| j¡\| _}| j| j_| j ¡  |  ¡  d S )Nr   F)r:  rÇ   r?   )r  rÇ   r@   )r‚   rÇ   )rÈ   r  rG  rW   r9   rÖ   ræ   r%   )ri   r7   r8   rñ   r    r    r!   Ú_size_changed«  s    

zBox._size_changedc                 C   sf   | j |d dd� | j |d dd� | j |d dd� t||| jƒ| _| j| j_| j ¡  |  ¡  d S r  )rÈ   r;   r9   rÖ   ræ   r%   r  r    r    r!   r»   ´  s    

zBox._pos_changedc                 C   s4   t ||| j| jƒ| _| j| j_| j ¡  |  ¡  d S rƒ   )r]   rW   r9   rÖ   ræ   r%   r  r    r    r!   rÃ   ½  s    

zBox._axis_changedc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   Ã  s    zBox._color_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   Æ  s    zBox._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   Ê  s    zBox._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   Î  s    zBox._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   Ò  s    

zBox._representation_changedc                 C   s   | j | jd | jd f| _d S rô   )r:  rG  rö   r    r    r!   rB  ×  s    zBox._length_changedc                 C   s   | j d | j| j d f| _ d S r÷   )rG  r  rö   r    r    r!   r*  Ú  s    zBox._height_changedc                 C   s   | j d | j d | jf| _ d S rù   )rG  r‚   rö   r    r    r!   rH  Ý  s    zBox._width_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ   à  s    
zBox._visibility_changedc                 C   sV   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j ¡  |  ¡  dS r,  r-  rë   r    r    r!   ra   é  s    
z
Box.rotatec                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%   ö  s    z
Box.renderN)7rp   rq   rr   r¨   r
   rG  r   rW   r   rÑ   r   r+   rJ   rK   r   rÓ   r:  r  r‚   rH   r9   r   rµ   r   r   r	   r   r  rÖ   r  r*   r  r©   r   r   r   rŠ   rf   r  rI  r»   rÃ   rß   r¼   r½   r¾   r   rB  r*  rH  rÆ   rC   r�   ra   r%   r    r    r    r!   rE  W  s`   



öõ			rE  c                   @   sÎ  e Zd ZdZeddd�Zeddddd	�Zedd
ddd	�Zeddddd	�Z	eddd	�Z
edƒZeddd	�Zeddddd�Zeddddd�Zeddddd�ZedddƒZedƒZeZeejdƒZeejƒZeejdƒZee ¡ dƒZ e!e"e#d d!�e#d"d!�e#d#d!�e#d$d%d&�e#d'd(d&�e#d)d*d&�e#d+d!�e#d,d!�e#d-d!�d.dd/�d0gd1�Z$d2d3„ Z%d4d5„ Z&d6d7„ Z'd8d9„ Z(d:d;„ Z)d<d=„ Z*d>d?„ Z+d@dA„ Z,dBdC„ Z-dDdE„ Z.dFdG„ Z/dHdI„ Z0dJdK„ Z1e2 3g d¢¡fdLdM„Z4dNdO„ Z5dPS )QÚArrowz´Arrow class creates Arrow from tvtk ArrowSource, follows the
    usual VTK pipeline and creates a Arrow actor, which is passed to
    the show_actor() function as an argument.
    r  )é   rB   r
  rQ   g      $@g{®Gáz´?z#the radius of cone portion of arrowr¬   g      @g¸…ëQ¸ž?z$the radius of shaft portion of arrowrO   gffffffÖ?zshaft length of arrowr«   zthe arrow axisrÍ   r¯   zthe Arrow posr­   r®   z the X coordinate of arrow centerrt   z the Y coordinate of arrow centerz the Z coordinate of arrow centerrÎ   rÏ   rÐ   Tr    Úradius_coner|   Úlength_coneÚradius_shaftr+   r°   r±   rJ   r³   rK   r´   rÑ   rµ   rÓ   zArrow Propertiesr¶   r~   r·   c                 K   s  | j j| _t ¡ | _t| j| jƒ | j ¡  t ¡ }t|| jƒ || j _	| j j| _| j
| j_
t| j ƒ tƒ | _| j | jjj¡ | j  | jjj¡ tj| fi |¤Ž |  | j| j| j| j¡ |  | j¡ |  | j¡ |  | j¡ |  | j¡ |   | j!¡ |  "t# $d¡| j%¡ d S r;  )&r*   r©   r   r  r  r   rÖ   rÜ   rÚ   rÛ   rÓ   r)   r&   r   rg   r   r%   r   rf   r  rL  rM  rN  rW   rß   rÑ   rÆ   rµ   r¼   r+   r½   rJ   r¾   rK   rÃ   rC   r�   rH   r  r    r    r!   rf   %  s*    





zArrow.__init__c                 C   sd   t j|||d�}| ¡  |j}|j ¡ }tt g d¢¡| j	|ƒ}|| _| j| j
_|j| j
_||jfS )N)Z
tip_radiusZ
tip_lengthZshaft_radiusr¯   )r   ZArrowSourcerÜ   r!  r9   r"  r;   rC   r�   rW   rÖ   r#  )ri   ÚrcÚlcÚrsr'  Zasrcr9   r    r    r!   r  B  s    


zArrow._create_pointsc                 C   sH   |   | j| j| j| j¡\| _}| j| j_| j ¡  | j 	¡  |  
¡  d S rƒ   ©r  rL  rM  rN  rW   r9   rÖ   ræ   r  rÜ   r%   rA  r    r    r!   Ú_radius_cone_changedM  s
    


zArrow._radius_cone_changedc                 C   sH   |   | j| j| j| j¡\| _}| j| j_| j ¡  | j 	¡  |  
¡  d S rƒ   rR  rA  r    r    r!   Ú_length_cone_changedT  s
    


zArrow._length_cone_changedc                 C   sH   |   | j| j| j| j¡\| _}| j| j_| j ¡  | j 	¡  |  
¡  d S rƒ   rR  rA  r    r    r!   Ú_radius_shaft_changed[  s
    


zArrow._radius_shaft_changedc                 C   sp   | j |d dd� | j |d dd� | j |d dd� t||| jƒ| _| j| j_| j ¡  | j ¡  |  ¡  d S r  rC  r  r    r    r!   r»   b  s    


zArrow._pos_changedc                 C   s>   t ||| j| jƒ| _| j| j_| j ¡  | j ¡  |  ¡  d S rƒ   r7  r  r    r    r!   rÃ   l  s
    


zArrow._axis_changedc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   s  s    zArrow._color_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   v  s    zArrow._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   z  s    zArrow._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   ~  s    zArrow._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   ‚  s    

zArrow._representation_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ   ‡  s    
zArrow._visibility_changedc                 C   sj   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  | j ¡  |  	¡  dS r,  rD  rë   r    r    r!   ra   �  s    


zArrow.rotatec                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%   ž  s    zArrow.renderN)6rp   rq   rr   r¨   r   r9   r   rL  rN  rM  rH   r   rÑ   rW   r+   rJ   rK   r   rÓ   r   rµ   r   r   r	   r   r  r*   r  r©   r  rÖ   r  r  r   r   r   rŠ   rf   r  rS  rT  rU  r»   rÃ   rß   r¼   r½   r¾   r   rÆ   rC   r�   ra   r%   r    r    r    r!   rJ  û  s^   



ö
ö
	rJ  c                   @   sò  e Zd ZdZedƒZeddd�Zedddd	d
�Z	eddddd
�Z
eddd
�Zeddd
�ZedƒZeddddd�Zeddddd�Zeddddd�ZedddƒZeddddd
�ZedƒZeZeejdƒZeejƒZeejdƒZ eej!dƒZ"ee #¡ dƒZ$e%e&e'dd �e'd!d �e'd"d �e'd#d$d%�e'd&d'd%�e'd(d)d%�e'd*d �e'd+d �e'd,d �d-dd.�d/gd0�Z(d1d2„ Z)d3d4„ Z*d5d6„ Z+d7d8„ Z,d9d:„ Z-d;d<„ Z.d=d>„ Z/d?d@„ Z0dAdB„ Z1dCdD„ Z2dEdF„ Z3dGdH„ Z4dIdJ„ Z5dKdL„ Z6dMdN„ Z7e8 9g d¢¡fdOdP„Z:dQdR„ Z;dSS )TÚHelixz¹Helix class creates Helix/Spring from tvtk polydata, follows the
    usual VTK pipeline and creates an Helix actor, which is passed to
    the show_actor() function as an argument.
    é   r  rË   r
  rÌ   r®   gš™™™™™É?zthe helix radiusr¬   rO   zthe helix lengthr¯   zthe helix positionr«   zthe helix axisrÍ   r­   rQ   z the X coordinate of helix centerrt   z the Y coordinate of helix centerz the Z coordinate of helix centerrÎ   rÏ   rÐ   r   zthe helix thicknessTr    rÒ   r|   r:  r  r+   r°   r±   rJ   r³   rK   r´   rÑ   rµ   rÓ   zHelix Propertiesr¶   r~   r·   c                 K   sJ  | j j| _t ¡ | _t| j| jƒ t| j| jƒ d| j_d| j_	t 
¡ }t|| jƒ || j _| j j| _| j| j_t| j ƒ tƒ | _| j | jjj¡ | j  | jjj¡ | j | jjj¡ tj| fi |¤Ž |  ¡  |  t g d¢¡| j¡ |  | j¡ |  | j¡ |  | j¡ |   | j!¡ |  "| j#¡ |  $| j%¡ |  &t d¡| j'¡ d S r  )(r*   r©   r   r  r  r   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÓ   r)   r&   r   rg   r   r%   r   rf   r  r»   rC   r�   rW   r¼   r+   r½   rJ   r¾   rK   rß   rÑ   rÆ   rµ   r  r  rÃ   rH   r  r    r    r!   rf   Ð  s4    




zHelix.__init__c                 C   s8  | j | jd  }| j | jd  }d}t | j| jd df¡| _td| jd dƒD ]^}|t d }|| j| d< | jt|ƒ | j| d< | jt	|ƒ | j| d< |d }|| }qPt
| jƒd }t |dfd	¡}t d|d
 dd	¡|d d …df< t d|d
 dd	¡|d d …df< | j| j_|| j_| j ¡  | j ¡  d S )Né
   r   rB   r	  é$   rA   r?   r@   rï   rð   )r:  ÚcoilsrC   rä   r9   r  r   rÒ   r   r   rå   rG   rò   rÖ   rñ   r  rÜ   r×   )ri   r%  Úconsr£   r¢   r  ró   rñ   r    r    r!   r  ó  s&    
  

zHelix._create_pointsc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   	  s    zHelix._color_changedc                 C   sh   |   ¡  |  t g d¢¡| j¡ |  t d¡| j¡ | j| j_| j 	¡  | j
 ¡  | j ¡  |  ¡  d S )Nr¯   r«   )r  r»   rC   r�   rW   Úchange_axisrH   r9   rÖ   ræ   r  rÜ   r×   r%   r  r    r    r!   rà     s    



zHelix._radius_changedc                 C   s‚  t j| jd d td�}| | jd d¡}| j| jd  }| j| jd  }d}td| jd dƒD ]X}|t d }||| d< | jt	|ƒ || d< | jt
|ƒ || d	< |d }|| }q`t|ƒd }	t  |	d	fd
¡}
t  d|	d dd
¡|
d d …df< t  d|	d dd
¡|
d d …df< || j_|
| j_|| _|  t  g d¢¡| j¡ |  t  d¡| j¡ | j ¡  | j ¡  | j ¡  |  ¡  d S )NrX  rB   r=   r   r	  rY  rA   r?   r@   rï   rð   r¯   r«   )rC   rò   rZ  rE   Zreshaper:  r  r   rÒ   r   r   rå   rG   rÖ   r9   rñ   r»   r�   rW   r\  rH   ræ   r  rÜ   r×   r%   )ri   r7   r8   rÐ   r%  r[  r£   r¢   r  ró   rñ   r    r    r!   Ú_coils_changed  s2    
  


zHelix._coils_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼   2  s    zHelix._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½   6  s    zHelix._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾   :  s    zHelix._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r   >  s    

zHelix._representation_changedc                 C   sz   | j |d dd� | j |d dd� | j |d dd� t||| jƒ| _| j| j_| j ¡  | j ¡  | j ¡  |  ¡  d S r  r  r  r    r    r!   r»   C  s    



zHelix._pos_changedc                 C   sH   t ||| j| jƒ| _| j| j_| j ¡  | j ¡  | j ¡  |  ¡  d S rƒ   r  r  r    r    r!   rÃ   N  s    



zHelix._axis_changedc                 C   s"   t ||| j| jƒ| _| j| j_d S rƒ   )r]   rW   r9   rÖ   r  r    r    r!   r\  V  s    zHelix.change_axisc                 C   s†   |   ¡  | j}|rd|j_|  t g d¢¡| j¡ |  t d¡| j	¡ |rRd|j_| j
| j_
| j ¡  | j ¡  | j ¡  |  ¡  d S )NTr¯   r«   F)r  r   r   Zdisable_renderr»   rC   r�   rW   r\  rH   r9   rÖ   ræ   r  rÜ   r×   r%   )ri   r7   r8   r   r    r    r!   rB  Z  s    



zHelix._length_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ   i  s    
zHelix._visibility_changedc                 C   s   || j _d S rƒ   r  rö   r    r    r!   r  p  s    zHelix._thickness_changedc                 C   st   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  | j ¡  | j	 ¡  |  
¡  dS r,  r  rë   r    r    r!   ra   u  s    



zHelix.rotatec                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%   „  s    zHelix.renderN)<rp   rq   rr   r¨   r   rZ  r   r9   r   rÒ   r:  rW   rH   r   rÑ   r+   rJ   rK   r   rÓ   r  r   rµ   r   r   r	   r   r  rÖ   r  r©   r  r×   r  r*   r  r  r   r   r   rŠ   rf   r  rß   rà   r]  r¼   r½   r¾   r   r»   rÃ   r\  rB  rÆ   r  rC   r�   ra   r%   r    r    r    r!   rV  £  sf   



ö
ö#
rV  c                   @   sþ  e Zd ZdZeddddd�Zeddd�Zed	ƒZ	ed
dd�Z
eddd�Zeddddd�Zeddddd�Zeddddd�Zeddddd�Zeddddd�Zeddddd�ZedddƒZedƒZeZeejdƒZeejƒZeejdƒZee  ¡ dƒZ!e"e#e$ddd�e$dd d!�e$d"d#d!�e$d$d%d!�e$d&d'd!�e$d(d)d!�e$d*d+d!�e$d,d-�e$d.d-�e$d/d-�d0dd1�d2gd3�Z%d4d5„ Z&d6d7„ Z'd8d9„ Z(d:d;„ Z)d<d=„ Z*d>d?„ Z+d@dA„ Z,dBdC„ Z-dDdE„ Z.dFdG„ Z/dHdI„ Z0dJdK„ Z1dLdM„ Z2dNdO„ Z3dPdQ„ Z4dRdS„ Z5e6 7g d¢¡fdTdU„Z8dVS )WÚ	EllipsoidzÜEllipsoid class creates Ellipsoid from tvtk SphereSource by
    suitably scaling it, follows the usual VTK pipeline and creates a
    Ellipsoid actor, which is passed to the show_actor() function as
    an argument.
    rQ   r®   rð   zUndistorted ellipsoid radiusr¬   r¯   zEllipsoid posrÍ   r«   zEllipsoid axis)rO   rð   rO   zEllipsoid size_factorrO   zScaling factor in X directionrt   zSscaling factor in Y directionzScaling factor in Z directionr­   z X coordinate of ellipsoid centerz Y coordinate of ellipsoid centerz Z coordinate of ellipsoid centerrÎ   rÏ   rÐ   Tr    rÒ   rw   r/  r+   r°   r±   rJ   r³   rK   r´   r:  ZLengthr  ZHeightr‚   ZWidthrÑ   r|   rµ   rÓ   zEllipsoid Propertiesr¶   r~   r·   c                 K   sþ   | j j| _t ¡ | _t| j| jƒ t ¡ }t|| jƒ || j _| j j| _| j	| j_	t
j| fi |¤Ž |  | j| j¡ |  | j¡ |  | j¡ |  | j¡ |  | j¡ |  | j¡ |  t d¡| j¡ t| j ƒ tƒ | _| j  | jj!j"¡ | j   | jj!j"¡ d S r;  )#r*   r©   r   r  r  r   rÖ   rÚ   rÛ   rÓ   r   rf   r  rÒ   rW   rß   rÑ   rÆ   rµ   r¼   r+   r½   rJ   r¾   rK   rÃ   rC   r�   rH   r)   r&   r   rg   r   r%   r  r    r    r!   rf   ¶  s(    




zEllipsoid.__init__c                 C   sb   t j|t|ƒddd�}| ¡  |j}|j ¡ }t| j|| j	ƒ}|| _| j| j
_|j| j
_||jfS r0  )r   r2  r   rÜ   r!  r9   r"  rc   rG  rW   rÖ   r#  r3  r    r    r!   r  Ò  s    ÿ


zEllipsoid._create_pointsc                 C   s<   |   | j| j¡\}}|| j_| j ¡  | j ¡  |  ¡  d S rƒ   )	r  rÒ   rW   rÖ   r9   ræ   r  rÜ   r%   r5  r    r    r!   rà   ß  s
    

zEllipsoid._radius_changedc                 C   sZ   |   | j| j¡\}}| j|d |d |d dd� || j_| j ¡  | j ¡  |  	¡  d S )Nr   r?   r@   F)r:  r  r‚   rÇ   )
r  rÒ   rW   rÈ   rÖ   r9   ræ   r  rÜ   r%   r5  r    r    r!   rI  æ  s    ÿ

zEllipsoid._size_changedc                 C   s   || j j_d S rƒ   rþ   rö   r    r    r!   rß   ï  s    zEllipsoid._color_changedc                 C   sr   | j |d dd� | j |d dd� | j |d dd� |  | j| j¡\}}|| j_| j ¡  | j ¡  |  	¡  d S r  r6  r+  r    r    r!   r»   ò  s    

zEllipsoid._pos_changedc                 C   sB   t ||| j| jƒ}|| _| j| j_| j ¡  | j ¡  |  ¡  d S rƒ   r7  )ri   r7   r8   r9   r    r    r!   rÃ   ü  s    


zEllipsoid._axis_changedc                 C   s$   || _ | j | jd | jd f| _d S rô   rõ   rö   r    r    r!   r¼     s    zEllipsoid._x_changedc                 C   s$   || _ | jd | j | jd f| _d S r÷   rø   rö   r    r    r!   r½     s    zEllipsoid._y_changedc                 C   s$   || _ | jd | jd | j f| _d S rù   rú   rö   r    r    r!   r¾     s    zEllipsoid._z_changedc                 C   s    | j | j_ | j ¡  |  ¡  d S rƒ   rÿ   rö   r    r    r!   r     s    

z!Ellipsoid._representation_changedc                 C   s$   || _ | j| jd | jd f| _d S rô   )Zx_scaler:  rG  rö   r    r    r!   rB    s    zEllipsoid._length_changedc                 C   s$   || _ | jd | j| jd f| _d S r÷   )Zy_scalerG  r  rö   r    r    r!   r*    s    zEllipsoid._height_changedc                 C   s$   || _ | jd | jd | jf| _d S rù   )Zz_scalerG  r‚   rö   r    r    r!   rH    s    zEllipsoid._width_changedc                 C   s&   t |ƒ}|dkrd| j_nd| j_d S rÄ   r  r  r    r    r!   rÆ   !  s    
zEllipsoid._visibility_changedc                 C   s   | j }|d ur|j ¡  d S rƒ   rí   rî   r    r    r!   r%   *  s    zEllipsoid.renderc                 C   s`   t |||| j| j| jƒ\}}}| j|dd� || _| j|dd� | j| j_| j ¡  |  ¡  dS r,  r-  rë   r    r    r!   ra   /  s    

zEllipsoid.rotateN)9rp   rq   rr   r¨   r   rÒ   r   rW   r   rÑ   rH   rG  r:  r  r‚   r+   rJ   rK   r   rÓ   r   rµ   r   r   r	   r   r  rÖ   r  r©   r  r*   r  r  r   r   r   rŠ   rf   r  rà   rI  rß   r»   rÃ   r¼   r½   r¾   r   rB  r*  rH  rÆ   r%   rC   r�   ra   r    r    r    r!   r^  ‰  sf   






õõ	
	r^  c                 C   s    d}t dƒ t |ƒ t dƒ d S )NzàDo not use rate, instead use the iterate() function.
    Iterate should be called with a callback.  This callback will be
    periodically called via a timer.  This will make your script's UI
    completely interactive.
    zP********************************************************************************)rl   )r¹   Úmsgr    r    r!   ÚrateN  s    r`  c                  C   sp   t dddd�} tdddd�}tdd	d
d�}tdddd�}t d¡ tdƒ t| ƒ t d¡ tdƒ t|ƒ dS )zDTest fuction for testing integrity of remove function for
    actorsg      ø?r   ©r?   r   r   ©rÒ   rW   rÑ   )r@   r?   r?   )rð   rð   rO   )r  rG  rÑ   rs   ©r@   r   r   ©r   r?   r   )r=  rW   rÑ   ©rB   r   r   )r   r   r?   rB   zRemoved sphere from scenezRemoved cone from coneN)ÚsphereÚboxÚconeÚcylinderÚtimeÚsleeprl   r,   )rÎ   ÚbÚcoÚcyr    r    r!   Útest_remove_actors\  s    

ro  c                  C   s&   t dd�} tƒ }t|| ƒ}| ¡  |S )N)g      @rQ   rQ   ©rW   )rh  ÚringÚframeÚedit_traits)Zc1Úr1Úfr    r    r!   Ú
test_framel  s
    

rv  c                     sR   t dd�} tdd�}t| |ƒ‰ dˆ _dˆ _d‰‡ ‡fdd„}td|ƒ}| ¡  |S )	zDTest fuction for testing integrity of rotation function of
    framera  rp  rc  )r?   r?   r?   r?   c                      s   ˆ   ˆg d¢¡ d S )Nr>  )ra   r    ©ru  r£   r    r!   Úanim|  s    zrotate_frame.<locals>.animéÈ   )rq  Úhelixrr  rW   rH   r6   rs  )rt  Úh1rx  Útir    rw  r!   Úrotate_frames  s    



r}  c                  C   sp   t ƒ } d| _t dd�}|j}|  dg d¢g d¢¡ |  dg d¢g d¢¡ | j}t ||¡rdtdƒ ntdƒ | S )	zETest fuction for testing integrity of rotation function of
    actorsre  rp  éZ   rd  ra  i¦ÿÿÿz	All clearzTest failed)rq  rW   r9   ra   rC   rU   rl   )r$  Zr2Zpoints1Zpoints2r    r    r!   Útest_rotate‚  s    

r  c                     sD   t ƒ } d‰tˆddfd�‰ dˆ _‡ ‡fdd„}td|ƒ}| ¡  dS )	z«This is a basic examples function demonstrating the creating
    simple animation from visual actors.  Note the show function has
    to be called in stand alone programs.rX  r   rp  ©r^   r   r   c                     s8   ˆ j } | dk rdˆ _n| ˆkr$dˆ _| ˆ jd  ˆ _ d S ©Nr?   ra  r€  r   ©r+   Úvelocity©r+   ©rÎ   Úxlenr    r!   rx  ›  s    ztest_translate.<locals>.animé2   N©rg  rf  rƒ  r6   rs  )rl  rx  r|  r    r…  r!   Útest_translate’  s    
r‰  c                     sb   d‰t ddd�} t ddˆddfd�}tdˆddfdd	�‰ d
ˆ _‡ ‡fdd„}td|ƒ}| ¡  |S )zEThis is a basic example function, extending the previous
    example.rX  )r?   rÔ   rÔ   rd  )rG  rÑ   r   )rG  rÑ   rW   rð   ra  rb  r€  c                     s<   ˆ j } | dkrdˆ _n| ˆd kr(dˆ _| ˆ jd  ˆ _ d S r�  r‚  r„  r…  r    r!   rx  ¯  s    ztest_bounce.<locals>.animr9  rˆ  )Úb1Úb2rx  rL   r    r…  r!   Útest_bounce¦  s    
rŒ  )Yr¨   r-   rC   rj  Úmathr   r   r   r   r   Z
traits.apir   r   r	   r
   r   r   r   r   r   r   r   r   Ztraitsui.apir   r   r   Ztvtk.apir   Z
tvtk.toolsr   Ztvtk.commonr   Z
pyface.apir   Zpyface.timer.apir   Ztvtk.tvtk_baser   r#   r"   r$   r&   r)   r,   r0   r6   r;   r<   rN   r]   ra   rb   rc   rd   r1   r�   r‹   rª   rÊ   r  r  r.  r8  rE  rJ  rV  r^  rf  Zvectorrr  Zcurverq  rh  ri  rg  Zarrowrz  Z	ellipsoidZlinalgr§   r¦   r`  ro  rv  r}  r  r‰  rŒ  r    r    r    r!   Ú<module>   sˆ   08*0Ac < 8   & % ) g 9