[vtkusers] AWT + SWT + Event Loops (was Re: VTK6 and Java Cone Example 5)
Sebastien Jourdain
sebastien.jourdain at kitware.com
Wed Aug 14 10:52:39 EDT 2013
You need to build VTK with the SWT component ON. Moreover,
vtkRenderWIndowInteractor
does not spawn a new event loop as VTK is NOT thread safe.
On Wed, Aug 14, 2013 at 10:31 AM, rkwright <rkwright at geofx.com> wrote:
> I have been working through the samples in the jar. The only failure so
> far is the vtkRenderWindowInteractor.
>
> I was not aware of a SWT component in VTK. I see a Java file
> vtkSwtComponent.java but it isn't clear to me that it is going to solve my
> problems. There are two issues I see:
>
> - vtkSwtComponent appears to use the SWT OpenGL canvas widget. This
> is largely unsupported in SWT and was half-broken last time I looked at it.
> I gave up on it long ago and turned to JOGL embedding in SWT via the
> bridge (which works for me at present)
> - It's not clear how this would solve the other issue
> where vtkRenderWIndowInteractor spawns its own event loop and that causes
> problems with SWT – or does vtkRenderWIndowInteractor not use any AWT
> utilities or methods?
>
> I'll experiment with the vtkSwtComponent (I see one simple example file,
> swtConeRendering.java) and see if that helps. Though there is no SWT
> support in vtk.jar so I'll guess I'll have to include the SWT files
> directly in my project.
>
> Thanks for your advice.
>
> Ric
>
> BTW, I am running Apple's Java 1.6.0_51-b11-457-11M4509. 64 bit
>
> From: "Sebastien Jourdain-2 [via VTK]" <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722724&i=0>
> >
> Date: Wednesday, August 14, 2013 8:42 AM
> To: Ric Wright <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722724&i=1>
> >
> Subject: Re: AWT + SWT + Event Loops (was Re: VTK6 and Java Cone Example
> 5)
>
> Just read the sample codes that are provided in the vtk.jar or in the
> Source code under Wrapping/Java/vtk/sample, they should be pretty strait
> forward.
> Moreover, VTK do provide a SWT component for rendering if you build it, so
> you shouldn't have any event loop issue...
>
> Seb
>
>
> On Wed, Aug 14, 2013 at 9:30 AM, Ric Wright <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=0>
> > wrote:
>
>> So did some more spelunking and it looks like this is just a basic
>> incompatibility for SWT and AWT – in the specific case where AWT is trying
>> to start their own event loop once SWT has started. Previously, in my
>> other work, I handled events on my own – I didn't ask or expect AWT to
>> start or manage it's own events. I used AWT basically to host the OpenGL
>> canvas (based on JOGL). But when one invokes the vtkRenderWIndowInteractor
>> an event loop IS spawned and the causes various weird problems.
>>
>> There is a fairly long summary of some of the issues here:
>>
>> http://marc.info/?l=openjdk-awt-dev&m=135818602009136&w=2
>>
>> So the question that comes to my mind is how dependent is the rest of VTK
>> on starting its own event loops? I.e. Can I use the rest of VTK and its
>> pipeline to perform graphics, manage datasets, etc. I am willing to give
>> up the Interactor and its mimicking of trackball if everything else is
>> likely to work. But if spawning its own event loop(s) is intrinsic to how
>> most of VTK works then I'm probably dead in the water.
>>
>> Thoughts or suggestions?
>>
>> Thanks
>> Ric
>>
>>
>> From: Ric Wright <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=1>
>> >
>>
>> Date: Tuesday, August 13, 2013 12:59 PM
>> To: Sebastien Jourdain <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=2>
>> >
>> Cc: Sean McBride <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=3>>,
>> vtkusers <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=4>
>> >
>>
>> Subject: Re: [vtkusers] VTK6 and Java Cone Example 5
>>
>> An update on this. I ported over some of my other Eclipse work and
>> adapted it to VTK. It is pushed to my account on github and there is a
>> writeup here: http://rkwright.github.io/geofx-pages/vtkview.html.
>> There are 3 articles in there. The latest rev of the code is here:
>> https://github.com/rkwright/vtkscene in the develop branch.
>>
>> Mostly, it works great. However, when I tried the fifth cone example,
>> which has the problematic vtkRenderWindowInteractor, I ran into similar
>> problems as before. I instantiated it with a valid vtkPanel.RenderWindow
>> but it still goes off into the ozone, sometimes crashing the native
>> vtkOpenGL dylib.
>>
>> I'm going to skip the interactor for now and move on to see if I run into
>> more problems. If not, I can probably live without that widget but the
>> problems there might be symptomatic of deeper problems on OSX 64 bit
>> systems.
>>
>> Any further suggestions would be welcome.
>>
>> Thanks
>> Ric
>>
>>
>> From: Sebastien Jourdain <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=5>
>> >
>>
>> Date: Tuesday, August 6, 2013 8:56 AM
>> To: Ric Wright <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=6>
>> >
>> Cc: Sean McBride <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=7>>,
>> vtkusers <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=8>
>> >
>>
>> Subject: Re: [vtkusers] VTK6 and Java Cone Example 5
>>
>> In Java you should use the Java specific classes anyway like
>> vtkPanel/vtkCanvas or the new version of them used in the vtk.sample
>> package of the vtk.jar...
>>
>> The purpose of those example was to show the possible match between the
>> different languages...
>>
>> Nothing more I believe,
>>
>> Seb
>>
>>
>> On Tue, Aug 6, 2013 at 8:52 AM, Ric Wright <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=9>
>> > wrote:
>>
>>> Ah, OK. Well, I don't know what to do here. Is this happening to
>>> others?
>>> Should I file a bug? Just try to work around it by not using
>>> RenderWindowInteractors (sounds kind of lame). Or?
>>>
>>> Suggestions?
>>>
>>> Thanks
>>> Ric
>>>
>>>
>>> On 8/5/13 4:15 PM, "Sean McBride" <[hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=10>>
>>> wrote:
>>>
>>> >On Mon, 5 Aug 2013 16:10:55 -0500, Ric Wright said:
>>> >
>>> >>Well, a little playing around didn't seem to help, but I am frankly not
>>> >>an
>>> >>expert on threads. However, it seems to me that the source of the
>>> >>problem
>>> >>is that the vtkRenderWindowInteractor gets initialized then the start()
>>> >>method creates an event loop that is monitored by the
>>> >>vtkRenderWindowInteractor. I suspect that start() method spawns a new
>>> >>thread to listen to the events and it is the spawning of that thread
>>> that
>>> >>causes the exception.
>>> >
>>> >VTK's Cocoa classes never create any threads.
>>> >
>>> >Cheers,
>>> >
>>> >--
>>> >____________________________________________________________
>>> >Sean McBride, B. Eng [hidden email]<http://user/SendEmail.jtp?type=node&node=5722710&i=11>
>>>
>>> >Rogue Research www.rogue-research.com
>>> >Mac Software Developer Montréal, Québec, Canada
>>> >
>>> >
>>>
>>>
>>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://vtk.1045678.n5.nabble.com/VTK6-and-Java-Examples-tp5722474p5722710.html
> To unsubscribe from VTK6 and Java Examples, click here.
> NAML<http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> ------------------------------
> View this message in context: Re: AWT + SWT + Event Loops (was Re: VTK6
> and Java Cone Example 5)<http://vtk.1045678.n5.nabble.com/VTK6-and-Java-Examples-tp5722474p5722724.html>
> Sent from the VTK - Users mailing list archive<http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html>at Nabble.com.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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/20130814/32967b1a/attachment.htm>
More information about the vtkusers
mailing list