[vtkusers] [QVTKRenderWindowInteractor.py] GL_MULTISAMPLE disabled by default?

Clinton Stimpson clinton at elemtech.com
Tue Nov 18 13:51:11 EST 2008


Is is possible the working vs. non working antialiasing related to 
whether vtkXOpenGLRenderWindow::GetDesiredVisual() was used when 
creating the Window?  The VTK/Tk code and QVTKWidget code use the Visual 
from vtkXOpenGLRenderWindow.  It appears the others don't.

Clint

Maik Beckmann wrote:
> Hello Again,
>
> The reason for my previous mail
>  - http://www.vtk.org/pipermail/vtkusers/2008-November/098400.html
> was my struggle to understand how vtk uses opengl to solve the following 
> problem:
> Using PyQt4 with QVTKRenderWindowInteractor.py (part of vtk) gives me no anti-
> aliasing.
>
> The attached python script draws the same scene as the C++ source at the email 
> mentioned above.  At the very top one can choose the GUI toolkit to use:
> {{{
> GUI='qt' # no antialiasing
> #GUI='vtk' # antialiasing
> #GUI='tk' # antialiasing
> #GUI='wx' # no antialiasing (wx is presented just for completeness)
> }}}
> As the comments state only native vtk and tk interactors give anti-aliasing.
>
> Francois pointed me to MultiSamples and my impression is, that 
> glEnable(GL_MULTISAMPLE) wasn't called in case of PyQt4 and wx (Qt4-C++ with 
> QVTKWidget works fine, btw.) .
>
> I will investigate further, but I'm thankful for any hints.
>
> Thanks,
>  -- Maik
>
>   
> ------------------------------------------------------------------------
>
> GUI='qt' # no antialiasing
> #GUI='vtk' # antialiasing
> #GUI='tk' # antialiasing
> #GUI='wx' # no antialiasing (wx is presented just for completeness)
>
> import sys
> import vtk
> if(GUI == 'qt'):
>     from PyQt4 import QtGui
>     import vtk.qt4.QVTKRenderWindowInteractor as QVTKRenderWindowInteractor
> elif(GUI == 'tk'):
>     import vtk.tk.vtkTkRenderWindowInteractor as vtkTkRenderWindowInteractor
>     import Tkinter
>     Tkinter.wantobjects = 0 
> elif(GUI == 'wx'):
>     import wx
>     import vtk.wx.wxVTKRenderWindowInteractor as wxVTKRenderWindowInteractor
>
>
>
> points = vtk.vtkPoints()
> triangleCells = vtk.vtkCellArray()
> lineCells = vtk.vtkCellArray()
>
> points.InsertNextPoint(0, 0.5, 0) # 0
> points.InsertNextPoint(1, 1.5, 0) # 1
>
> points.InsertNextPoint(0,0,0) # 2
> points.InsertNextPoint(1,0,0) # 3
> points.InsertNextPoint(1,1,0) # 4
>
> # Line
> ids = vtk.vtkIdList()
> for i in (0,1):
>     ids.InsertNextId(i)
> lineCells.InsertNextCell(ids)
>
> linePolyData = vtk.vtkPolyData()
> linePolyData.SetPoints(points);
> linePolyData.SetLines(lineCells)
> linePolyData.BuildCells()
>
> lineMapper = vtk.vtkPolyDataMapper()
> lineMapper.SetInput(linePolyData)
>
> lineActor = vtk.vtkActor()
> lineActor.SetMapper(lineMapper)
>
> # Triangle
> ids = vtk.vtkIdList()
> for i in (2,3,4):
>     ids.InsertNextId(i)
> triangleCells.InsertNextCell(ids)
>
> trianglePolyData = vtk.vtkPolyData()
> trianglePolyData.SetPoints(points);
> trianglePolyData.SetPolys(triangleCells)
> trianglePolyData.BuildCells()
>
> triangleMapper = vtk.vtkPolyDataMapper()
> triangleMapper.SetInput(trianglePolyData)
>
> triangleActor = vtk.vtkActor()
> triangleActor.SetMapper(triangleMapper)
>
>
> ren1 = vtk.vtkRenderer() 
> ren1.AddActor(lineActor)
> ren1.AddActor(triangleActor)
> ren1.AddActor(vtk.vtkAxesActor() )  
> ren1.SetBackground( 0.1, 0.2, 0.4 )
>
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren1)
>
>
>
> # GUI
> if(GUI == 'qt'):
>     app = QtGui.QApplication(sys.argv)
>     widget = QVTKRenderWindowInteractor.QVTKRenderWindowInteractor(rw = renWin)
>     widget._Iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera());
>     widget.show()
>     sys.exit(app.exec_())
> elif(GUI == 'vtk'):
>     iren = vtk.vtkRenderWindowInteractor()
>     iren.SetRenderWindow(renWin);
>     iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera());
>     iren.Initialize();
>     iren.Start();
> elif(GUI == 'tk'):
>     root = Tkinter.Tk()
>     widget = vtkTkRenderWindowInteractor.vtkTkRenderWindowInteractor(root, width=300, height=300, rw=renWin)
>     widget.Initialize()
>     widget._Iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
>     
>     def quit(obj=root):
>         obj.quit()
>     widget.AddObserver("ExitEvent", lambda o,e,q=quit: q())
>     
>     widget.pack(fill='both', expand=1)
>     widget.Start()
>     root.mainloop()
> elif(GUI == 'wx'):
>     app = wx.PySimpleApp()
>     
>     frame = wx.Frame(None, -1, "Test", size=(400,400))
>     
>     widget = wxVTKRenderWindowInteractor.wxVTKRenderWindowInteractor(frame,-1)
>     sizer = wx.BoxSizer(wx.VERTICAL)
>     sizer.Add(widget, 1, wx.EXPAND)
>     frame.SetSizer(sizer)
>     frame.Layout()
>
>     widget.Enable(1)
>     widget.AddObserver("ExitEvent", lambda o,e,f=frame: f.Close())
>     widget._Iren.SetRenderWindow(renWin)
>     widget._Iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
>     
>     frame.Show()
>     app.MainLoop()
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the 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