class MayaviScene(DecoratedScene):
    """ A scene UI, similar to a decorated scene, but with more buttons.
    """

    image_search_path = [join(resource_path(), 'images'), ]

    ##########################################################################
    # Non-public interface.
    ##########################################################################
    def show_engine(self):
        """ Open the engine view corresponding to the engine of the
            scene.
        """
        from mayavi.core.registry import registry
        from mayavi.core.ui.engine_rich_view import EngineRichView
        try:
            engine = registry.find_scene_engine(self)
        except TypeError:
            error('This scene is not managed by Mayavi')
        return EngineRichView(engine=engine).scene_editing_view(scene=self)

    ######################################################################
    # Trait handlers.
    ######################################################################
    def _actions_default(self):
        actions = [ Group(
                    Action(tooltip="View the Mayavi pipeline",
                        image=ImageResource('m2',
                                search_path=self.image_search_path),
                        on_perform=self.show_engine,
                        ),
                        ),
                        ]
        actions.extend(DecoratedScene._actions_default(self))
        return actions
class PreferenceManagerView(PreferencesManager):
    """ A preference manager UI for Mayavi, to be used outside of
        Envisage.
    """

    # Path used to search for images
    _image_path = [
        join(resource_path(), 'images'),
    ]

    # The icon of the dialog
    icon = ImageResource('preferences.ico', search_path=_image_path)

    # The preference pages displayed
    pages = List(PreferencesPage)

    def _pages_default(self):
        return [
            MayaviRootPreferencesPage(
                preferences=preference_manager.root.preferences),
            MayaviMlabPreferencesPage(
                preferences=preference_manager.mlab.preferences),
        ]

    def dialog_view(self):
        """ Poor-man's subclassing of view to overload size.
        """
        view = self.trait_view()
        view.width = 0.7
        view.height = 0.5
        view.title = 'Mayavi preferences'
        view.icon = self.icon
        ui = self.edit_traits(view=view,
                              scrollable=True,
                              id='mayavi.preferences.preference_view')
        return ui

    def _get_root(self):
        """ Subclass the root getter, to work outside of envisage, with
            no well-defined root.
        """
        root = PreferencesNode(page=self.pages[0])
        for page in self.pages:
            root.append(PreferencesNode(page=page))
        return root

    def apply(self):
        super(PreferenceManagerView, self).apply()
        for page in self.pages:
            page.preferences.save()
Example #3
0
 def __icon_path_default(self):
     return resource_path()
Example #4
0
 def get_icon_path(self):
     return resource_path()
Example #5
0
def mk_scene_icon():
    icon_path = os.path.join(resource_path(), 'images', 'scene.ico')
    return ImageResource(icon_path)
Example #6
0
 def get_icon_path(self):
     return resource_path()
Example #7
0
 def __icon_path_default(self):
     return resource_path()
Example #8
0
def mk_scene_icon():
    icon_path = os.path.join(resource_path(), 'images', 'scene.ico')
    return ImageResource(icon_path)