Пример #1
0
 def close_scene(self, scene):
     """Given a VTK scene instance, this method closes it.
     """
     active_window = self.window 
     s = scene.scene
     for editor in active_window.editors[:]:
         if isinstance(editor, scene_editor.SceneEditor):
             if id(editor.scene) == id(s):
                 editor.close()
                 break
     # Flush the UI.
     GUI.process_events()
Пример #2
0
 def new_scene(self):
     """Creates a new TVTK scene, sets its size to that prescribed
     and returns the scene.
     """
     script = self.script
     # Create a new VTK scene.
     script.new_scene()
     # Set its background.
     if self.standalone:
         GUI.process_events()
     s = script.engine.current_scene
     s.scene.background = (0.5, 0.5, 0.5)
     return s
Пример #3
0
    def new_scene(self, name=None, **kwargs):
        """ Creates a new VTK scene window.

            For the time being the extra kwargs are ignored with the
            envisage engine.
        """
        action = NewScene(window=self.window)
        editor = action.perform(None)
        if name is not None:
            editor.name = name
        
        # Flush the UI.
        GUI.process_events()
        return self.scenes[-1]
Пример #4
0
def compare_image_raw(renwin, img_fname, threshold=10, allow_resize=True):
    """Compares renwin's (a tvtk.RenderWindow) contents with the image
    file whose name is given in the second argument.  If the image
    file does not exist the image is generated and stored.  If not the
    image in the render window is compared to that of the figure.
    This function also handles multiple images and finds the best
    matching image.  If `allow_resize` is True then the images are
    rescaled if they are not of the same size.
    """
    # If this is not done the window may not be parented correctly.
    GUI.process_events()
    
    w2if = tvtk.WindowToImageFilter(read_front_buffer=False, input=renwin)
    w2if.update()
    return compare_image_with_saved_image(w2if.output, img_fname,
                                          threshold, allow_resize)