当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkRenderWindowInteractor方法代码示例

本文整理汇总了Python中vtk.vtkRenderWindowInteractor方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkRenderWindowInteractor方法的具体用法?Python vtk.vtkRenderWindowInteractor怎么用?Python vtk.vtkRenderWindowInteractor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vtk的用法示例。


在下文中一共展示了vtk.vtkRenderWindowInteractor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def __init__(self):
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0.5, 0.5, 0.5)
        self.renderer.ResetCamera()

        axes_actor = vtk.vtkAxesActor()
        axes_actor.AxisLabelsOff()
        self.renderer.AddActor(axes_actor)

        self.window = vtk.vtkRenderWindow()
        self.window.AddRenderer(self.renderer)

        self.interactor = vtk.vtkRenderWindowInteractor()
        self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        self.interactor.SetRenderWindow(self.window)

        self.camera = vtk.vtkCamera()
        self.camera.SetViewUp(0.0, -1.0, 0.0)
        self.camera.SetPosition(0.0, 0.0, -5)
        self.camera.SetFocalPoint(0.0, 0.0, 0.0)
        # self.camera.SetClippingRange(0.0, 100000)

        self.renderer.SetActiveCamera(self.camera) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:25,代码来源:vtkVisualization.py

示例2: viewer

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def viewer(pointclouds):
        assert all([isinstance(p, VtkPointCloud) for p in pointclouds])

        # Renderer
        renderer = vtk.vtkRenderer()
        renderer.SetBackground(1.0, 1.0, 1.0)

        for p in pointclouds:
            renderer.AddActor(p.vtkActor)
        renderer.ResetCamera()

        # Render Window
        renderWindow = vtk.vtkRenderWindow()
        renderWindow.AddRenderer(renderer)

        # Interactor
        renderWindowInteractor = vtk.vtkRenderWindowInteractor()
        renderWindowInteractor.SetRenderWindow(renderWindow)

        # Begin Interaction
        renderWindow.Render()
        renderWindow.SetWindowName("XYZ Data Viewer")

        renderWindowInteractor.Start() 
开发者ID:moberweger,项目名称:deep-prior-pp,代码行数:26,代码来源:vtkpointcloud.py

示例3: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def __init__(self, background=(0.15, 0.15, 0.15), total_time_steps=None, timer_rate=60, gif_file=None):
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(background[0], background[1], background[2])
        self.ren_win = vtk.vtkRenderWindow()
        self.ren_win.AddRenderer(self.ren)
        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.ren_win)
        self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        self.actor_list = []
        self.mapper_list = []
        self.source_list = []
        self.screenshot_count = 0
        self.timer_rate = timer_rate
        self.gif_data = []
        if gif_file is not None:
            try:
                assert type(gif_file) is str
            except AssertionError:
                gif_file = str(gif_file)
            self.gif_file = gif_file
        else:
            self.gif_file = None

        if total_time_steps is not None:
            assert type(total_time_steps) is int
            self.timer_count = 0
            self.total_time_steps = total_time_steps 
开发者ID:adityadua24,项目名称:robopy,代码行数:29,代码来源:graphics.py

示例4: display_from_actor

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def display_from_actor(actor):
    renderer = vtkRenderer()
    renderWindow = vtkRenderWindow()
    renderWindow.AddRenderer(renderer)

    renderer.AddActor(actor)
    # enable user interface interactor
    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow(renderWindow)
    iren.Initialize()
    renderWindow.Render()
    iren.Start() 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:14,代码来源:vtkhelpers.py

