[vtkusers] Embedding Python QVTKRenderWindowInteractor into Qt-Enviroment

Rocco Gasteiger post at rocco-gasteiger.de
Wed May 20 04:20:06 EDT 2009


Dear members,

I want to render some vtk-data into a Qt-Enviroment via Python scripting. To
do this, I use Qt-Designer, PyQt 4.4.4 and python binding for the vtk
classes. In my old C++ implementation I use a QVTKWidget embedded into a
QGroupBox for 2D/3D rendering and it works fine. For some reasons, I want to
switch to do the same via python scripting. But here I have the following
problem: 

A QVTKWidget does not exist in PyQt. So I found in a prior posting, that I
have to use a QVTKRenderWindowInteractor class instead. In my python script
I initialized this class with a QFrame-object, which I have defined and
placed in the Qt-Designer before. It compiles correct and the render content
is displayed into the QFrame-Object BUT with the wrong size. In my old
C++-Implementation the size of the render window fits into the QVTKWidget
according its size. Changing the size of render window by hand has no effect
of the displayed render window. Can anybody give me a hint what I'm doing
wrong or where my mistake is? For better understanding what I have done, I
listed some code snipped from my python script below. Additionally I
attached a picture of the running Qt-application.

For any help I would be very appreciate.
Best Regards, Rocco Gasteiger 

// This is the initializing part of my QVTKRenderWindowInteractor. The
object "axialView" is a QFrame object
// which I have defined in Qt-Designer
def __init__(self, parent = None):
        """
        Constructor
        """
        QMainWindow.__init__(self, parent)
        self.setupUi(self)        
        self.connect(self.actionOpenDICOM,  QtCore.SIGNAL('triggered()'),
self.loadFiles)        
        self.axialViewerWidget = QVTKRenderWindowInteractor(self.axialView)

        
        self.axialViewerWidget.Initialize()
        self.axialViewerWidget.Start()       
        self.initDatasets();
        self.initSliceViews();
        
// Here I setup the the image viewer and its interactor. 
def initSliceViews(self):
        print 'Init Slice Views'
        axialViewer = vtk.vtkImageViewer2()
        self.axialViewer.SetInput(self.dataset)      
        
        self.interactorForAxialView = vtk.vtkInteractorStyleImage()
 
self.axialViewer.SetupInteractor(self.axialViewerWidget.GetRenderWindow().Ge
tInteractor())
        self.interactorForAxialView = self.axialViewer.GetInteractorStyle()
 
self.axialViewer.SetRenderWindow(self.axialViewerWidget.GetRenderWindow())

        self.axialViewerWidget.show()
        self.axialViewer.Render()



-------------- next part --------------
A non-text attachment was scrubbed...
Name: QtResult.png
Type: image/png
Size: 6162 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090520/c2e570b9/attachment.png>


More information about the vtkusers mailing list