Skip to content

Instantly share code, notes, and snippets.

@ianliu
Created January 30, 2020 16:36
Show Gist options
  • Save ianliu/3e281d6fc523f9235b26c8d0674bc01e to your computer and use it in GitHub Desktop.
Save ianliu/3e281d6fc523f9235b26c8d0674bc01e to your computer and use it in GitHub Desktop.
Anti-aliasing issues with Python VTK and Qt
import vtk
import vtkmodules.qt
vtkmodules.qt.PyQtImpl = 'PySide2'
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from PySide2.QtWidgets import QApplication
app = QApplication([])
renderer = vtk.vtkRenderer()
axes = vtk.vtkCubeAxesActor()
axes.SetBounds(-.1, .1, -.1, .1, -.1, .1)
axes.SetCamera(renderer.GetActiveCamera())
axes.SetFlyModeToStaticTriad()
renderer.AddActor(axes)
widget = QVTKRenderWindowInteractor()
widget.GetRenderWindow().AddRenderer(renderer)
widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
widget.Initialize()
widget.Start()
widget.show()
app.exec_()
import vtk
renderer = vtk.vtkRenderer()
axes = vtk.vtkCubeAxesActor()
axes.SetBounds(-.1, .1, -.1, .1, -.1, .1)
axes.SetCamera(renderer.GetActiveCamera())
axes.SetFlyModeToStaticTriad()
renderer.AddActor(axes)
rw = vtk.vtkRenderWindow()
rw.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(rw)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
rw.Render()
iren.Start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment