Ejemplo n.º 1
0
 def remove(self):
     """Remove ourselves from the mayavi pipeline.
     """
     if self.parent is not None:
         e = get_engine(self)
         self.parent.remove_child(self)
         if e.current_object is self:
             e.current_object = self.parent
Ejemplo n.º 2
0
 def remove(self):
     """Remove ourselves from the mayavi pipeline.
     """
     if self.parent is not None:
         e = get_engine(self)
         self.parent.remove_child(self)
         if e.current_object is self:
             e.current_object = self.parent
Ejemplo n.º 3
0
 def _make_active(self, obj):
     """Make the object given, `obj`, the current selection of the
     engine."""
     engine = get_engine(obj)
     if engine is not None:
         # This is required when running mayavi in envisage.
         GUI.set_trait_later(engine, 'current_selection', obj)
     else:
         print("No engine")
Ejemplo n.º 4
0
 def _make_active(self, obj):
     """Make the object given, `obj`, the current selection of the
     engine."""
     engine = get_engine(obj)
     if engine is not None:
         # This is required when running mayavi in envisage.
         GUI.set_trait_later(engine, 'current_selection', obj)
     else:
         print "No engine"
Ejemplo n.º 5
0
 def _create_object(self, metadata, select=True):
     """Create mayavi pipeline object given its metadata.  If
     `select` is `True` make the created object the active selection.
     """
     callable = metadata.get_callable()
     obj = callable()
     parent = self.object
     engine = get_engine(parent)
     engine.add_filter(obj, parent)
     if select:
         self._make_active(obj)
Ejemplo n.º 6
0
 def _create_object(self, metadata, select=True):
     """Create mayavi pipeline object given its metadata.  If
     `select` is `True` make the created object the active selection.
     """
     callable = metadata.get_callable()
     obj = callable()
     parent = self.object
     engine = get_engine(parent)
     engine.add_filter(obj, parent)
     if select:
         self._make_active(obj)
 def test_get_engine(self):
     e, scene, s, o, o1 = self.e, self.scene, self.s, self.o, self.o1
     self.assertEqual(e, get_engine(scene))
     self.assertEqual(e, get_engine(s))
     self.assertEqual(e, get_engine(o))
     self.assertEqual(e, get_engine(o1))
     self.assertEqual(e, get_engine(o.module_manager))
     self.assertEqual(e, get_engine(o1.module_manager))
Ejemplo n.º 8
0
 def test_get_engine(self):
     e, scene, s, o, o1 = self.e, self.scene, self.s, self.o, self.o1
     self.assertEqual(e, get_engine(scene))
     self.assertEqual(e, get_engine(s))
     self.assertEqual(e, get_engine(o))
     self.assertEqual(e, get_engine(o1))
     self.assertEqual(e, get_engine(o.module_manager))
     self.assertEqual(e, get_engine(o1.module_manager))
Ejemplo n.º 9
0
    def open_file_action(self):
        wildcard = "All files (*.*)|*.*"
        for src in registry.sources:
            if len(src.extensions) > 0:
                if wildcard.endswith("|") or src.wildcard.startswith("|"):
                    wildcard += src.wildcard
                else:
                    wildcard += "|" + src.wildcard

        dialog = FileDialog(parent=None, title="Open supported data file", action="open", wildcard=wildcard)
        if dialog.open() == OK:
            if not isfile(dialog.path):
                error("File '%s' does not exist!" % dialog.path)
                return
            # FIXME: Ask for user input if a filetype is unknown and
            # choose appropriate reader.
            object = self.object
            engine = get_engine(object)
            engine.open(dialog.path, object)
Ejemplo n.º 10
0
    def open_file_action(self):
        wildcard = 'All files (*.*)|*.*'
        for src in registry.sources:
            if len(src.extensions) > 0:
                if wildcard.endswith('|') or \
                   src.wildcard.startswith('|'):
                       wildcard += src.wildcard
                else:
                    wildcard += '|' + src.wildcard

        dialog = FileDialog(parent=None,
                            title='Open supported data file',
                            action='open', wildcard=wildcard
                            )
        if dialog.open() == OK:
            if not isfile(dialog.path):
                error("File '%s' does not exist!"%dialog.path)
                return
            # FIXME: Ask for user input if a filetype is unknown and
            # choose appropriate reader.
            object = self.object
            engine = get_engine(object)
            engine.open(dialog.path, object)