[vtkusers] Adding mouse wheel support to Java GUI components

Sebastien Jourdain sebastien.jourdain at kitware.com
Fri May 30 15:06:54 EDT 2014


Hi Eli,

Sure that would make sense. Please push your patch using gerrit and add me
as a reviewer.

http://www.kitware.com/source/home/post/62

Thanks,

Seb


On Thu, May 29, 2014 at 9:03 PM, E KN <egk865 at gmail.com> wrote:

> Hi Seb,
>
> Thank you so much for all your work on the Java wrappers. I was wondering
> if there is interest in adding mouse wheel support to the Java GUI
> components. I was able to add mouse wheel support by making the
> vtkInteractorForwarder class implement the MouseWheelListener interface and
> adding the following function:
>
>     @Override
>     public void mouseWheelMoved(MouseWheelEvent e) {
>         if (component == null || component.getRenderer() == null) {
>             return;
>         }
>
>         // Allow user to override some behavior
>         if (this.eventInterceptor != null &&
> this.eventInterceptor.mouseWheelMoved(e)) {
>             return;
>         }
>
>         try {
>             component.getVTKLock().lockInterruptibly();
>
> component.getRenderWindow().SetDesiredUpdateRate(this.updateRateRelease);
>             lastX = e.getX();
>             lastY = e.getY();
>             ctrlPressed = (e.getModifiers() & InputEvent.CTRL_MASK) ==
> InputEvent.CTRL_MASK ? 1 : 0;
>             shiftPressed = (e.getModifiers() & InputEvent.SHIFT_MASK) ==
> InputEvent.SHIFT_MASK ? 1 : 0;
>
> component.getRenderWindowInteractor().SetEventInformationFlipY(lastX,
> lastY, ctrlPressed, shiftPressed, '0', 0, "0");
>             if (e.getWheelRotation() > 0)
>
> component.getRenderWindowInteractor().MouseWheelBackwardEvent();
>             else
>
> component.getRenderWindowInteractor().MouseWheelForwardEvent();
>         }
>         catch (InterruptedException interupt) {
>             // Nothing to do
>         }
>         finally {
>             component.getVTKLock().unlock();
>         }
>     }
>
> A few other minor changes are needed as well in a few other Java files.
> Would this be of interest?
>
> Thanks,
> Eli
>
> _______________________________________________
> 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/20140530/67e8618f/attachment.html>


More information about the vtkusers mailing list