[vtkusers] Issues with picking in VTK Java on Mac OS X

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Feb 1 19:58:27 EST 2017

Hi Kevin,

The issue seems to be related to the retina display and maybe macOS sierra.

Which version of VTK are you using? I know that I fixed some picking issue
on mac with retina display before Sierra.

The change I'm talking about is:

commit b6df993770cfcd9a69a48a2730415a992d698c5b
> Author: Sebastien Jourdain <sebastien.jourdain at kitware.com>
> Date:   Fri Jul 8 09:45:58 2016 -0400
>     Fix VTK/Java JOGL
>     - Update JOGL version to 2.32
>     - Update documentation on how to download the JOGL jars with Maven
>     - Add support for Retina display

Ideally, you should make sure you have this commit in your VTK and that is
working on system older than Sierra. Then if Sierra is the issue, I think
more advanced debugging may be require. Although, VTK compiled on an older
OS should work just fine on Sierra.

Let me know if you find out more about it.


On Wed, Feb 1, 2017 at 5:19 PM, Kevin Milner <kmilner at usc.edu> wrote:

> Hello. I develop a VTK Java application for visualizing georeferenced
> earthquake data, SCEC-VDO (http://scecvdo.usc.edu/). One of the important
> features of this software is the ability to click on elements of the 3D
> view to perform actions or view information. This works perfectly on
> Windows and Linux, but does not work on Macs. I believe that this is due to
> an internal bug in the Mac version of VTK. We use the vtkJoglPanelComponent
> to embed the 3D view into our Java application.
> Here is the code that I use to pick items (where renderWindow is a
> vtkJoglPanelComponent):
>         renderWindow.getComponent().addMouseListener(new MouseAdapter() {
>             public void mousePressed(MouseEvent e) {
>                 int[] clickPos = renderWindow.getRenderWindowIn
> teractor().GetEventPosition();
>                 int x = clickPos[0];
>                 int y = clickPos[1];
>                 cellPicker.Pick(x, y, 0, renderWindow.getRenderer());
>                 if (cellPicker.GetActor() != null) {
>                     // do stuff
>                     ...
>                 }
>             }
>         });
> The first bug is that the y value of getRenderWindowInteractor().GetEventPosition()
> is just flat out wrong on the Mac (correct on Windows and Linux). For
> example, if I click near the top of my window with height 700, if will give
> me a y value that is greater than 1300! It should actually be very small,
> as y should be zero at the top of the window and 700 at the bottom of the
> window. I can get around this, and make it match the position on
> Linux/Windows with the following fix using the mouseEvent (e) and the
> height of the 3D view component:
>                 int height = renderWindow.getComponent().getHeight();
>                 int calcY = (height - e.getY()) - 1;
>                 int x = e.getX();
>                 int y = calcY;
> Now when I click on a location in the 3D viewer, the x/y coordinates match
> the results on Linux/Windows. But picking actors still doesn't work.
> Instead, VTK thinks that I have clicked somewhere roughly between where I
> actually clicked and the bottom left corner. So if I click on the top right
> corner of the viewer, it thinks that I clicked in the middle. If I click on
> the top left, if thinks that I clicked middle left. If I click on the
> middle of the viewer, it thinks that I clicked 1/4 up and right of the
> lower left corner. I have posted a video which demonstrates this bug:
> http://sendvid.com/yqz1qww2
> In this video, whatever actor is clicked turns red. This works as expected
> on Windows/Linux, both with and without the x/y fix mentioned above.
> Without the previous fix on a Mac, the behavior is similar but centered
> around the top left corner and sometimes doesn't detect clicks at all (due
> to y values which make no sense).
> Any ideas what could be going on? I have experienced this behavior on all
> 4 Mac's on which I have tried the software.
> Thanks,
> Kevin Milner
> _______________________________________________
> Powered by www.kitware.com
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170201/797b6dbd/attachment.html>

More information about the vtkusers mailing list