[vtkusers] Embed QVTKRenderWindowInteractor in a QTabWidget
Kene Meniru
Kene.Meniru at illom.org
Thu Mar 28 07:55:14 EDT 2013
Hi:
My app is the Window class object below and I am trying to embed a
QVTKRenderWindowInteractor class called ConeWindow below in its QTabWidget.
First, running ConeWindow alone gives out QPainter::begin:, QPainter::save:,
QPainter::setClipRegion:, and QPainter::restore: messages. I can't seem to
stop these messages and it may be what is crashing the Window class when I
embed it.
Can somebody help me here? Thanks.
-------------------
#!/usr/bin/env python
from PyQt4 import QtGui, QtCore
import vtk
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
import sys
class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.treeArea = QtGui.QTreeWidget()
self.textArea = QtGui.QTextEdit()
self.viewArea = QtGui.QTabWidget()
self.msgArea = QtGui.QTextBrowser()
# Add tabs
self.modelTab = ConeWindow(self)
#self.modelTab = QtGui.QTextBrowser()
self.reportTab = QtGui.QTextBrowser()
self.viewArea.addTab(self.modelTab, "Model")
self.viewArea.addTab(self.reportTab, "Report")
# Window area splitters
self.vSplitter = QtGui.QSplitter(QtCore.Qt.Vertical)
self.vSplitter.addWidget(self.viewArea)
self.vSplitter.addWidget(self.msgArea)
self.hSplitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
self.hSplitter.addWidget(self.treeArea)
self.hSplitter.addWidget(self.textArea)
self.hSplitter.addWidget(self.vSplitter)
# Assign mainwindow
self.setCentralWidget(self.hSplitter)
class ConeWindow(QVTKRenderWindowInteractor):
def __init__(self, parent=None):
QVTKRenderWindowInteractor.__init__(self, parent)
self._parent = parent
self.vrenderer = vtk.vtkRenderer()
self.renderWindow = self.GetRenderWindow()
self.renderWindow.AddRenderer(self.vrenderer)
self.iren = self.renderWindow.GetInteractor()
#
self.cone = vtk.vtkConeSource()
self.cone.SetResolution(8)
self.coneMapper = vtk.vtkPolyDataMapper()
self.coneMapper.SetInput(self.cone.GetOutput())
self.coneActor = vtk.vtkActor()
self.coneActor.SetMapper(self.coneMapper)
self.vrenderer.AddActor(self.coneActor)
self.iren.Initialize()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
widge = Window()
widge.show()
sys.exit(app.exec_())
--
Kene
::::::::::::::::::
KeMeniru at gmail.com
More information about the vtkusers
mailing list