def testQVTKWidget2(self): w2 = vtk.QVTKWidget2() w2.resize(500, 500) ren = vtk.vtkRenderer() ren.SetBackground(0, 0, 0) ren.SetBackground2(1, 1, 1) ren.SetGradientBackground(1) win2 = vtk.vtkGenericOpenGLRenderWindow() win2.AddRenderer(ren) w2.SetRenderWindow(win2) renwin = w2.GetRenderWindow() cone = vtk.vtkConeSource() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cone.GetOutput()) actor = vtk.vtkActor() actor.SetMapper(mapper) ren.AddViewProp(actor) ren.ResetCamera() w2.show() if Testing.isInteractive(): PyQt4.QtGui.qApp.exec_()
def __init__(self): super(MyGraphicsView, self).__init__() self.mWidget = vtk.QVTKWidget2() self.setViewport(self.mWidget) self.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate) self.mScene = MyOpenGLScene(self.mWidget.context()) self.setScene(self.mScene) self.mRen = vtk.vtkRenderer() self.mRen.SetBackground(0, 0, 0) self.mRen.SetBackground2(1, 1, 1) self.mRen.SetGradientBackground(1) textActor = vtk.vtkTextActor3D() textActor.SetInput("Qt & VTK!!") self.mRen.AddViewProp(textActor) self.mRen.ResetCamera() self.mWidget.GetRenderWindow().AddRenderer(self.mRen) self.mWidget.GetRenderWindow().SetSwapBuffers(0)