3
ÐÆ‘[¸  ã               @   sÂ  d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZmZ ddlmZ dd	lmZ d
Zeejƒ jƒZdd„ Zdbdd„Zdd„ Zdd„ Z dd„ Z!ddddgd
fdd„Z"dcdd„Z#dddd„Z$G dd„ deƒZ%G dd „ d e%ƒZ&G d!d"„ d"e&ƒZ'G d#d$„ d$e&ƒZ(G d%d&„ d&e&ƒZ)G d'd(„ d(e&ƒZ*G d)d*„ d*e&ƒZ+G d+d,„ d,e&ƒZ,G d-d.„ d.e%ƒZ-G d/d0„ d0e%ƒZ.G d1d2„ d2e%ƒZ/G d3d4„ d4e%ƒZ0G d5d6„ d6e0ƒZ1G d7d8„ d8e0ƒZ2G d9d:„ d:e0ƒZ3G d;d<„ d<e0ƒZ4G d=d>„ d>e3ƒZ5G d?d@„ d@e4ƒZ6G dAdB„ dBe0ƒZ7G dCdD„ dDe0ƒZ8G dEdF„ dFe0ƒZ9G dGdH„ dHeƒZ:dedIdJ„Z;dKdL„ Z<dMdN„ Z=dOdP„ Z>dQdR„ Z?dfdSdT„Z@dUdV„ ZAdWdX„ ZBdYdZ„ ZCd[d\„ ZDd]d^„ ZEd_d`„ ZFeGdak�r¾eFƒ  dS )ga�  A module that provides Matlab like 3d visualization functionality.

The general idea is shamelessly stolen from the `high-level API`_
provided by Octaviz_. Some of the test cases and demos are also
translated from there!

.. _Octaviz: http://octaviz.sourceforge.net/
.. _high-level API: http://octaviz.sourceforge.net/index.php?page=manpagesq

The implementation provided here is object oriented and each
visualization capability is implemented as a class that has traits.
So each of these may be configured.  Each visualization class derives
(ultimately) from MLabBase which is responsible for adding/removing
its actors into the render window.  The classes all require that the
RenderWindow be a `pyface.tvtk.scene.Scene` instance (this constraint
can be relaxed if necessary later on).

This module offers the following broad class of functionality:

`Figure`
  This basically manages all of the objects rendered.  Just like
  figure in any Matlab like environment.  A convenience function
  called `figure` may be used to create a nice Figure instance.

`Glyphs`
  This and its subclasses let one place glyphs at points specified as
  inputs.  The subclasses are: `Arrows`, `Cones`, `Cubes`,
  `Cylinders`, `Spheres`, and `Points`.

`Line3`
  Draws lines between the points specified at initialization time.

`Outline`
  Draws an outline for the contained objects.

`Title`
  Draws a title for the entire figure.

`LUTBase`
  Manages a lookup table and a scalar bar (legend) for it.  This is
  subclassed by all classes that need a LUT.

`SurfRegular`
  MayaVi1's imv.surf like functionality that plots surfaces given x
  (1D), y(1D) and z (or a callable) arrays.

`SurfRegularC`
  Also plots contour lines.

`TriMesh`
  Given triangle connectivity and points, plots a mesh of them.

`FancyTriMesh`
  Plots the mesh using tubes and spheres so its fancier.

`Mesh`
  Given x, y generated from numpy.mgrid, and a z to go with it.  Along
  with optional scalars.  This class builds the triangle connectivity
  (assuming that x, y are from numpy.mgrid) and builds a mesh and
  shows it.

`FancyMesh`
  Like mesh but shows the mesh using tubes and spheres.

`Surf`
  This generates a surface mesh just like Mesh but renders the mesh as
  a surface.

`Contour3`
  Shows contour for a mesh.

`ImShow`
  Allows one to view large numeric arrays as image data using an image
  actor.  This is just like MayaVi1's `mayavi.tools.imv.viewi`.

To see nice examples of all of these look at the `test_*` functions at
the end of this file.  Here is a quick example that uses these test
functions::

 >>> from tvtk.tools import mlab
 >>> f = mlab.figure()
 >>> mlab.test_surf(f) # Create a spherical harmonic.
 >>> f.pop() # Remove it.
 >>> mlab.test_molecule(f) # Show a caffeine molecule.
 >>> f.renwin.reset_zoom() # Scale the view.
 >>> f.pop() # Remove this.
 >>> mlab.test_lines(f) # Show pretty lines.
 >>> f.clear() # Remove all the stuff on screen.

é    )ÚStrictVersionN)	Ú	HasTraitsÚListÚInstanceÚAnyÚFloatÚBoolÚStrÚTraitÚInt)ÚGUI)Útvtk)ÚTVTKBaseÚvtk_color_trait)Úconfigure_input_data)ÚivtkTc              K   s8   t r(tjdd�}d|j_|jf | Ž |S tjf | ŽS dS )zyReturn a TVTK actor.  If `mlab.USE_LOD_ACTOR` is `True` it
    returns an LODActor if not it returns a normal actor.
    iÜ  )Znumber_of_cloud_pointsg       @N)ÚUSE_LOD_ACTORr   ZLODActorÚpropertyÚ
point_sizeÚ	trait_setZActor)ÚkwargsÚr© r   úR/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/tvtk/tools/mlab.pyÚ_make_actort   s    r   c             C   sº   t | ƒ}t |ƒ}|dk	r@tj|ƒ}|| |ks@td|||f ƒ‚| d |d  }}| d | d  |d |d   }}	tj||df||df||	dfd�}
|dk	r¶tj|ƒ|
j_d|
jj_	|
S )a0  Creates a StructuredPoints object given input data in the form
    of numpy arrays.

    Input Arguments:
       x -- Array of x-coordinates.  These should be regularly spaced.

       y -- Array of y-coordinates.  These should be regularly spaced.

       z -- Array of z values for the x, y values given.  The values
       should be computed such that the z values are computed as x
       varies fastest and y next.  If z is None then no scalars are
       associated with the structured points.  Only the structured
       points data set is created.
    Nz6len(x)*len(y) != len(z)You passed nx=%d, ny=%d,  nz=%dr   é   )Ú
