From: <ha...@us...> - 2010-02-18 18:14:04
|
Revision: 12407 http://jmol.svn.sourceforge.net/jmol/?rev=12407&view=rev Author: hansonr Date: 2010-02-18 18:13:57 +0000 (Thu, 18 Feb 2010) Log Message: ----------- version=11.9.30_dev # code: preliminary set useArcBall -- Ken Shoemake's idea for better mouse drag action Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/ActionManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2010-02-18 15:04:53 UTC (rev 12406) +++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2010-02-18 18:13:57 UTC (rev 12407) @@ -628,6 +628,8 @@ viewer.popupMenu(x, y); return; } + if (viewer.useArcBall()) + viewer.rotateArcBall(x, y, true); checkMotionRotateZoom(action, x, 0, 0, true); } @@ -809,7 +811,7 @@ * mouseDragFactor; if (isRotate) { if (viewer.useArcBall()) - viewer.rotateArcBall(x - deltaX, y - deltaY, x, y); + viewer.rotateArcBall(x, y, false); else viewer.rotateXYBy(degX, degY); } else { Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2010-02-18 15:04:53 UTC (rev 12406) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2010-02-18 18:13:57 UTC (rev 12407) @@ -346,24 +346,27 @@ final Vector3f arcBall0 = new Vector3f(); final Vector3f arcBall1 = new Vector3f(); final Vector3f arcBallAxis = new Vector3f(); + final Matrix3f arcBall0Rotation = new Matrix3f(); - void rotateArcBall(float x0, float y0, float x1, float y1) { + void rotateArcBall(float x, float y, boolean isInit) { float radius2 = (screenPixelCount >> 2) * screenPixelCount; - float x, y, z; - x = x0 - fixedTranslation.x; - y = y0 - fixedTranslation.y; - if (Float.isNaN(z = (float) Math.sqrt(radius2 - x * x - y * y))) + x -= fixedTranslation.x; + y -= fixedTranslation.y; + float z = (float) Math.sqrt(radius2 - x * x - y * y); + if (isInit) { + arcBall0Rotation.set(matrixRotate); + arcBall0.set(x, -y, z); + if (!Float.isNaN(z)) + arcBall0.normalize(); return; - arcBall0.set(x, -y, z); - x = x1 - fixedTranslation.x; - y = y1 - fixedTranslation.y; - if (Float.isNaN(z = (float) Math.sqrt(radius2 - x * x - y * y))) + } + if (Float.isNaN(arcBall0.z) || Float.isNaN(z)) return; arcBall1.set(x, -y, z); - arcBall0.normalize(); arcBall1.normalize(); arcBallAxis.cross(arcBall0, arcBall1); - axisangleT.set(arcBallAxis, (float) Math.acos(arcBall0.dot(arcBall1))); + axisangleT.set(arcBallAxis, 2 * (float) Math.acos(arcBall0.dot(arcBall1))); + matrixRotate.set(arcBall0Rotation); rotateAxisAngle(axisangleT, null); } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-02-18 15:04:53 UTC (rev 12406) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-02-18 18:13:57 UTC (rev 12407) @@ -7620,11 +7620,9 @@ else if (key.equals("rotateZBy")) rotateZBy(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), Parser.parseInt(tokens[4])); - break; - case 6: - if (key.equals("rotateArcBall")) + else if (key.equals("rotateArcBall")) rotateArcBall(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), - Parser.parseInt(tokens[4]),Parser.parseInt(tokens[5])); + Parser.parseInt(tokens[4]) == 1); break; case 7: if (key.equals("centerAt")) @@ -8133,13 +8131,12 @@ return global.useArcBall; } - void rotateArcBall(int x0, int y0, int x1, int y1) { - transformManager.rotateArcBall(x0, y0, x1, y1); + void rotateArcBall(int x, int y, boolean isInit) { + transformManager.rotateArcBall(x, y, isInit); refresh(2, statusManager.syncingMouse ? "Mouse: rotateArcBall " - + x0 + " " - + y0 + " " - + x1 + " " - + y1 + " " + + x + " " + + y + " " + + (isInit ? 1 : 0) : ""); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |