From: <ha...@us...> - 2006-05-02 02:14:55
|
Revision: 5044 Author: hansonr Date: 2006-05-01 19:14:44 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=5044&view=rev Log Message: ----------- bob200603 for crystallography: adds within(molecule, expression) not quite perfect -- only returns the molecule of the FIRST atom in the expression. Modified Paths: -------------- branches/bob200603/Jmol/src/org/jmol/viewer/Compiler.java branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java branches/bob200603/Jmol/src/org/jmol/viewer/PickingManager.java branches/bob200603/Jmol/src/org/jmol/viewer/Token.java branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Compiler.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Compiler.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Compiler.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -1128,6 +1128,7 @@ case Token.decimal: case Token.group: case Token.chain: + case Token.molecule: case Token.model: distance = tokenDistance.value; break; @@ -1158,20 +1159,20 @@ if (tok == Token.integer) { token = tokenNext(); // minimum # or exact # of bonds (optional) if (token.intValue < 0) - nonnegativeIntegerExpected(); + return nonnegativeIntegerExpected(); min = max = token.intValue; token = tokenNext(); tok = token.tok; if (tok == Token.rightparen) // ) break; if (tok != Token.opOr) // , - commaOrCloseExpected(); + return commaOrCloseExpected(); tok = tokPeek(); } if (tok == Token.integer) { token = tokenNext(); // maximum # of bonds (optional) if (token.intValue < 0) - nonnegativeIntegerExpected(); + return nonnegativeIntegerExpected(); max = token.intValue; token = tokenNext(); tok = token.tok; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -1273,17 +1273,15 @@ } } - BitSet within(Token instruction, BitSet bs) - throws ScriptException { + BitSet within(Token instruction, BitSet bs) throws ScriptException { Object withinSpec = instruction.value; if (withinSpec instanceof Float) return viewer.getAtomsWithin(((Float) withinSpec).floatValue(), bs); if (withinSpec instanceof String) { String withinStr = (String) withinSpec; - if (withinStr.equals("group") - || withinStr.equals("chain") - || withinStr.equals("model")) - return viewer.getAtomsWithin(withinStr, bs); + if (withinStr.equals("group") || withinStr.equals("chain") + || withinStr.equals("molecule") || withinStr.equals("model")) + return viewer.getAtomsWithin(withinStr, bs); } evalError("Unrecognized within parameter:" + withinSpec); return null; //can't get here Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -2333,10 +2333,17 @@ BitSet bs = new BitSet(atomCount); BitSet bsToTest = getModelAtomBitSet(atoms[atomIndex].modelIndex); getCovalentlyConnectedBitSet(atoms[atomIndex], bs, bsToTest); - System.out.println(bs); return bs; } + BitSet getMoleculeBitSet(BitSet bs) { + //limited to the first atom found + for (int i = 0; i < atomCount; i++ ) + if (bs.get(i)) + return getMoleculeBitSet(i); + return null; + } + void getCovalentlyConnectedBitSet(Atom atom, BitSet bs, BitSet bsToTest) { int atomIndex = atom.atomIndex; if (!bsToTest.get(atomIndex)) Modified: branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -654,10 +654,14 @@ } BitSet getAtomsWithin(String withinWhat, BitSet bs) { + if (frame == null) + return null; if (withinWhat.equals("group")) return withinGroup(bs); if (withinWhat.equals("chain")) return withinChain(bs); + if (withinWhat.equals("molecule")) + return withinMolecule(bs); if (withinWhat.equals("model")) return withinModel(bs); return null; @@ -696,6 +700,10 @@ return bsResult; } + BitSet withinMolecule(BitSet bs) { + return frame.getMoleculeBitSet(bs); + } + BitSet withinModel(BitSet bs) { int modelIndexLast = -1; BitSet bsResult = new BitSet(); Modified: branches/bob200603/Jmol/src/org/jmol/viewer/PickingManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/PickingManager.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/PickingManager.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -154,7 +154,6 @@ break; case JmolConstants.PICKING_SELECT_MOLECULE: BitSet bsMolecule = frame.getMoleculeBitSet(atomIndex); - System.out.println("OK, have: " + bsMolecule + " " + chimeStylePicking); if (shiftKey | chimeStylePicking) viewer.toggleSelectionSet(bsMolecule); else Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Token.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Token.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Token.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -125,7 +125,7 @@ final static int help = command | 14; final static int label = command | 15 | specialstring; final static int load = command | 16 | specialstring2; - final static int molecule = command | 17; + final static int molecule = command | 17 | expression; final static int monitor = command | 18 | setparam | bool | embeddedExpression; final static int pause = command | 19 | misc; final static int print = command | 20; @@ -283,10 +283,11 @@ final static int colon = expression | 14; final static int slash = expression | 15; final static int substructure = expression | 16; - final static int leftbrace = coordinate | 17; - final static int rightbrace = coordinate | 18; - final static int dollarsign = objectid | 19; - final static int connected = expression | 20; + // 17 reserved for molecule + final static int leftbrace = coordinate | 18; + final static int rightbrace = coordinate | 19; + final static int dollarsign = objectid | 20; + final static int connected = expression | 21; // miguel 2005 01 01 Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-05-02 01:08:20 UTC (rev 5043) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-05-02 02:14:44 UTC (rev 5044) @@ -905,13 +905,11 @@ } public void setSelectionSet(BitSet set) { - System.out.print("Viewer.setSelectionSet"+set); selectionManager.setSelectionSet(set); refresh(0, "Viewer:setSelectionSet()"); } void toggleSelectionSet(BitSet set) { - System.out.print("Viewer.toggleSelectionSet"+set); selectionManager.toggleSelectionSet(set); refresh(0, "Viewer:toggleSelectionSet()"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |