Python vtk.vtkInteractorStyleTrackballCamera() Examples
The following are 12
code examples of vtk.vtkInteractorStyleTrackballCamera().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vtk
, or try the search function
.
Example #1
Source File: vtkVisualization.py From MOTSFusion with MIT License | 5 votes |
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)
Example #2
Source File: QVTKWidget.py From pcloudpy with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #3
Source File: ViewWidget.py From pcloudpy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_interactor_style_trackball(self): self.vtkWidget.set_interactor_style(vtkInteractorStyleTrackballCamera())
Example #4
Source File: graphics.py From robopy with MIT License | 5 votes |
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
Example #5
Source File: plotting.py From pyvista with MIT License | 5 votes |
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)
Example #6
Source File: plotting.py From pyvista with MIT License | 5 votes |
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()
Example #7
Source File: vis.py From DeepV2D with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #8
Source File: vis.py From DeepV2D with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #9
Source File: show_vtk.py From pyrealsense with Apache License 2.0 | 5 votes |
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)
Example #10
Source File: visualizer_3d.py From sanet_relocal_demo with GNU General Public License v3.0 | 5 votes |
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 = []
Example #11
Source File: renderwidget.py From Det3D with Apache License 2.0 | 5 votes |
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()
Example #12
Source File: vtk_helpers.py From NURBS-Python with MIT License | 4 votes |
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