Exemple #1
0
    def wrapper(*args, **kw):
        script = get_mayavi_script_instance()
        if script is None and mayavi is not None:
            script = mayavi.script
        if script is None:
            def caller(script):
                """Callback that runs the function inside the mayavi
                app."""
                # Bind the 'mayavi' name to the script instance
                func.__globals__['mayavi'] = script
                # Run the function in the event loop.
                g = script.window.application.gui
                g.invoke_later(func, *args, **kw)

            # Start up mayavi and invoke caller when the script instance
            # is available.
            m = Mayavi()
            m.on_trait_change(caller, 'script')
            # Run the mayavi app.
            m.main()
        else:
            ns = func.__globals__
            if not contains_mayavi(ns):
                # Bind the 'mayavi' name to the script instance
                ns['mayavi'] = script
            # Now run the function.
            func(*args, **kw)
Exemple #2
0
    def new_engine(self):
        """ Creates a new engine, envisage or not depending on the
            options.
        """
        check_backend()
        if options.backend == "envisage":
            from mayavi.plugins.app import Mayavi

            m = Mayavi(start_gui_event_loop=False)
            m.main()
            process_ui_events()
            window = m.application.workbench.active_window
            engine = window.get_service(Engine)
        elif options.backend == "test":
            engine = NullEngine(name="Null Mlab Engine")
            engine.start()
        else:
            if options.offscreen:
                engine = OffScreenEngine(name="Mlab offscreen Engine")
                engine.start()
            else:
                engine = Engine(name="Mlab Engine")
                engine.start()
        self.current_engine = engine
        return engine
Exemple #3
0
    def wrapper(*args, **kw):
        script = get_mayavi_script_instance()
        if script is None and mayavi is not None:
            script = mayavi.script
        if script is None:
            def caller(script):
                """Callback that runs the function inside the mayavi
                app."""
                # Bind the 'mayavi' name to the script instance
                func.__globals__['mayavi'] = script
                # Run the function in the event loop.
                g = script.window.application.gui
                g.invoke_later(func, *args, **kw)

            # Start up mayavi and invoke caller when the script instance
            # is available.
            m = Mayavi()
            m.on_trait_change(caller, 'script')
            # Run the mayavi app.
            m.main()
        else:
            ns = func.__globals__
            if not contains_mayavi(ns):
                # Bind the 'mayavi' name to the script instance
                ns['mayavi'] = script
            # Now run the function.
            func(*args, **kw)
Exemple #4
0
 def new_engine(self):
     """ Creates a new engine, envisage or not depending on the
         options.
     """
     check_backend()
     if options.backend == 'envisage':
         from mayavi.plugins.app import Mayavi
         m = Mayavi(start_gui_event_loop=False)
         m.main()
         process_ui_events()
         window = m.application.workbench.active_window
         engine = window.get_service(Engine)
     elif options.backend == 'test':
         engine = NullEngine(name='Null Mlab Engine')
         engine.start()
     else:
         if options.offscreen:
             engine = OffScreenEngine(name='Mlab offscreen Engine')
             engine.start()
         else:
             engine = Engine(name='Mlab Engine')
             engine.start()
     self.current_engine = engine
     return engine