caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3));
caps.setDoubleBuffered(true);
caps.setHardwareAccelerated(true);
- caps.setSampleBuffers(false);
- caps.setNumSamples(4);
+ caps.setSampleBuffers(true);
+ caps.setRedBits(8);
+ caps.setGreenBits(8);
+ caps.setBlueBits(8);
caps.setAlphaBits(8);
+ caps.setDepthBits(24);
+ caps.setStencilBits(8);
+
+// caps.setAccumRedBits(8);
+// caps.setAccumGreenBits(8);
+// caps.setAccumBlueBits(8);
+// caps.setAccumAlphaBits(8);
+//
+// caps.setBitmap(true);
+// caps.setOnscreen(true);
+
+
+ //caps.setPBuffer(true);
+ //caps.setFBO(true);
+ caps.setNumSamples(4);
+
+
return caps;
}
this.removeListener(SWT.Close, this);
this.removeListener(SWT.Dispose, this);
this.removeListener(SWT.Resize, this);
+
+ if (parent != null) {
+ parent.getRenderer().DrawOff();
+ parent.Delete();
+ vtkObject.JAVA_OBJECT_MANAGER.gc(false);
+ parent = null;
+ }
- if (getContext().isCurrent()) {
+ if (getContext() != null && getContext().isCurrent()) {
getContext().release();
}
+
super.dispose();
}
vtkObject.JAVA_OBJECT_MANAGER.gc(false);
break;
case SWT.Close:
- // System.out.println("closing");
break;
case SWT.Resize:
parent.setSize(getClientArea().width, getClientArea().height);
this.forwarder = forwarder;
}
- public static int convertModifiers(int mods) {
+ public static int convertModifiers(int button , int mods) {
int modifiers = 0;
if ((mods & SWT.SHIFT) != 0) modifiers |= java.awt.Event.SHIFT_MASK;
if ((mods & SWT.CTRL) != 0) modifiers |= java.awt.Event.CTRL_MASK;
if ((mods & SWT.ALT) != 0) modifiers |= java.awt.Event.ALT_MASK;
+ if ((mods & SWT.BUTTON1) != 0 || button == 1) modifiers |= java.awt.event.InputEvent.BUTTON1_MASK;
+ if ((mods & SWT.BUTTON2) != 0 || button == 2) modifiers |= java.awt.event.InputEvent.BUTTON2_MASK;
+ if ((mods & SWT.BUTTON3) != 0 || button == 3) modifiers |= java.awt.event.InputEvent.BUTTON3_MASK;
return modifiers;
}
public java.awt.event.KeyEvent convertKeyEvent(org.eclipse.swt.events.KeyEvent e) {
- return new java.awt.event.KeyEvent(dummyComponent, 0, (long)e.time, convertModifiers(e.stateMask), e.keyCode, e.character);
+ return new java.awt.event.KeyEvent(dummyComponent, 0, (long)e.time, convertModifiers(0, e.stateMask), convertKeyCode(e.keyCode), e.character);
}
public java.awt.event.MouseEvent convertMouseEvent(org.eclipse.swt.events.MouseEvent e) {
if ((e.button == 1) || (e.stateMask & SWT.BUTTON1) != 0) button = java.awt.event.MouseEvent.BUTTON1;
else if ((e.button == 2) || (e.stateMask & SWT.BUTTON2) != 0) button = java.awt.event.MouseEvent.BUTTON2;
else if ((e.button == 3) || (e.stateMask & SWT.BUTTON3) != 0) button = java.awt.event.MouseEvent.BUTTON3;
- return new java.awt.event.MouseEvent(dummyComponent, 0, (long)e.time, convertModifiers(e.stateMask), e.x, e.y, e.count, false, button);
+ return new java.awt.event.MouseEvent(dummyComponent, 0, (long)e.time, convertModifiers(e.button,e.stateMask), e.x, e.y, e.count, false, button);
+ }
+
+ public int convertKeyCode(int swtKeyCode) {
+ if (swtKeyCode >= 'a' && swtKeyCode <= 'z') {
+ return Character.toUpperCase(swtKeyCode);
+ }
+ return swtKeyCode;
}
public java.awt.event.MouseWheelEvent convertMouseWheelEvent(org.eclipse.swt.events.MouseEvent e) {
- return new java.awt.event.MouseWheelEvent(dummyComponent, 0, e.time, convertModifiers(e.stateMask), e.x, e.y, 0, false, java.awt.event.MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, e.count);
+ return new java.awt.event.MouseWheelEvent(dummyComponent, 0, e.time, convertModifiers(e.button,e.stateMask), e.x, e.y, 0, false, java.awt.event.MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, e.count);
}
public void keyPressed(KeyEvent e) {
}
}
+ int x = 0;
+ int y = 0;
+ int d = 4;
+
public void mouseDown(MouseEvent e) {
super.mousePressed(convertMouseEvent(e));
+ x = e.x;
+ y = e.y;
}
public void mouseUp(MouseEvent e) {
super.mouseReleased(convertMouseEvent(e));
+ // Emulate AWT mouse clicks
+ if (Math.abs(x-e.x) < d && Math.abs(y-e.y) < d)
+ super.mouseClicked(convertMouseEvent(e));
}
public void mouseScrolled(MouseEvent e) {
shiftPressed = (e.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK ? 1 : 0;
if (e.getWheelRotation() > 0) {
component.getRenderWindowInteractor().SetEventInformationFlipY(lastX, lastY, ctrlPressed, shiftPressed, '0', 0, "0");
- component.getRenderWindowInteractor().MouseWheelBackwardEvent();
+ component.getRenderWindowInteractor().MouseWheelForwardEvent();
}
else if (e.getWheelRotation() < 0) {
component.getRenderWindowInteractor().SetEventInformationFlipY(lastX, lastY, ctrlPressed, shiftPressed, '0', 0, "0");
- component.getRenderWindowInteractor().MouseWheelForwardEvent();
+ component.getRenderWindowInteractor().MouseWheelBackwardEvent();
}
} catch (InterruptedException interupt) {
// Nothing to do