3
ÌœŸWå  ã               @   s    d Z ddlmZmZmZ ddlmZmZ ddl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dlmZ G dd„ deƒZdS )z@ Tests for the garbage collection of objects in mayavi package.
é    )ÚsqrtÚsinÚmgrid)ÚInstanceÚ	HasTraits)ÚViewÚItem)Ú	ETSConfig)ÚSceneEditor)ÚTestGarbageCollection)ÚMayaviScene)ÚEngine)Ú
NullEngine)ÚMlabSceneModelc               @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚTestMayaviGarbageCollectionz2 See: tvtk.tests.common.TestGarbageCollection
    c                s4   G dd„ dt ƒ‰ dd„ }‡ fdd„}| j||ƒ dS )z; Tests if MlabSceneModel with GUI can be garbage collected.c            	   @   sH   e Zd Zeef ƒZeedee	d�ddddd�dd�Z
dd	„ Zd
d„ ZdS )zKTestMayaviGarbageCollection.test_mlab_scene_model_with_gui.<locals>.MlabAppÚscene)Zscene_classFTiô  )ÚnameÚeditorÚ
show_labelÚ	resizableÚheightÚwidth)r   c             [   s   | j ƒ  d S )N)Úgenerate_data)ÚselfÚtraits© r   úg/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/tests/test_garbage_collection.pyÚ__init__%   s    zTTestMayaviGarbageCollection.test_mlab_scene_model_with_gui.<locals>.MlabApp.__init__c             S   sZ   t ddd…ddd…f \}}dt|d |d  ƒ }t|ƒ| }| jjj|||dd� d S )Né   y              Y@é
   Z
gist_earth)Úcolormapéþÿÿÿr!   )r   r   r   r   ÚmlabÚsurf)r   ÚXÚYÚRÚZr   r   r   r   (   s    zYTestMayaviGarbageCollection.test_mlab_scene_model_with_gui.<locals>.MlabApp.generate_dataN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r
   r   Úviewr   r   r   r   r   r   ÚMlabApp   s   
r,   c             S   s$   d | j _tjdkrd | _| jƒ  d S )NÚqt4)ÚownerÚuir	   ÚtoolkitÚcontrolÚdispose)Úor   r   r   Úclose_fn/   s    
zLTestMayaviGarbageCollection.test_mlab_scene_model_with_gui.<locals>.close_fnc                 s   ˆ ƒ } | j ƒ S )N)Úedit_traits)Úapp)r,   r   r   Ú	create_fn5   s    zMTestMayaviGarbageCollection.test_mlab_scene_model_with_gui.<locals>.create_fnN)r   Úcheck_object_garbage_collected)r   r4   r7   r   )r,   r   Útest_mlab_scene_model_with_gui   s    z:TestMayaviGarbageCollection.test_mlab_scene_model_with_guic             C   s    dd„ }dd„ }| j ||ƒ dS )z2 Tests if MlabSceneModel can be garbage collected.c               S   s   t ƒ S )N)r   r   r   r   r   r7   >   s    zDTestMayaviGarbageCollection.test_mlab_scene_model.<locals>.create_fnc             S   s
   d| _ d S )NT)Úclosing)r3   r   r   r   r4   A   s    zCTestMayaviGarbageCollection.test_mlab_scene_model.<locals>.close_fnN)r8   )r   r7   r4   r   r   r   Útest_mlab_scene_model;   s    z1TestMayaviGarbageCollection.test_mlab_scene_modelc             C   s    dd„ }dd„ }| j ||ƒ dS )z. Tests if core Scene can be garbage collected.c              S   s   t ƒ } | jƒ  | jƒ }|S )N)r   ÚstartÚ	new_scene)Úer   r   r   r   r7   H   s    z9TestMayaviGarbageCollection.test_scene.<locals>.create_fnc             S   s
   d| _ d S )NT)r:   )r3   r   r   r   r4   N   s    z8TestMayaviGarbageCollection.test_scene.<locals>.close_fnN)r8   )r   r7   r4   r   r   r   Ú
test_sceneF   s    z&TestMayaviGarbageCollection.test_scenec             C   s   dd„ }dd„ }dS )z3 Tests if Mayavi UI Scene can be garbage collected.c              S   s   t d d�} | S )N)Úparent)r   )r   r   r   r   r7   U   s    
z@TestMayaviGarbageCollection.test_mayavi_scene.<locals>.create_fnc             S   s
   d| _ d S )NT)r:   )r3   r   r   r   r4   Y   s    z?TestMayaviGarbageCollection.test_mayavi_scene.<locals>.close_fnNr   )r   r7   r4   r   r   r   Útest_mayavi_sceneS   s    z-TestMayaviGarbageCollection.test_mayavi_scenec             C   s    dd„ }dd„ }| j ||ƒ dS )z4 Tests if core Null Engine can be garbage collected.c              S   s*   t ƒ } | jƒ  | jƒ  | jƒ  | jƒ  | S )N)r   r<   r=   )r>   r   r   r   r7   ^   s    z?TestMayaviGarbageCollection.test_null_engine.<locals>.create_fnc             S   s   | j ƒ  d S )N)Ústop)r3   r   r   r   r4   f   s    z>TestMayaviGarbageCollection.test_null_engine.<locals>.close_fnN)r8   )r   r7   r4   r   r   r   Útest_null_engine\   s    z,TestMayaviGarbageCollection.test_null_enginec             C   s    dd„ }dd„ }| j ||ƒ dS )z/ Tests if core Engine can be garbage collected.c              S   s   t ƒ } | jƒ  | S )N)r   r<   )r>   r   r   r   r7   m   s    z:TestMayaviGarbageCollection.test_engine.<locals>.create_fnc             S   s   | j ƒ  d S )N)rB   )r3   r   r   r   r4   r   s    z9TestMayaviGarbageCollection.test_engine.<locals>.close_fnN)r8   )r   r7   r4   r   r   r   Útest_enginek   s    z'TestMayaviGarbageCollection.test_engineN)
r(   r)   r*   Ú__doc__r9   r;   r?   rA   rC   rD   r   r   r   r   r      s   &	r   N)rE   Únumpyr   r   r   Ú
traits.apir   r   Útraitsui.apir   r   Útraits.etsconfig.apir	   Ztvtk.pyface.scene_editorr
   Ztvtk.tests.commonr   Zmayavi.core.ui.mayavi_scener   Úmayavi.core.enginer   Úmayavi.core.null_enginer   Zmayavi.tools.mlab_scene_modelr   r   r   r   r   r   Ú<module>   s   