[vtkusers] resetting vtkRenderer contents

David Cole david.cole at kitware.com
Thu Aug 7 13:25:36 EDT 2008


I use this code and it works for that sort of scenario:
  ren.RemoveAllViewProps()
  ren.ResetCamera()
  renWin.Render()

  # ...code to add all new actors to "ren" omitted...

  ren.ResetCamera()
  renWin.Render()


ren and renWin are the same all the way through... Are you sure that your
self.renderer, self.screen.GetRenderWindow() and self.screen objects are
remaining constant throughout this? Is there something else changing state
or swapping objects during your self.visitor.load_system() call?? Or is it
really just adding new actors to self.renderer??


HTH,
David


On Thu, Aug 7, 2008 at 1:00 PM, Deacon Sweeney <sweeney.2 at wright.edu> wrote:

> 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
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080807/77e462f7/attachment.htm>


More information about the vtkusers mailing list