a
    «ˆcH  ã                   @   s€   d Z ddlZddlmZmZ ddlmZ ddlmZm	Z	 ddl
mZ e ¡ ZdZdZd	Zd
ZG dd„ deƒZG dd„ deƒZdS )zThe Mayavi UI plugin
é    N)ÚListÚon_trait_change)ÚPlugin)ÚPerspectiveÚPerspectiveItem)Ú	ETSConfigz%mayavi.core.ui.engine_view.EngineViewz+mayavi.core.engine.Engine.current_selectionz"envisage.plugins.python_shell_viewz2apptools.logger.plugin.view.logger_view.LoggerViewc                   @   s*   e Zd ZdZdZdZdZeƒ Zdd„ Z	dS )ÚMayaviPerspectivez# A default perspective for Mayavi. ÚMayaviTc                 C   sv   t tdd�t tdtd�t tdd�g}d}tjdkrZdd l}|j d¡d d	… d
dgkrZd}|rr| 	t t
dtd�¡ |S )NÚleft)ÚidÚpositionÚbottom)r   r   Úrelative_toTÚwxr   Ú.é   Ú2Ú6FÚwith)r   ÚENGINE_VIEWÚCURRENT_SELECTION_VIEWÚ
SHELL_VIEWr   Ztoolkitr   Ú__version__ÚsplitÚappendÚLOGGER_VIEW)ÚselfÚcontentsZshow_loggerr   © r   úb/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/plugins/mayavi_ui_plugin.pyÚ_contents_default*   s     
ÿ
ü

ÿz#MayaviPerspective._contents_defaultN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameZenabledZshow_editor_arear   r   r    r   r   r   r   r      s   r   c                   @   s²   e Zd ZdZdZdZdZdZdZdZ	e
ed�Ze
ed�Ze
ed�Ze
ed�Ze
e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„ Zdd„ Zedƒdd„ ƒZdS )ÚMayaviUIPluginzenvisage.ui.workbench.viewsz"envisage.ui.workbench.perspectivesz'envisage.ui.workbench.preferences_pagesz!envisage.ui.workbench.action_setsz%envisage.plugins.ipython_shell.bannerzMayavi UI pluginZ	mayavi_ui)Zcontributes_toc                 C   s   | j | jgS ©ú Trait initializer. )Ú_engine_view_factoryÚ_current_selection_view_factory©r   r   r   r   Ú_views_defaultb   s    ÿzMayaviUIPlugin._views_defaultc                 C   s   t gS r'   )r   r+   r   r   r   Ú_perspectives_defaultg   s    z$MayaviUIPlugin._perspectives_defaultc                 C   s   ddl m}m} ||gS )r(   r   )ÚMayaviRootPreferencesPageÚMayaviMlabPreferencesPage)Z*mayavi.preferences.mayavi_preferences_pager.   r/   )r   r.   r/   r   r   r   Ú_preferences_pages_defaultk   s    z)MayaviUIPlugin._preferences_pages_defaultc                 C   s   ddl m} |gS )r(   r   )ÚMayaviUIActionSet)Z#mayavi.plugins.mayavi_ui_action_setr1   )r   r1   r   r   r   Ú_action_sets_defaultq   s    z#MayaviUIPlugin._action_sets_defaultc                 C   s   dgS )zTrait initializer a-  Welcome to Mayavi, this is the interactive IPython shell.

If this is your first time using Mayavi, take a quick look at the tutorial examples section of the user guide, accessible via the help menu.
To use Mayavi, you need to load your data in "data sources" and apply "visualization modules" to it.
r   r+   r   r   r   Ú_banner_defaultx   s    zMayaviUIPlugin._banner_defaultc                 K   sF   ddl m} ddlm} ||  |¡d�}|f |td|ddœ|¤Ž}|S )z" Factory method for engine views. r   ©ÚTraitsUIView)Ú
EngineView)Úenginer	   r
   )Úobjr   r%   Úwindowr   )Úpyface.workbench.traits_ui_viewr5   Zmayavi.core.ui.engine_viewr6   Ú_get_enginer   )r   r9   Útraitsr5   r6   Zengine_viewÚtui_engine_viewr   r   r   r)   ‚   s    üûz#MayaviUIPlugin._engine_view_factoryc              
   K   s8   ddl m} |  |¡}|f |dtd|dtdœ|¤Ž}|S )z9 Factory method for the current selection of the engine. r   r4   Zcurrent_selection_viewzMayavi object editorr   )r8   Úviewr   r%   r9   r   r   )r:   r5   r;   r   r   )r   r9   r<   r5   r7   r=   r   r   r   r*   “   s    
úù	z.MayaviUIPlugin._current_selection_view_factoryc                 C   s   ddl m} | |¡S )z2Return the Mayavi engine of the particular window.r   )ÚEngine)Zmayavi.core.enginer?   Úget_service)r   r9   r?   r   r   r   r;   ¥   s    zMayaviUIPlugin._get_enginec                 C   s   ddl m} | |¡S )zIReturn the `mayavi.plugins.script.Script` instance
        of the window.r   )ÚScript)Zmayavi.plugins.scriptrA   r@   )r   r9   rA   r   r   r   Ú_get_scriptª   s    zMayaviUIPlugin._get_scriptzapplication.gui:startedc              
   C   sâ   |dks|sdS | j }|jj}|  |¡}t}| |¡}	|	du rVt d¡ t d¡ dS zN|	 d|¡ |	 d|j	¡ zddl
m}
 |	 d	|
¡ W n ty    Y n0 W n8 tyÜ } z t |¡ t d
¡ W Y d}~n
d}~0 0 dS )z—This is called when the application's GUI is started.  The
        method binds the `Script` and `Engine` instance on the
        interpreter.
        ÚstartedNzP********************************************************************************z2Can't find the Python shell view to bind variablesZmayavir7   r   )ÚexplorerD   z-Can't find the Python shell to bind variables)ZapplicationZ	workbenchZactive_windowrB   r   Zget_view_by_idÚloggerÚwarnÚbindr7   Zapptools.naming.ui.apirD   ÚImportErrorÚAttributeError)r   r8   Z
trait_nameÚoldÚnewZappr9   Úscriptr   ÚpyrD   Úmsgr   r   r   Ú_on_application_gui_started²   s,    





z*MayaviUIPlugin._on_application_gui_startedN)r!   r"   r#   ZVIEWSZPERSPECTIVESZPREFERENCES_PAGESZACTION_SETSZBANNERr%   r   r   ZviewsZperspectivesZpreferences_pagesZaction_setsZbannerr,   r-   r0   r2   r3   r)   r*   r;   rB   r   rO   r   r   r   r   r&   A   s.   





r&   )r$   ÚloggingZ
traits.apir   r   Zenvisage.apir   Zpyface.workbench.apir   r   Ztraits.etsconfig.apir   Ú	getLoggerrE   r   r   r   r   r   r&   r   r   r   r   Ú<module>   s   &