[vtkusers] InfoVis: vtkGraphLayoutView in QVTK Widget

Eric E. Monson emonson at cs.duke.edu
Mon Jun 29 12:43:26 EDT 2009


Hey Clint,

Now that you mention it, I'm really not sure why it's not complaining  
when my code gets to the vtkWidget.SetRenderWindow() call...

My vtkWidget is really a QVTKRenderWindowInteractor. The beginning of  
my UI code (mostly generated by pyuic4, but modified a bit to replace  
QVTKWidget with QVTKRenderWindowInteractor and 'from QVTK' with 'from  
vtk.qt4.QVTK') is:

from PyQt4 import QtCore, QtGui
from vtk.qt4.QVTKRenderWindowInteractor import  
QVTKRenderWindowInteractor

class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName("MainWindow")
         MainWindow.resize(603, 553)
         self.centralWidget = QtGui.QWidget(MainWindow)
         self.centralWidget.setObjectName("centralWidget")
         self.gridlayout = QtGui.QGridLayout(self.centralWidget)
         self.gridlayout.setObjectName("gridlayout")
         self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
         self.vtkWidget.setObjectName("vtkWidget")
         self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)
         MainWindow.setCentralWidget(self.centralWidget)

When running the debugger in ipython, it doesn't list  
SetRenderWindow() as one of the possible methods for my vtkWidget (and  
I don't see it in my QVTKRenderWindowInteractor.py file), but it also  
doesn't complain when I execute that line. I didn't make my own, so I  
don't know what's going on...

Thanks,
-Eric


On Jun 29, 2009, at 12:01 PM, Clinton Stimpson wrote:

>
> They PyQt4 wrapping doesn't have a SetRenderWindow().  Did you make  
> your own?
> The PyQt[4] code isn't a wrapper around the C++ QVTKWidget class.
>
> And Jeff, what changes and where were you thinking of to remove the  
> SetInteractor()?
> I imagine vtkXRenderWindowInteractor needs changed.
>
> Clint
>
> Eric E. Monson wrote:
>> Hey Jeff,
>>
>> Thanks for the quick reply. I tried (after updating to current CVS):
>>
>>        self.view = vtk.vtkGraphLayoutView()
>>        self.view.SetInteractor(self.ui.vtkWidget.GetInteractor())
>>        self.ui.vtkWidget.SetRenderWindow(self.view.GetRenderWindow())
>>
>> but for some reason the GetInteractor() method doesn't seem to be  
>> wrapped in Python. I tried to cheat it by calling:
>>
>>        self.view.SetInteractor(self.ui.vtkWidget._Iren)
>>
>> and it ran but still popped up an extra render window as before...
>>
>> I'll try looking through the page you referenced, but let me know  
>> if you have any other ideas.
>>
>> Thanks,
>> -Eric
>>
>>
>> On Jun 29, 2009, at 10:57 AM, Jeff Baumes wrote:
>>
>>> Try the following, it should work. This is the result of some  
>>> major view/representation refactoring that has taken place in VTK  
>>> CVS. I'd like to avoid the need for the SetInteractor() call in  
>>> the future, but currently it's necessary to avoid the popout on  
>>> some systems.
>>>
>>> vtkRenderViewPtr->SetInteractor(qvtkWidget->GetInteractor());
>>> qvtkWidget->SetRenderWindow(vtkRenderViewPtr->GetRenderWindow());
>>>
>>> If you're interested in some discussion of the refactoring, look  
>>> here
>>>
>>> https://www.kitware.com/InfovisWiki/index.php/View_Representation_Refactoring
>>>
>>> Jeff
>>>
>>> On Mon, Jun 29, 2009 at 10:44 AM, Eric E. Monson <emonson at cs.duke.edu 
>>>  <mailto:emonson at cs.duke.edu>> wrote:
>>>
>>>    Hey again,
>>>
>>>    I just tried to follow the Cxx EasyView and it still opens
>>>    another render window with all of my graph stuff in it, and the
>>>    QVTK widget just shows garbage from the last application that I
>>>    ran (which here happens to be another PyQt4 app showing a
>>>    cylinder that worked just fine -- screen shot attached).
>>>
>>>    class SimpleView(QtGui.QMainWindow):
>>>
>>>       def __init__(self, parent = None):
>>>
>>>
>>>           QtGui.QMainWindow.__init__(self, parent)
>>>           self.ui = Ui_MainWindow()
>>>           self.ui.setupUi(self)
>>>
>>>           self.view = vtk.vtkGraphLayoutView()
>>>            
>>> self.ui.vtkWidget.SetRenderWindow(self.view.GetRenderWindow())
>>>
>>>
>>>    I'm using OS X 10.5.7, Qt 4.4.3, VTK CVS from June 18th, Python  
>>> 2.5.
>>>
>>>    Thanks,
>>>    -Eric
>>>
>>>
>>>
>>>
>>>
>>>    On Jun 29, 2009, at 9:59 AM, Eric E. Monson wrote:
>>>
>>>        Hello,
>>>
>>>        I have a little Python/PyQt4 app that I made about six months
>>>        ago to view graphs using the Titan classes. A
>>>        vtkGraphLayoutView should show up in a QVTK Widget which I
>>>        placed using Designer, but now with CVS VTK I get a separate
>>>        RenderWindow popping up showing my graph...
>>>
>>>        vtkGraphLayoutView used to have a SetupRenderWindow() method,
>>>        so I used to set things up by:
>>>
>>>              QtGui.QMainWindow.__init__(self, parent)
>>>              self.ui = Ui_MainWindow()
>>>              self.ui.setupUi(self)
>>>
>>>              self.ren = vtk.vtkRenderer()
>>>               
>>> self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
>>>
>>>              [...]
>>>
>>>              self.view = vtk.vtkGraphLayoutView()
>>>              win = self.ren.GetRenderWindow()
>>>              self.view.SetupRenderWindow(win)
>>>
>>>        Now if I just take out the view.SetupRenderWindow(win) call,
>>>        I get a separate RenderWindow popping up and the QVTK widget
>>>        is all black. I tried reordering the calls to something like
>>>        this:
>>>
>>>              self.view = vtk.vtkGraphLayoutView()
>>>              self.ren = self.view.GetRenderer()
>>>               
>>> self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
>>>              self.win = self.ui.vtkWidget.GetRenderWindow()
>>>
>>>        Then the graph shows up in BOTH the extra window and my QVTK
>>>        Widget.
>>>
>>>        I know I'm just ignorant about the correct method -- can
>>>        anybody help me set up a vtkGraphLayoutView in a QVTK Widget
>>>        properly?
>>>
>>>        Thanks a lot,
>>>        -Eric
>>>
>>>        ------------------------------------------------------
>>>        Eric E Monson
>>>        Duke Visualization Technology Group
>>>
>>>
>>>        _______________________________________________
>>>        Powered by www.kitware.com <http://www.kitware.com>
>>>
>>>        Visit other Kitware open-source projects at
>>>        http://www.kitware.com/opensource/opensource.html
>>>
>>>        Please keep messages on-topic and check the VTK FAQ at:
>>>        http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>>        Follow this link to subscribe/unsubscribe:
>>>        http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>>
>>>    _______________________________________________
>>>    Powered by www.kitware.com <http://www.kitware.com>
>>>
>>>    Visit other Kitware open-source projects at
>>>    http://www.kitware.com/opensource/opensource.html
>>>
>>>    Please keep messages on-topic and check the VTK FAQ at:
>>>    http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>>    Follow this link to subscribe/unsubscribe:
>>>    http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>>
>>>
>>> -- 
>>> Jeff Baumes, Ph.D.
>>> R&D Engineer, Kitware Inc.
>>> (518) 881-4932
>>> jeff.baumes at kitware.com <mailto:jeff.baumes at kitware.com>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>




More information about the vtkusers mailing list