示例5: update

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def update(self, stime=1, force_redraw=True):
        """Update window, redraw, process messages query.

        Parameters
        ----------
        stime : int, optional
            Duration of timer that interrupt vtkRenderWindowInteractor in
            milliseconds.

        force_redraw : bool, optional
            Call ``render`` immediately.

        """
        if stime <= 0:
            stime = 1

        curr_time = time.time()
        if Plotter.last_update_time > curr_time:
            Plotter.last_update_time = curr_time

        if not hasattr(self, 'iren'):
            return

        update_rate = self.iren.GetDesiredUpdateRate()
        if (curr_time - Plotter.last_update_time) > (1.0/update_rate):
            self.right_timer_id = self.iren.CreateRepeatingTimer(stime)

            self.iren.Start()
            self.iren.DestroyTimer(self.right_timer_id)

            self.render()
            Plotter.last_update_time = curr_time
        elif force_redraw:
            self.render() 
开发者ID:pyvista,项目名称:pyvista,代码行数:36,代码来源:plotting.py

示例6: visualize_prediction

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def visualize_prediction(pointcloud, colors, poses=None, renwin=None):
    """ render point cloud and cameras """

    renderer = vtk.vtkRenderer()
    renderer.SetBackground(0, 0, 0)

    pointcloud_actor = create_pointcloud_actor(points=pointcloud, colors=colors)
    pointcloud_actor.GetProperty().SetPointSize(2)
    renderer.AddActor(pointcloud_actor)

    for pose in poses:
        R, t = pose[:3, :3], pose[:3, 3]
        cam_actor = create_camera_actor(R,t)
        cam_actor.GetProperty().SetColor((255, 255, 0))
        renderer.AddActor(cam_actor)

    camera = vtk.vtkCamera()
    camera.SetPosition((1, -1, -2));
    camera.SetViewUp((0, -1, 0));
    camera.SetFocalPoint((0, 0, 2));

    renderer.SetActiveCamera(camera)
    renwin = vtk.vtkRenderWindow()

    renwin.SetWindowName("Point Cloud Viewer")
    renwin.SetSize(800,600)
    renwin.AddRenderer(renderer)
 
    # An interactor
    interactor = vtk.vtkRenderWindowInteractor()
    interstyle = vtk.vtkInteractorStyleTrackballCamera()
    interactor.SetInteractorStyle(interstyle)
    interactor.SetRenderWindow(renwin)

    # Render and interact
    renwin.Render()
    interactor.Initialize()
    interactor.Start() 
开发者ID:princeton-vl,项目名称:DeepV2D,代码行数:40,代码来源:vis.py

示例7: run

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def run(self):
        renderer = vtk.vtkRenderer()
        renderer.SetBackground(0, 0, 0)

        camera = vtk.vtkCamera()
        camera.SetPosition((1, -1, -2));
        camera.SetViewUp((0, -1, 0));
        camera.SetFocalPoint((0, 0, 2));
        renderer.SetActiveCamera(camera)

        renwin = vtk.vtkRenderWindow()
        renwin.SetWindowName("Point Cloud Viewer")
        renwin.SetSize(800,600)
        renwin.AddRenderer(renderer)

        interactor = vtk.vtkRenderWindowInteractor()
        interstyle = vtk.vtkInteractorStyleTrackballCamera()
        interactor.SetInteractorStyle(interstyle)
        interactor.SetRenderWindow(renwin)

        interactor.Initialize()

        cb = vtkTimerCallback(self.cinematic, self.render_path, self.clear_points)
        cb.queue = self.queue

        interactor.AddObserver('TimerEvent', cb.execute)
        timerId = interactor.CreateRepeatingTimer(100);

        #start the interaction and timer
        interactor.Start() 
开发者ID:princeton-vl,项目名称:DeepV2D,代码行数:32,代码来源:vis.py

示例8: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def __init__(self):
        self.ren = vtk.vtkRenderer()
        self.renWin = vtk.vtkRenderWindow()
        self.renWin.AddRenderer(self.ren)
        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.renWin)

        self.lut = vtk.vtkLookupTable()
        self.lut.SetHueRange(0.6, 0.6)
        self.lut.SetSaturationRange(.5, .5)
        self.lut.SetValueRange(0.2, 1.0)
        self.lut.SetNumberOfColors(256)
        self.lut.Build() 
开发者ID:cwant,项目名称:tessagon,代码行数:15,代码来源:tessagon_vtk_demo.py

