[vtkusers] more on GtkGLExtVTKRenderWindowInteractor

Jed Haile jed at philtered.net
Fri Oct 17 15:39:13 EDT 2003


Hi,

I'm still working on the rendering problem with 
GtkGLExtVTKRenderWindowInteractor.py on Mac OSX. I have found that if I 
comment out:
self._RenderWindow.SetWindowInfo(win_id)

This forces the rendering to happen in its own window, and everything 
is correct. Otherwise, as I described previously, objects appear to be 
rendered inside out, and do not change size when the model is rotated, 
and there are other problems with perspective. It seems the problem is 
somehow related to the window being embedded in gtk. Any ideas why?

Thanks,
Jed


> Hi,
>
> I have been using GtkGLExtVTKRenderWindowInteractor to embed a vtk 
> window into a pygtk application. I am using a recent build of VTK 
> built for X11 (apple's X11) on Mac OS X 10.2.6 with python 2.2 and 
> pygtk 2.0. When I render a nondirected graph using an ordinary 
> vtkRenderWindow (not embedded in gtk) the graph renders fine. When I 
> switch to GtkGLExtVTKRenderWindowInteractor, all the nodes of the 
> graph appear to be rendered inside out. Also there is a perspective 
> problem as you rotate the graph the nodes that were in back continue 
> to be rendered behind the nodes that were in the front, and the nodes 
> never appear to resize correctly for perspective, but always remain 
> the same size, the vertices are also rendered behind or in front of 
> nodes incorrectly.
>
> The python code below replicates this behavior, and oddly enough works 
> fine on linux and windows.
>
> Any ideas of what might be going wrong here?
>
> Thanks in advance,
> Jed
>
>
> #!/usr/bin/python
>
> from random import Random
> import sys
> import vtk
> from vtk.util.colors import *
> from GtkGLExtVTKRenderWindowInteractor import 
> GtkGLExtVTKRenderWindowInteractor
> import gtk
>
> def makegraph() :
> 	r = Random()
> 	space = 8
>
> 	max = 0
> 	lines = vtk.vtkCellArray()
> 	for n1,n2 in [(0,1), (0,2), (1,2), (2,3), (3,4), (3,5)] :
> 		lines.InsertNextCell(2)
> 		lines.InsertCellPoint(n1)
> 		lines.InsertCellPoint(n2)
> 		if n1 > max : max = n1
> 		if n2 > max : max = n2
>
> 	pts = vtk.vtkPoints()
> 	pts.SetNumberOfPoints(max + 1)
> 	for idx in range(max + 1) :
> 		x = r.uniform(-space,space)
> 		y = r.uniform(-space,space)
> 		z = r.uniform(-space,space)
> 		pts.SetPoint(idx, x, y, z)
>
> 	pd = vtk.vtkPolyData()
> 	pd.SetPoints(pts)
> 	pd.SetLines(lines)
> 	return pd
>
> def setprops(prop, color) :
> 	prop.SetColor(color)
> 	prop.SetSpecularColor(1,1,1)
> 	prop.SetSpecular(0.3)
> 	prop.SetSpecularPower(20)
> 	prop.SetAmbient(0.2)
> 	prop.SetDiffuse(0.8)
>
> def mapactor(pd, color) :
> 	map = vtk.vtkPolyDataMapper()
> 	act = vtk.vtkActor()
> 	map.SetInput(pd.GetOutput())
> 	act.SetMapper(map)
> 	setprops(act.GetProperty(), color)
> 	return act
>
> def main() :
> 	pd = makegraph()
>
> 	lay3d = vtk.vtkGraphLayoutFilter()
> 	lay3d.SetInput(pd)
> 	lay3d.SetMaxNumberOfIterations(100)
> 	lay3d.ThreeDimensionalLayoutOn()
> 	lay3d.AutomaticBoundsComputationOn()
>
> 	edges = vtk.vtkTubeFilter()
> 	edges.SetInput(lay3d.GetOutput())
> 	edges.SetRadius(.2)
> 	edges.SetNumberOfSides(6)
> 	edgeActor = mapactor(edges, hot_pink)
>
> 	node = vtk.vtkCubeSource()
> 	node.SetXLength(1)
> 	node.SetYLength(1)
> 	node.SetZLength(1)
> 	nodes = vtk.vtkGlyph3D()
> 	nodes.SetInput(lay3d.GetOutput())
> 	nodes.SetSource(node.GetOutput())
> 	nodeActor = mapactor(nodes, peacock)
> 	
> 	window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> 	window.set_title("Test")
> 	window.connect("destroy", gtk.mainquit)
> 	window.connect("delete_event", gtk.mainquit)
> 	window.set_border_width(10)
> 	vbox = gtk.VBox(spacing=3)
> 	window.add(vbox)
> 	vbox.show()
>
> 	gvtk = GtkGLExtVTKRenderWindowInteractor()
> 	gvtk.set_size_request(400, 400)
> 	vbox.pack_start(gvtk)
> 	gvtk.show()
> 	gvtk.Initialize()
> 	gvtk.Start()
>
> 	renderer = vtk.vtkRenderer()
> 	renWin = gvtk.GetRenderWindow()
> 	renWin.AddRenderer(renderer)
> 	renderer.AddActor(edgeActor)
> 	renderer.AddActor(nodeActor)
>
> 	window.show()
> 	gtk.mainloop()
>
> if __name__ == "__main__" :
> 	main()
>




More information about the vtkusers mailing list