本文整理汇总了Python中vtk.vtkRenderWindowInteractor函数的典型用法代码示例。如果您正苦于以下问题:Python vtkRenderWindowInteractor函数的具体用法?Python vtkRenderWindowInteractor怎么用?Python vtkRenderWindowInteractor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkRenderWindowInteractor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Visualize_Orientation
def Visualize_Orientation(model, out_file):
# create coordinate actor
axes_actor = vtk.vtkAxesActor()
axes_actor.SetTotalLength(500.0, 500.0, 500.0)
# create model actor
model_mapper = vtk.vtkPolyDataMapper()
model_mapper.SetInputData(model)
model_actor = vtk.vtkActor()
model_actor.SetMapper(model_mapper)
global renderer
global interactor
renderer = vtk.vtkRenderer()
renderer.AddActor(model_actor)
renderer.AddActor(axes_actor)
win = vtk.vtkRenderWindow()
win.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
interactor_style = QIN_Style()
interactor_style.SetRenderer(renderer)
interactor_style.SetActor(model_actor)
interactor_style.SetPolyData(model)
interactor_style.SetOutName(out_file)
interactor.SetInteractorStyle(interactor_style)
win.SetInteractor(interactor)
win.Render()
interactor.Start()
pass
开发者ID:Beastmaster,项目名称:itk-python-example,代码行数:32,代码来源:vtkModifySTLOrientation.py
示例17: vtk_Nviews
def vtk_Nviews( actors ):
"""
Create a window, an interactor and one renderer per actor
Parameters
----------
actors : list of vtkActors
Returns
-------
nothing
"""
N = len(actors)
# create a rendering window and renderers
renderers = [vtk.vtkRenderer() for i in range(N)]
renWin = vtk.vtkRenderWindow()
renWin.SetSize( 600, 600 )
for i in range(N):
# split the viewport
renderers[i].SetViewport(0,float(N-i-1)/N,1,float(N-i)/N)
renderers[i].SetBackground( 1, 1, 1)
renderers[i].AddActor( actors[i] )
renWin.AddRenderer(renderers[i])
# create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
#enable user interface interactor
iren.Initialize()
renWin.Render()
iren.Start()
开发者ID:kevin-keraudren,项目名称:MSc-code,代码行数:33,代码来源:ManifoldVTK.py
示例18: show
def show(self):
# Add to the cloud
self.vtkPolyData.SetPoints(self.vtkPoints)
self.vtkPolyData.SetVerts(self.vtkCells)
self.vtkPolyData.GetPointData().SetVectors(self.vtkColor)
self.vtkPolyData.Modified()
self.vtkPolyData.Update()
# Renderer
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(self.vtkPolyData)
renderer = vtk.vtkRenderer()
self.vtkActor.SetMapper(mapper)
renderer.AddActor(self.vtkActor)
renderer.SetBackground(.2, .3, .4)
renderer.ResetCamera()
#renderer.SetPosition([-3, 0, 11])
# Render Window
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
# Interactor
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
# Begin Interaction
renderWindow.Render()
renderWindowInteractor.Start()
开发者ID:dquinnfrank,项目名称:will-it-blend,代码行数:32,代码来源:cloud_vis.py
示例19: __test_adjust_sphere
def __test_adjust_sphere():
import vtk
n_points = 4
points = []
for i in xrange(n_points):
p = np.random.random(3) * 100
points.append(p)
r, ctr = adjust_sphere(points)
r2 = r / 10
ren_win = vtk.vtkRenderWindow()
iren = vtk.vtkRenderWindowInteractor()
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.SetRenderWindow(ren_win)
ren = vtk.vtkRenderer()
ren_win.AddRenderer(ren)
# draw points
for p in points:
__add_sphere_to_ren(p, r2, ren)
#draw big sphere
ac = __add_sphere_to_ren(ctr, r, ren)
ac.GetProperty().SetColor((1, 0, 0))
iren.Initialize()
iren.Start()
开发者ID:deherinu,项目名称:TmsViewer,代码行数:25,代码来源:tms_geom.py
示例20: initialize
def initialize():
# Create a rendering window and renderer
transform = vtk.vtkTransform()
transform.Scale(10.0, 10.0, 10.0)
axes = vtk.vtkAxesActor()
axes.SetUserTransform(transform)
transform.Translate(3.0, -2.0, 0.0)
axes.SetUserTransform(transform)
ren = vtk.vtkRenderer()
ren.AddActor(axes)
ren.ResetCamera()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
# Create a RenderWindowInteractor to permit manipulating the camera
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
style = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(style)
# enable user interface interactor
iren.Initialize()
renWin.Render()
iren.Start()
return ren, iren, renWin
开发者ID:Andrew-AbiMansour,项目名称:PyDEM,代码行数:31,代码来源:visualize.py
注:本文中的vtk.vtkRenderWindowInteractor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论