From: <ha...@us...> - 2009-11-30 03:40:47
|
Revision: 11816 http://jmol.svn.sourceforge.net/jmol/?rev=11816&view=rev Author: hansonr Date: 2009-11-30 03:40:39 +0000 (Mon, 30 Nov 2009) Log Message: ----------- version=11.9.10_dev # new feature: double-click-drag translates model # new feature: multitouch gesture antiparallel strokes: rotate at point # new feature: multitouch gesture spread/pinch: zoom in/out at point # new feature: app command parameter [-M or --multitouch] "sparshui" or "sparshui-simulated" # applet jmolSetCallback("multiTouchSparshUI", "true") # applet jmolSetCallback("multiTouchSparshUI-simulated", "true") # with those variables set, Jmol will load the multitouch package and start # an integrated SparshUI server (if none is already started). In addition, # with the -simulated flag, Jmol simulates multitouch using CTRL-LEFT drag (twice) # This incorporation of SparshUI also demonstrates the on-the-fly loading # of a client gesture into the SparshUI system using an extension of the # SparshUI protocol that allows delivery of a class name rather than a SparshUI # gesture ordinal. # # code: ActionManagerMT - for multitouch # code: preliminary org.jmol.multitouch package # code: preliminary com.sparshui package (I've been assured this is LGPL # despite the GPL license in the direcory) # Modified Paths: -------------- trunk/Jmol/src/org/jmol/multitouch/sparshui/TwoPointGesture.java trunk/Jmol/src/org/jmol/viewer/ActionManager.java trunk/Jmol/src/org/jmol/viewer/ActionManagerMT.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java Modified: trunk/Jmol/src/org/jmol/multitouch/sparshui/TwoPointGesture.java =================================================================== --- trunk/Jmol/src/org/jmol/multitouch/sparshui/TwoPointGesture.java 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/multitouch/sparshui/TwoPointGesture.java 2009-11-30 03:40:39 UTC (rev 11816) @@ -4,6 +4,7 @@ import javax.vecmath.Vector3f; +import org.jmol.util.Logger; import org.jmol.viewer.ActionManagerMT; import com.sparshui.common.Event; @@ -181,7 +182,8 @@ _myType = ActionManagerMT.ZOOM_GESTURE; } } - // TODO scale and rotation values + if (Logger.debugging) + Logger.debug("TwoPointGesture type=" + _myType + " cos:" + cos01 + "/" + cos02 + "/" + cos12); } private boolean updateCentroid() { Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2009-11-30 03:40:39 UTC (rev 11816) @@ -581,7 +581,8 @@ timeCurrent = time; xCurrent = x; yCurrent = y; - boolean dragRelease = (previousPressedX != x || previousPressedY != y); + boolean dragRelease = (pressedCount == 1 && + (previousPressedX != x || previousPressedY != y)); viewer.setInMotion(false); viewer.setCursor(Viewer.CURSOR_DEFAULT); int action = Binding.getMouseAction(pressedCount, mods); @@ -744,19 +745,15 @@ } else if (Math.abs(deltaX) > 5 * Math.abs(deltaY)) { // if (deltaX < 0 && deltaY > deltaX || deltaX > 0 && deltaY < deltaX) checkMotion(Viewer.CURSOR_MOVE); - viewer.rotateZBy(-deltaX); + viewer.rotateZBy(-deltaX, Integer.MAX_VALUE, Integer.MAX_VALUE); } return; } else if (isBound(action, ACTION_wheelZoom)) { - checkMotion(Viewer.CURSOR_ZOOM); - if (deltaY == 0) - return; - float zoomFactor = (float) Math.pow(ZOOM_FACTOR, deltaY); - viewer.zoomByFactor(zoomFactor); + zoomByFactor(deltaY, Integer.MAX_VALUE, Integer.MAX_VALUE); return; } else if (isBound(action, ACTION_rotateZ)) { checkMotion(Viewer.CURSOR_MOVE); - viewer.rotateZBy(-deltaX); + viewer.rotateZBy(-deltaX, Integer.MAX_VALUE, Integer.MAX_VALUE); return; } if (viewer.getSlabEnabled()) { @@ -775,6 +772,13 @@ } } + protected void zoomByFactor(int dz, int x, int y) { + checkMotion(Viewer.CURSOR_ZOOM); + if (dz == 0) + return; + viewer.zoomByFactor((float) Math.pow(ZOOM_FACTOR, dz), x, y); + } + private boolean checkUserAction(int action, int x, int y, int deltaX, int deltaY, long time, int mode) { if (!binding.isUserAction(action)) Modified: trunk/Jmol/src/org/jmol/viewer/ActionManagerMT.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ActionManagerMT.java 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/viewer/ActionManagerMT.java 2009-11-30 03:40:39 UTC (rev 11816) @@ -177,14 +177,13 @@ case ZOOM_EVENT: float scale = pt.z; if (scale == -1 || scale == 1) { - previousDragX = (int) pt.x; - previousDragY = (int) pt.y; - mouseWheel(time, (int) scale, Binding.WHEEL); + pt.z = Float.NaN; + zoomByFactor((int)scale, (int) pt.x, (int) pt.y); } break; case ROTATE_EVENT: checkMotion(Viewer.CURSOR_MOVE); - viewer.rotateZBy((int) pt.z); + viewer.rotateZBy((int) pt.z, (int) pt.x, (int) pt.y); break; case DRAG_EVENT: if (iData == 2) { Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-11-30 03:40:39 UTC (rev 11816) @@ -3,6 +3,9 @@ version=11.9.10_dev +# new feature: double-click-drag translates model +# new feature: multitouch gesture antiparallel strokes: rotate at point +# new feature: multitouch gesture spread/pinch: zoom in/out at point # new feature: app command parameter [-M or --multitouch] "sparshui" or "sparshui-simulated" # applet jmolSetCallback("multiTouchSparshUI", "true") # applet jmolSetCallback("multiTouchSparshUI-simulated", "true") Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2009-11-30 03:40:39 UTC (rev 11816) @@ -338,7 +338,9 @@ rotateYRadians(xDelta * JmolConstants.radiansPerDegree, bsAtoms); } - void rotateZBy(int zDelta) { + void rotateZBy(int zDelta, int x, int y) { + if (x != Integer.MAX_VALUE && y != Integer.MAX_VALUE) + resetXYCenter(x, y); rotateZRadians((float) Math.PI * zDelta / 180); } @@ -715,13 +717,26 @@ zoomPercentSetting = newZoomPercent; } - void zoomByFactor(float factor) { + void zoomByFactor(float factor, int x, int y) { if (factor <= 0) return; zoomRatio = factor; zoomPercentSetting *= factor; + resetXYCenter(x, y); } + private void resetXYCenter(int x, int y) { + if (x == Integer.MAX_VALUE || y == Integer.MAX_VALUE) + return; + if (windowCentered) + viewer.setBooleanProperty("windowCentered", false); + transformPoint(fixedRotationCenter, pointT); + pointT.set(x, y, pointT.z); + unTransformPoint(pointT, pointT); + fixedTranslation.set(x, y, 0); + setFixedRotationCenter(pointT); + } + void zoomByPercent(float percentZoom) { float deltaPercent = percentZoom * zoomPercentSetting / 100; if (deltaPercent == 0) Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-11-30 03:40:39 UTC (rev 11816) @@ -871,12 +871,12 @@ refresh(2, statusManager.syncingMouse ? "Mouse: zoomBy " + pixels : ""); } - void zoomByFactor(float factor) { + void zoomByFactor(float factor, int x, int y) { // MouseManager.mouseWheel if (mouseEnabled) - transformManager.zoomByFactor(factor); - refresh(2, statusManager.syncingMouse ? "Mouse: zoomByFactor " + factor - : ""); + transformManager.zoomByFactor(factor, x, y); + refresh(2, !statusManager.syncingMouse ? "" : "Mouse: zoomByFactor " + factor + + (x == Integer.MAX_VALUE ? "" : " " + x + " " + y)); } void rotateXYBy(int xDelta, int yDelta) { @@ -896,11 +896,12 @@ + yDelta + " " + speed : ""); } - void rotateZBy(int zDelta) { + void rotateZBy(int zDelta, int x, int y) { // mouseSinglePressDrag if (mouseEnabled) - transformManager.rotateZBy(zDelta); - refresh(2, statusManager.syncingMouse ? "Mouse: rotateZBy " + zDelta : ""); + transformManager.rotateZBy(zDelta, x, y); + refresh(2, statusManager.syncingMouse ? "Mouse: rotateZBy " + zDelta + + (x == Integer.MAX_VALUE ? "" : " " + x + " " + y): ""); } void rotateMolecule(int deltaX, int deltaY) { @@ -7592,11 +7593,11 @@ switch (tokens.length) { case 3: if (key.equals("zoomByFactor")) - zoomByFactor(Parser.parseFloat(tokens[2])); + zoomByFactor(Parser.parseFloat(tokens[2]), Integer.MAX_VALUE, Integer.MAX_VALUE); else if (key.equals("zoomBy")) zoomBy(Parser.parseInt(tokens[2])); else if (key.equals("rotateZBy")) - rotateZBy(Parser.parseInt(tokens[2])); + rotateZBy(Parser.parseInt(tokens[2]), Integer.MAX_VALUE, Integer.MAX_VALUE); break; case 4: if (key.equals("rotateXYBy")) @@ -7609,6 +7610,11 @@ case 5: if (key.equals("spinXYBy")) spinXYBy(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), Parser.parseFloat(tokens[4])); + else if (key.equals("zoomByFactor")) + zoomByFactor(Parser.parseFloat(tokens[2]), Parser.parseInt(tokens[3]), Parser.parseInt(tokens[4])); + else if (key.equals("rotateZBy")) + rotateZBy(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), Parser.parseInt(tokens[4])); + break; } if (disableSend) setSyncDriver(StatusManager.SYNC_ENABLE); Modified: trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java 2009-11-30 01:49:44 UTC (rev 11815) +++ trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java 2009-11-30 03:40:39 UTC (rev 11816) @@ -39,6 +39,7 @@ bind(SINGLE_CLICK+CTRL+RIGHT, ActionManager.ACTION_translate); bind(DOUBLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_translate); bind(DOUBLE_CLICK+MIDDLE, ActionManager.ACTION_translate); + bind(DOUBLE_CLICK+LEFT, ActionManager.ACTION_translate); bind(SINGLE_CLICK+ALT+SHIFT+LEFT, ActionManager.ACTION_dragSelected); bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_rotateSelected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |