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


Python vtk.vtkRenderWindowInteractor函数代码示例

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


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

示例1: main

def main():
    pointSource = vtk.vtkPointSource()
    pointSource.SetNumberOfPoints(20)
    pointSource.Update()

    idFilter = vtk.vtkIdFilter()
    idFilter.SetInputConnection(pointSource.GetOutputPort())
    idFilter.SetIdsArrayName("OriginalIds")
    idFilter.Update()

    surfaceFilter = vtk.vtkDataSetSurfaceFilter()
    surfaceFilter.SetInputConnection(idFilter.GetOutputPort())
    surfaceFilter.Update()

    poly_input = surfaceFilter.GetOutput()

    # Create a mapper and actor
    mapper = vtk.vtkPolyDataMapper()

    if vtk.VTK_MAJOR_VERSION <= 5:
        mapper.SetInputConnection(poly_input.GetProducerPort())
    else:
        mapper.SetInputData(poly_input)
    mapper.ScalarVisibilityOff()

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    # Visualize
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)

    areaPicker = vtk.vtkAreaPicker()
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetPicker(areaPicker)
    renderWindowInteractor.SetRenderWindow(renderWindow)

    renderer.AddActor(actor)
    #renderer.SetBackground(1,1,1) # Background color white

    renderWindow.Render()

    style = vtk.vtkRenderWindowInteractor()
    #style = myInteractorStyle()
    #style = InteractorStyle()
    #style = QVTKRenderWindowInteractor()
    #style.SetPoints(poly_input)
    renderWindowInteractor.SetInteractorStyle(style)

    renderWindowInteractor.Start()
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:51,代码来源:highlight_selected_points.py

示例2: __init__

 def __init__(self,ext_actors=None): #ext_actors is a list of any external vtkActors.
     #initializations:
     self.renderer  = vtk.vtkRenderer()
     self.window    = vtk.vtkRenderWindow()
     self.window.SetSize(1000,1000)
     self.mapper    = vtk.vtkPolyDataMapper()
     self.points    = vtk.vtkPoints()
     self.poly_data = vtk.vtkPolyData()
     self.glyph3d   = vtk.vtkGlyph3D()
     self.actor     = vtk.vtkActor()
     self.point_s   = vtk.vtkPointSource()
     self.sphere    = vtk.vtkSphereSource() 
     self.interactor= vtk.vtkRenderWindowInteractor()
     self.inter_sty = PdbInteractorStyle()
     self.axes_actor= vtk.vtkAxesActor()
     #configurations:
     self.point_s.SetNumberOfPoints(1)
     self.sphere.SetRadius(1.0)
     self.interactor.SetInteractorStyle(self.inter_sty)
     self.interactor.SetRenderWindow(self.window)
     self.axes_actor.SetTotalLength(100,100,100)
     if ext_actors:
         self.ex_actors = ext_actors
     else:
         self.ex_actors=[]
开发者ID:alinar,项目名称:Molar,代码行数:25,代码来源:pdb_viewer.py

示例3: testFixedPointRayCasterLinearCropped

    def testFixedPointRayCasterLinearCropped(self):

        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        iRen = vtk.vtkRenderWindowInteractor()

        tFPRCN = TestFixedPointRayCasterNearest.FixedPointRayCasterNearest(ren, renWin, iRen)
        volumeProperty = tFPRCN.GetVolumeProperty()
        volumeMapper = tFPRCN.GetVolumeMapper()

        for j in range(0, 5):
            for i in range(0, 5):
                volumeMapper[i][j].SetCroppingRegionPlanes(10, 20, 10, 20, 10, 20)
                volumeMapper[i][j].SetCroppingRegionFlags(253440)
                volumeMapper[i][j].CroppingOn()

                volumeProperty[i][j].SetInterpolationTypeToLinear()

        # render and interact with data

        renWin.Render()

        img_file = "TestFixedPointRayCasterLinearCropped.png"
        vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=10)
        vtk.test.Testing.interact()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:25,代码来源:TestFixedPointRayCasterLinearCropped.py

示例4: view

def view(stlfilename):
    reader = vtk.vtkSTLReader()
    reader.SetFileName(stlfilename)

    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(reader.GetOutputPort())

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    # Create a rendering window and renderer
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)

    # Create a renderwindowinteractor
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    # Assign actor to the renderer
    ren.AddActor(actor)

    # Enable user interface interactor
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:Mouse-Imaging-Centre,项目名称:minc-stuffs,代码行数:26,代码来源:vtk_meshconvert.py

示例5: initialize

def initialize(self, VTKWebApp, args):
    if not VTKWebApp.view:
        # VTK specific code
        renderer = vtk.vtkRenderer()
        renderWindow = vtk.vtkRenderWindow()
        renderWindow.AddRenderer(renderer)

        renderWindowInteractor = vtk.vtkRenderWindowInteractor()
        renderWindowInteractor.SetRenderWindow(renderWindow)
        renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()

        cone = vtk.vtkConeSource()
        mapper = vtk.vtkPolyDataMapper()
        actor = vtk.vtkActor()

        mapper.SetInputConnection(cone.GetOutputPort())
        actor.SetMapper(mapper)

        renderer.AddActor(actor)
        renderer.ResetCamera()
        renderWindow.Render()

        # VTK Web application specific
        VTKWebApp.view = renderWindow
        self.Application.GetObjectIdMap().SetActiveObject("VIEW", renderWindow)
开发者ID:Halfnhav,项目名称:tangelo,代码行数:25,代码来源:vtkweb_cone.py

示例6: vtk_basic

