Revision: 20869 http://sourceforge.net/p/jmol/code/20869 Author: hansonr Date: 2015-11-27 11:57:16 +0000 (Fri, 27 Nov 2015) Log Message: ----------- Jmol.___JmolVersion="14.5.0_2015.11.27"
bug fix: {atomset}.split() [split atomset by model] returns array of strings, not array of atoms code: BSUtil.cardinalityOf cleanup. Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/ModelSet.java trunk/Jmol/src/org/jmol/script/SV.java trunk/Jmol/src/org/jmol/script/ScriptExpr.java trunk/Jmol/src/org/jmol/scriptext/CmdExt.java trunk/Jmol/src/org/jmol/scriptext/MathExt.java trunk/Jmol/src/org/jmol/shape/Measures.java trunk/Jmol/src/org/jmol/shapespecial/Dipoles.java trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/symmetry/PointGroup.java trunk/Jmol/src/org/jmol/util/TriangleData.java trunk/Jmol/src/org/jmol/viewer/AnimationManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/PropertyManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/modelset/ModelSet.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelSet.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/modelset/ModelSet.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -667,7 +667,7 @@ // full models are deleted for any model containing the specified atoms includeAllRelatedFrames(bsModels); - int nModelsDeleted = BSUtil.cardinalityOf(bsModels); + int nModelsDeleted = bsModels.cardinality(); if (nModelsDeleted == 0) return null; @@ -1309,14 +1309,14 @@ ptCenter.add(at[i]); } } - if (nPoints > 0) + if (nPoints > 1) ptCenter.scale(1.0f / nPoints); return ptCenter; } public P3 getAverageAtomPoint() { if (averageAtomPoint == null) - (averageAtomPoint = new P3()).setT(getAtomSetCenter(vwr.getAllAtoms())); + averageAtomPoint = getAtomSetCenter(vwr.getAllAtoms()); return averageAtomPoint; } @@ -2709,7 +2709,7 @@ + " pseudo-hbond calculation"); calcRasmolHydrogenBonds(bsA, bsB, null, false, Integer.MAX_VALUE, false, bsHBonds); - return -BSUtil.cardinalityOf(bsHBonds); + return -bsHBonds.cardinality(); } Logger.info(haveHAtoms ? "Standard Hbond calculation" : "Jmol pseudo-hbond calculation"); Modified: trunk/Jmol/src/org/jmol/script/SV.java =================================================================== --- trunk/Jmol/src/org/jmol/script/SV.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/script/SV.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -122,7 +122,7 @@ static int sizeOf(T x) { switch (x == null ? nada : x.tok) { case bitset: - return BSUtil.cardinalityOf(bsSelectToken(x)); + return bsSelectToken(x).cardinality(); case on: case off: return -1; @@ -549,7 +549,7 @@ // case matrix4f: return (int) fValue(x); case bitset: - return BSUtil.cardinalityOf(bsSelectToken(x)); + return bsSelectToken(x).cardinality(); case barray: return ((BArray) x.value).data.length; default: @@ -881,10 +881,10 @@ if (tokenIn.value instanceof BondSet) { bs = BondSet.newBS((BS) tokenIn.value, ((BondSet) tokenIn.value).associatedAtoms); - len = BSUtil.cardinalityOf(bs); + len = bs.cardinality(); } else { bs = BSUtil.copy((BS) tokenIn.value); - len = (isInputSelected ? 1 : BSUtil.cardinalityOf(bs)); + len = (isInputSelected ? 1 : bs.cardinality()); } break; case barray: Modified: trunk/Jmol/src/org/jmol/script/ScriptExpr.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptExpr.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/script/ScriptExpr.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -298,7 +298,7 @@ // are there for now that require it; could go, though. BS bsSelect = new BS(); BS bsX = new BS(); - String[] sout = (isFor ? new String[BSUtil.cardinalityOf(bsAtoms)] + String[] sout = (isFor ? new String[bsAtoms.cardinality()] : null); if (localVars == null) localVars = new Hashtable<String, SV>(); @@ -2248,7 +2248,7 @@ private void setBitsetProperty(BS bs, int tok, int iValue, float fValue, T tokenValue) throws ScriptException { - if (chk || BSUtil.cardinalityOf(bs) == 0) + if (chk || bs.cardinality() == 0) return; String[] list = null; String sValue = null; Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -276,7 +276,7 @@ LabelToken[] tokens = (asIdentity ? null : isAtoms ? labeler.compile( vwr, label, '\0', null) : labeler.compile(vwr, label, '\1', htValues)); - int nmax = (haveIndex ? 1 : BSUtil.cardinalityOf(bs)); + int nmax = (haveIndex ? 1 : bs.cardinality()); String[] sout = new String[nmax]; P3 ptTemp = new P3(); for (int j = (haveIndex ? index : bs.nextSetBit(0)); j >= 0; j = bs @@ -4790,7 +4790,7 @@ switch (tokAt(++i)) { case T.bitset: case T.expressionBegin: - pt = P3.newP(vwr.ms.getAtomSetCenter(atomExpressionAt(i))); + pt = vwr.ms.getAtomSetCenter(atomExpressionAt(i)); vwr.toFractional(pt, true); i = eval.iToken; break; Modified: trunk/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -2883,15 +2883,14 @@ case T.split: if (x.tok == T.bitset) { BS bsSelected = SV.bsSelectVar(x); - sArg = "\n"; int modelCount = vwr.ms.mc; - s = ""; + Lst<SV> lst = new Lst<SV>(); for (int i = 0; i < modelCount; i++) { - s += (i == 0 ? "" : "\n"); BS bs = vwr.getModelUndeletedAtomsBitSet(i); bs.and(bsSelected); - s += Escape.eBS(bs); + lst.addLast(SV.getVariable(bs)); } + return mp.addXList(lst); } return mp.addXAS(PT.split(s, sArg)); case T.join: @@ -3372,7 +3371,7 @@ private BS getAtomsNearPts(float distance, T3[] points, BS bsInclude) { BS bsResult = new BS(); - if (points.length == 0 || bsInclude != null && bsInclude.cardinality() == 0) + if (points.length == 0 || bsInclude != null && bsInclude.isEmpty()) return bsResult; if (bsInclude == null) bsInclude = BSUtil.setAll(points.length); Modified: trunk/Jmol/src/org/jmol/shape/Measures.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/Measures.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/shape/Measures.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -140,7 +140,7 @@ if ("select" == propertyName) { BS bs = (BS) value; - if (bs == null || BSUtil.cardinalityOf(bs) == 0) { + if (BSUtil.cardinalityOf(bs) == 0) { bsSelected = null; } else { bsSelected = new BS(); Modified: trunk/Jmol/src/org/jmol/shapespecial/Dipoles.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Dipoles.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/shapespecial/Dipoles.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -227,7 +227,7 @@ endCoord = null; startCoord = ms.getAtomSetCenter(bsAtoms); tempDipole.set2Value(startCoord, P3.new3(0, 0, 0), dipoleValue); - if (BSUtil.cardinalityOf(bsAtoms) == 1) + if (bsAtoms.cardinality() == 1) atomIndex1 = bsAtoms.nextSetBit(0); return; } @@ -248,7 +248,7 @@ if ("endSet" == propertyName) { iHaveTwoEnds = true; BS atomset = (BS) value; - if (atomIndex1 >= 0 && BSUtil.cardinalityOf(atomset) == 1) { + if (atomIndex1 >= 0 && atomset.cardinality() == 1) { atomIndex2 = atomset.nextSetBit(0); tempDipole.set2AtomValue(ms.at[atomIndex1], ms.at[atomIndex2], 1); currentDipole = findDipoleFor(tempDipole.thisID, tempDipole.dipoleInfo); Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -358,13 +358,6 @@ return; } - if ("coords" == propertyName) { - Lst<SV> pts = (Lst<SV>) value; - for (int i = 0, n = pts.size(); i < n; i++) - vData.addLast(new Object[] { Integer.valueOf(PT_COORD), SV.ptValue(pts.get(i)) }); - return; - } - if ("offset" == propertyName) { offset = V3.newV((P3) value); if (thisMesh != null) @@ -373,9 +366,9 @@ } if ("atomSet" == propertyName) { - if (BSUtil.cardinalityOf((BS) value) == 0) + BS bsAtoms = (BS) value; + if (bsAtoms.isEmpty()) return; - BS bsAtoms = (BS) value; vData.addLast(new Object[] { Integer.valueOf(PT_BITSET), bsAtoms }); //nbitsets++; if (isCircle && diameter == 0 && width == 0) @@ -383,9 +376,13 @@ return; } + if ("coords" == propertyName) { + addPoints(PT_COORD, value, false); + return; + } + if ("modelBasedPoints" == propertyName) { - vData.addLast(new Object[] { Integer.valueOf(PT_MODEL_BASED_POINTS), - value }); + addPoints(PT_MODEL_BASED_POINTS, value, true); return; } @@ -419,7 +416,27 @@ setPropertySuper(propertyName, value, bs); } - private void deleteModels(int modelIndex) { + private void addPoints(int type, Object value, boolean allowNull) { + @SuppressWarnings("unchecked") + Lst<SV> pts = (Lst<SV>) value; + Integer key = Integer.valueOf(type); + for (int i = 0, n = pts.size(); i < n; i++) { + SV v = pts.get(i); + P3 pt; + switch (v.tok) { + case T.bitset: + if (!allowNull && ((BS) v.value).isEmpty()) + continue; + pt = vwr.ms.getAtomSetCenter((BS) v.value); + break; + default: + pt = SV.ptValue(v); + } + vData.addLast(new Object[] { key, pt }); + } + } + +private void deleteModels(int modelIndex) { //int firstAtomDeleted = ((int[])((Object[])value)[2])[1]; //int nAtomsDeleted = ((int[])((Object[])value)[2])[2]; for (int i = meshCount; --i >= 0;) { @@ -1034,7 +1051,7 @@ return; } - protected void scale(Mesh mesh, float newScale) { + private void scale(Mesh mesh, float newScale) { DrawMesh dmesh = (DrawMesh) mesh; /* * allows for Draw to scale object @@ -1149,7 +1166,7 @@ T3 v = pickedMesh.vs[pickedMesh.pis[pickedModel][pickedVertex]]; int modelIndex = pickedMesh.modelIndex; BS bs = ((DrawMesh) pickedMesh).modelFlags; - if (modelIndex < 0 && bs != null && BSUtil.cardinalityOf(bs) == 1) + if (modelIndex < 0 && BSUtil.cardinalityOf(bs) == 1) modelIndex = bs.nextSetBit(0); Map<String, Object> map = null; if (action != 0) @@ -1323,7 +1340,7 @@ return (pickedMesh != null); } - protected String getCommand(Mesh mesh) { + private String getCommand(Mesh mesh) { if (mesh != null) return getCommand2(mesh, mesh.modelIndex); @@ -1339,7 +1356,7 @@ return sb.toString(); } - protected String getCommand2(Mesh mesh, int iModel) { + private String getCommand2(Mesh mesh, int iModel) { DrawMesh dmesh = (DrawMesh) mesh; if (!dmesh.isValid || dmesh.drawType == EnumDrawType.NONE Modified: trunk/Jmol/src/org/jmol/symmetry/PointGroup.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/PointGroup.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/symmetry/PointGroup.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -393,7 +393,7 @@ private final static int ATOM_COUNT_MAX = 100; private boolean getPointsAndElements(T3[] atomset) { - int ac = BSUtil.cardinalityOf(bsAtoms); + int ac = bsAtoms.cardinality(); if (isAtoms && ac > ATOM_COUNT_MAX) return false; points = new P3[ac]; Modified: trunk/Jmol/src/org/jmol/util/TriangleData.java =================================================================== --- trunk/Jmol/src/org/jmol/util/TriangleData.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/util/TriangleData.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -357,7 +357,7 @@ i++; } //System.out.println(); - int nPoints = BSUtil.cardinalityOf(bsPoints); + int nPoints = bsPoints.cardinality(); P3[] pts = new P3[nPoints]; v.addLast(pts); int[]list = new int[12]; Modified: trunk/Jmol/src/org/jmol/viewer/AnimationManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/AnimationManager.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/viewer/AnimationManager.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -173,7 +173,7 @@ } void setDisplay(BS bs) { - bsDisplay = (bs == null || bs.cardinality() == 0? null : BSUtil.copy(bs)); + bsDisplay = (bs == null || bs.isEmpty() ? null : BSUtil.copy(bs)); } public void setMorphCount(int n) { Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-11-27 11:57:16 UTC (rev 20869) @@ -62,8 +62,13 @@ TODO: consider if models with no atoms will cause issues in relation to model.firstAtomIndex -Jmol.___JmolVersion="14.5.0_2015.11.26" +Jmol.___JmolVersion="14.5.0_2015.11.27" +bug fix: {atomset}.split() [split atomset by model] returns array of strings, not array of atoms +code: BSUtil.cardinalityOf cleanup. + +JmolVersion="14.5.0_2015.11.26" + bug fix: getproperty SHAPEINFO fails if CGO is present bug fix: CGO from state deletes DRAW objects bug fix: CGO not properly isolated to current model; "fixed" not implemented Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -976,8 +976,7 @@ if (m.modelSetProperties != null) { info.put("modelSetProperties", m.modelSetProperties); } - info.put("modelCountSelected", Integer.valueOf(BSUtil - .cardinalityOf(bsModels))); + info.put("modelCountSelected", Integer.valueOf(bsModels.cardinality())); info.put("modelsSelected", bsModels); Lst<Map<String, Object>> vModels = new Lst<Map<String, Object>>(); m.getMolecules(); @@ -1186,7 +1185,7 @@ if (doTransform && atoms[i].isDeleted()) bsAtoms.clear(i); BS bsBonds = getCovalentBondsForAtoms(ms.bo, ms.bondCount, bsAtoms); - if (!asXYZVIB && bsAtoms.cardinality() == 0) + if (!asXYZVIB && bsAtoms.isEmpty()) return ""; boolean isOK = true; BS bsModels = vwr.ms.getModelBS(bsAtoms, true); @@ -1217,7 +1216,7 @@ .nextSetBit(i + 1)) { BS bsTemp = BSUtil.copy(bsAtoms); bsTemp.and(ms.getModelAtomBitSetIncludingDeleted(i, false)); - if (bsTemp.cardinality() == 0) + if (bsTemp.isEmpty()) continue; mol.appendI(bsTemp.cardinality()).appendC('\n'); Properties props = ms.am[i].properties; @@ -2290,7 +2289,7 @@ public String getModelCml(BS bs, int atomsMax, boolean addBonds, boolean doTransform, boolean allTrajectories) { // not allowing full trajectory business here. SB sb = new SB(); - int nAtoms = BSUtil.cardinalityOf(bs); + int nAtoms = bs.cardinality(); if (nAtoms == 0) return ""; // creating an instance prevents pre-loading by JavaScript Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-11-26 16:34:25 UTC (rev 20868) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-11-27 11:57:16 UTC (rev 20869) @@ -7381,7 +7381,7 @@ } public void setAtomCoords(BS bs, int tokType, Object xyzValues) { - if (bs.cardinality() == 0) + if (bs.isEmpty()) return; ms.setAtomCoords(bs, tokType, xyzValues); checkMinimization(); @@ -7392,7 +7392,7 @@ // Eval if (bs == null) bs = bsA(); - if (bs.cardinality() == 0) + if (bs.isEmpty()) return; ms.setAtomCoordsRelative(offset, bs); checkMinimization(); @@ -7415,7 +7415,7 @@ public void invertSelected(P3 pt, P4 plane, int iAtom, BS invAtoms) { // Eval BS bs = bsA(); - if (bs.cardinality() == 0) + if (bs.isEmpty()) return; ms.invertSelected(pt, plane, iAtom, invAtoms, bs); checkMinimization(); @@ -7425,7 +7425,7 @@ public void moveAtoms(M4 m4, M3 mNew, M3 rotation, V3 translation, P3 center, boolean isInternal, BS bsAtoms, boolean translationOnly) { // from TransformManager exclusively - if (bsAtoms.cardinality() == 0) + if (bsAtoms.isEmpty()) return; ms.moveAtoms(m4, mNew, rotation, translation, bsAtoms, center, isInternal, translationOnly); @@ -7470,7 +7470,7 @@ actionRotateBond(deltaX, deltaY, x, y); } else { bsSelected = setMovableBitSet(bsSelected, !asAtoms); - if (bsSelected.cardinality() != 0) { + if (!bsSelected.isEmpty()) { if (isTranslation) { P3 ptCenter = ms.getAtomSetCenter(bsSelected); tm.finalizeTransformParameters(); @@ -8872,7 +8872,7 @@ } public void calculatePartialCharges(BS bsSelected) throws JmolAsyncException { - if (bsSelected == null || bsSelected.cardinality() == 0) + if (bsSelected == null || bsSelected.isEmpty()) bsSelected = getModelUndeletedAtomsBitSetBs(getVisibleFramesBitSet()); int pt = bsSelected.nextSetBit(0); if (pt < 0) @@ -9009,7 +9009,7 @@ if (bsAtoms == null) bsAtoms = getModelUndeletedAtomsBitSet(getVisibleFramesBitSet().length() - 1); BS bsB = new BS(); - if (bsAtoms.cardinality() == 0) + if (bsAtoms.isEmpty()) return bsB; int modelIndex = ms.at[bsAtoms.nextSetBit(0)].mi; if (modelIndex != ms.mc - 1) @@ -9324,7 +9324,7 @@ void dragMinimizeAtom(int iAtom) { stopMinimization(); - BS bs = (getMotionFixedAtoms().cardinality() == 0 ? ms.getAtoms( + BS bs = (getMotionFixedAtoms().isEmpty() ? ms.getAtoms( (ms.isAtomPDB(iAtom) ? T.group : T.molecule), BSUtil.newAndSetBit(iAtom)) : BSUtil.setAll(ms.ac)); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits