From: <ha...@us...> - 2013-06-16 16:46:25
|
Revision: 18337 http://sourceforge.net/p/jmol/code/18337 Author: hansonr Date: 2013-06-16 16:46:21 +0000 (Sun, 16 Jun 2013) Log Message: ----------- ___JmolVersion="13.1.17_dev_2013.06.16" new feature: {atomset1}.distance.min({atomset2}) -- returns an array -- minimum distance of each atom in atomset1 to any atom in atomset2 new feature: {atomset1}.distance.max({atomset2}) -- returns an array -- maximum distance of each atom in atomset1 to any atom in atomset2 Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/SV.java trunk/Jmol/src/org/jmol/script/ScriptCompiler.java trunk/Jmol/src/org/jmol/script/ScriptContext.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/thread/SpinThread.java trunk/Jmol/src/org/jmol/util/Measure.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/TransformManager.java Modified: trunk/Jmol/src/org/jmol/script/SV.java =================================================================== --- trunk/Jmol/src/org/jmol/script/SV.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/script/SV.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -1266,15 +1266,11 @@ JmolList<Object> o = new JmolList<Object>(); for (int j = 0; j < l2.size(); j++) { v = l2.get(j); - System.out.println(v); - } list.addLast(o); } - System.out.println(v); } - return list; - + return list; } static float[] flistValue(T x, int nMin) { if (x.tok != varray) Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -2667,7 +2667,7 @@ : errorLine) + " <<<<"; errorMessage = GT._("script compiler ERROR: ") + errorMessage - + ScriptEvaluator.setErrorLineMessage(null, filename, lineCurrent, iCommand, lineInfo); + + ScriptEvaluator.getErrorLineMessage(null, filename, lineCurrent, iCommand, lineInfo); if (!isSilent) { ichToken = Math.max(ichEnd, ichToken); while (!lookingAtEndOfLine() && !lookingAtTerminator()) Modified: trunk/Jmol/src/org/jmol/script/ScriptContext.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptContext.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/script/ScriptContext.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -31,45 +31,49 @@ import org.jmol.util.SB; public class ScriptContext { - /** - * - */ - public String fullpath = ""; - public String scriptFileName; - public JmolParallelProcessor parallelProcessor; - public String functionName; - public String script; - public short[] lineNumbers; - public int[][] lineIndices; + + private static int contextCount = 0; + public T[][] aatoken; - public T[] statement; - public int statementLength; - public int pc; - public int pcEnd = Integer.MAX_VALUE; - public int lineEnd = Integer.MAX_VALUE; - public int iToken; - public SB outputBuffer; - public Map<String, SV> contextVariables; - public boolean isFunction; - public boolean isStateScript; - public boolean isTryCatch; + public boolean allowJSThreads; + boolean chk; + public String contextPath = " >> "; + Map<String, SV> contextVariables; + boolean displayLoadErrorsSave; public String errorMessage; - public String errorMessageUntranslated; - public int iCommandError = -1; + String errorMessageUntranslated; public String errorType; - public int scriptLevel; - public boolean chk; + public boolean executionPaused; public boolean executionStepping; - public boolean executionPaused; - public String scriptExtensions; - public String contextPath = " >> "; + public String functionName; + public int iCommandError = -1; + int id; + public boolean isComplete = true; + boolean isFunction; + public boolean isJSThread; + boolean isStateScript; + boolean isTryCatch; + int iToken; + int lineEnd = Integer.MAX_VALUE; + public int[][] lineIndices; + short[] lineNumbers; + public boolean mustResumeEval; + public SB outputBuffer; + JmolParallelProcessor parallelProcessor; public ScriptContext parentContext; - public ContextToken token; - public boolean mustResumeEval; - public boolean isJSThread; - public boolean allowJSThreads; - public boolean displayLoadErrorsSave; - public int tryPt; - public boolean isComplete = true; + public int pc; + public int pcEnd = Integer.MAX_VALUE; + public String script; + String scriptExtensions; + public String scriptFileName; + int scriptLevel; + T[] statement; + int statementLength; + ContextToken token; + int tryPt; + + ScriptContext() { + id = ++contextCount; + } } \ No newline at end of file Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -463,7 +463,7 @@ static SB getContextTrace(ScriptContext sc, SB sb, boolean isTop) { if (sb == null) sb = new SB(); - sb.append(setErrorLineMessage(sc.functionName, sc.scriptFileName, + sb.append(getErrorLineMessage(sc.functionName, sc.scriptFileName, sc.lineNumbers[sc.pc], sc.pc, ScriptEvaluator.statementAsString(sc.statement, (isTop ? sc.iToken : 9999), false))); if (sc.parentContext != null) getContextTrace(sc.parentContext, sb, false); @@ -548,7 +548,7 @@ * @return a string indicating the statement */ public String getNextStatement() { - return (pc < aatoken.length ? setErrorLineMessage(functionName, scriptFileName, + return (pc < aatoken.length ? getErrorLineMessage(functionName, scriptFileName, getLinenumber(null), pc, statementAsString(aatoken[pc], -9999, logMessages)) : ""); } @@ -1124,7 +1124,7 @@ case T.sum: case T.sum2: case T.average: - allowMathFunc = (isUserFunction || tok2 == T.minmaxmask || tok2 == T.selectedfloat); + allowMathFunc = (isUserFunction || token.intValue == T.distance || tok2 == T.minmaxmask || tok2 == T.selectedfloat); token.intValue |= tok2; getToken(iToken + 2); } @@ -2730,11 +2730,13 @@ if (debugScript || isCmdLine_c_or_C_Option) Logger.info("-->>-------------".substring(0, Math .max(17, scriptLevel + 5)) - + scriptLevel + " " + scriptFileName + " " + token + " " + thisContext); + + scriptLevel + " " + scriptFileName + " " + token + " " + thisContext.id); } public ScriptContext getScriptContext() { ScriptContext context = new ScriptContext(); + if (debugScript) + Logger.info("creating context " + context.id); context.scriptLevel = scriptLevel; context.parentContext = thisContext; context.contextPath = contextPath; @@ -2787,9 +2789,7 @@ + " " + scriptFileName + " " - + (thisContext == null ? "" : "" + thisContext.token) - + " " - + thisContext); + + (thisContext == null ? "" : "" + thisContext.id)); } private void restoreScriptContext(ScriptContext context, @@ -2798,6 +2798,10 @@ if (context == null) return; + if (debugScript || isCmdLine_c_or_C_Option) + Logger.info("--<<-------------".substring(0, Math + .max(17, scriptLevel + 5)) + + scriptLevel + " " + scriptFileName + " isPop " + isPopContext + " " + context.id); if (!isFlowCommand) { st = context.statement; slen = context.statementLength; @@ -2846,7 +2850,7 @@ true, false)); } } else { - sb.append(setErrorLineMessage(context.functionName, context.scriptFileName, + sb.append(getErrorLineMessage(context.functionName, context.scriptFileName, getLinenumber(context), context.pc, statementAsString( context.statement, -9999, logMessages))); } @@ -2859,7 +2863,7 @@ false)); } } else { - sb.append(setErrorLineMessage(functionName, scriptFileName, + sb.append(getErrorLineMessage(functionName, scriptFileName, getLinenumber(null), pc, statementAsString(st, -9999, logMessages))); } @@ -2875,7 +2879,7 @@ String fuName = (context == null ? functionName : "function " + context.functionName); String fiName = (context == null ? scriptFileName : context.scriptFileName); - return "\n# " + fuName + " (file " + fiName + ")\n"; + return "\n# " + fuName + " (file " + fiName + (context == null ? "" : " context " + context.id)+")\n"; } // /////////////// error message support ///////////////// @@ -3269,7 +3273,7 @@ return msg; } - static String setErrorLineMessage(String functionName, String filename, + static String getErrorLineMessage(String functionName, String filename, int lineCurrent, int pcCurrent, String lineInfo) { String err = "\n----"; @@ -3756,11 +3760,13 @@ case T.selected: rpn.addXBs(BSUtil.copy(viewer.getSelectionSet(false))); break; - case T.subset: - BS bsSubset = viewer.getSelectionSubset(); - rpn.addXBs(bsSubset == null ? viewer.getModelUndeletedAtomsBitSet(-1) - : BSUtil.copy(bsSubset)); - break; + //removed in 13.1.17. Undocumented; unneccessary (same as "all") + + //case T.subset: + //BS bsSubset = viewer.getSelectionSubset(); + //rpn.addXBs(bsSubset == null ? viewer.getModelUndeletedAtomsBitSet(-1) + // : BSUtil.copy(bsSubset)); + //break; case T.hidden: rpn.addXBs(BSUtil.copy(viewer.getHiddenSet())); break; @@ -5520,6 +5526,8 @@ break; if (lineNumbers[pc] > lineEnd) break; + if (debugScript && !chk) + Logger.info("Command " + pc); theToken = (aatoken[pc].length == 0 ? null : aatoken[pc][0]); // when checking scripts, we can't check statments // containing @{...} @@ -7175,10 +7183,12 @@ iToken = 0; float nSeconds = (isFloatParameter(1) ? floatParameter(++iToken) : Float.NaN); - BS bsFrom = (tokAt(++iToken) == T.subset ? null : atomExpressionAt(iToken)); - BS bsTo = (tokAt(++iToken) == T.subset ? null : atomExpressionAt(iToken)); - if (bsFrom == null || bsTo == null) - error(ERROR_invalidArgument); + ///BS bsFrom = (tokAt(++iToken) == T.subset ? null : atomExpressionAt(iToken)); + //BS bsTo = (tokAt(++iToken) == T.subset ? null : atomExpressionAt(iToken)); + //if (bsFrom == null || bsTo == null) + ///error(ERROR_invalidArgument); + BS bsFrom = atomExpressionAt(++iToken); + BS bsTo = atomExpressionAt(++iToken); BS bsSubset = null; boolean isSmiles = false; String strSmiles = null; @@ -7406,10 +7416,9 @@ } if (!useThreads()) doAnimate = false; - viewer.rotateAboutPointsInternal(this, center, pt1, + if (viewer.rotateAboutPointsInternal(this, center, pt1, endDegrees / nSeconds, endDegrees, doAnimate, bsFrom, translation, - ptsB, null); - if (doAnimate && isJS) + ptsB, null) && doAnimate && isJS) throw new ScriptInterruption(this, "compare", 1); } } Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -766,13 +766,13 @@ return evaluateCross(args); case T.data: return evaluateData(args); - case T.angle: case T.distance: case T.dot: + if (op.tok == T.propselector) + return evaluateDot(args, tok, op.intValue); + //$FALL-THROUGH$ + case T.angle: case T.measure: - if ((tok == T.distance || tok == T.dot) - && op.tok == T.propselector) - return evaluateDot(args, tok); return evaluateMeasure(args, op.tok); case T.file: case T.load: @@ -1224,37 +1224,72 @@ return false; } - private boolean evaluateDot(SV[] args, int tok) + /** + * distance, dot + * + * @param args + * @param tok + * @param intValue + * @return variable + * @throws ScriptException + */ + private boolean evaluateDot(SV[] args, int tok, int intValue) throws ScriptException { if (args.length != 1) return false; SV x1 = getX(); SV x2 = args[0]; - P3 pt2 = ptValue(x2, true); + P3 pt2 = (x2.tok == T.varray ? null : ptValue(x2, false)); P4 plane2 = planeValue(x2); - if (x1.tok == T.bitset && tok != T.dot) - return addXObj(eval.getBitsetProperty(SV.bsSelectVar(x1), - T.distance, pt2, plane2, x1.value, null, false, x1.index, false)); + if (tok == T.distance) { + int minMax = intValue & T.minmaxmask; + switch (x1.tok) { + case T.bitset: + switch (x2.tok) { + case T.bitset: + BS bs = SV.bsSelectVar(x1); + if (minMax == T.min || minMax == T.max) { + BS bs2 = SV.bsSelectVar(x2); + float[] data = new float[bs.cardinality()]; + Atom[] atoms = viewer.modelSet.atoms; + for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { + pt2 = atoms[i]; + data[i] = ((Float) eval.getBitsetProperty(bs2, intValue, pt2, + plane2, x1.value, null, false, x1.index, false)).floatValue(); + } + return addXAF(data); + } + return addXObj(eval.getBitsetProperty(bs, intValue, pt2, plane2, + x1.value, null, false, x1.index, false)); + } + } + } + return addXFloat(getDistance(x1, x2, tok)); + } + + private float getDistance(SV x1, SV x2, int tok) throws ScriptException { P3 pt1 = ptValue(x1, true); P4 plane1 = planeValue(x1); + P3 pt2 = ptValue(x2, true); + P4 plane2 = planeValue(x2); if (tok == T.dot) { if (plane1 != null && plane2 != null) // q1.dot(q2) assume quaternions - return addXFloat(plane1.x * plane2.x + plane1.y * plane2.y + plane1.z - * plane2.z + plane1.w * plane2.w); + return plane1.x * plane2.x + plane1.y * plane2.y + plane1.z + * plane2.z + plane1.w * plane2.w; // plane.dot(point) = if (plane1 != null) pt1 = P3.new3(plane1.x, plane1.y, plane1.z); // point.dot(plane) if (plane2 != null) pt2 = P3.new3(plane2.x, plane2.y, plane2.z); - return addXFloat(pt1.x * pt2.x + pt1.y * pt2.y + pt1.z * pt2.z); + return pt1.x * pt2.x + pt1.y * pt2.y + pt1.z * pt2.z; } if (plane1 == null) - return addXFloat(plane2 == null ? pt2.distance(pt1) : Measure.distanceToPlane( + return (plane2 == null ? pt2.distance(pt1) : Measure.distanceToPlane( plane2, pt1)); - return addXFloat(Measure.distanceToPlane(plane1, pt2)); + return Measure.distanceToPlane(plane1, pt2); } public P3 ptValue(SV x, boolean allowFloat) Modified: trunk/Jmol/src/org/jmol/thread/SpinThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/SpinThread.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/thread/SpinThread.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -53,9 +53,8 @@ private int index; //private boolean navigatingSurface; private BS[] bsBranches; + boolean isDone = false; - private int nmove = 0; - public boolean isGesture() { return isGesture; } @@ -165,8 +164,10 @@ else viewer.requestRepaintAndWait(); //System.out.println(angle * degreesPerRadian + " " + count + " " + nDegrees + " " + endDegrees); - if (!isNav && nDegrees >= endDegrees - 0.001) + if (!isNav && nDegrees >= endDegrees - 0.001) { + isDone = true; transformManager.setSpinOff(); + } if (!runSleep(sleepTime, MAIN)) return; mode = MAIN; @@ -185,7 +186,9 @@ transformManager.setSpinOff(); viewer.startHoverWatcher(true); } + stopped = !isDone; resumeEval(); + stopped = true; return; } } Modified: trunk/Jmol/src/org/jmol/util/Measure.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Measure.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/util/Measure.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -456,8 +456,8 @@ public static float getTransformMatrix4(JmolList<P3> ptsA, JmolList<P3> ptsB, Matrix4f m, P3 centerA) { P3[] cptsA = getCenterAndPoints(ptsA); P3[] cptsB = getCenterAndPoints(ptsB); - System.out.println("draw d1 @{point" + cptsA[0] + "}"); - System.out.println("draw d2 @{point" + cptsB[0] + "}"); + //System.out.println("draw d1 @{point" + cptsA[0] + "}"); + //System.out.println("draw d2 @{point" + cptsB[0] + "}"); float[] retStddev = new float[2]; Quaternion q = calculateQuaternionRotation(new P3[][] { cptsA, cptsB }, retStddev, true); // was false Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-06-16 16:46:21 UTC (rev 18337) @@ -9,8 +9,15 @@ # The quotes above look odd for a parameter file, but they are # important for the JavaScript version of Jmol. -___JmolVersion="13.1.17_dev_2013.06.15" +___JmolVersion="13.1.17_dev_2013.06.16" +new feature: {atomset1}.distance.min({atomset2}) + -- returns an array + -- minimum distance of each atom in atomset1 to any atom in atomset2 +new feature: {atomset1}.distance.max({atomset2}) + -- returns an array + -- maximum distance of each atom in atomset1 to any atom in atomset2 + bug fix: JavaScript not returning arrays properly from Jmol.getPropertyXXXX() -- very important to have {} after j2sNative directive! bug fix: COMPARE could rotate to less-good fit with SMARTS search Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2013-06-15 15:33:57 UTC (rev 18336) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2013-06-16 16:46:21 UTC (rev 18337) @@ -383,12 +383,29 @@ * ROTATIONS************************************************************** */ + /** + * + * @param eval + * @param point1 + * @param point2 + * @param degreesPerSecond + * @param endDegrees + * @param isClockwise + * @param isSpin + * @param bsAtoms + * @param isGesture + * @param translation + * @param finalPoints + * @param dihedralList + * @return true if synchronous so that JavaScript can restart properly + */ boolean rotateAboutPointsInternal(JmolScriptEvaluator eval, P3 point1, P3 point2, float degreesPerSecond, float endDegrees, boolean isClockwise, boolean isSpin, BS bsAtoms, boolean isGesture, V3 translation, - JmolList<P3> finalPoints, float[] dihedralList) { + JmolList<P3> finalPoints, + float[] dihedralList) { // *THE* Viewer INTERNAL frame rotation entry point @@ -401,7 +418,8 @@ isSpin = false; } - if (dihedralList == null && (translation == null || translation.length() < 0.001) + if (dihedralList == null + && (translation == null || translation.length() < 0.001) && (!isSpin || endDegrees == 0 || Float.isNaN(degreesPerSecond) || degreesPerSecond == 0) && (isSpin || endDegrees == 0)) return false; @@ -421,29 +439,30 @@ if (isSpin) { // we need to adjust the degreesPerSecond to match a multiple of the frame rate if (dihedralList == null) { - int nFrames = (int) (Math.abs(endDegrees) / Math.abs(degreesPerSecond) - * spinFps + 0.5); - if (Float.isNaN(endDegrees)) { - rotationRate = degreesPerSecond; + int nFrames = (int) (Math.abs(endDegrees) / Math.abs(degreesPerSecond) + * spinFps + 0.5); + if (Float.isNaN(endDegrees)) { + rotationRate = degreesPerSecond; + } else { + rotationRate = degreesPerSecond = endDegrees / nFrames * spinFps; + if (translation != null) + internalTranslation.scale(1f / (nFrames)); + } + internalRotationAxis.setVA(axis, rotationRate * JC.radiansPerDegree); + isSpinInternal = true; + isSpinFixed = false; + isSpinSelected = isSelected; } else { - rotationRate = degreesPerSecond = endDegrees / nFrames * spinFps; - if (translation != null) - internalTranslation.scale(1f / (nFrames)); - } - internalRotationAxis.setVA(axis, rotationRate * JC.radiansPerDegree); - isSpinInternal = true; - isSpinFixed = false; - isSpinSelected = isSelected; - } else { endDegrees = degreesPerSecond; } - setSpin(eval, true, endDegrees, finalPoints, dihedralList, bsAtoms, isGesture); - return false; + setSpin(eval, true, endDegrees, finalPoints, dihedralList, bsAtoms, + isGesture); + return (dihedralList != null || bsAtoms != null); } float radians = endDegrees * JC.radiansPerDegree; internalRotationAxis.setVA(axis, radians); rotateAxisAngleRadiansInternal(radians, bsAtoms); - return true; + return false; } public synchronized void rotateAxisAngleRadiansInternal(float radians, @@ -1981,16 +2000,18 @@ boolean isGesture) { if (navOn && spinOn) setNavOn(false); + if (this.spinOn == spinOn) + return; this.spinOn = spinOn; viewer.getGlobalSettings().setB("_spinning", spinOn); if (spinOn) { if (spinThread == null) { spinThread = new SpinThread(this, viewer, endDegrees, endPositions, dihedralList, bsAtoms, false, isGesture); - spinThread.setEval(eval); - if (bsAtoms == null) { + if (bsAtoms == null && dihedralList == null) { spinThread.start(); } else { + spinThread.setEval(eval); spinThread.run(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |