Created
June 11, 2012 18:35
-
-
Save fmorency/2911801 to your computer and use it in GitHub Desktop.
QVTKRenderWindowInteractor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vtk | |
from vtk.qt4.QVTKRenderWindowInteractor import * | |
from PySide.QtCore import * | |
from PySide.QtGui import * | |
from PySide.QtXml import * | |
from PySide.QtUiTools import * | |
if __name__ == "__main__": | |
app = QApplication(['QVTKRenderWindowInteractor']) | |
w, h = 400, 400 | |
main_window = QMainWindow() | |
grid_layout = QGridLayout() | |
button_test = QPushButton('Dummy') | |
#VTK renderer | |
ren = vtk.vtkRenderer() | |
ren.SetBackground(0.1, 0.1, 0.2) | |
#Cone source | |
cone = vtk.vtkConeSource() | |
cone.SetResolution(8) | |
coneMapper = vtk.vtkPolyDataMapper() | |
coneMapper.SetInputConnection(cone.GetOutputPort()) | |
coneActor = vtk.vtkActor() | |
coneActor.SetMapper(coneMapper) | |
#Add cone source to renderer | |
ren.AddActor(coneActor) | |
# Rendering window | |
renWin = vtk.vtkRenderWindow() | |
renWin.AddRenderer(ren) | |
renWin.SetSize(w,h) | |
#Qt Window Interactor | |
axial_view = QVTKRenderWindowInteractor(rw=renWin, width=w, height=h) | |
axial_view.Initialize() | |
axial_view.Start() | |
axial_view.SetPicker(vtk.vtkPointPicker()) | |
#Comment the next line to render the QVTKRenderWindowInteractor in its own | |
#window | |
grid_layout.addWidget(axial_view) | |
grid_layout.addWidget(button_test, 0, 1) | |
main_window.setCentralWidget(QWidget()) | |
main_window.centralWidget().setLayout(grid_layout) | |
#Render VTK | |
renWin.Render() | |
axial_view.Render() | |
#Show Qt widgets | |
axial_view.show() | |
main_window.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment