[vtkusers] Problems with vtkPanel (Java) under Windows

Christopher Auer christopher.auer at web.de
Tue Mar 29 08:19:09 EST 2005


Hi Jeff,

thanks for your fast response! You led me to the solution and saved my
day :-)

SWT forks two threads: The UI thread (responsible for drawing the UI
etc.) and the obligatory event thread. I made my calls to the VTK class
in the SWT-event thread. The vtkPanel runs in the AWT thread which seems
to be embedded in the SWT UI thread (afaik AWT and Swing only have one
thread - no separate threads for UI and event dispatching, but I am not
sure right now). The solution (code snippet):

SwingUtilities.invokeLater( new RunnableClass( ) )

The "RunnableClass" implements the run-method and this method executes
the call to the vtkPanel. That did the trick! I wrapped the AddActor-,
RemoveActor- and Render-methods.

So I implemented my my vtk panel which inherits from vtkPanel and
wrapped the calls in small runnable classes which execute the real
calls.

Thanks again!


Christopher

On Tue, 2005-03-29 at 06:50 -0500, Jeff Lee wrote:
> 
> Christopher Auer wrote:
> 
> >Hello!
> >
> >We are currently doing our thesis about an application using VTK under
> >Java. We are usually displaying more than one vtkPanel on a Frame (but
> >the problem I am going to describe here also raises its head with only
> >one vtkPanel in use). For our GUI we are using the SWT
> >(http://www.eclipse.org) which is a Java library with bindings to the
> >native GUI library (via a DLL/.so for MFC/GTK+/Motif etc.). Under SWT
> >there is a SWT-AWT bridge to display AWT/Swing components under SWT -
> >this usually works very fine and seems not to be the root of the problem
> >(the problem does also occur with pure AWT application). We are using
> >Java 1.5.
> >
> >But to shorten the story, here is my problem: When I start up the
> >application everything is working fine. All the vtkPanels behave the way
> >they should do (rotating and other user interactions work). I am
> >currently just displaying the surface of the objects - so nothing
> >special. In my application the user is able to change the displayed
> >object (e.g. Sphere -> Plane). So what I do is to remove the old actor
> >(e.g. Sphere) from the scene and then add the new actor (e.g. Plane).
> >But after that the vtkPanel does not react anymore. Instead the
> >vtkOutputWindow raises, with always the same error message:
> >
> >ERROR: In C:\VTK\Rendering\vtkWin32OpenGLRenderWindow.cxx ...
> >...wglMakeCurrent... 
> >
> >The rest of the error message is hidden and I cannot resize the
> >vtkOutputWindow. But I know that the error message has something to do
> >we already used resources or something like that.
> >
> >To me it seems that there are several concurrent accesses to the
> >vtkPanel object, but I am running out of ideas (and time!).
> >  
> >
> Hi Christopher,
> If you haven't already done this, make sure that the thread doing the 
> add/remove is the event thread.  Can you post your awt example which 
> exhibits the problem?
> -Jeff
> 
> >What I've tried so far:
> >
> >* created my own vtkPanel which derives from vtkPanel provides its own
> >removeActor/addActor-method with Lock()/UnLock()-calls wrapped around
> >the actual Remove/AddActor-calls (I tried also to use Lock/UnLock only
> >for the RemoveActor-method)
> >* I tried VTK4.2 and VTK4.4-latest-release (both with exactly the same
> >result)
> >* Created pure AWT-Frames
> >
> >The only (impure) solution is to set the actors invisible instead of
> >removing them. But the errors also occurs after calling
> >vtkPanel.Render() to update the display after a change.
> >
> >The searched the vtk mailinglists and the internet and tried the
> >solutions (see above). So my last hope is this mailinglist.
> >
> >Has anyone an idea how to solve the problem?
> >
> >Thanks in advance!
> >
> >
> >
> >Christopher Auer
> >  
> >
-- 
Christopher Auer <christopher.auer at web.de>




More information about the vtkusers mailing list