dimensionsÚoriginÚspacingÚscalars)
ÚlenÚnumpyÚsizeÚAssertionErrorr   ZStructuredPointsÚravelÚ
point_datar   Úname)ÚxÚyÚzÚnxÚnyZnzÚxminZyminÚdxÚdyÚspr   r   r   Ú _create_structured_points_direct�   s    
"
r0   c             O   sN   || dd…df t j|ƒ t j|dd…df t j| ƒ ƒf|ž|Ž}t j|ƒS )a  Samples a function at an array of ordered points (with equal
    spacing) and returns an array of scalars as per VTK's requirements
    for a structured points data set, i.e. x varying fastest and y
    varying next.

    Input Arguments:
        xa -- Array of x points.

        ya -- Array if y points.

        func -- function of x, and y to sample.

        args -- additional positional arguments for func()
        (default is empty)

        kwargs -- a dict of additional keyword arguments for func()
        (default is empty)
    N)r!   Ú
zeros_likeÚ	transpose)ÚxaÚyaÚfuncÚargsr   Úretr   r   r   Úsampler¤   s     
r8   c             C   s´   dt |jƒ }t|jƒdks$t|ƒ‚t|jƒdkr°dt| ƒt|ƒ|jf }|jd |jd  t| ƒt|ƒ ksvt|ƒ‚dt|ƒt| ƒt |jƒf }|jt|ƒt| ƒfks°t|ƒ‚dS )zAChecks the given arrays to see if they are suitable for
    surf.zAOnly ravelled or 2D arrays can be viewed! This array has shape %sé   zElen(x)*len(y) != len(z.flat).  You passed nx=%d, ny=%d, shape of z=%sr   r   zUlength of y(%d) and x(%d) must match shape of z %s. (Maybe you need to swap x and y?)N)ÚstrÚshaper    r#   )r'   r(   r)   Úmsgr   r   r   Ú_check_sanity¾   s    ,r=   c             C   s:   t j| ƒ} t j| jƒ}t j| tt jt j|dƒ|ƒƒƒ}|S )z3Returns a with any ones from the shape of a removedr   )r!   Úasarrayr;   ÚreshapeÚtupleÚcompressÚ	not_equal)ÚaÚbÚvalr   r   r   ÚsqueezeÐ   s
    
rF   r   g      ð?c             O   sD  t |ƒr6tjt| ||f|ž|Žƒ}t| ƒt|ƒ } }n<t| ƒt|ƒ } }t| ||ƒ tj|ƒ}t|ƒdksrtdƒ‚| |d  }	||d  }
t|	|
|ƒ}|sž|S |�rt	j
ƒ }t||ƒ t	j|d d�}t||jƒ t	jdd�}t||jƒ t	jt|ƒt|ƒfd�}t||jƒ n"t	jt|ƒt|ƒfd�}t||ƒ t|d	�}||fS )
aµ  Creates a surface given regularly spaced values of x, y and the
    corresponding z as arrays.  Also works if z is a function.
    Currently works only for regular data - can be enhanced later.

    Parameters
    ----------

        x -- Array of x points (regularly spaced)

        y -- Array if y points (regularly spaced)

        z -- A 2D array for the x and y points with x varying fastest
        and y next.  Also will work if z is a callable which supports
        x and y arrays as the arguments.

        warp -- If true, warp the data to show a 3D surface
        (default = 1).

        scale -- Scale the x, y and z axis as per passed values.
        Defaults to [1.0, 1.0, 1.0].

        make_actor -- also create actors suitably (default True)

        args -- additional positional arguments for func()
        (default is empty)

        kwargs -- a dict of additional keyword arguments for func()
        (default is empty)
    r   zz is empty - nothing to plot!r   r9   )Úscale_factoré-   )Zfeature_angle)Úscalar_range)Úmapper)Úcallabler!   r$   r8   rF   r=   r    r#   r0   r   ZImageDataGeometryFilterr   Z
WarpScalarÚoutputZPolyDataNormalsÚPolyDataMapperÚminÚmaxr   )r'   r(   r)   ÚwarpÚscaleZ
make_actorr6   r   ZzvalÚxsZysÚdataZgeom_fZwarperZnormalsrJ   Úactorr   r   r   Úmake_surf_actorÙ   s2     



rU   c             C   sv   t j| dƒ}|jd dks"tdƒ‚|d k	rDt|ƒtt j|ƒƒksDt‚tj||d�}|d k	rrt j|ƒ|j_	d|jj	_
|S )NÚlr   é   z!The list of polygons must be Nx3.)ÚpointsÚpolysr   )r!   r>   r;   r#   r    r$   r   ÚPolyDatar%   r   r&   )Ú	trianglesrX   r   ÚtÚpdr   r   r   Úmake_triangle_polydata  s    
r^   c             C   sø  t | jƒdkstdƒ‚t |jƒdks,tdƒ‚t |jƒdksBtdƒ‚| j|jksVtdƒ‚|j|jksjtdƒ‚| j\}}tjd|d …d|d …f \}}tj|ƒtj|ƒ }}|| | |d | | |d | |d  f}|d | |d  || |d  || | f}	t |d ƒ}
tj|
d d	fd
ƒ}|\|d|
…df< |d|
…df< |d|
…df< |	\||
d…df< ||
d…df< ||
d…df< tj||d	fdƒ}| ||  |dd…dd…df< |dd…dd…df< |dd…dd…df< tj||| d	fƒ}||fS )a  Given x, y, and z co-ordinates made using numpy.mgrid and
    optional scalars.  This function returns triangles and points
    corresponding to a mesh formed by them.

    Parameters
    ----------

    - x : array
        A list of x coordinate values formed using numpy.mgrid.
    - y : array
        A list of y coordinate values formed using numpy.mgrid.
    - z : array
        A list of z coordinate values formed using numpy.mgrid.
    - scalars : array (optional)
        Scalars to associate with the points.
    r9   zArray x must be 2 dimensional.zArray y must be 2 dimensional.zArray z must be 2 dimensional.z$Arrays x and y must have same shape.z$Arrays y and z must have same shape.r   r   rW   rV   NÚd)r    r;   r#   r!   Úmgridr$   Úzerosr?   )r'   r(   r)   r   r*   r+   ÚiÚjÚt1Út2Úntr[   rX   r   r   r   Úmake_triangles_points'  s$    
