(actors, callbacks, **kwargs)
Creates VTK render window with an interactor.

    :param actors: list of VTK actors
    :type actors: list, tuple
    :param callbacks: callback functions for registering custom events
    :type callbacks: dict
Creates VTK render window with an interactor.
Creates VTK render window with an interactor .
def create_render_window(actors, callbacks, **kwargs):
    """ Creates VTK render window with an interactor.

    :param actors: list of VTK actors
    :type actors: list, tuple
    :param callbacks: callback functions for registering custom events
    :type callbacks: dict
    """
    # Get keyword arguments
    figure_size = kwargs.get('figure_size', (800, 600))
    camera_position = kwargs.get('camera_position', (0, 0, 100))
    display_plot = kwargs.get('display_plot', True)
    image_filename = kwargs.get('image_filename', "screenshot.png")

    # Find camera focal point
    center_points = []
    for actor in actors:
        center_points.append(actor.GetCenter())
    camera_focal_point = linalg.vector_mean(*center_points)

    # Create camera
    camera = vtk.vtkCamera()
    camera.SetPosition(*camera_position)
    camera.SetFocalPoint(*camera_focal_point)

    # Create renderer
    renderer = vtk.vtkRenderer()
    renderer.SetActiveCamera(camera)
    renderer.SetBackground(1.0, 1.0, 1.0)

    # Add actors to the scene
    for actor in actors:
        renderer.AddActor(actor)

    # Render window
    render_window = vtk.vtkRenderWindow()
    render_window.AddRenderer(renderer)
    render_window.SetSize(*figure_size)
    render_window.SetOffScreenRendering(not display_plot)

    # Render actors
    render_window.Render()

    # Set window name after render() is called
    render_window.SetWindowName("geomdl")

    if display_plot:
        # Render window interactor
        window_interactor = vtk.vtkRenderWindowInteractor()
        window_interactor.SetRenderWindow(render_window)

        # Add event observers
        for cb in callbacks:
            window_interactor.AddObserver(cb, callbacks[cb][0], callbacks[cb][1])  # cb name, cb function ref, cb priority

        # Use trackball camera
        interactor_style = vtk.vtkInteractorStyleTrackballCamera()
        window_interactor.SetInteractorStyle(interactor_style)

        # Start interactor
        window_interactor.Start()
    else:
        # Get the screenshot
        window_image = vtk.vtkWindowToImageFilter()
        window_image.SetInput(render_window)
        window_image.Update()

        # Export screenshot to an image file
        window_image_writer = vtk.vtkPNGWriter()
        window_image_writer.SetFileName(image_filename)
        window_image_writer.SetInputConnection(window_image.GetOutputPort())
        window_image_writer.Write()
def create_render_window ( actors , callbacks , * * kwargs ) : # Get keyword arguments figure_size = kwargs . get ( 'figure_size' , ( 800 , 600 ) ) camera_position = kwargs . get ( 'camera_position' , ( 0 , 0 , 100 ) ) display_plot = kwargs . get ( 'display_plot' , True ) image_filename = kwargs . get ( 'image_filename' , "screenshot.png" ) # Find camera focal point center_points = [ ] for actor in actors : center_points . append ( actor . GetCenter ( ) ) camera_focal_point = linalg . vector_mean ( * center_points ) # Create camera camera = vtk . vtkCamera ( ) camera . SetPosition ( * camera_position ) camera . SetFocalPoint ( * camera_focal_point ) # Create renderer renderer = vtk . vtkRenderer ( ) renderer . SetActiveCamera ( camera ) renderer . SetBackground ( 1.0 , 1.0 , 1.0 ) # Add actors to the scene for actor in actors : renderer . AddActor ( actor ) # Render window render_window = vtk . vtkRenderWindow ( ) render_window . AddRenderer ( renderer ) render_window . SetSize ( * figure_size ) render_window . SetOffScreenRendering ( not display_plot ) # Render actors render_window . Render ( ) # Set window name after render() is called render_window . SetWindowName ( "geomdl" ) if display_plot : # Render window interactor window_interactor = vtk . vtkRenderWindowInteractor ( ) window_interactor . SetRenderWindow ( render_window ) # Add event observers for cb in callbacks : window_interactor . AddObserver ( cb , callbacks [ cb ] [ 0 ] , callbacks [ cb ] [ 1 ] ) # cb name, cb function ref, cb priority # Use trackball camera interactor_style = vtk . vtkInteractorStyleTrackballCamera ( ) window_interactor . SetInteractorStyle ( interactor_style ) # Start interactor window_interactor . Start ( ) else : # Get the screenshot window_image = vtk . vtkWindowToImageFilter ( ) window_image . SetInput ( render_window ) window_image . Update ( ) # Export screenshot to an image file window_image_writer = vtk . vtkPNGWriter ( ) window_image_writer . SetFileName ( image_filename ) window_image_writer . SetInputConnection ( window_image . GetOutputPort ( ) ) window_image_writer . Write ( )