[vtkusers] Vertex Labels with vtkGraphLayoutView

Don Pellegrino donpellegrino at live.com
Thu Mar 29 10:01:28 EDT 2012


I found that "renWin.AddRenderer(view.GetRenderer())" produces different behavior than "view.Render()" in the following cases:


-- Snippet 1: Unexpected behavior, vertices are not labeled --

// View
 vtkGraphLayoutView view = vtkGraphLayoutView.New();
 view.AddRepresentationFromInput(g);
 view.VertexLabelVisibilityOn();
 view.SetVertexLabelArrayName("label"); 
view.Update();

 // Render
 vtkRenderWindow renWin = vtkRenderWindow.New(); 
renWin.AddRenderer(view.GetRenderer());
 renWin.Render();

 // Interact
 vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();
 iren.SetRenderWindow(renWin);
 iren.Initialize();
 iren.Start();

 

-- Snippet 2: Expected behavior, vertices are labeled --

 

// View
vtkGraphLayoutView view = vtkGraphLayoutView.New();
view.AddRepresentationFromInput(g);
view.VertexLabelVisibilityOn();

view.SetVertexLabelArrayName("label");

 

// Housekeeping
view.Update();
view.ResetCamera();
view.Render();
view.GetInteractor().Start();

 

// Clean up memory.                       
g.Dispose();
label.Dispose();
view.GetInteractor().Dispose();
view.Dispose();

 

In Snippet 1, a vtkRenderWindow was created while in Snippet 2 a separate vtkRenderWindow was not created. In a third test, I created created a vtkRenderWindow similar to Snippet 1 and found that the following two lines appear to exhibit the difference in behavior:

 

renWin.AddRenderer(view.GetRenderer()); -- Same as Snippet 1, vertices are not labeled.


view.SetRenderWindow(renWin); -- Same as Snipper 2, vertices are labeled.

 

I had assumed that adding the vtkGraphLayoutView to the vtkRenderWindow would be equivalent to setting the the render window for the vtkGraphLayoutView to vtkRenderWindow. I suspect I have misunderstood something fundamental about the relationship between views and renderwindows. What is the nature of the difference between adding a view to a renderwindow versus setting the renderwindow for a view? 		 	   		  


More information about the vtkusers mailing list