"....Frg   c               @   sH   e Zd ZeeƒZeZdd„ Zdd„ Z	dd„ Z
dd„ Zd	d
„ Zdd„ ZdS )ÚMLabBasec             C   s   | j jƒ  d S )N)ÚrenwinÚrender)Úselfr   r   r   ÚupdateY  s    zMLabBase.updatec             C   s   | j r| j jƒ  d S )N)ri   rj   )rk   r   r   r   rj   \  s    zMLabBase.renderc             C   s4   |r|j | jƒ |jƒ  |r0|j| jƒ |jƒ  d S )N)Úremove_actorsÚactorsrj   Ú
add_actors)rk   ÚoldÚnewr   r   r   Ú_renwin_changed`  s    zMLabBase._renwin_changedc             C   s   | j ||ƒ d S )N)Ú_handle_actors)rk   rp   rq   r   r   r   Ú_actors_changedh  s    zMLabBase._actors_changedc             C   s   | j |j|jƒ d S )N)rs   ÚremovedÚadded)rk   Ú
list_eventr   r   r   Ú_actors_items_changedk  s    zMLabBase._actors_items_changedc             C   s*   | j }|r&|j|ƒ |j|ƒ |jƒ  d S )N)ri   rm   ro   rj   )rk   ru   rv   Úrwr   r   r   rs   n  s
    

zMLabBase._handle_actorsN)Ú__name__Ú
__module__Ú__qualname__r   r   rn   r   ri   rl   rj   rr   rt   rx   rs   r   r   r   r   rh   S  s   rh   c                   sV   e Zd ZeZeejf dddœƒZe	dƒZ
d‡ fdd„	Zdd	„ Zd
d„ Zdd„ Z‡  ZS )ÚGlyphsZ
use_vectorZdata_scaling_off)Zvector_modeZ
scale_modeç      ð?Nc       	         s"  t t| ƒjf |Ž |d k	r.t|ƒt|ƒks.t‚|d k	rJt|ƒt|ƒksJt‚|| _|| _|| _tj	dt|ƒddƒ}tj
|t|ƒdfƒ}tj||d�}| jd k	r®||j_d|jj_| jd k	rÊ||j_d|jj_|| _t| j|ƒ | jrî| jj| j_tj| jjd�}t|d�}| j|j_| jj|ƒ d S )	Nr   r   rV   )rX   rY   Úvectorsr   )Úinput)rJ   )Úsuperr}   Ú__init__r    r#   rX   r   r   r!   Úaranger?   r   rZ   r%   r&   Ú	poly_datar   ÚglyphÚglyph_sourcerL   ÚsourcerM   r   Úcolorr   rn   Úappend)	rk   rX   r   r   ÚtraitsrY   r]   rJ   rT   )Ú	__class__r   r   r‚   †  s2    





zGlyphs.__init__c             C   s   | j jƒ  | jjƒ  d S )N)r„   rl   ri   rj   )rk   r   r   r   rl   §  s    
zGlyphs.updatec             C   s    | j r|| j d j_| jƒ  d S )Nr   )rn   r   rˆ   rj   )rk   rE   r   r   r   Ú_color_changed«  s    zGlyphs._color_changedc             C   s   |j | j_| jƒ  d S )N)rL   r…   r‡   rj   )rk   rE   r   r   r   Ú_glyph_source_changed°  s    
zGlyphs._glyph_source_changed)r~   r~   r~   )NN)rz   r{   r|   r   r†   r   r   ÚGlyph3Dr…   r   rˆ   r‚   rl   rŒ   r�   Ú__classcell__r   r   )r‹   r   r}   z  s   

!r}   c               @   s   e Zd Zeejf ƒZdS )ÚArrowsN)rz   r{   r|   r   r   ZArrowSourcer†   r   r   r   r   r�   ¸  s   r�   c                   s>   e Zd Zeejf ƒZeddd�Zd	‡ fdd„	Z	dd„ Z
‡  ZS )
ÚConesgš™™™™™©?zradius of the cone)ÚdescNc                s(   t t| ƒj|||f|Ž | j| jƒ d S )N)r�   r‘   r‚   Ú_radius_changedÚradius)rk   rX   r   r   rŠ   )r‹   r   r   r‚   Æ  s    zCones.__init__c             C   s   || j _| jƒ  d S )N)r†   r”   rj   )rk   rE   r   r   r   r“   Ê  s    zCones._radius_changed)NN)rz   r{   r|   r   r   Z
ConeSourcer†   r   r”   r‚   r“   r�   r   r   )r‹   r   r‘   ¿  s   r‘   c                   s>   e Zd Zeejf ƒZeddd�Zd	‡ fdd„	Z	dd„ Z
‡  ZS )
ÚCubesgš™™™™™©?zside length of the cube)r’   Nc                s(   t t| ƒj|||f|Ž | j| jƒ d S )N)r�   r•   r‚   r“   r”   )rk   rX   r   r   rŠ   )r‹   r   r   r‚   Ø  s    zCubes.__init__c             C   s$   || j _|| j _|| j _| jƒ  d S )N)r†   Zx_lengthZy_lengthZz_lengthrj   )rk   rE   r   r   r   Ú_length_changedÜ  s    zCubes._length_changed)NN)rz   r{   r|   r   r   Z
CubeSourcer†   r   Úlengthr‚   r–   r�   r   r   )r‹   r   r•   Ò  s   r•   c               @   s   e Zd Zeejf ƒZdS )Ú	CylindersN)rz   r{   r|   r   r   ZCylinderSourcer†   r   r   r   r   r˜   æ  s   r˜   c                   sF   e Zd Zeejf dddœƒZeddd�Zd‡ fdd	„	Z	d
d„ Z
‡  ZS )ÚSpheresé   é   )Úphi_resolutionÚtheta_resolutiongš™™™™™©?zradius of the sphere)r’   Nc                s(   t t| ƒj|||f|Ž | j| jƒ d S )N)r�   r™   r‚   r“   r”   )rk   rX   r   r   rŠ   )r‹   r   r   r‚   ö  s    zSpheres.__init__c             C   s   || j _| jƒ  d S )N)r†   r”   rj   )rk   rE   r   r   r   r“   ú  s    zSpheres._radius_changed)NN)rz   r{   r|   r   r   ÚSphereSourcer†   r   r”   r‚   r“   r�   r   r   )r‹   r   r™   î  s   
r™   c               @   s    e Zd Zeejf dddœƒZdS )ÚPointsr   r   )r”   Znumber_of_pointsN)rz   r{   r|   r   r   ZPointSourcer†   r   r   r   r   rŸ     s   rŸ   c                   sf   e Zd Zeddd�Zeddd�Zeej	f ddiƒZ
edƒZ‡ fd	d
„Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚLine3g{®Gáz„?zradius of the tubes)r’   Tz+specifies if the tube filter should be usedÚnumber_of_sidesé   ç      ð?c       	         sü   t t| ƒjf |Ž t|d ƒdks*tdƒ‚|| _t|ƒd }tj|dfdƒ}tjd|d ddƒ|d d …df< tjd|d ddƒ|d d …df< t	j
||d�}|| _t	jƒ }|| _| j}| j|_| jrØt||ƒ t||jƒ t|d	�}| j|j_| jj|ƒ d S )
Nr   rW   zThe points must be 3Dr   r9   rV   g      à?)rX   Úlines)rJ   )r�   rh   r‚   r    r#   rX   r!   ra   rƒ   r   rZ   r„   rM   rJ   Útube_filterr”   Ú	use_tubesr   rL   r   rˆ   r   rn   r‰   )	rk   rX   rŠ   Únpr¤   r]   rJ   ÚtfrC   )r‹   r   r   r‚     s&      


zLine3.__init__c             C   s   || j _| jƒ  d S )N)r¥   r”   rj   )rk   rE   r   r   r   r“   2  s    zLine3._radius_changedc             C   s@   |r&| j }t|| jƒ t| j|jƒ nt| j| jƒ | jƒ  d S )N)r¥   r   r„   rJ   rL   rj   )rk   rE   r¨   r   r   r   Ú_use_tubes_changed6  s    zLine3._use_tubes_changedc             C   s    | j r|| j d j_| jƒ  d S )Nr   )rn   r   rˆ   rj   )rk   rE   r   r   r   rŒ   ?  s    zLine3._color_changed)r£   r£   r£   )rz   r{   r|   r   r”   r   r¦   r   r   Ú
TubeFilterr¥   r   rˆ   r‚   r“   r©   rŒ   r�   r   r   )r‹   r   r      s   	r    c            
       sX   e Zd Zeejf dddddddœƒZeejf ƒZ‡ fdd	„Z	d
d„ Z
‡ fdd„Z‡  ZS )ÚOutlinez%4.2gZouter_edgesg      ô?é   g        r   )Zlabel_formatZfly_modeZfont_factorZnumber_of_labelsZcorner_offsetÚscalingc                s^   t t| ƒjf |Ž tj| jjd�}t|d�}| j}t	|dƒrD||_
n||_| jj||gƒ d S )N)r€   )rJ   Ú	view_prop)r�   r«   r‚   r   rM   ÚoutlinerL   r   ÚaxisÚhasattrr®   Úproprn   Úextend)rk   rŠ   Z
out_mapperZ	out_actorr°   )r‹   r   r   r‚   Q  s    

zOutline.__init__c             C   sv   | j rr| j }dd„ | jD ƒ\}}d| jd _d| jd _|jƒ  |jjƒ }|| j_|jƒ  || jd _|| jd _d S )Nc             S   s   g | ]
}|j ‘qS r   )Ú
visibility)Ú.0r'   r   r   r   ú
<listcomp>a  s    z"Outline.update.<locals>.<listcomp>r   r   )ri   rn   r´   rj   ÚrendererÚcompute_visible_prop_boundsr¯   Úbounds)rk   ry   Úv1Úv2r¹   r   r   r   rl   ^  s    
zOutline.updatec                sj   t t| ƒj||ƒ |r:|j| jddd� |j| jddd� |rf|jj| j_|j| jdƒ |j| jdƒ d S )NZactor_addedT)ÚremoveZactor_removed)	r�   r«   rr   Úon_trait_changerl   r·   Zactive_camerar°   Úcamera)rk   rp   rq   )r‹   r   r   rr   k  s    zOutline._renwin_changed)rz   r{   r|   r   r   ZCubeAxesActor2Dr°   ZOutlineSourcer¯   r‚   rl   rr   r�   r   r   )r‹   r   r«   H  s   r«   c                   s<   e Zd Zed dd�Zeejf ƒZ‡ fdd„Z	dd„ Z
‡  ZS )ÚTitleztext of the title)r’   c                sj   t t| ƒjf |Ž | j}tdkr4|jdd| jd� n|jdd| jd� |j}d|_d|_	| j
j| jƒ d S )Nz5.1r²   gš™™™™™©?)Ztext_scale_modeÚheightr€   T)Zscaled_textrÀ   r€   Únormalized_viewportç      Ð?çš™™™™™í?ç        )rÂ   rÃ   rÄ   )r�   r¿   r‚   Ú
text_actorÚVTK_VERr   ÚtextÚposition_coordinateÚcoordinate_systemÚvaluern   r‰   )rk   rŠ   ÚtaÚpc)r‹   r   r   r‚   €  s    zTitle.__init__c             C   s   || j _| jƒ  d S )N)rÅ   r€   rj   )rk   rE   r   r   r   Ú_text_changed�  s    zTitle._text_changed)rz   r{   r|   r	   rÇ   r   r   Z	TextActorrÅ   r‚   rÍ   r�   r   r   )r‹   r   r¿   y  s   r¿   c                   sš   e Zd Zeddddddd�Zeejf ƒZeej	f ddd	d
œƒZ
eejf ƒZeddd�Zeddd�Z‡ fdd„Zdd„ Zdd„ Zdd„ Z‡ fdd„Z‡  ZS )ÚLUTBasezred-bluezblue-redzblack-whitezwhite-blackzthe type of the lookup table)r’   Ú
horizontalgš™™™™™é?gÃõ(\�ÂÅ?)ÚorientationÚwidthrÀ   ZScalarzthe title of the legendFz'specifies if scalar bar is shown or notc                sd   t t| ƒjf |Ž d| j_| j| jƒ | jj| j| j	d� | jj
}d|_d	|_| jj| jdd� d S )
Né   )Úlookup_tableÚtitlerÁ   çš™™™™™¹?ç{®Gáz„?ç        F)Zscalar_bar_actorZkey_press_activation)rÕ   rÖ   r×   )r�   rÎ   r‚   ÚlutZnumber_of_colorsÚ_lut_type_changedÚlut_typeÚ
scalar_barr   Úlegend_textrÈ   rÉ   rÊ   Úscalar_bar_widget)rk   rŠ   rÌ   )r‹   r   r   r‚   ¬  s    


zLUTBase.__init__c             C   s„   |dkrd}d}d}n@|dkr,d}d}d}n*|dkrBd}d}d}n|dkrVd}d}d}| j }|j|||dd	d
� |jƒ  | jƒ  d S )Nzred-blueç        çKÈ=›Uå?ç      ð?zblue-redzblack-whitezwhite-blackrÒ   Úsqrt)Ú	hue_rangeÚsaturation_rangeÚvalue_rangeZnumber_of_table_valuesÚramp)rÞ   rß   )rà   rà   )rà   rà   )rß   rÞ   )rà   rà   )rà   rà   )rÞ   rÞ   )rÞ   rÞ   )rÞ   rà   )rÞ   rÞ   )rÞ   rÞ   )rà   rÞ   )rØ   r   Zforce_buildrj   )rk   rE   râ   rã   rä   rØ   r   r   r   rÙ   ¸  s,    zLUTBase._lut_type_changedc             C   s   || j _| j jƒ  | jƒ  d S )N)rÛ   rÔ   Úmodifiedrj   )rk   rE   r   r   r   Ú_legend_text_changedÑ  s    
zLUTBase._legend_text_changedc             C   s   | j r|| j_| j jƒ  d S )N)ri   rÝ   Úenabledrj   )rk   rE   r   r   r   Ú_show_scalar_bar_changedÖ  s    z LUTBase._show_scalar_bar_changedc                sJ   | j }|rd |_|jƒ  |r4|j|_| j|_|jƒ  tt| ƒj||ƒ d S )N)rÝ   Z
interactorrj   Úshow_scalar_barrè   r�   rÎ   rr   )rk   rp   rq   Zsbw)r‹   r   r   rr   Û  s    zLUTBase._renwin_changed)rz   r{   r|   r
   rÚ   r   r   ZLookupTablerØ   ZScalarBarActorrÛ   ZScalarBarWidgetrÝ   r	   rÜ   r   rê   r‚   rÙ   rç   ré   rr   r�   r   r   )r‹   r   rÎ   ”  s    rÎ   c                   s,   e Zd Zddddgf df‡ fdd„	Z‡  ZS )ÚSurfRegularr   g      ð?Nc                sh   t t| ƒjf |Ž |d kri }t|||||f|ž|Ž\}	}
|	| _|
j}| j|_|j| j_	| j
j|
ƒ d S )N)r�   rë   r‚   rU   rS   rJ   rØ   rÓ   rI   Útable_rangern   r‰   )rk   r'   r(   r)   rP   rQ   Úf_argsÚf_kwargsrŠ   rS   rT   rJ   )r‹   r   r   r‚   í  s    

zSurfRegular.__init__)rz   r{   r|   r‚   r�   r   r   )r‹   r   rë   ë  s   rë   c                   sL   e Zd Zeddd�Zeejf ƒZddddgf df‡ fdd„	Z	d	d
„ Z
‡  ZS )ÚSurfRegularCé
   znumber of contours values)r’   r   g      ð?Nc                sº   t t| ƒjf |Ž |d kri }t|||||f|ž|Ž\}	}
|
j}| j|_|j| j_|	| _	|	j
jj}| j}t||	ƒ |j| j|d |d ƒ tj|j| jd�}t|d�}| jj|
|gƒ d S )Nr   r   )r€   rÓ   )rJ   )r�   rï   r‚   rU   rJ   rØ   rÓ   rI   rì   rS   r%   r   ÚrangeÚcontour_filterr   Úgenerate_valuesÚnumber_of_contoursr   rM   rL   r   rn   r³   )rk   r'   r(   r)   rP   rQ   rí   rî   rŠ   rS   rT   rJ   ÚdrÚcfÚ
cont_actor)r‹   r   r   r‚     s     




zSurfRegularC.__init__c             C   s0   | j jjj}| jj||d |d ƒ | jƒ  d S )Nr   r   )rS   r%   r   rñ   rò   ró   rj   )rk   rE   rõ   r   r   r   Ú_number_of_contours_changed  s    z(SurfRegularC._number_of_contours_changed)rz   r{   r|   r   rô   r   r   ÚContourFilterrò   r‚   rø   r�   r   r   )r‹   r   rï     s
   rï   c                   sV   e Zd Zeddd�Zeddd�ZedƒZd‡ fdd	„	Zd
d„ Z	dd„ Z
dd„ Z‡  ZS )ÚTriMeshFzshow scalar visibility)r’   zshow as surface or wireframeç      à?ç      ð?Nc       
         sÄ   t t| ƒjf |Ž t|||ƒ| _tj| j| j| jd�}|dk	rft	j
|ƒ}t|ƒt|ƒf}||_|| j_t|d�}d}	| jr~d}	|	dkrž|jjdd| j|	d� n|jjdd| j|	d� | jj|ƒ dS )	aJ  
        Parameters
        ----------

        - triangles : array
          This contains a list of vertex indices forming the triangles.
        - points : array
          Contains the list of points referred to in the triangle list.
        - scalars : array (optional)
          Scalars to associate with the points.
        )r€   rÓ   Úscalar_visibilityN)rJ   ÚwÚsg        g      ð?)ÚdiffuseÚambientrˆ   Úrepresentation)r�   rú   r‚   r^   r]   r   rM   rØ   rý   r!   r$   rN   rO   rI   rì   r   Úsurfacer   r   rˆ   rn   r‰   )
rk   r[   rX   r   rŠ   rJ   Úrsrõ   rT   r  )r‹   r   r   r‚   2  s&    



zTriMesh.__init__c             C   s$   | j r| j d j}||_| jƒ  d S )Nr   )rn   rJ   rý   rj   )rk   rE   rJ   r   r   r   Ú_scalar_visibility_changedW  s    z"TriMesh._scalar_visibility_changedc             C   sV   | j rJd}|rd}| j d }|dkr8|jjdd|d� n|jjdd|d� | jƒ  d S )Nrþ   rÿ   r   g        g      ð?)r   r  r  )rn   r   r   rj   )rk   rE   r  rT   r   r   r   Ú_surface_changed]  s    



zTriMesh._surface_changedc             C   s    | j r|| j d j_| jƒ  d S )Nr   )rn   r   rˆ   rj   )rk   rE   r   r   r   rŒ   l  s    zTriMesh._color_changed)rû   rü   rû   )N)rz   r{   r|   r   rý   r  r   rˆ   r‚   r  r  rŒ   r�   r   r   )r‹   r   rú   (  s   %rú   c                   s–   e Zd ZdZeddd�ZedƒZeddd�Z	edd	d�Z
eejf d
ddœƒZeejf dddœƒZd‡ fdd„	Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚFancyTriMeshzOShows a mesh of triangles and draws the edges as tubes and
    points as balls.Fzshow scalar visibility)r’   ç      à?ç      ð?g        zradius of the tubeszradius of the spheresZvary_radius_offr¢   )Zvary_radiusr¡   é   )r�   rœ   Nc                s,  t t| ƒjf |Ž || _t|||ƒ| _| j| jƒ | j| j	ƒ | j
}tj| jd�| _| j}| jj|j| jd� tj| jj| j|d�}t|d�}| j|j_| j	| j_tjd| jj|jd�}	tj|	j| j|d�}
t|
d�}| j|j_|dk	�rtj|ƒ}t|ƒt|ƒf}|| j_||_||
_| jj ||gƒ dS )aJ  
        Parameters
        ----------

        - triangles : array
          This contains a list of vertex indices forming the triangles.
        - points : array
          Contains the list of points referred to in the triangle list.
        - scalars : array (optional)
          Scalars to associate with the points.
        )r€   )r€   r”   )r€   rÓ   rý   )rJ   r   )r­   r‡   r€   N)!r�   r  r‚   rX   r^   r]   Ú_tube_radius_changedÚtube_radiusÚ_sphere_radius_changedÚsphere_radiusrý   r   ZExtractEdgesZextract_filterr¥   r   rL   rM   rØ   r   rˆ   r   Úsphere_sourcer”   rŽ   r!   r$   rN   rO   rì   rI   rn   r³   )rk   r[   rX   r   rŠ   Z
scalar_visZ	extract_fZedge_mapperZ
edge_actorZspheresZsphere_mapperZsphere_actorr  rõ   )r‹   r   r   r‚   �  s<    










zFancyTriMesh.__init__c             C   s*   | j rx| j D ]}||j_qW | jƒ  d S )N)rn   rJ   rý   rj   )rk   rE   rb   r   r   r   r  Â  s    z'FancyTriMesh._scalar_visibility_changedc             C   sH   | j }|dk r.ttj|ƒƒttj|ƒƒ d }|| _|| j_| jƒ  d S )Ng•Ö&è.>g     @o@)	rX   rO   r!   r$   rN   r  r¥   r”   rj   )rk   rE   rX   r   r   r   r  È  s    z!FancyTriMesh._tube_radius_changedc             C   sH   | j }|dk r.ttj|ƒƒttj|ƒƒ d }|| _|| j_| jƒ  d S )Ng•Ö&è.>g      Y@)	rX   rO   r!   r$   rN   r  r  r”   rj   )rk   rE   rX   r   r   r   r  Ñ  s    z#FancyTriMesh._sphere_radius_changedc             C   s    | j r|| j d j_| jƒ  d S )Nr   )rn   r   rˆ   rj   )rk   rE   r   r   r   rŒ   Ú  s    zFancyTriMesh._color_changed)r  r	  r  )N)rz   r{   r|   Ú__doc__r   rý   r   rˆ   r   r  r  r   r   rª   r¥   rž   r  r‚   r  r  r  rŒ   r�   r   r   )r‹   r   r  u  s    

5		r  c                   s   e Zd Zd‡ fdd„	Z‡  ZS )ÚMeshNc                s.   t ||||ƒ\}}tt| ƒj|||f|Ž dS )a‡  
        Parameters
        ----------

        - x : array
          A list of x coordinate values formed using numpy.mgrid.
        - y : array
          A list of y coordinate values formed using numpy.mgrid.
        - z : array
          A list of z coordinate values formed using numpy.mgrid.
        - scalars : array (optional)
          Scalars to associate with the points.
        N)rg   r�   r  r‚   )rk   r'   r(   r)   r   rŠ   r[   rX   )r‹   r   r   r‚   ã  s    zMesh.__init__)N)rz   r{   r|   r‚   r�   r   r   )r‹   r   r  â  s   r  c                   s   e Zd Zd‡ fdd„	Z‡  ZS )Ú	FancyMeshNc                s.   t ||||ƒ\}}tt| ƒj|||f|Ž dS )a‡  
        Parameters
        ----------

        - x : array
          A list of x coordinate values formed using numpy.mgrid.
        - y : array
          A list of y coordinate values formed using numpy.mgrid.
        - z : array
          A list of z coordinate values formed using numpy.mgrid.
        - scalars : array (optional)
          Scalars to associate with the points.
        N)rg   r�   r  r‚   )rk   r'   r(   r)   r   rŠ   r[   rX   )r‹   r   r   r‚   ù  s    zFancyMesh.__init__)N)rz   r{   r|   r‚   r�   r   r   )r‹   r   r  ø  s   r  c                   sJ   e Zd Zeddd�ZedƒZd‡ fdd„	Zd	d
„ Zdd„ Z	dd„ Z
‡  ZS )ÚSurfTzshow scalar visibility)r’   ç      à?ç      ð?Nc                s¢   t t| ƒjf |Ž t||||ƒ\}}t|||ƒ| _tj| j| j| j	d�}|dk	rxt
j|ƒ}	t|	ƒt|	ƒf}
|
|_|
| j_t|d�}|jj| jd� | jj|ƒ dS )a‡  
        Parameters
        ----------

        - x : array
          A list of x coordinate values formed using numpy.mgrid.
        - y : array
          A list of y coordinate values formed using numpy.mgrid.
        - z : array
          A list of z coordinate values formed using numpy.mgrid.
        - scalars : array (optional)
          Scalars to associate with the points.
        )r€   rÓ   rý   N)rJ   )rˆ   )r�   r  r‚   rg   r^   r]   r   rM   rØ   rý   r!   r$   rN   rO   rI   rì   r   r   r   rˆ   rn   r‰   )rk   r'   r(   r)   r   rŠ   r[   rX   rJ   r  rõ   rT   )r‹   r   r   r‚     s    


zSurf.__init__c             C   s$   | j r| j d j}||_| jƒ  d S )Nr   )rn   rJ   rý   rj   )rk   rE   rJ   r   r   r   r  3  s    zSurf._scalar_visibility_changedc             C   s,   | j r d}|rd}|| j d j_| jƒ  d S )Nrþ   rÿ   r   )rn   r   r  rj   )rk   rE   r  r   r   r   r  9  s    zSurf._surface_changedc             C   s    | j r|| j d j_| jƒ  d S )Nr   )rn   r   rˆ   rj   )rk   rE   r   r   r   rŒ   A  s    zSurf._color_changed)r  r  r  )N)rz   r{   r|   r   rý   r   rˆ   r‚   r  r  rŒ   r�   r   r   )r‹   r   r    s   r  c                   s<   e Zd Zeddd�Zeejf ƒZ‡ fdd„Z	dd„ Z
‡  ZS )ÚContour3rð   znumber of contours values)r’   c                sž   t t| ƒjf |Ž t||||ƒ\}}t|||ƒ| _| jjjj}|| j	_
| j}	t|	| jƒ |	j| j|d |d ƒ tj|	j| j	|d�}
t|
d�}| jj|ƒ dS )a|  
        Parameters
        ----------

        - x : array
          A list of x coordinate values formed using numpy.mgrid.
        - y : array
          A list of y coordinate values formed using numpy.mgrid.
        - z : array
          A list of z coordinate values formed using numpy.mgrid.
        - scalars : array
          Scalars to associate with the points.
        r   r   )r€   rÓ   rI   )rJ   N)r�   r  r‚   rg   r^   r]   r%   r   rñ   rØ   rì   rò   r   ró   rô   r   rM   rL   r   rn   r‰   )rk   r'   r(   r)   r   rŠ   r[   rX   rõ   rö   rJ   r÷   )r‹   r   r   r‚   Q  s    
zContour3.__init__c             C   s0   | j jjj}| jj||d |d ƒ | jƒ  d S )Nr   r   )r]   r%   r   rñ   rò   ró   rj   )rk   rE   rõ   r   r   r   rø   o  s    z$Contour3._number_of_contours_changed)rz   r{   r|   r   rô   r   r   rù   rò   r‚   rø   r�   r   r   )r‹   r   r  J  s   r  c                   s>   e Zd ZdZeddd�Zdddgf‡ fdd„	Zdd	„ Z‡  ZS )
ÚImShowzyAllows one to view a 2D numpy array as an image.  This works
    best for very large arrays (like 1024x1024 arrays).
    Fz)specifies if image should be interpolated)r’   g      ð?c                s  t t| ƒjf |Ž t|jƒdks(tdƒ‚|j\}}tj|ƒd \}}}tjd||d  d|  |dƒ}	tjd||d  d|  |dƒ}
tj	|ƒ}t
|ƒ}t|ƒ}t|	|
ƒ}| j}||f|_|j|ddƒ}||j_d|jj_d	|_d
|_tj|| jd�}| jj|ƒ dS )z½
        Parameters
        ----------
        - arr : Array to be viewed.

        - scale : Scale the x, y and z axis as per passed values.
          Defaults to [1.0, 1.0, 1.0].
        r9   zOnly 2D arrays can be viewed!g      ð?r   gš™™™™™¹?Úfr   r   Zunsigned_charé   )r€   ÚinterpolateN)r�   r  r‚   r    r;   r#   r!   Úarrayrƒ   r$   rN   rO   r0   rØ   rì   Zmap_scalarsr%   r   r&   Zscalar_typeZnumber_of_scalar_componentsr   Z
ImageActorr  rn   r‰   )rk   ÚarrrQ   rŠ   r+   r*   r-   r.   Újunkr3   r4   Zarr_flatÚmin_valÚmax_valr/   rØ   rC   Úia)r‹   r   r   r‚   €  s&    	
  



zImShow.__init__c             C   s"   | j r| j d }||_| jƒ  d S )Nr   )rn   r  rj   )rk   rE   r   r   r   r   Ú_interpolate_changed£  s    
zImShow._interpolate_changed)	rz   r{   r|   r  r   r  r‚   r!  r�   r   r   )r‹   r   r  x  s   #r  c                   sX   e Zd ZdZeeƒZ‡ fdd„Zdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Z‡  ZS )ÚFigurezpA Figure manages varuous MLabBase objects.  Each of these
    objects contains an actor and does something neat.c                s   t t| ƒjf |Ž || _d S )N)r�   r"  r‚   ri   )rk   ri   rŠ   )r‹   r   r   r‚   ´  s    zFigure.__init__c             C   s   | j j|ƒ dS )z]Add an object to the figure.  This adds the actors of the
        object to the renderwindow.N)Úobjectsr‰   )rk   Úobjr   r   r   Úadd¸  s    z
Figure.addc             C   s
   | j jƒ S )zPops out the last object.)r#  Úpop)rk   r   r   r   r&  ½  s    z
Figure.popc             C   s
   g | _ dS )z"Removes all objects in the figure.N)r#  )rk   r   r   r   ÚclearÁ  s    zFigure.clearc             C   s   | j ||ƒ d S )N)Ú_handle_objects)rk   rq   rp   r   r   r   Ú_objects_changedÅ  s    zFigure._objects_changedc             C   s   | j |j|jƒ d S )N)r(  ru   rv   )rk   rw   r   r   r   Ú_objects_items_changedÈ  s    zFigure._objects_items_changedc             C   sB   x|D ]
}d |_ qW | j }x|D ]
}||_ q W |jƒ  |jƒ  d S )N)ri   Ú
reset_zoomrj   )rk   ru   rv   r$  ry   r   r   r   r(  Ë  s    



zFigure._handle_objects)rz   r{   r|   r  r   rh   r#  r‚   r%  r&  r'  r)  r*  r(  r�   r   r   )r‹   r   r"  ­  s   r"  c             C   s6   t j|ƒ}t|jƒ}| r(tƒ }|j|ƒ |jjƒ  |S )ar  Simple helper function that returns a usable figure.

    Parameters
    ----------

    - outline : `bool` (default: True)

      If True, create an outline bounding box along with an axes
      marker for the scene.

    - browser : `bool` (default, True)

      If True, creates an IVTK scene with an embedded PipelineBrowser.
      If False, does not create it.
    )r   Zviewerr"  Úscener«   r%  r+  )r¯   ZbrowserÚvr  Úor   r   r   ÚfigureÕ  s    



r/  c             C   s<   t dddgdddggdddgdddggdd�}| j|ƒ d S )Nr   r   )rˆ   éÿÿÿÿr0  r0  )r   r   r   )r�   r%  )ÚfigrC   r   r   r   Útest_arrowsñ  s    .r2  c             C   sü   d\}}t j}|d }t jdd| d|  |dƒ}|| }t j|ƒdt j|| | ƒd   }t j|ƒdt j|| | ƒd   }t j|| | ƒd }	t jt|ƒd	fdƒ}
|||	  |
d
d
…df< |
d
d
…df< |
d
d
…df< t|
ddd�}| j|ƒ d
S )z Generates a pretty set of lines.r¢   é   g     @�@ç        r9   g      à?r_   r   rW   Nr   gš™™™™™©?çš™™™™™é?)r”   rˆ   )r¢   r3  )r4  r4  r5  )	r!   Úpirƒ   ÚcosÚsinra   r    r    r%  )r1  Ún_merÚn_longr6  ÚdphiÚphiÚmur'   r(   r)   ÚptsrV   r   r   r   Ú
test_linesö  s    $$4r?  c       
      C   s.  dddgdddgg}dddgd	d
dgdddgdddgg}dddgdddgd
d
dgdddgd	ddgdddgdddgdd d!gg}d"dd#gdd$dgd%dd$gd&ddgd'd d!gd(ddgd)d*dgdddgd+d,d-gd$ddgg
}t |dd0d.�}t |dd1d.�}t |dd2d.�}t |dd3d.�}x ||||fD ]}	| j|	ƒ �qW d/S )4z(Generates and shows a Caffeine molecule.r›   é>   é   é   é   rð   é   r3  é   é*   é   é7   é.   é   é8   é   é   r¬   é1   rš   é2   é   é+   é   é   r
  é    r¢   é?   é$   é;   é<   é   é   é   r   é%   éI   éE   é6   é9   éB   r   é,   é   )r”   rˆ   N)r   r   r   )r   r   r   )r   r   r   )r   r   r   )r™   r%  )
r1  r.  ÚnÚcÚhZoxygenZnitrogenZcarbonZhydrogenrb   r   r   r   Útest_molecule  s    $((,rg  c             C   st   t jdddgdddgdddggdƒ}dddgg}t||ƒ}| j|ƒ |jƒ }d|dd…df< t||ƒ}| j|ƒ dS )zTest for simple triangle mesh.g        r   g      ð?r   r_   r9   N)r!   r  rú   r%  Úcopyr  )r1  r>  r[   rd   Zpts1re   r   r   r   Útest_trimesh  s    $


ri  c             C   sP   dd„ }t jd
ddƒ}t jdddƒ}|r6t|||ƒ}nt|||ƒ}| j|ƒ d	S )z7Test Surf on regularly spaced co-ordinates like MayaVi.c             S   s   t j| | ƒ| |  S )N)r!   r8  )r'   r(   r   r   r   r  &  s    ztest_surf_regular.<locals>.fg      @g333333@gš™™™™™¹?g      @g333333@gš™™™™™©?Ng      Àg      À)r!   rƒ   rï   rë   r%  )r1  Zcontourr  r'   r(   rÿ   r   r   r   Útest_surf_regular$  s    rj  c             C   sF   t jddd…ddd…f \}}|}t|||t j|dƒƒ}| j|ƒ dS )z-Test Surf with a simple collection of points.r   rW   r   r_   N)r!   r`   r  r>   r%  )r1  r'   r(   r)   rÿ   r   r   r   Útest_simple_surf2  s    rk  c             C   s  t j}t j}t j}|d |d  }}t jd||d  |…dd| |d  |…f \}}d}d}	d}
d}d}d}d}d}||| ƒ|	 ||
| ƒ|  ||| ƒ|  ||| ƒ|  }|||ƒ ||ƒ }|||ƒ }|||ƒ ||ƒ }t||||ƒ}| j|ƒ dS )	zUA very pretty picture of spherical harmonics translated from
    the octaviz example.g     @o@r   g      ø?r9   r  rW   r¢   N)r!   r6  r7  r8  r`   r  r%  )r1  r6  r7  r8  r;  Zdthetar<  ÚthetaZm0Úm1Úm2Zm3Zm4Zm5Zm6Zm7r   r'   r(   r)   rÿ   r   r   r   Ú	test_surf9  s&    2       @ro  c             C   s®   t j}t j}t j}|d |d  }}t jd||d  |…dd| |d  |…f \}}d}|||ƒ ||ƒ }	|||ƒ ||ƒ }
|||ƒ }t|	|
||dd�}| j|ƒ d	S )
z)Create a simple sphere and test the mesh.g      4@g{®Gáz„?g      ø?r   r9   g      ð?T)rý   N)r!   r6  r7  r8  r`   r  r%  )r1  r6  r7  r8  ÚduÚdvr<  rl  r   r'   r(   r)   rÿ   r   r   r   Útest_mesh_sphereJ  s    2rr  c             C   sú   t j}t j}t j}|d |d  }}t jd||d  |…dd| |d  |…f \}}d||ƒ ||d| d  ƒ ||d| d  ƒ d	 }d||ƒ ||d| d  ƒ ||d| d  ƒ d	 }	||d| d  ƒ}
t||	|
|
d
d�}| j|ƒ dS )z9Create a fancy looking mesh (example taken from octaviz).g      4@g{®Gáz„?g      ø?r   r9   r   rW   g      @g      à?T)rý   N)r!   r6  r7  r8  r`   r  r%  )r1  r6  r7  r8  rp  rq  Úur-  r'   r(   r)   Úmr   r   r   Ú	test_meshX  s    288ru  c             C   s"   t jjdƒ}t|ƒ}| j|ƒ dS )zShow a large random array.é   é   N)rv  rw  )r!   Úrandomr  r%  )r1  Zz_largerb   r   r   r   Útest_imshowf  s    ry  c              C   sR   t ƒ } tjdd�}|jƒ  t|jƒ}tƒ }|j|ƒ t|ƒ |jj	ƒ  | j
ƒ  d S )Né   éX  )r"   )rz  r{  )r   r   ZIVTKWithCrustAndBrowserÚopenr"  r,  r«   r%  ro  r+  Zstart_event_loop)ÚguiÚwindowr  r.  r   r   r   Úmainm  s    


r  Ú__main__)N)N)N)TT)r   )Hr  Údistutils.versionr   r!   Ú
traits.apir   r   r   r   r   r   r	   r
   r   Ú
pyface.apir   Útvtk.apir   Útvtk.tvtk_baser   r   Ztvtk.commonr   Z
tvtk.toolsr   r   ÚVersionÚvtk_versionrÆ   r   r0   r8   r=   rF   rU   r^   rg   rh   r}   r�   r‘   r•   r˜   r™   rŸ   r    r«   r¿   rÎ   rë   rï   rú   r  r  r  r  r  r  r"  r/  r2  r?  rg  ri  rj  rk  ro  rr  ru  ry  r  rz   r   r   r   r   Ú<module>Z   sn   ,
#	
?

,'>	=1W'Mm<.5(