示例9: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def __init__(self, threadLock, actorWrapper, axis=True,):
        super(VTKVisualisation, self).__init__()

        self.threadLock = threadLock

        self.ren = vtk.vtkRenderer()
        self.ren.AddActor(actorWrapper.actor)

        self.axesActor = vtk.vtkAxesActor()
        self.axesActor.AxisLabelsOff()
        self.axesActor.SetTotalLength(1, 1, 1)
        self.ren.AddActor(self.axesActor)

        self.renWin = vtk.vtkRenderWindow()
        self.renWin.AddRenderer(self.ren)

        ## IREN
        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.renWin)
        self.iren.Initialize()

        self.style = vtk.vtkInteractorStyleTrackballCamera()
        self.iren.SetInteractorStyle(self.style)

        self.iren.AddObserver("TimerEvent", self.update_visualisation)
        dt = 30 # ms
        timer_id = self.iren.CreateRepeatingTimer(dt) 
开发者ID:toinsson,项目名称:pyrealsense,代码行数:29,代码来源:show_vtk.py

示例10: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def __init__(self, h=800, w=600):
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0.1, 0.1, 0.1)

        # Add axes
        axes = vtk.vtkAxesActor()
        axes.GetXAxisCaptionActor2D().SetHeight(0.05)
        axes.GetYAxisCaptionActor2D().SetHeight(0.05)
        axes.GetZAxisCaptionActor2D().SetHeight(0.05)
        axes.SetCylinderRadius(0.03)
        axes.SetShaftTypeToCylinder()
        self.renderer.AddActor(axes)

        # Add render window
        self.renwin = vtk.vtkRenderWindow()
        self.renwin.SetWindowName("Point Cloud Viewer")
        self.renwin.SetSize(h, w)
        self.renwin.AddRenderer(self.renderer)

        # An interactor
        self.interactor = vtk.vtkRenderWindowInteractor()
        interstyle = vtk.vtkInteractorStyleTrackballCamera()
        self.interactor.SetInteractorStyle(interstyle)
        self.interactor.SetRenderWindow(self.renwin)

        self.camera_actors = [] 
开发者ID:sfu-gruvi-3dv,项目名称:sanet_relocal_demo,代码行数:28,代码来源:visualizer_3d.py

示例11: create_render_window

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
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))

    # 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 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

    # Render actors
    render_window.Render()

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

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

    # Start interactor
    window_interactor.Start()

    # Return window interactor instance
    return window_interactor 
开发者ID:orbingol,项目名称:NURBS-Python,代码行数:62,代码来源:vtk_helpers.py

示例12: show_pcd_ndarray

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def show_pcd_ndarray(array_data, color_arr=[0, 255, 0]):
        all_rows = array_data.shape[0]
        Colors = vtk.vtkUnsignedCharArray()
        Colors.SetNumberOfComponents(3)
        Colors.SetName("Colors")

        Points = vtk.vtkPoints()
        Vertices = vtk.vtkCellArray()

        for k in xrange(all_rows):
            point = array_data[k, :]
            id = Points.InsertNextPoint(point[0], point[1], point[2])
            Vertices.InsertNextCell(1)
            Vertices.InsertCellPoint(id)
            if vtk.VTK_MAJOR_VERSION > 6:
                Colors.InsertNextTuple(color_arr)
            else:
                Colors.InsertNextTupleValue(color_arr)

            dis_tmp = np.sqrt((point ** 2).sum(0))
            # Colors.InsertNextTupleValue([0,255-dis_tmp/max_dist*255,0])
            # Colors.InsertNextTupleValue([255-abs(point[0]/x_max*255),255-abs(point[1]/y_max*255),255-abs(point[2]/z_max*255)])
            # Colors.InsertNextTupleValue([255-abs(point[0]/x_max*255),255,255])

        polydata = vtk.vtkPolyData()
        polydata.SetPoints(Points)
        polydata.SetVerts(Vertices)
        polydata.GetPointData().SetScalars(Colors)
        polydata.Modified()

        mapper = vtk.vtkPolyDataMapper()
        if vtk.VTK_MAJOR_VERSION <= 5:
            mapper.SetInput(polydata)
        else:
            mapper.SetInputData(polydata)
        mapper.SetColorModeToDefault()
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().SetPointSize(5)

        # Renderer
        renderer = vtk.vtkRenderer()
        renderer.AddActor(actor)
        renderer.SetBackground(.2, .3, .4)
        renderer.ResetCamera()

        # Render Window
        renderWindow = vtk.vtkRenderWindow()
        renderWindow.AddRenderer(renderer)

        # Interactor
        renderWindowInteractor = vtk.vtkRenderWindowInteractor()
        renderWindowInteractor.SetRenderWindow(renderWindow)

        # Begin Interaction
        renderWindow.Render()
        renderWindowInteractor.Start()


