From: <ha...@us...> - 2010-01-13 00:29:21
|
Revision: 12108 http://jmol.svn.sourceforge.net/jmol/?rev=12108&view=rev Author: hansonr Date: 2010-01-13 00:29:14 +0000 (Wed, 13 Jan 2010) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/Measurement.java trunk/Jmol/src/org/jmol/modelset/MeasurementData.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/shape/Measures.java Modified: trunk/Jmol/src/org/jmol/modelset/Measurement.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Measurement.java 2010-01-12 23:33:38 UTC (rev 12107) +++ trunk/Jmol/src/org/jmol/modelset/Measurement.java 2010-01-13 00:29:14 UTC (rev 12108) @@ -360,8 +360,6 @@ private boolean sameAs(int[] atoms, Point3fi[] points, int i, int j) { int ipt = countPlusIndices[i]; int jpt = atoms[j]; - if (jpt < 0 && points[-2-jpt] == null) - System.out.println("measurement -- ohoh"); return (ipt >= 0 || jpt >= 0 ? ipt == jpt : this.pts[-2 - ipt].distance(points[-2 - jpt]) < 0.01); } Modified: trunk/Jmol/src/org/jmol/modelset/MeasurementData.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/MeasurementData.java 2010-01-12 23:33:38 UTC (rev 12107) +++ trunk/Jmol/src/org/jmol/modelset/MeasurementData.java 2010-01-13 00:29:14 UTC (rev 12108) @@ -45,6 +45,7 @@ private Atom[] atoms; private int atomCount; public boolean mustBeConnected; + public boolean mustNotBeConnected; public TickInfo tickInfo; public int tokAction; public Vector points; @@ -61,7 +62,8 @@ public MeasurementData(Vector points, int tokAction, float[] rangeMinMax, String strFormat, String units, TickInfo tickInfo, - boolean mustBeConnected, boolean isAll) { + boolean mustBeConnected, boolean mustNotBeConnected, + boolean isAll) { this.tokAction = tokAction; this.points = points; this.rangeMinMax = rangeMinMax; @@ -69,6 +71,7 @@ this.units = units; this.tickInfo = tickInfo; this.mustBeConnected = mustBeConnected; + this.mustNotBeConnected = mustNotBeConnected; this.isAll = isAll; } @@ -134,11 +137,14 @@ Measurement m = new Measurement(modelSet, indices, pts, null); m.setCount(nPoints); int ptLastAtom = -1; - BitSet bs; for (int i = 0; i < nPoints; i++) { Object obj = points.get(i); if (obj instanceof BitSet) { - if (BitSetUtil.cardinalityOf((bs = (BitSet) obj)) > 1) + BitSet bs = (BitSet) obj; + int nAtoms = BitSetUtil.cardinalityOf(bs); + if (nAtoms == 0) + return; + if (nAtoms > 1) modelIndex = 0; ptLastAtom = i; indices[i + 1] = BitSetUtil.firstSetBit(bs); @@ -162,7 +168,9 @@ */ private void nextMeasure(int thispt, int ptLastAtom, Measurement m, int thisModel ) { if (thispt > ptLastAtom) { - if (m.isValid() && (!mustBeConnected || m.isConnected(atoms, thispt))) + if (m.isValid() + && (!mustBeConnected || m.isConnected(atoms, thispt)) + && (!mustNotBeConnected || !m.isConnected(atoms, thispt))) client.processNextMeasure(m); return; } Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-01-12 23:33:38 UTC (rev 12107) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-01-13 00:29:14 UTC (rev 12108) @@ -7048,6 +7048,7 @@ float[] rangeMinMax = new float[] { Float.MAX_VALUE, Float.MAX_VALUE }; boolean isAll = false; boolean isAllConnected = false; + boolean isNotConnected = false; boolean isRange = true; int tokAction = Token.opToggle; String strFormat = null; @@ -7058,14 +7059,23 @@ for (int i = 1; i < statementLength; ++i) { switch (getToken(i).tok) { case Token.identifier: - error(ERROR_keywordExpected, "ALL, ALLCONNECTED, DELETE"); + error(ERROR_keywordExpected, "ALL, ALLCONNECTED, DELETE"); default: error(ERROR_expressionOrIntegerExpected); + case Token.opNot: + if (tokAt(i + 1) != Token.connected) + error(ERROR_invalidArgument); + i++; + isNotConnected = true; + break; + case Token.connected: case Token.allconnected: case Token.all: isAllConnected = (theTok == Token.allconnected); atomIndex = -1; isAll = true; + if (isAllConnected && isNotConnected) + error(ERROR_invalidArgument); break; case Token.decimal: isAll = true; @@ -7138,7 +7148,7 @@ } if (value instanceof Point3f) { Point3fi v = new Point3fi(); - v.set((Point3f)value); + v.set((Point3f) value); v.modelIndex = (short) modelIndex; value = v; } @@ -7163,15 +7173,10 @@ if (value != null || tickInfo != null) { if (value == null) tickInfo.id = "default"; - setShapeProperty(JmolConstants.SHAPE_MEASURES, "measure", new MeasurementData( - points, - tokAction, - rangeMinMax, - strFormat, null, - tickInfo, - isAllConnected, - isAll)); - return; + setShapeProperty(JmolConstants.SHAPE_MEASURES, "measure", + new MeasurementData(points, tokAction, rangeMinMax, strFormat, null, + tickInfo, isAllConnected, isNotConnected, isAll)); + return; } switch (tokAction) { case Token.delete: Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-01-12 23:33:38 UTC (rev 12107) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-01-13 00:29:14 UTC (rev 12108) @@ -931,19 +931,24 @@ // measure({a},{b}, min, max, format, units) // measure({a},{b},{c},{d}, min, max, format, units) Vector points = new Vector(); - float[] rangeMinMax = new float[] {Float.MAX_VALUE, Float.MAX_VALUE} ; + float[] rangeMinMax = new float[] { Float.MAX_VALUE, Float.MAX_VALUE }; String strFormat = null; String units = null; boolean isAllConnected = false; + boolean isNotConnected = false; int rPt = 0; + boolean isNull = false; for (int i = 0; i < args.length; i++) { switch (args[i].tok) { case Token.bitset: - points.add(args[i].value); + BitSet bs = (BitSet) args[i].value; + if (!isSyntaxCheck && BitSetUtil.firstSetBit(bs) < 0) + isNull = true; + points.add(bs); nPoints++; break; case Token.point3f: - Point3fi v = new Point3fi((Point3f)args[i].value); + Point3fi v = new Point3fi((Point3f) args[i].value); points.add(v); nPoints++; break; @@ -955,9 +960,12 @@ break; case Token.string: String s = ScriptVariable.sValue(args[i]); - if (s.equalsIgnoreCase("connected")) + if (s.equalsIgnoreCase("notConnected")) + isNotConnected = true; + else if (s.equalsIgnoreCase("connected")) isAllConnected = true; - else if (Parser.isOneOf(s.toLowerCase(), "nm;nanometers;pm;picometers;angstroms;ang;au")) + else if (Parser.isOneOf(s.toLowerCase(), + "nm;nanometers;pm;picometers;angstroms;ang;au")) units = s.toLowerCase(); else strFormat = nPoints + ":" + s; @@ -966,27 +974,22 @@ return false; } } - if (nPoints < 2 || nPoints > 4 || rPt > 2) + if (nPoints < 2 || nPoints > 4 || rPt > 2 || isNotConnected + && isAllConnected) return false; - if (isSyntaxCheck) + if (isSyntaxCheck || isNull) return addX(""); - MeasurementData md = new MeasurementData( - points, - 0, - rangeMinMax, - strFormat, units, - null, - isAllConnected, - true); + MeasurementData md = new MeasurementData(points, 0, rangeMinMax, + strFormat, units, null, isAllConnected, isNotConnected, true); return addX(md.getMeasurements(viewer)); case Token.angle: - if ((nPoints = args.length ) != 3 && nPoints != 4) + if ((nPoints = args.length) != 3 && nPoints != 4) return false; break; default: // distance - if ((nPoints = args.length ) != 2) + if ((nPoints = args.length) != 2) return false; - } + } if (isSyntaxCheck) return addX(1f); Modified: trunk/Jmol/src/org/jmol/shape/Measures.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/Measures.java 2010-01-12 23:33:38 UTC (rev 12107) +++ trunk/Jmol/src/org/jmol/shape/Measures.java 2010-01-13 00:29:14 UTC (rev 12108) @@ -47,7 +47,8 @@ private BitSet bsColixSet; private BitSet bsSelected; private String strFormat; - private boolean isAllConnected = false; + private boolean mustBeConnected = false; + private boolean mustNotBeConnected = false; private float[] rangeMinMax = {Float.MAX_VALUE, Float.MAX_VALUE}; private Atom[] atoms; @@ -157,7 +158,8 @@ } rangeMinMax[0] = md.rangeMinMax[0]; rangeMinMax[1] = md.rangeMinMax[1]; - isAllConnected = md.mustBeConnected; + mustBeConnected = md.mustBeConnected; + mustNotBeConnected = md.mustNotBeConnected; strFormat = md.strFormat; if (md.isAll) { if (tickInfo != null) @@ -404,7 +406,8 @@ rangeMinMax, strFormat, null, tickInfo, - isAllConnected, + mustBeConnected, + mustNotBeConnected, true); define(md, (isDelete ? Token.delete : 0)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |