From: <ha...@us...> - 2015-06-19 08:29:29
|
Revision: 20590 http://sourceforge.net/p/jmol/code/20590 Author: hansonr Date: 2015-06-19 08:29:26 +0000 (Fri, 19 Jun 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.15_2015.06.18" new feature: cleaning empty array values using .find() - arrays of hash info: array = array.find() bug fix: msCIF reader can hang if occupancy is not fractional bug fix: JSmol applet not returning full set of parameters in animFrameCallback bug fix: load FILL command can fail if base unit cell is not part of the needed set for the specified volume Modified Paths: -------------- trunk/Jmol/src/javajs/util/Measure.java trunk/Jmol/src/org/jmol/appletjs/Jmol.java trunk/Jmol/src/org/jmol/script/SV.java trunk/Jmol/src/org/jmol/script/ScriptCompiler.java trunk/Jmol/src/org/jmol/script/ScriptExpr.java trunk/Jmol/src/org/jmol/scriptext/MathExt.java trunk/Jmol/src/org/jmol/viewer/JC.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/ShapeManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/javajs/util/Measure.java =================================================================== --- trunk/Jmol/src/javajs/util/Measure.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/javajs/util/Measure.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -179,21 +179,22 @@ public static float distanceToPlane(P4 plane, T3 pt) { return (plane == null ? Float.NaN - : (plane.x * pt.x + plane.y * pt.y + plane.z * pt.z + plane.w) - / (float) Math.sqrt(plane.x * plane.x + plane.y * plane.y + plane.z - * plane.z)); + : (plane.dot(pt) + plane.w) / (float) Math.sqrt(plane.dot(plane))); } + public static float directedDistanceToPlane(P3 pt, P4 plane, P3 ptref) { + float f = plane.dot(pt) + plane.w; + float f1 = plane.dot(ptref) + plane.w; + return Math.signum(f1) * f / (float) Math.sqrt(plane.dot(plane)); + } + public static float distanceToPlaneD(P4 plane, float d, P3 pt) { - return (plane == null ? Float.NaN : (plane.x * pt.x + plane.y - * pt.y + plane.z * pt.z + plane.w) / d); + return (plane == null ? Float.NaN : (plane.dot(pt) + plane.w) / d); } public static float distanceToPlaneV(V3 norm, float w, P3 pt) { return (norm == null ? Float.NaN - : (norm.x * pt.x + norm.y * pt.y + norm.z * pt.z + w) - / (float) Math.sqrt(norm.x * norm.x + norm.y * norm.y + norm.z - * norm.z)); + : (norm.dot(pt) + w) / (float) Math.sqrt(norm.dot(norm))); } /** Modified: trunk/Jmol/src/org/jmol/appletjs/Jmol.java =================================================================== --- trunk/Jmol/src/org/jmol/appletjs/Jmol.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/appletjs/Jmol.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -230,7 +230,7 @@ * o = o[tokens[i]]; * for (var i = 0; i < data.length; i++) * data[i] && data[i].booleanValue && (data[i] = data[i].booleanValue()); - * return o(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]); + * return o.apply(null,data) * } catch (e) { System.out.println(callback + " failed " + e); } */ { Modified: trunk/Jmol/src/org/jmol/script/SV.java =================================================================== --- trunk/Jmol/src/org/jmol/script/SV.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/script/SV.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -849,8 +849,9 @@ case string: break; default: - return ((tokenIn instanceof SV) && ((SV) tokenIn).myName != null ? newI(0) - .setv((SV) tokenIn) : tokenIn); + return ((tokenIn instanceof SV) && ((SV) tokenIn).myName != null + ? newI(0).setv((SV) tokenIn) + : tokenIn); } // negative number is a count from the end Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -65,7 +65,7 @@ */ /** - * @param vwr + * @param vwr * @j2sIgnoreSuperConstructor * */ @@ -906,20 +906,19 @@ private void getPrefixToken() { ident = script.substring(ichToken, ichToken + cchToken); identLC = ident.toLowerCase(); - boolean isUserVar = (lastToken.tok != T.per && !isDotDot && isContextVariable(identLC)); - String myName = (isUserVar ? ident : null); + boolean isUserVar = isContextVariable(identLC); + String myName = ident;//(isUserVar ? ident : null); String preserveCase = null; if (nTokens == 0) isUserToken = isUserVar; if (nTokens == 1 - && (tokCommand == T.function || tokCommand == T.parallel - || tokCommand == T.var) - - || nTokens != 0 && isUserVar - - || !isDotDot && isUserFunction(identLC) && ((preserveCase = ident) != null) - - + && (tokCommand == T.function || tokCommand == T.parallel || tokCommand == T.var) + + || nTokens != 0 && isUserVar + + || !isDotDot && isUserFunction(identLC) + && ((preserveCase = ident) != null) + && (thisFunction == null || !thisFunction.name.equals(identLC))) { // we need to allow: @@ -954,8 +953,8 @@ if (identLC.indexOf("property_") == 0) { theToken = T.o(T.property, identLC); } else if (myName != null) { - theToken = SV.newSV(T.identifier, 0, ident); - ((SV)theToken).myName = myName; + theToken = SV.newSV(T.identifier, Integer.MAX_VALUE, ident); + ((SV) theToken).myName = myName; } else { theToken = T.o(T.identifier, ident); } @@ -986,8 +985,9 @@ && lastToken.tok == T.defaultdirectory || tokCommand == T.load || tokCommand == T.background || tokCommand == T.script)); iHaveQuotedString = true; - if ((tokCommand == T.load || tokCommand == T.cgo) && lastToken.tok == T.data - || tokCommand == T.data && str.indexOf("@") < 0) { + if ((tokCommand == T.load || tokCommand == T.cgo) + && lastToken.tok == T.data || tokCommand == T.data + && str.indexOf("@") < 0) { if (!getData(str)) { return ERROR(ERROR_missingEnd, "data"); } @@ -1034,6 +1034,7 @@ cchToken = 1; switch (ch) { case '[': + tokLastMath = 1; addTokenToPrefix(T.tokenArrayOpen); bracketCount++; return CONTINUE; @@ -1071,9 +1072,9 @@ if (nTokens == 2) { if (lastToken.tok == T.image) iHaveQuotedString = true; - } else - if (!iHaveQuotedString && lastToken.tok != T.domains && lastToken.tok != T.validation) { - return OK; + } else if (!iHaveQuotedString && lastToken.tok != T.domains + && lastToken.tok != T.validation) { + return OK; } //$FALL-THROUGH$ case T.load: @@ -1130,8 +1131,8 @@ } } if (!iHaveQuotedString - && lookingAtImpliedString(tokCommand == T.show, tokCommand == T.load, nTokens > 1 - || tokCommand != T.script)) { + && lookingAtImpliedString(tokCommand == T.show, tokCommand == T.load, + nTokens > 1 || tokCommand != T.script)) { String str = script.substring(ichToken, ichToken + cchToken); if (tokCommand == T.script) { if (str.startsWith("javascript:")) { @@ -1268,7 +1269,8 @@ boolean isBondOrMatrix = (script.charAt(ichToken) == '['); BS bs = lookingAtBitset(); if (bs != null) { - addTokenToPrefix(T.o(T.bitset, isBondOrMatrix ? BondSet.newBS(bs, null) : bs)); + addTokenToPrefix(T.o(T.bitset, isBondOrMatrix ? BondSet.newBS(bs, null) + : bs)); return CONTINUE; } if (isBondOrMatrix) { @@ -1905,8 +1907,8 @@ } private static ScriptFunction newScriptParallelProcessor(String name, int tok) { - ScriptFunction jpp = (ScriptFunction) Interface - .getInterface("org.jmol.script.ScriptParallelProcessor", null, null); + ScriptFunction jpp = (ScriptFunction) Interface.getInterface( + "org.jmol.script.ScriptParallelProcessor", null, null); jpp.set(name, tok); return jpp; } @@ -1920,18 +1922,16 @@ ptNewSetModifier = (isNewSet ? (ident.equals("(") ? 2 : 1) : Integer.MAX_VALUE); // unfortunately we have to look here for defaultLattice, because it must not turn into a string. - return ((isSetBrace || theToken.tok == T.leftparen - || theToken.tok == T.defaultlattice - || theToken.tok == T.plusPlus || theToken.tok == T.minusMinus) ? theToken + return ((isSetBrace || theToken.tok == T.leftparen + || theToken.tok == T.defaultlattice || theToken.tok == T.plusPlus || theToken.tok == T.minusMinus) ? theToken : T.o(T.identifier, ident)); } private void checkUnquotedFileName() { int ichT = ichToken; char ch; - while (++ichT < cchScript - && !PT.isWhitespace(ch = script.charAt(ichT)) && ch != '#' - && ch != ';' && ch != '}') { + while (++ichT < cchScript && !PT.isWhitespace(ch = script.charAt(ichT)) + && ch != '#' && ch != ';' && ch != '}') { } String name = script.substring(ichToken, ichT).replace('\\', '/'); cchToken = ichT - ichToken; @@ -2774,10 +2774,10 @@ tokLastMath = 1; // last is hack for insertion codes embedded in an atom expression :-( // select c3^a - while (PT.isLetterOrDigit(ch = charAt(ichT)) || ch == '_' - || ch == '*' && charAt(ichT - 1) == '?' || ch == '?' || ch == '~' - || ch == '\'' || ch == '\\' && charAt(ichT + 1) == '?' || ch == '^' - && ichT > ichT0 && PT.isDigit(charAt(ichT - 1))) + while (PT.isLetterOrDigit(ch = charAt(ichT)) || ch == '_' || ch == '*' + && charAt(ichT - 1) == '?' || ch == '?' || ch == '~' || ch == '\'' + || ch == '\\' && charAt(ichT + 1) == '?' || ch == '^' && ichT > ichT0 + && PT.isDigit(charAt(ichT - 1))) ++ichT; break; } Modified: trunk/Jmol/src/org/jmol/script/ScriptExpr.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptExpr.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/script/ScriptExpr.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -522,7 +522,7 @@ if (!isWhere) { rpn.addX(SV.newT(theToken)); break; - } + }//$FALL-THROUGH$ default: if (theTok == T.leftsquare && tokAt(i + 2) == T.colon) { v = getAssocArray(i); Modified: trunk/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -839,13 +839,15 @@ * x = {atomset1}.distance.max({atomset2}).max returns the furthest distance * from any atom in atomset1 to any atom in atomset2. * - * x = {atomset1}.distance.all({atomset2}) returns an array or array of arrays of values + * x = {atomset1}.distance.all({atomset2}) returns an array or array of arrays + * of values * - * @param mp - * @param args - * @param intValue optional .min .max + * @param mp + * @param args + * @param intValue + * optional .min .max * @return true if successful - * @throws ScriptException + * @throws ScriptException */ private boolean evaluateDotDist(ScriptMathProcessor mp, SV[] args, @@ -933,7 +935,10 @@ float f = Float.NaN; try { if (isDist) { - f = (plane1 == null ? (plane2 == null ? pt2.distance(pt1) : Measure + if (plane2 != null && args.length == 2) + f = Measure.directedDistanceToPlane(pt1, plane2, SV.ptValue(args[1])); + else + f = (plane1 == null ? (plane2 == null ? pt2.distance(pt1) : Measure .distanceToPlane(plane2, pt1)) : Measure.distanceToPlane(plane1, pt2)); } else { @@ -1013,8 +1018,6 @@ private boolean evaluateFind(ScriptMathProcessor mp, SV[] args) throws ScriptException { - if (args.length == 0) - return false; // {*}.find("CF",true|false) // {*}.find("MF") @@ -1031,7 +1034,8 @@ SV x1 = mp.getX(); boolean isList = (x1.tok == T.varray); - String sFind = SV.sValue(args[0]); + boolean isEmpty = (args.length == 0); + String sFind = (isEmpty ? "" : SV.sValue(args[0])); String flags = (args.length > 1 && args[1].tok != T.on && args[1].tok != T.off ? SV.sValue(args[1]) : ""); boolean isSequence = !isList && sFind.equalsIgnoreCase("SEQUENCE"); @@ -1082,17 +1086,22 @@ (BS) x1.value, false, (isMF ? null : vwr.ms.getCellWeights((BS) x1.value)), isON)); if (isSequence) - return mp.addXStr(vwr.getSmilesOpt((BS) x1.value, -1, -1, - JC.SMILES_BIO - | (isAll ? JC.SMILES_BIO_ALLOW_UNMACHED_RINGS | JC.SMILES_BIO_CROSSLINK : 0))); + return mp.addXStr(vwr.getSmilesOpt((BS) x1.value, -1, -1, + JC.SMILES_BIO + | (isAll ? JC.SMILES_BIO_ALLOW_UNMACHED_RINGS + | JC.SMILES_BIO_CROSSLINK : 0))); if (isSmiles || isSearch) sFind = flags; BS bsMatch3D = bs2; if (asBonds) { // this will return a single match - int[][] map = vwr.getSmilesMatcher().getCorrelationMaps(sFind, - vwr.ms.at, vwr.ms.ac, (BS) x1.value, - (isSmiles ? JC.SMILES_TYPE_SMILES : JC.SMILES_TYPE_SMARTS) | JC.SMILES_RETURN_FIRST); + int[][] map = vwr.getSmilesMatcher().getCorrelationMaps( + sFind, + vwr.ms.at, + vwr.ms.ac, + (BS) x1.value, + (isSmiles ? JC.SMILES_TYPE_SMILES : JC.SMILES_TYPE_SMARTS) + | JC.SMILES_RETURN_FIRST); ret = (map.length > 0 ? vwr.ms.getDihedralMap(map[0]) : new int[0]); } else { ret = e.getSmilesExt().getSmilesMatches(sFind, null, (BS) x1.value, @@ -1114,27 +1123,46 @@ if (isList || isPattern) { JmolPatternMatcher pm = getPatternMatcher(); Pattern pattern = null; - try { - pattern = (sFind.length() == 0 ? null : pm.compile(sFind, isCaseInsensitive)); - } catch (Exception ex) { - e.evalError(ex.toString(), null); + String[] list = null; + Lst<SV> svlist = (isList ? x1.getList() : null); + if (sFind.length() > 0) { + try { + pattern = (sFind.length() == 0 ? null : pm.compile(sFind, + isCaseInsensitive)); + list = SV.strListValue(x1); + } catch (Exception ex) { + e.evalError(ex.toString(), null); + } } - String[] list = SV.strListValue(x1); - Lst<SV> svlist = (isList ? x1.getList() : null); + int nlist = (list == null ? svlist.size() : list.length); if (Logger.debugging) Logger.debug("finding " + sFind); BS bs = new BS(); int n = 0; Matcher matcher = null; Lst<String> v = (asMatch ? new Lst<String>() : null); - for (int i = 0; i < list.length; i++) { - String what = list[i]; + String what = ""; + for (int i = 0; i < nlist; i++) { boolean isMatch; if (pattern == null) { - isMatch = (what.length() != 0); + SV o = svlist.get(i); + switch (o.tok) { + case T.hash: + isMatch = (o.getMap().isEmpty() != isEmpty); + break; + case T.varray: + isMatch = ((o.getList().size() == 0) != isEmpty); + break; + case T.string: + isMatch = ((o.asString().length() == 0) != isEmpty); + break; + default: + isMatch = true; + } } else { - matcher = pattern.matcher(what); - isMatch = matcher.find(); + what = list[i]; + matcher = pattern.matcher(what); + isMatch = matcher.find(); } if (asMatch && isMatch || !asMatch && isMatch == !isReverse) { n++; @@ -1150,9 +1178,9 @@ .addXStr(n == 0 ? "" : matcher.group()) : mp.addXInt(n == 0 ? 0 : matcher.start() + 1)); } - // removed in 14.2/3.14 -- not documented and not expected if (n == 1) -// return mp.addXStr(asMatch ? (String) v.get(0) : list[ipt]); - + // removed in 14.2/3.14 -- not documented and not expected if (n == 1) + // return mp.addXStr(asMatch ? (String) v.get(0) : list[ipt]); + if (asMatch) { String[] listNew = new String[n]; if (n > 0) @@ -1165,8 +1193,8 @@ } Lst<SV> l = new Lst<SV>(); for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) - l.addLast(svlist.get(i)); - return mp.addXList(l); + l.addLast(svlist.get(i)); + return mp.addXList(l); } if (isSequence) { return mp.addXStr(vwr.getJBR().toStdAmino3(SV.sValue(x1))); Modified: trunk/Jmol/src/org/jmol/viewer/JC.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/JC.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/viewer/JC.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -66,7 +66,7 @@ }; - public final static String copyright = "(C) 2012 Jmol Development"; + public final static String copyright = "(C) 2015 Jmol Development"; public final static String version; public final static String date; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-06-19 08:29:26 UTC (rev 20590) @@ -16,6 +16,13 @@ Jmol.___JmolVersion="14.3.15_2015.06.18" +new feature: cleaning empty array values using .find() + - arrays of hash info: + + array = array.find() + +bug fix: msCIF reader can hang if occupancy is not fractional +bug fix: JSmol applet not returning full set of parameters in animFrameCallback bug fix: load FILL command can fail if base unit cell is not part of the needed set for the specified volume JmolVersion="14.3.15_2015.06.18" @@ -56,15 +63,6 @@ print b.format(["energy", "pointGroup"]).sort(1).reverse.format("%5.3f %5s") -new feature: cleaning empty array values using .find() - - arrays of hash info: - - array = array.find(":") - - - arrays of numbers: - - array = array.find("") - new feature: polyhedra highlight with select ON or set selectionHalos ON Modified: trunk/Jmol/src/org/jmol/viewer/ShapeManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -439,7 +439,7 @@ ms.getAtomsInFrame(bs); Vibration[] vibrationVectors = ms.vibrations; boolean vibs = (vibrationVectors != null && tm.vibrationOn); - boolean checkOccupancy = (ms.bsModulated != null); + boolean checkOccupancy = (ms.bsModulated != null && ms.occupancies != null); Atom[] atoms = ms.at; int occ; boolean haveMods = false; Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-06-18 19:51:21 UTC (rev 20589) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-06-19 08:29:26 UTC (rev 20590) @@ -488,10 +488,14 @@ display = info.get("display"); isSingleThreaded = apiPlatform.isSingleThreaded(); noGraphicsAllowed = checkOption2("noGraphics", "-n"); + System.out.println("nographics " + noGraphicsAllowed); + headless = apiPlatform.isHeadless(); haveDisplay = (isWebGL || display != null && !noGraphicsAllowed && !headless && !dataOnly); noGraphicsAllowed &= (display == null); - headless = (noGraphicsAllowed || apiPlatform.isHeadless()); + System.out.println("nographics " + noGraphicsAllowed); + headless |= noGraphicsAllowed; + System.out.println("headless " + headless + commandOptions); if (haveDisplay) { mustRender = true; multiTouch = checkOption2("multiTouch", "-multitouch"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |