[vtkusers] vtkActor2D not visible when added to vtkImageViewer on Windows

Johannes Rosander johannes.rosander at gmail.com
Fri Feb 8 08:18:00 EST 2013


I am using vtkImageViewer class to visualize different planes in a 3D
volume. Then I like to overlay a vertical and a horizontal line to mark the
current mouse position. I use the following code to add a vtkActor2D to the
viewer:
imageViewer = vtk.vtkImageViewer()
...
line = vtk.vtkLineSource()
line.SetResolution(20)
mapper = vtk.vtkPolyDataMapper2D()
mapper.SetInputConnection(line.GetOutputPort())
actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
imageViewer.GetRenderer().AddActor2D(actor)
...
line.SetPoint1(x,0.0,0.0) line.SetPoint2(x,y,0.0)
actor.GetProperty().SetColor(color)
actor.GetProperty().SetOpacity(0.75)
...
imageViewer.Render()


On Mac OS X it works as expected, but when I try on my Windows machine the
line does not show at all. If I change to vtkActor instead the actors are
rendered behind the imageViewer, how do I bring a vtkActor to the
foreground? (On Windows)
imageViewer = vtk.vtkImageViewer()
...
line = vtk.vtkLineSource()
line.SetResolution(20)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(line.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
imageViewer.GetRenderer().AddActor(actor)
...
line.SetPoint1(x,0.0,0.0)
line.SetPoint2(x,y,0.0)
actor.GetProperty().SetColor(color)
actor.GetProperty().SetOpacity(0.75)
...
imageViewer.Render()

// JR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130208/73e125eb/attachment.htm>


More information about the vtkusers mailing list