本文整理汇总了Python中vtk.vtkRenderWindow方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkRenderWindow方法的具体用法?Python vtk.vtkRenderWindow怎么用?Python vtk.vtkRenderWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkRenderWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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)
示例2: viewer
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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()
示例3: make_render_window
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [as 别名]
def make_render_window():
#cone actor
cone = vtk.vtkConeSource()
coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInputConnection(cone.GetOutputPort())
coneActor = vtk.vtkActor()
coneActor.SetMapper(coneMapper)
#text actor following camera
text = vtk.vtkVectorText()
text.SetText("Origin")
textMapper = vtk.vtkPolyDataMapper()
textMapper.SetInputConnection(text.GetOutputPort())
textActor = vtk.vtkFollower()
textActor.SetMapper(textMapper)
ren = vtk.vtkRenderer()
ren.AddActor(coneActor)
ren.AddActor(textActor)
textActor.SetCamera(ren.GetActiveCamera())
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
return renWin
示例4: display_from_actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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()
示例5: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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
示例6: check_depth_peeling
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [as 别名]
def check_depth_peeling(number_of_peels=100, occlusion_ratio=0.0):
"""Check if depth peeling is available.
Attempts to use depth peeling to see if it is available for the current
environment. Returns ``True`` if depth peeling is available and has been
successfully leveraged, otherwise ``False``.
"""
# Try Depth Peeling with a basic scene
source = vtk.vtkSphereSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# requires opacity < 1
actor.GetProperty().SetOpacity(0.5)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.SetOffScreenRendering(True)
renderWindow.SetAlphaBitPlanes(True)
renderWindow.SetMultiSamples(0)
renderer.AddActor(actor)
renderer.SetUseDepthPeeling(True)
renderer.SetMaximumNumberOfPeels(number_of_peels)
renderer.SetOcclusionRatio(occlusion_ratio)
renderWindow.Render()
return renderer.GetLastRenderingUsedDepthPeeling() == 1
示例7: resizeEvent
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [as 别名]
def resizeEvent(self, ev):
w = self.width()
h = self.height()-25
vtk.vtkRenderWindow.SetSize(self._RenderWindow, w, h)
self._Iren.SetSize(w, h)
self._Iren.ConfigureEvent()
self.update()
示例8: visualize_prediction
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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()
示例9: run
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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()
示例10: make_ren_win
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [as 别名]
def make_ren_win(self):
import vtk
ren = vtk.vtkRenderer()
ren_win = vtk.vtkRenderWindow()
ren_win.AddRenderer(ren)
return ren_win
示例11: applies
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [as 别名]
def applies(cls, obj, **kwargs):
if 'vtk' not in sys.modules and 'vtkmodules' not in sys.modules:
return False
else:
import vtk
return isinstance(obj, vtk.vtkRenderWindow)
示例12: test_get_vtk_pane_type_from_render_window
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [as 别名]
def test_get_vtk_pane_type_from_render_window():
assert PaneBase.get_pane_type(vtk.vtkRenderWindow()) is VTKRenderWindowSynchronized
assert PaneBase.get_pane_type(vtk.vtkRenderWindow(), serialize_on_instantiation=True) is VTKRenderWindow
示例13: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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()
示例14: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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)
示例15: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkRenderWindow [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 = []