def vtk_basic( actors ):
    """
    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:
        # assign actor to the renderer
        ren.AddActor(a )

    #enable user interface interactor
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:kevin-keraudren,项目名称:MSc-code,代码行数:32,代码来源:ManifoldVTK.py

示例7: draw

    def draw(self):

        # Update location and movement
        self.update()

        # create a rendering window and renderer
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.SetSize(1200, 900)
        renWin.AddRenderer(ren)

        # Create camera
        camera = vtk.vtkCamera()
        #camera.SetPosition(0.5,10.0,0.0);
        #camera.Roll(-90)
        #ren.SetActiveCamera(camera)

        # create a renderwindowinteractor
        iren = vtk.vtkRenderWindowInteractor()
        iren.SetRenderWindow(renWin)

        # Add actors
        ren.AddActor(self.modelActor)
        ren.AddActor(self.axesActor)

        # enable user interface interactor
        iren.Initialize()
        renWin.Render()
        style = vtk.vtkInteractorStyleMultiTouchCamera()
        iren.SetInteractorStyle(style)
        iren.Start()
开发者ID:dgmato,项目名称:LIAC-Guidance,代码行数:31,代码来源:PyRobotics.py

示例8: show_vtk_file

def show_vtk_file(path):
	# open vtk file from arglist
	reader = vtk.vtkDataSetReader()
	reader.SetFileName(path)
	reader.Update()
	# read out data and scalarrange
	output = reader.GetOutput()
	scalarrange = output.GetScalarRange()
	# generate Mapper and set DataSource
	mapper = vtk.vtkDataSetMapper()
	mapper.SetInput(output)
	mapper.SetScalarRange(scalarrange)
	# create actor
	actor = vtk.vtkActor()
	actor.SetMapper(mapper)
	# build renderer
	renderer = vtk.vtkRenderer()
	window = vtk.vtkRenderWindow()
	window.AddRenderer(renderer)
	# create interaction
	interaction = vtk.vtkRenderWindowInteractor()
	interaction.SetRenderWindow(window)
	# add actor
	renderer.AddActor(actor)
	# show window and start inteaction and renderer
	interaction.Initialize()
	window.Render()
	interaction.Start()
开发者ID:stetro,项目名称:objScanner,代码行数:28,代码来源:pcd_scanner.py

示例9: createRenderWindow

    def createRenderWindow( self, **args ):
        blocking = args.get( 'blocking', False )
        renWin = args.get( 'renwin', None ) 
        if renWin == None:
            renWin = vtk.vtkRenderWindow()
            
        rendWinInteractor = renWin.GetInteractor()
        if rendWinInteractor == None:                
            rendWinInteractor = vtk.vtkRenderWindowInteractor() if blocking else vtk.vtkGenericRenderWindowInteractor()
            renWin.SetInteractor( rendWinInteractor )
            rendWinInteractor.SetRenderWindow(renWin)  
        
        self.renderWindowInteractor =  rendWinInteractor              
        self.renderer = vtk.vtkRenderer()
        renWin.AddRenderer( self.renderer )

        self.interactorStyle = vtk.vtkInteractorStyleTrackballCamera( )
        self.renderWindowInteractor.SetInteractorStyle( self.interactorStyle )
        self.interactorStyle.KeyPressActivationOff( )
        self.interactorStyle.SetEnabled(1)
                     
        if self.useDepthPeeling:
            self.renderer.UseDepthPeelingOn( )
            self.renderer.SetOcclusionRatio( 0.2 )       
            renWin.SetAlphaBitPlanes( 1 )
            renWin.SetMultiSamples( 0 )
            
        self.renderer.SetBackground(1.0, 1.0, 1.0)
        self.renderer.SetNearClippingPlaneTolerance( 0.0001 )    
        self.renderWindow = renWin
开发者ID:arulalant,项目名称:uvcdat,代码行数:30,代码来源:DV3DPlot.py

示例10: showact

def showact(actors):
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)
    try:
        for a in actors:
            renderer.AddActor(a)
    except:
        renderer.AddActor(actors)

    renderWindow.Render()
    renderWindowInteractor.Start()

# def showact2(actors):
#     renderer = vtk.vtkRenderer()
#     renderWindow = vtk.vtkRenderWindow()
#     renderWindow.AddRenderer(renderer)
#     renderWindowInteractor = vtk.vtkRenderWindowInteractor()
#     renderWindowInteractor.SetRenderWindow(renderWindow)
#     for a in actors:
#         renderer.AddActor(a)
#     renderer.AddActor(actors)
#
#     renderWindow.Render()
#     renderWindowInteractor.Start()
开发者ID:David-webb,项目名称:python_homework,代码行数:27,代码来源:visu.py

示例11: main

def main():
   #Create a sphere
   sphereSource = vtk.vtkSphereSource()
   sphereSource.SetCenter(0.0, 0.0, 0.0)
   sphereSource.SetRadius(5)
 
   #Create a mapper and actor
   mapper = vtk.vtkPolyDataMapper()
   mapper.SetInputConnection(sphereSource.GetOutputPort())
   actor = vtk.vtkActor()
   actor.SetMapper(mapper)
 
   # Setup a renderer, render window, and interactor
   renderer = vtk.vtkRenderer()
   renderWindow = vtk.vtkRenderWindow()
   #renderWindow.SetWindowName("Test")
 
   renderWindow.AddRenderer(renderer);
   renderWindowInteractor = vtk.vtkRenderWindowInteractor()
   renderWindowInteractor.SetRenderWindow(renderWindow)
 
   #Add the actor to the scene
   renderer.AddActor(actor)
   renderer.SetBackground(1,1,1) # Background color white
 
   #Render and interact
   renderWindow.Render()
 
   #*** SetWindowName after renderWindow.Render() is called***
   renderWindow.SetWindowName("Test")
 
   renderWindowInteractor.Start()
开发者ID:alon,项目名称:chibi-juggling,代码行数:32,代码来源:viewer.py

示例12: ex

def ex():
    # create a rendering window and renderer
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    WIDTH=640
    HEIGHT=480
    renWin.SetSize(WIDTH,HEIGHT)
 
    # create a renderwindowinteractor
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)
 
    # create cone
    cone = vtk.vtkConeSource()
    cone.SetResolution(60)
    cone.SetCenter(-2,0,0)
 
    # mapper
    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInput(cone.GetOutput())
 
    # actor
    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)
 
    # assign actor to the renderer
    ren.AddActor(coneActor)

    # enable user interface interactor
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:haskellpostgresprogrammer,项目名称:python_files,代码行数:33,代码来源:vtkstuff.py

示例13: DiscreteMarchingCubes

def DiscreteMarchingCubes(image):
    
    # Main part of discretemarchingcubes
    discreteCubes = vtk.vtkDiscreteMarchingCubes()
    discreteCubes.SetInputData(image)
    discreteCubes.GenerateValues( 116, 1-50,116-50);
    discreteCubes.Update()
    for i in range(0,116):
        print discreteCubes.GetValue(i)


    lut = CreateLookUpTable(color_map);

    # visualization
    print "visualizing..."
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputData(discreteCubes.GetOutput())
    mapper.ScalarVisibilityOn()
    mapper.SetScalarRange(0,4)
    mapper.SetLookupTable(lut)
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    renderer = vtk.vtkRenderer()
    renderer.AddActor(actor)
    window = vtk.vtkRenderWindow()
    window.AddRenderer(renderer)
    interactor = vtk.vtkRenderWindowInteractor()
    window.SetInteractor(interactor)
    
    window.Render()
    interactor.Start()
开发者ID:Beastmaster,项目名称:itk-python-example,代码行数:32,代码来源:vtkDiscreteMarchingCubesDemo.py

示例14: main

def main(pairs):

    import __main__ as _main_module

    renderer = vtk.vtkRenderer()

    for op, file in pairs:
        handler_name = g_op_map[op]
        handler = _main_module.__dict__[handler_name]
        fname = file
        if not os.access(fname, os.R_OK):
            print "Missing file %s" % (fname)
            sys.exit(1)
        else:
            handler(fname, renderer)

    show_axes(renderer)

    # Create the usual rendering stuff.
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(renderer)
    renWin.SetSize(1000, 750)
    iren = vtk.vtkRenderWindowInteractor()
    style = vtk.vtkInteractorStyleTrackballCamera()
    iren.SetInteractorStyle(style)
    iren.SetRenderWindow(renWin)

    # color
    renderer.SetBackground(.1, .2, .4)

    # Render the scene and start interaction.
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:JDonner,项目名称:gabbleduck,代码行数:34,代码来源:sse.py

示例15: testThreshold

  def testThreshold(self):
    global args
    writefiles = "SaveData" in args

    renderer = vtk.vtkRenderer()
    renwin = vtk.vtkRenderWindow()
    renwin.AddRenderer(renderer)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renwin)
    renwin.Render()

    if "GPURender" in args:
        vtk.vtkPistonMapper.InitCUDAGL(renwin)

    src = vtk.vtkImageMandelbrotSource()
    src.SetWholeExtent(0,10,0,10,0,10)

    #scale and bias until piston's threshold understands origin and spacing
    src.Update()
    inputdata = src.GetOutput()
    if "Normalize" in args:
         testdata1 = inputdata.NewInstance()
         testdata1.ShallowCopy(inputdata)
         testdata1.SetSpacing(1,1,1)
         testdata1.SetOrigin(0,0,0)
         inputdata = testdata1

    d2p = vtk.vtkDataSetToPiston()
    d2p.SetInputData(inputdata)
    #d2p.SetInputConnection(src.GetOutputPort())

    threshF = vtk.vtkPistonThreshold()
    threshF.SetInputConnection(d2p.GetOutputPort())
    threshF.SetMinValue(0)
    threshF.SetMaxValue(80)

    p2d = vtk.vtkPistonToDataSet()
    p2d.SetInputConnection(threshF.GetOutputPort())
    p2d.SetOutputDataSetType(vtk.VTK_POLY_DATA)

    if writefiles:
        writeFile(p2d, "piston_threshold.vtk")

    mapper = vtk.vtkPistonMapper()
    mapper.SetInputConnection(threshF.GetOutputPort())
    mapper.Update()

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    renderer.AddActor(actor)

    renderer.ResetCamera()
    renwin.Render()

    img_file = "TestThreshold.png"
    Testing.compareImage(renwin, Testing.getAbsImagePath(img_file))

    if Testing.isInteractive():
        iren.Start()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:60,代码来源:TestThreshold.py


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