From: <ha...@us...> - 2010-02-18 13:21:13
|
Revision: 12404 http://jmol.svn.sourceforge.net/jmol/?rev=12404&view=rev Author: hansonr Date: 2010-02-18 13:21:03 +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/script/Token.java trunk/Jmol/src/org/jmol/viewer/ActionManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/script/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/script/Token.java 2010-02-17 22:11:38 UTC (rev 12403) +++ trunk/Jmol/src/org/jmol/script/Token.java 2010-02-18 13:21:03 UTC (rev 12404) @@ -927,6 +927,7 @@ public final static int testflag3 = booleanparam | 188; public final static int testflag4 = booleanparam | 190; public final static int tracealpha = booleanparam | 192; + public final static int usearcball = booleanparam | 191; public final static int useminimizationthread = booleanparam | 194; public final static int usenumberlocalization = booleanparam | 196; public final static int waitformoveto = booleanparam | 197; @@ -2117,6 +2118,7 @@ "testFlag3", new Token(testflag3), "testFlag4", new Token(testflag4), "traceAlpha", new Token(tracealpha), + "useArcBall", new Token(usearcball), "useMinimizationThread", new Token(useminimizationthread), "useNumberLocalization", new Token(usenumberlocalization), "waitForMoveTo", new Token(waitformoveto), Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2010-02-17 22:11:38 UTC (rev 12403) +++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2010-02-18 13:21:03 UTC (rev 12404) @@ -808,7 +808,10 @@ float degY = ((float) deltaY) / viewer.getScreenHeight() * 180 * mouseDragFactor; if (isRotate) { - viewer.rotateXYBy(degX, degY); + if (viewer.useArcBall()) + viewer.rotateArcBall(x - deltaX, y - deltaY, x, y); + else + viewer.rotateXYBy(degX, degY); } else { checkMotion(Viewer.CURSOR_MOVE); viewer.rotateMolecule(degX, degY); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-02-17 22:11:38 UTC (rev 12403) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-02-18 13:21:03 UTC (rev 12404) @@ -3,6 +3,7 @@ version=11.9.30_dev +# code: preliminary set useArcBall -- Ken Shoemake's idea for better mouse drag action # code: very prelminary http://www.cse.clrc.ac.uk/cmg/CRYSTAL/ output reader # bug fix: some VASP files not readable because they contain ">vasp <" instead of ">vasp<" # bug fix: calculate hydrogens for cumulenes -- but not for whole molecule Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2010-02-17 22:11:38 UTC (rev 12403) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2010-02-18 13:21:03 UTC (rev 12404) @@ -922,6 +922,7 @@ setParameterValue("testFlag3", testFlag3); setParameterValue("testFlag4", testFlag4); setParameterValue("traceAlpha", traceAlpha); + setParameterValue("useArcBall", useArcBall); setParameterValue("useMinimizationThread", useMinimizationThread); setParameterValue("useNumberLocalization", useNumberLocalization); setParameterValue("vectorScale", vectorScale); @@ -1154,6 +1155,7 @@ float strutLengthMaximum = 7.0f; float strutDefaultRadius = JmolConstants.DEFAULT_STRUT_RADIUS; boolean strutsMultiple = false; //on a single position + boolean useArcBall = false; boolean useMinimizationThread = true; boolean useNumberLocalization = true; boolean useScriptQueue = true; Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2010-02-17 22:11:38 UTC (rev 12403) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2010-02-18 13:21:03 UTC (rev 12404) @@ -343,6 +343,30 @@ rotateAboutPointsInternal(pt2, pt1, 10 * speed, Float.NaN, false, true, null, true); } + final Vector3f arcBall0 = new Vector3f(); + final Vector3f arcBall1 = new Vector3f(); + final Vector3f arcBallAxis = new Vector3f(); + + void rotateArcBall(float x0, float y0, float x1, float y1) { + 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))) + 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))) + return; + arcBall1.set(x, -y, z); + arcBall0.normalize(); + arcBall1.normalize(); + arcBallAxis.cross(arcBall0, arcBall1); + axisangleT.set(arcBallAxis, (float) Math.acos(arcBall0.dot(arcBall1))); + rotateAxisAngle(axisangleT, null); + } + void rotateXYBy(float xDelta, float yDelta, BitSet bsAtoms) { // from mouse action rotateXRadians(yDelta * JmolConstants.radiansPerDegree, bsAtoms); @@ -352,7 +376,7 @@ void rotateZBy(int zDelta, int x, int y) { if (x != Integer.MAX_VALUE && y != Integer.MAX_VALUE) resetXYCenter(x, y, null); - rotateZRadians((float) Math.PI * zDelta / 180); + rotateZRadians((float) (zDelta / degreesPerRadian)); } void rotateFront() { @@ -400,7 +424,7 @@ } synchronized void rotateAxisAngle(AxisAngle4f axisAngle, BitSet bsAtoms) { - matrixTemp3.setIdentity(); + //matrixTemp3.setIdentity(); matrixTemp3.set(axisAngle); applyRotation(matrixTemp3, false, bsAtoms); } @@ -1509,7 +1533,7 @@ int totalSteps = (int) (fps * floatSecondsTotal); if (totalSteps <= 0) totalSteps = 1; // to catch a zero secondsTotal parameter - float radiansPerDegreePerStep = (float) Math.PI / 180 / totalSteps; + float radiansPerDegreePerStep = (float) (1 / degreesPerRadian / totalSteps); float radiansXStep = radiansPerDegreePerStep * dRot.x; float radiansYStep = radiansPerDegreePerStep * dRot.y; float radiansZStep = radiansPerDegreePerStep * dRot.z; @@ -1561,7 +1585,7 @@ boolean isInPosition(Vector3f axis, float degrees) { if (Float.isNaN(degrees)) return true; - aaTest1.set(axis, degrees * (float) Math.PI / 180); + aaTest1.set(axis, (float) (degrees / degreesPerRadian)); ptTest1.set(4.321f, 1.23456f, 3.14159f); getRotation(matrixTest); matrixTest.transform(ptTest1, ptTest2); @@ -1594,7 +1618,7 @@ return; } AxisAngle4f aaMoveTo = new AxisAngle4f(); - aaMoveTo.set(axis, degrees * (float) Math.PI / 180); + aaMoveTo.set(axis, (float) (degrees / degreesPerRadian)); matrixEnd.set(aaMoveTo); } } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-02-17 22:11:38 UTC (rev 12403) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-02-18 13:21:03 UTC (rev 12404) @@ -5438,6 +5438,9 @@ boolean found = true; boolean doRepaint = true; switch (tok) { + case Token.usearcball: + global.useArcBall = value; + break; case Token.iskiosk: // 11.9.29 isKiosk = value; @@ -7618,6 +7621,11 @@ rotateZBy(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), Parser.parseInt(tokens[4])); break; + case 6: + if (key.equals("rotateArcBall")) + rotateArcBall(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), + Parser.parseInt(tokens[4]),Parser.parseInt(tokens[5])); + break; case 7: if (key.equals("centerAt")) centerAt(Parser.parseInt(tokens[2]), Parser.parseInt(tokens[3]), @@ -8121,4 +8129,18 @@ } } + boolean useArcBall() { + return global.useArcBall; + } + + void rotateArcBall(int x0, int y0, int x1, int y1) { + transformManager.rotateArcBall(x0, y0, x1, y1); + refresh(2, statusManager.syncingMouse ? "Mouse: rotateArcBall " + + x0 + " " + + y0 + " " + + x1 + " " + + y1 + " " + : ""); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |