[vtkusers] vtk and Java : problem when remove a vtkactor to avtkrenderer or add avtkrenderer to a vtkrenderwindow
Romain Ollivier
Romain.Ollivier at sophia.inria.fr
Wed Jul 9 08:20:39 EDT 2003
For my viewer, I use the class myVtkPanel wich extends vtkPanel with :
public void removeActor(vtkProp actor)
{
Lock();
ren.RemoveActor(actor);
UnLock();
}
public void addActor(vtkProp actor)
{
Lock();
ren.AddActor(actor);
UnLock();
}
Then, I have a myVtkJPanel class, wich extends a JPanel, containing this :
........
private myVtkPanel view;
........
public void addActor(vtkProp actor)
{
view.addActor(actor);
}
public void removeActor(vtkProp actor)
{
view.removeActor(actor);
}
My viewer use an instance of this JPanel. When I call the addActor() function in my viewer
constructor, I get this :
Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner
at vtk.vtkPanel.UnLock(Native Method)
at myVtkPanel.addActor(myVtkPanel.java:33)
at myVtkJPanel.addActor(myVtkJPanel.java:82)
at myViewer.makeDataPanel(myViewer.java:86)
at myViewer.<init>(myViewer.java:62)
at myViewer.main(myViewer.java:190)
Do you know what I'm doing wrong when I use Lock() an UnLock() ?
Thank you for your help,
Romain
Jeff Lee wrote:
> Hi,
> i think your solution with multiple renderers is not necessary, but I do
> something like
>
> public void removeActor(vtkActor actor)
> {
> Lock();
> ren.RemoveActor(actor);
> UnLock();
> }
>
> inside vtkPanel. I could add this functionality to vtkPanel, since
> adding/removing of actors is a common thing, but you could try it by
> sublcassing vtkPanel and adding the above. This is not a graphics card
> problem.
> -Jeff
>
> Romain Ollivier wrote:
>
> > Thank you for your reply.
> > I've tried to replace my code with your's but I still get :
> > Xlib: unexpected async reply (sequence 0x5a1)!
> >Has anyone any idea about the way to solve this problem ? I think this is a
> >graphic card problem, but I'm not sure... I work with a VGA compatible
> >controler : nVidia Corporation NV25 [GeForce4 Ti4600]...
> >
> > Thanks for any help,
> >
> > Romain
> >
> >
> >R K Shyamprakash wrote:
> >
> >
> >
> >>public void removeActor(vtkActor actor)
> >> {
> >> ren.RemoveActor(actor);
> >> }
> >>
> >>This should work fine as it works for me. make sure reference to the
> >>argument actor has not changed and its actually the part of the renderer.
> >>also you can put check to see if the argument actor is null like
> >>
> >>public void removeActor(vtkActor actor)
> >> {
> >> if(actor != null)
> >> ren.RemoveActor(actor);
> >> }
> >>
> >>one more method will be
> >>
> >>public void removeActor(vtkActor actor)
> >> {
> >> vtkActorCollection col = ren.GetActors();
> >> col.InitTraversal();
> >> int count = col.GetNumberOfItems();
> >> for(int i=0;i<count;i++){
> >> if(col.GetNextActor()==actor){
> >> ren.RemoveActor(actor);
> >> return;
> >> }
> >> }
> >> }
> >>make sure you call Render() to see the changes
> >>
> >>
> >
> >_______________________________________________
> >This is the private VTK discussion list.
> >Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> >Follow this link to subscribe/unsubscribe:
> >http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
> >
> >
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list