# determine whether a segment is the potential chessboard's point cloud 
开发者ID:mfxox,项目名称:ILCC,代码行数:62,代码来源:pcd_corners_est.py

示例13: vis_with_renderer

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def vis_with_renderer(renderer):
    # Renderer

    # renderer.SetBackground(.2, .3, .4)
    renderer.SetBackground(1, 1, 1)
    renderer.ResetCamera()

    transform = vtk.vtkTransform()
    transform.Translate(1.0, 0.0, 0.0)
    axes = vtk.vtkAxesActor()
    renderer.AddActor(axes)

    # Render Window
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)

    # Interactor
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    def get_camera_info(obj, ev):
        if renderWindowInteractor.GetKeyCode() == "s":
            w2if = vtk.vtkWindowToImageFilter()
            w2if.SetInput(renderWindow)
            w2if.Update()

            writer = vtk.vtkPNGWriter()
            writer.SetFileName("screenshot.png")
            if vtk.VTK_MAJOR_VERSION == 5:
                writer.SetInput(w2if.GetOutput())
            else:
                writer.SetInputData(w2if.GetOutput())
            writer.Write()
            print "screenshot saved"

    style = vtk.vtkInteractorStyleSwitch()
    renderWindowInteractor.SetInteractorStyle(style)
    # style.SetCurrentStyleToTrackballActor()
    style.SetCurrentStyleToTrackballCamera()

    # Begin Interaction
    renderWindowInteractor.AddObserver(vtk.vtkCommand.KeyPressEvent, get_camera_info, 1)
    renderWindow.Render()
    renderWindowInteractor.Start() 
开发者ID:mfxox,项目名称:ILCC,代码行数:46,代码来源:utility.py

示例14: vtk_basic

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindowInteractor [as 别名]
def vtk_basic( actors, embed=False, magnification=1.0 ):
    """
    Create a window, renderer, interactor, add the actors and start the thing
    
    Parameters
    ----------
    actors :  list of vtkActors
    
    Returns
    -------
    nothing
    """     
    
    # create a rendering window and renderer
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    renWin.SetSize(600,600)
    # ren.SetBackground( 1, 1, 1)
 
    # create a renderwindowinteractor
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    for a in actors:

        move( a, np.dot(Ry(-180),Rx(-180)) )
        
        # assign actor to the renderer
        ren.AddActor(a )
    
    # render
    renWin.Render()

    if embed:
        renWin.SetSize(300,300)
        grabber = vtk.vtkWindowToImageFilter()
        grabber.SetInput( renWin )
        grabber.SetMagnification( magnification )
        grabber.Update()
        
        writer = vtk.vtkPNGWriter()
        writer.SetInput( grabber.GetOutput() )
        writer.SetFileName( "screenshot.png" )
        writer.Write()
        return display.Image("screenshot.png")
    else:   
        # enable user interface interactor
        iren.Initialize()
        iren.Start() 
开发者ID:curiale,项目名称:Medical-Image-Analysis-IPython-Tutorials,代码行数:52,代码来源:volumerendering.py


注:本文中的vtk.vtkRenderWindowInteractor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。