[vtkusers] Getting Java threads and VTK to work: how to avoid the event-handling thread?
Greg Scott
g.scott at oneteldsl.net
Thu Jul 17 17:55:51 EDT 2003
Hi, I've found some 'interesting' behaviour involving Java and C++ VTK usage.
My program performs the following steps:
1. In Java, create a vtkPanel with a particular actor (a cube, say), then,
2. When the user clicks on a Swing button,
3. The renderer and renderwindow belonging to the vtkPanel are passed to some native C++ code, which
4. Does some C++ VTK processing involving the renderer and window which would take too long in Java,
and using GetPixelData etc.
Now, the program works fine if the code required for 3 and 4 occurs in the event-handling thread for 2., that is:
JButton jMyButton = ....
jMyButton.addActionListener(new ActionListener() {
public void actionPerformed(...) {
// Code for 3. here, which calls the C++ code to do step 4.
}});
HOWEVER, the big disadvantage in this is that the whole GUI locks up since the processor-intensive C++ code executes in the event-handling code, so the GUI is not redrawn; in effect it freezes until stage 4. returns. It would be better to spawn a new thread to do 3 (and 4).
But, when start a new thread to execute 3 and 4 (i.e. a SwingWorker), I get lots of C++-side errors in a pop-up window.
Please, does anyone know (a) why this is, and (b) how to get around it?
Many thanks for any suggestions.
Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030717/c0708ce9/attachment.htm>
More information about the vtkusers
mailing list