[vtkusers] Getting Java threads and VTK to work: how to avoid the event-handling thread?

R K Shyamprakash ramakrishna.prakash at quest-global.com
Fri Jul 18 00:01:23 EDT 2003


Greg,
            Looks like you are doing GUI updates or calling Render() in the
construct() method of SwingWorker thread. This is a possible cause of
problem. save all this for finished() method of SwingWorker

    Let me know if  I am not clear
--Shyam

  -----Original Message-----
  From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org]On Behalf Of
Greg Scott
  Sent: Friday, July 18, 2003 3:26 AM
  To: vtkusers at vtk.org
  Subject: [vtkusers] Getting Java threads and VTK to work: how to avoid the
event-handling thread?


  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/20030718/0feb4368/attachment.htm>


More information about the vtkusers mailing list