[vtkusers] resetting vtkRenderer contents

Deacon Sweeney sweeney.2 at wright.edu
Thu Aug 7 13:00:51 EDT 2008


Hi all,

I would like my users to be able to load a visualization then unload it
and load new data. Currently, if a user loads a new file the old
visualization stays up, usually with missing data points, but the
coordinates are the same as the old data. I've tried a wide variety of
approaches and all either reload, or they crash the program (Finalize
and None for addRenderer). Here is my current minimalist approach
(doesn't work but doesn't crash), with some alternative approaches
commented out. This is all Python, using Enthought's Python distribution
with VTK 5.0.3.

        # manually remove any actors previously created
        #actors = self.renderer.GetActors()
        #actors.InitTraversal()
        #last = actors.GetLastActor()
        #actor = actors.GetNextActor()
        #while actor != last:
        #    self.renderer.RemoveActor(actor)
        #    actor = actors.GetNextActor()
        #self.renderer.RemoveActor(last)

        # instead just removeallviewprops. 
        #does this do the same thing as above?
        self.renderer.RemoveAllViewProps()

        # try removing the renderer and re-make it with:
        #self.screen.GetRenderWindow().RemoveRenderer(self.renderer)

        #  a new renderer,
        #del self.renderer
        #self.renderer = vtk.vtkRenderer()
        #self.screen.GetRenderWindow().AddRenderer(self.renderer)

        # or with no renderer
        #self.screen.GetRenderWindow().AddRenderer(None)
        
        # try the Finalize method even though it is virtual in
vtkRenderWindow
        #self.screen.GetRenderWindow().Finalize()

        # try Clear()?
        #self.renderer.Clear()

        # remake if needed
        #self.renderer = vtk.vtkRenderer()
        #self.screen.GetRenderWindow().AddRenderer(self.renderer)

        self.visitor.load_system(system, 0)   # creates new Actors for
renderer
        self.renderer.ResetCamera()
        self.screen.Render()

And nothing works. 

I'm surprised that I can't find anything on this apparent bug online
(aside for the RemoveAllViewProps suggestion which doesn't work), and I
hope its just a simple omission on my part and not a real bug. Thanks.

Deacon



More information about the vtkusers mailing list