From: <ha...@us...> - 2010-01-02 21:56:51
|
Revision: 12019 http://jmol.svn.sourceforge.net/jmol/?rev=12019&view=rev Author: hansonr Date: 2010-01-02 21:56:27 +0000 (Sat, 02 Jan 2010) Log Message: ----------- hkl fix Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/script/Token.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java 2010-01-02 21:10:20 UTC (rev 12018) +++ trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java 2010-01-02 21:56:27 UTC (rev 12019) @@ -560,15 +560,7 @@ if (key == null) { if (tok == Token.identifier) { //distance was specified, but to what? - getToken(); - key = ((String) theValue).toLowerCase(); - if (key.equals("hkl")) { - isCoordOrPlane = true; - addTokenToPostfix(Token.string, key); - } else { - returnToken(); - } - } else if (tok == Token.coord || tok == Token.plane) { + } else if (tok == Token.hkl || tok == Token.coord || tok == Token.plane) { isCoordOrPlane = true; addNextToken(); } else if (tok == Token.leftbrace) { Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-01-02 21:10:20 UTC (rev 12018) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-01-02 21:56:27 UTC (rev 12019) @@ -2915,6 +2915,11 @@ case Token.define: rpn.addX(getAtomBitSet(this, (String) value)); break; + case Token.hkl: + rpn.addX(new ScriptVariable(instruction)); + rpn.addX(new ScriptVariable(Token.point4f, hklParameter(pc + 2))); + pc = iToken; + break; case Token.plane: rpn.addX(new ScriptVariable(instruction)); rpn.addX(new ScriptVariable(Token.point4f, planeParameter(pc + 2))); @@ -3192,7 +3197,7 @@ rpn.addOp(instruction); break; } - if (Token.tokAttr(instruction.tok, Token.identifier)) { + if (instruction.tok == Token.identifier) { val = getParameter((String) value, false); if (val instanceof String) val = getStringObjectAsVariable((String) val, null); Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-01-02 21:10:20 UTC (rev 12018) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-01-02 21:56:27 UTC (rev 12019) @@ -118,7 +118,8 @@ if (x == null) x = xStack[0]; if (x.tok == Token.bitset || x.tok == Token.list - || x.tok == Token.string || x.tok == Token.matrix3f || x.tok == Token.matrix4f) + || x.tok == Token.string || x.tok == Token.matrix3f + || x.tok == Token.matrix4f) x = ScriptVariable.selectItem(x); return x; } @@ -184,7 +185,7 @@ break; case Token.decimal: float f = ((Float) x.value).floatValue(); - if (f < 0 || f == 0 && 1/f == Float.NEGATIVE_INFINITY) { + if (f < 0 || f == 0 && 1 / f == Float.NEGATIVE_INFINITY) { addOp(Token.tokenMinus); x = new ScriptVariable(Token.decimal, new Float(-f)); } @@ -195,8 +196,7 @@ } private boolean addX(boolean x) { - putX(ScriptVariable.getVariable(x ? Boolean.TRUE - : Boolean.FALSE)); + putX(ScriptVariable.getVariable(x ? Boolean.TRUE : Boolean.FALSE)); return wasX = true; } @@ -449,7 +449,7 @@ boolean isFirst = ScriptVariable.bValue(getX()); if (tok0 == Token.colon) ifPt--; - else + else putOp(Token.tokenColon); putIf(isFirst ? 'T' : 'F'); skipping = !isFirst; @@ -643,7 +643,7 @@ return evaluateHelix(args); case Token.label: case Token.format: - return evaluateLabel(op.intValue, args); + return evaluateLabel(op.intValue, args); case Token.data: return evaluateData(args); case Token.load: @@ -679,10 +679,11 @@ if (x1.tok != Token.bitset) return false; String type = (args.length == 0 ? null : ScriptVariable.sValue(args[0])); - return addX(viewer.getVolume((BitSet)x1.value, type)); + return addX(viewer.getVolume((BitSet) x1.value, type)); } - private boolean evaluateSymop(ScriptVariable[] args, boolean haveBitSet) throws ScriptException { + private boolean evaluateSymop(ScriptVariable[] args, boolean haveBitSet) + throws ScriptException { if (args.length == 0) return false; ScriptVariable x1 = (haveBitSet ? getX() : null); @@ -690,9 +691,9 @@ return addX(new Point3f()); if (x1 != null && x1.tok != Token.bitset) return false; - BitSet bs = (x1 != null ? (BitSet) x1.value - : args.length > 2 && args[1].tok == Token.bitset ? (BitSet) args[1].value - : viewer.getModelAtomBitSet(-1, false)); + BitSet bs = (x1 != null ? (BitSet) x1.value : args.length > 2 + && args[1].tok == Token.bitset ? (BitSet) args[1].value : viewer + .getModelAtomBitSet(-1, false)); String xyz; switch (args[0].tok) { case Token.string: @@ -708,7 +709,8 @@ Point3f pt = (args.length > 1 ? ptValue(args[1], true) : null); if (args.length == 2 && !Float.isNaN(pt.x)) return addX(viewer.getSymmetryInfo(bs, xyz, iOp, pt, null, Token.point)); - String desc = (args.length == 1 ? "" : ScriptVariable.sValue(args[args.length - 1])).toLowerCase(); + String desc = (args.length == 1 ? "" : ScriptVariable + .sValue(args[args.length - 1])).toLowerCase(); int tok = Token.draw; if (args.length == 1 || desc.equalsIgnoreCase("matrix")) { tok = Token.matrix4f; @@ -717,7 +719,7 @@ } else if (desc.equalsIgnoreCase("description")) { tok = Token.label; } else if (desc.equalsIgnoreCase("xyz")) { - tok = Token.info; + tok = Token.info; } else if (desc.equalsIgnoreCase("translation")) { tok = Token.translation; } else if (desc.equalsIgnoreCase("axis")) { @@ -730,7 +732,7 @@ tok = Token.point; } else if (desc.equalsIgnoreCase("center")) { tok = Token.center; - } + } return addX(viewer.getSymmetryInfo(bs, xyz, iOp, pt, desc, tok)); } @@ -794,7 +796,8 @@ case Token.monitor: return addX(Measure.computeHelicalAxis(null, t.tok, pta, ptb, dq)); case Token.array: - String[] data = (String[]) Measure.computeHelicalAxis(null, Token.list, pta, ptb, dq); + String[] data = (String[]) Measure.computeHelicalAxis(null, Token.list, + pta, ptb, dq); if (data == null) return false; return addX(data); @@ -820,8 +823,8 @@ Token.angle)).floatValue()); case Token.draw: case Token.monitor: - return addX(isSyntaxCheck ? "" : (String) viewer.getHelixData(bs, - t.tok)); + return addX(isSyntaxCheck ? "" : (String) viewer + .getHelixData(bs, t.tok)); case Token.array: String[] data = (String[]) viewer.getHelixData(bs, Token.list); if (data == null) @@ -867,7 +870,8 @@ return addX(Measure.distanceToPlane(plane1, pt2)); } - public Point3f ptValue(ScriptVariable x, boolean allowFloat) throws ScriptException { + public Point3f ptValue(ScriptVariable x, boolean allowFloat) + throws ScriptException { Object pt; if (isSyntaxCheck) return new Point3f(); @@ -1025,7 +1029,7 @@ String propertyName = (args.length > pt ? ScriptVariable.sValue(args[pt++]) .toLowerCase() : ""); if (propertyName.startsWith("$")) { -//TODO + // TODO } Object propertyValue; if (propertyName.equalsIgnoreCase("fileContents") && args.length > 2) { @@ -1334,7 +1338,7 @@ return false; } - + private boolean evaluateArray(ScriptVariable[] args) { if (isSyntaxCheck) return addX(""); @@ -1393,8 +1397,8 @@ case 4: break; case 2: - if ((pt0 = ptValue(args[0], false)) == null - || tok != Token.quaternion && args[1].tok == Token.point3f) + if ((pt0 = ptValue(args[0], false)) == null || tok != Token.quaternion + && args[1].tok == Token.point3f) return false; break; case 3: @@ -1531,9 +1535,10 @@ if (isSyntaxCheck) return addX(""); String file = ScriptVariable.sValue(args[0]); - int nBytesMax = (args.length == 2 ? ScriptVariable.iValue(args[1]) : Integer.MAX_VALUE); - return addX(tok == Token.load ? viewer.getFileAsString(file, nBytesMax, false) : viewer - .getFullPath(file)); + int nBytesMax = (args.length == 2 ? ScriptVariable.iValue(args[1]) + : Integer.MAX_VALUE); + return addX(tok == Token.load ? viewer.getFileAsString(file, nBytesMax, + false) : viewer.getFullPath(file)); } private boolean evaluateWrite(ScriptVariable[] args) throws ScriptException { @@ -1649,13 +1654,13 @@ // {xxx}.yyy.format("...") // (value).format("...") // format("....",a,b,c...) - + ScriptVariable x1 = (args.length < 2 ? getX() : null); if (isSyntaxCheck) return addX(""); String format = (args.length == 0 ? "%U" : ScriptVariable.sValue(args[0])); boolean asArray = Token.tokAttr(intValue, Token.minmaxmask); - if (x1 == null) + if (x1 == null) return addX(ScriptVariable.sprintf(args)); if (x1.tok == Token.bitset) return addX(eval.getBitsetIdent(ScriptVariable.bsSelect(x1), format, @@ -1702,9 +1707,10 @@ switch (i) { case 1: // within (boundbox) - boolean isHelix = withinStr.equalsIgnoreCase("helix"); + boolean isHelix = withinStr.equalsIgnoreCase("helix"); if (isHelix || withinStr.equalsIgnoreCase("sheet")) - return addX(isSyntaxCheck ? bs : viewer.getAtomBits(isHelix ? Token.helix : Token.sheet, null)); + return addX(isSyntaxCheck ? bs : viewer.getAtomBits( + isHelix ? Token.helix : Token.sheet, null)); return (!withinStr.equalsIgnoreCase("boundbox") ? false : addX(isSyntaxCheck ? bs : viewer.getAtomBits(Token.boundbox, null))); case 2: @@ -1767,7 +1773,7 @@ * * the first returns an atom bitset; the second returns a bond bitset. */ - + if (args.length > 5) return false; float min = Integer.MIN_VALUE, max = Integer.MAX_VALUE; @@ -2055,14 +2061,14 @@ case Token.integer: switch (x2.tok) { case Token.string: - if ((s = (ScriptVariable.sValue(x2)).trim()).indexOf(".") < 0 - && s.indexOf("+") <= 0 && s.lastIndexOf("-") <= 0) - return addX(x1.intValue + ScriptVariable.iValue(x2)); - break; + if ((s = (ScriptVariable.sValue(x2)).trim()).indexOf(".") < 0 + && s.indexOf("+") <= 0 && s.lastIndexOf("-") <= 0) + return addX(x1.intValue + ScriptVariable.iValue(x2)); + break; case Token.decimal: return addX(x1.intValue + ScriptVariable.fValue(x2)); default: - return addX(x1.intValue + ScriptVariable.iValue(x2)); + return addX(x1.intValue + ScriptVariable.iValue(x2)); } case Token.string: return addX(new ScriptVariable(Token.string, ScriptVariable.sValue(x1) @@ -2090,18 +2096,18 @@ float f = ScriptVariable.fValue(x2); return addX(new Point3f(pt.x + f, pt.y + f, pt.z + f)); } - case Token.matrix3f: + case Token.matrix3f: switch (x2.tok) { default: return addX(ScriptVariable.fValue(x1) + ScriptVariable.fValue(x2)); case Token.matrix3f: - m = new Matrix3f((Matrix3f)x1.value); - m.add((Matrix3f)x2.value); + m = new Matrix3f((Matrix3f) x1.value); + m.add((Matrix3f) x2.value); return addX(m); case Token.point3f: Matrix4f m4 = new Matrix4f(); - m = (Matrix3f)x1.value; - pt = (Point3f)x2.value; + m = (Matrix3f) x1.value; + pt = (Point3f) x2.value; m4.m00 = m.m00; m4.m01 = m.m01; m4.m02 = m.m02; @@ -2135,22 +2141,22 @@ switch (x1.tok) { default: return addX(ScriptVariable.fValue(x1) - ScriptVariable.fValue(x2)); - case Token.matrix3f: + case Token.matrix3f: switch (x2.tok) { default: return addX(ScriptVariable.fValue(x1) - ScriptVariable.fValue(x2)); case Token.matrix3f: - m = new Matrix3f((Matrix3f)x1.value); - m.sub((Matrix3f)x2.value); + m = new Matrix3f((Matrix3f) x1.value); + m.sub((Matrix3f) x2.value); return addX(m); } - case Token.matrix4f: + case Token.matrix4f: switch (x2.tok) { default: return addX(ScriptVariable.fValue(x1) - ScriptVariable.fValue(x2)); case Token.matrix4f: - Matrix4f m4 = new Matrix4f((Matrix4f)x1.value); - m4.sub((Matrix4f)x2.value); + Matrix4f m4 = new Matrix4f((Matrix4f) x1.value); + m4.sub((Matrix4f) x2.value); return addX(m4); } case Token.point3f: @@ -2266,8 +2272,8 @@ return addX(m); case Token.point4f: // m * q - return addX((new Quaternion(m3)).mul(new Quaternion( - (Point4f) x2.value)).getMatrix()); + return addX((new Quaternion(m3)).mul( + new Quaternion((Point4f) x2.value)).getMatrix()); default: float f = ScriptVariable.fValue(x2); AxisAngle4f aa = new AxisAngle4f(); @@ -2568,8 +2574,8 @@ private static Object getMinMax(Object floatOrStringArray, int tok) { float[] data; if (floatOrStringArray instanceof String[]) { - data = new float[((String[])floatOrStringArray).length]; - Parser.parseFloatArray((String[])floatOrStringArray, data); + data = new float[((String[]) floatOrStringArray).length]; + Parser.parseFloatArray((String[]) floatOrStringArray, data); } else { data = (float[]) floatOrStringArray; } @@ -2586,16 +2592,16 @@ } double sum2 = 0; int n = 0; - for (int i = data.length; --i >= 0; ) { + for (int i = data.length; --i >= 0;) { float v; if (Float.isNaN(v = data[i])) continue; n++; - switch(tok){ + switch (tok) { case Token.sum2: case Token.stddev: sum2 += ((double) v) * v; - //fall through + // fall through case Token.sum: case Token.average: sum += v; Modified: trunk/Jmol/src/org/jmol/script/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/script/Token.java 2010-01-02 21:10:20 UTC (rev 12018) +++ trunk/Jmol/src/org/jmol/script/Token.java 2010-01-02 21:56:27 UTC (rev 12019) @@ -598,7 +598,7 @@ public final static int angle = 7 | 0 << 9 | mathfunc; public final static int data = 8 | 0 << 9 | mathfunc | scriptCommand; - public final static int plane = 9 | 0 << 9 | mathfunc; + public final static int plane = 9 | 0 << 9 | mathfunc; public final static int point = 10 | 0 << 9 | mathfunc; final static int quaternion = 11 | 0 << 9 | mathfunc | scriptCommand; final static int axisangle = 12 | 0 << 9 | mathfunc; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-01-02 21:10:20 UTC (rev 12018) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-01-02 21:56:27 UTC (rev 12019) @@ -3,6 +3,7 @@ version=11.9.14_dev +# bug fix: select within(0.3, hkl, {1 2 3}) requires "hkl" # new feature: write PMESH creates XJVXL file # new feature: getproperty "shapeInfo.isosurface[1].xyzMin" # new feature: getproperty "shapeInfo.isosurface[1].xyzMax" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |