本文整理汇总了Python中vtk.vtkInteractorStyleTrackballCamera方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkInteractorStyleTrackballCamera方法的具体用法?Python vtk.vtkInteractorStyleTrackballCamera怎么用?Python vtk.vtkInteractorStyleTrackballCamera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkInteractorStyleTrackballCamera方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [as 别名]
def __init__(self, parent=None):
super(QVTKWidget, self).__init__(parent)
self._enable_axis = False
self._Iren.SetInteractorStyle (vtkInteractorStyleTrackballCamera ())
self.renderer = vtkRenderer()
self.renderer.GradientBackgroundOn()
self.renderer.SetBackground2(255.0,255.0,255.0)
self.renderer.SetBackground(37/255.0, 85/255.0,152/255.0)
self.GetRenderWindow().AddRenderer(self.renderer)
self.Initialize()
self.Start()
self.add_axes()
示例3: set_interactor_style_trackball
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [as 别名]
def set_interactor_style_trackball(self):
self.vtkWidget.set_interactor_style(vtkInteractorStyleTrackballCamera())
示例4: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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
示例5: update_style
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [as 别名]
def update_style(self):
"""Update the camera interactor style."""
if not hasattr(self, '_style'):
self._style = vtk.vtkInteractorStyleTrackballCamera()
if hasattr(self, 'iren'):
return self.iren.SetInteractorStyle(self._style)
示例6: enable_trackball_style
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [as 别名]
def enable_trackball_style(self):
"""Set the interactive style to trackball camera.
The trackball camera is the default interactor style.
"""
self._style = vtk.vtkInteractorStyleTrackballCamera()
return self.update_style()
示例7: visualize_prediction
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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()
示例8: run
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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()
示例9: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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)
示例10: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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 = []
示例11: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [as 别名]
def __init__(self, renderer=None, parent=None):
# Every QT app needs a QApplication
self.app = QApplication.instance()
if self.app is None:
self.app = QApplication(sys.argv)
# Create the widget
if renderer is None:
self.renderer = vtk.vtkRenderer()
else:
self.renderer = renderer
self.widget = QVTKRenderWindowInteractor(parent)
self.widget.Initialize
self.widget.Start()
# Set the interactor style
self.widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
# Get the render window from the widget
self.renderWindow = self.widget.GetRenderWindow()
self.renderWindow.AddRenderer(self.renderer)
# show the widget
self.widget.show()
示例12: create_render_window
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkInteractorStyleTrackballCamera [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