[vtkusers] Adding mouse wheel support to Java GUI components
E KN
egk865 at gmail.com
Thu May 29 23:03:26 EDT 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140529/f023ecec/attachment.html>
More information about the vtkusers
mailing list