From: <ha...@us...> - 2006-05-03 00:38:37
|
Revision: 5053 Author: hansonr Date: 2006-05-02 17:38:24 -0700 (Tue, 02 May 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=5053&view=rev Log Message: ----------- bob200603 -refines color molecule -adds show measurements and refines getproperty measurementInfo -moves label %X to %D (atom index) -creates label %N for molecule number -adjustments for set defaultLattice in conjunction with loadInline. -for XTLX Crystal Explorer http://www.stolaf.edu/people/hansonr/jmol/xtalx Modified Paths: -------------- branches/bob200603/Jmol/src/org/jmol/viewer/Atom.java branches/bob200603/Jmol/src/org/jmol/viewer/ColorManager.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/Measures.java branches/bob200603/Jmol/src/org/jmol/viewer/Model.java branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.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/Atom.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Atom.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Atom.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -902,6 +902,39 @@ ++ich; } } +/* + * the list: + * + * case '%': + case '{': + case 'a': atom name + case 'b': temperature factor ("b factor") + case 'C': formal Charge + case 'c': chain + case 'D': atom inDex (was "X") + case 'e': element symbol + case 'i': atom number + case 'I': Ionic radius + case 'L': polymer Length + case 'm': group1 + case 'M': Model number + case 'n': group3 + case 'N': molecule Number + case 'P': Partial charge + case 'q': occupancy + case 'r': residue sequence code + case 's': chain + case 't': temperature factor + case 'U': identity + case 'V': Van der Waals + case 'x': x coord + case 'X': fractional X coord + case 'y': y coord + case 'Y': fractional Y coord + case 'z': z coord + case 'Z': fractional Z coord + + */ switch (ch = strFormat.charAt(ich++)) { case 'i': strT = "" + getAtomNumber(); @@ -924,7 +957,7 @@ floatT = point3f.z; floatIsSet = true; break; - case 'X': + case 'D': strT = "" + atomIndex; break; case 'C': @@ -978,6 +1011,9 @@ case 'U': strT = getIdentity(); break; + case 'N': + strT = getMoleculeNumber(); + break; case '%': strT = "%"; break; @@ -1077,6 +1113,10 @@ return "" + info; } + String getMoleculeNumber() { + return "" + (group.chain.frame.getMoleculeIndex(atomIndex)+1); + } + boolean isCursorOnTopOfClickableAtom(int xCursor, int yCursor, int minRadius, Atom competitor) { return (isClickable() && Modified: branches/bob200603/Jmol/src/org/jmol/viewer/ColorManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/ColorManager.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/ColorManager.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -197,6 +197,15 @@ JmolConstants.argbsRoygbScale.length); index = JmolConstants.argbsRoygbScale.length - 1 - index; argb = JmolConstants.argbsRoygbScale[index]; + } else if ("molecule" == palette) { + // viewer.calcSelectedMoleculesCount() must be called first ... + Frame frame2 = viewer.getFrame(); + index = quantize(frame2.getMoleculeIndex(atom.atomIndex), + frame2.getLastMoleculeIndexInModel(atom.modelIndex), + frame2.getFirstMoleculeIndexInModel(atom.modelIndex), + JmolConstants.argbsRoygbScale.length); + index = JmolConstants.argbsRoygbScale.length - 1 - index; + argb = JmolConstants.argbsRoygbScale[index]; } else { System.out.println("ColorManager.getColixAtomPalette:" + " unrecognized color palette:" + palette); Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -1433,6 +1433,7 @@ case Token.partialCharge: case Token.user: case Token.monomer: + case Token.molecule: colorObject(Token.atom, 1); return; case Token.rubberband: @@ -1547,9 +1548,12 @@ case Token.group: viewer.calcSelectedGroupsCount(); break; - case Token.monomer: + case Token.monomer: viewer.calcSelectedMonomersCount(); break; + case Token.molecule: + viewer.calcSelectedMonomersCount(); + break; case Token.user: notImplemented(itoken); return; @@ -1785,7 +1789,7 @@ * * these are pure x or y spins or * - * spin axisangle [1 1 0] 10 + * spin axisangle {1 1 0} 10 * * this is the same as the old "spin x 10; spin y 10" -- or is it? * anyway, it's better! @@ -1799,9 +1803,9 @@ * and several new options * * spin -x - * spin axisangle [1 1 0] 10 + * spin axisangle {1 1 0} 10 * spin 10 (atomno=1)(atomno=2) - * spin 20 [0 0 0] [1 1 1] + * spin 20 {0 0 0} {1 1 1} * * The INTERNAL keyword indicates that spins or rotations are to be * carried out in the internal molecular coordinate frame, not the @@ -1906,15 +1910,15 @@ if (nPoints < 2 && !isInternal) { // simple, standard fixed-frame rotation // rotate x 10 - // rotate axisangle [0 1 0] 10 + // rotate axisangle {0 1 0} 10 if (nPoints == 1) rotCenter = new Point3f(points[0]); // point-centered rotation, but not internal -- "frieda" // rotate x 10 (atoms) - // rotate x 10 [point/line/plane] - // rotate x 10 [x y z] + // rotate x 10 $object + // rotate x 10 System.out.println("rotating externally: " + rotCenter + rotAxis); viewer.rotateAxisAngleAtCenter(rotCenter, rotAxis, degrees, isSpin); return; @@ -3300,6 +3304,9 @@ case Token.zoom: showZoom(); break; + case Token.monitor: + showMeasurements(); + break; case Token.symmetry: showSymmetry(); break; @@ -3340,6 +3347,10 @@ showString(viewer.getModelInfoAsString()); } + void showMeasurements() { + showString(viewer.getMeasurementInfoAsString()); + } + void showSymmetry() { showString(viewer.getSymmetryInfoAsString()); } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -102,6 +102,9 @@ BitSet groupsPresent; + int moleculeCount; + BitSet[] molecules = new BitSet[4]; + boolean hasBfactorRange; int bfactor100Lo; int bfactor100Hi; @@ -2072,6 +2075,25 @@ void calcSelectedMonomersCount(BitSet bsSelected) { mmset.calcSelectedMonomersCount(bsSelected); } + + BitSet selectedMolecules = new BitSet(); + BitSet bsTemp = new BitSet(); + int selectedMoleculeCount; + void calcSelectedMoleculesCount(BitSet bsSelected) { + if (moleculeCount == 0) + getMolecules(); + selectedMolecules.xor(selectedMolecules); + selectedMoleculeCount = 0; + for (int i = 0; i < moleculeCount; i++) { + bsTemp.clear(); + bsTemp.or(bsSelected); + bsTemp.and(molecules[i]); + if (bsTemp.length() > 0) { + selectedMolecules.set(i); + selectedMoleculeCount++; + } + } + } void findMaxRadii() { for (int i = atomCount; --i >= 0;) { @@ -2248,7 +2270,6 @@ } BitSet getMoleculeBitSet(BitSet bs) { - //limited to the first atom found int atomCount = getAtomCount(); BitSet bsResult = new BitSet(atomCount); for (int i = 0; i < atomCount; i++) @@ -2257,7 +2278,56 @@ return bsResult; } - void getCovalentlyConnectedBitSet(Atom atom, BitSet bs, BitSet bsToTest) { + void getMolecules() { + if (moleculeCount > 0) + return; + moleculeCount = 0; + int atomCount = getAtomCount(); + BitSet atomlist = new BitSet(atomCount); + BitSet bs = new BitSet(atomCount); + int thisModelIndex = -1; + int modelIndex = -1; + for (int i = 0; i < atomCount; i++) + if (!atomlist.get(i) && !bs.get(i)) { + bs = getMoleculeBitSet(i); + atomlist.or(bs); + if (moleculeCount == molecules.length) + molecules = (BitSet[]) Util.setLength(molecules, moleculeCount * 2); + molecules[moleculeCount] = new BitSet(); + molecules[moleculeCount].xor(bs); + modelIndex = atoms[i].modelIndex; + if (modelIndex != thisModelIndex) { + mmset.getModel(modelIndex).firstMolecule = moleculeCount; + thisModelIndex = modelIndex; + } + mmset.getModel(thisModelIndex).lastMolecule = moleculeCount; + moleculeCount++; + } + } + + int getMoleculeCount() { + return moleculeCount; + } + + int getMoleculeIndex(int atomIndex) { + if (moleculeCount == 0) + getMolecules(); + for (int i = 0; i < moleculeCount; i++) { + if (molecules[i].get(atomIndex)) + return i; + } + return 0; + } + + int getFirstMoleculeIndexInModel(int modelIndex) { + return mmset.getModel(modelIndex).firstMolecule; + } + + int getLastMoleculeIndexInModel(int modelIndex) { + return mmset.getModel(modelIndex).lastMolecule; + } + + private void getCovalentlyConnectedBitSet(Atom atom, BitSet bs, BitSet bsToTest) { int atomIndex = atom.atomIndex; if (!bsToTest.get(atomIndex)) return; @@ -2378,10 +2448,10 @@ / E_ANG_PER_DEBYE; if (value < 0) { dipole.set(atom2, atom1, -value); - System.out.println(atom2.getInfo() + atom1.getInfo() + (-value)); + //System.out.println(atom2.getInfo() + atom1.getInfo() + (-value)); } else { dipole.set(atom1, atom2, value); - System.out.println(atom1.getInfo() + atom2.getInfo() + value); + //System.out.println(atom1.getInfo() + atom2.getInfo() + value); } } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Measures.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Measures.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Measures.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -233,6 +233,9 @@ if ("info".equals(property)) { return getAllInfo(); } + if ("infostring".equals(property)) { + return getAllInfoAsString(); + } return null; } @@ -244,13 +247,23 @@ return info; } + String getAllInfoAsString() { + String info = "Measurement Information"; + for (int i = 0; i< measurementCount; i++) { + info += "\n" + getInfoAsString(i); + } + return info; + } + Hashtable getInfo(int index) { + int count = measurements[index].count; Hashtable info = new Hashtable(); - info.put("index",new Integer(index)); - info.put("strMeasurement",measurements[index].strMeasurement); - int count = measurements[index].count; - info.put("count",new Integer(count)); - info.put("value",new Float(measurements[index].value)); + info.put("index", new Integer(index)); + info.put("type", (count == 2 ? "distance" : count == 3 ? "angle" + : "dihedral")); + info.put("strMeasurement", measurements[index].strMeasurement); + info.put("count", new Integer(count)); + info.put("value", new Float(measurements[index].value)); Vector atomsInfo = new Vector(); for (int i = 0; i < count; i++) { Hashtable atomInfo = new Hashtable(); @@ -261,8 +274,20 @@ atomsInfo.add(atomInfo); } info.put("atoms", atomsInfo); - return info; + return info; } + + String getInfoAsString(int index) { + int count = measurements[index].count; + String info = (count == 2 ? "distance" : count == 3 ? "angle" : "dihedral") + + " \t" + measurements[index].value + " \t" + + measurements[index].strMeasurement; + for (int i = 0; i < count; i++) { + Atom atom = frame.atoms[measurements[index].countPlusIndices[i + 1]]; + info += " \t" + atom.getInfo(); + } + return info; + } void reformatDistances() { for (int i = measurementCount; --i >= 0; ) Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Model.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Model.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Model.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -31,6 +31,8 @@ String modelTag; int preSymmetryAtomIndex = -1; int preSymmetryAtomCount; + int firstMolecule; + int lastMolecule; private int chainCount = 0; private Chain[] chains = new Chain[8]; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -309,6 +309,10 @@ return (frame == null) ? 0 : frame.getBondCount(); } + int getMoleuleCount() { + return (frame == null) ? 0 : frame.getMoleculeCount(); + } + int getAtomCountInModel(int modelIndex) { return (frame == null) ? 0 : frame.getAtomCountInModel(modelIndex); } @@ -515,6 +519,10 @@ return (frame == null) ? null : frame.getModelAtomBitSet(modelIndex); } + BitSet getMoleculeBitSet(int modelIndex) { + return (frame == null) ? null : frame.getMoleculeBitSet(modelIndex); + } + void calcSelectedGroupsCount(BitSet bsSelected) { if (frame != null) frame.calcSelectedGroupsCount(bsSelected); @@ -525,6 +533,11 @@ frame.calcSelectedMonomersCount(bsSelected); } + void calcSelectedMoleculesCount(BitSet bsSelected) { + if (frame != null) + frame.calcSelectedGroupsCount(bsSelected); + } + //////////////////////////////////////////////////////////////// // Access to atom properties for clients //////////////////////////////////////////////////////////////// Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Token.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Token.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Token.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -125,8 +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 | expression; - final static int monitor = command | 18 | setparam | bool | embeddedExpression; + final static int monitor = command | 18 | setparam | showparam | bool | embeddedExpression; final static int pause = command | 19 | misc; final static int print = command | 20; final static int quit = command | 21; @@ -242,23 +241,28 @@ final static int information = showparam | 0; final static int phipsi = showparam | 1; - // center centre final static int ramprint = showparam | 2; final static int rotation = showparam | 3; - // selected final static int group = showparam | 4 | expression; final static int chain = showparam | 5 | expression; final static int atom = showparam | 6; final static int sequence = showparam | 7; final static int symmetry = showparam | 8 | expression | predefinedset; final static int translation = showparam | 9; - // zoom // chime show parameters final static int residue = showparam | 10; - // model // mlp // list // spin + //except for "symmetry", above are not implemented + // additional show parameters: + // selected + // center + // boundbox + // monitor + // model + // zoom + final static int all = showparam | 11 | expression; final static int pdbheader = showparam | 12 | expression; final static int axisangle = showparam | 13; @@ -266,6 +270,9 @@ final static int orientation = showparam | 15; final static int file = showparam | 16; + // of the above, only pdbheader, orientation, and file are implemented + // axisangle is used in the spin command, not the show command + // atom expression operators final static int leftparen = expression | 0; final static int rightparen = expression | 1; @@ -283,12 +290,10 @@ final static int colon = expression | 14; final static int slash = expression | 15; final static int substructure = expression | 16; - // 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; - + final static int leftbrace = coordinate | 17; + final static int rightbrace = coordinate | 18; + final static int dollarsign = objectid | 19; + final static int connected = expression | 20; // miguel 2005 01 01 // these are used to demark the beginning and end of expressions @@ -310,6 +315,7 @@ final static int _structure = atomproperty | 9; final static int occupancy = atomproperty | 10; final static int polymerLength= atomproperty | 11; + final static int molecule = atomproperty | command | 17 | expression; final static int opGT = comparator | 0; final static int opGE = comparator | 1; @@ -414,7 +420,7 @@ final static String[] comparatorNames = {">", ">=", "<=", "<", "=", "!="}; final static String[] atomPropertyNames = { "atomno", "elemno", "resno", "radius", "temperature", "model", - "_bondedcount", "_groupID", "_atomID", "_structure"}; + "_bondedcount", "_groupID", "_atomID", "_structure", "_molecule"}; /* Note that the RasMol scripting language is case-insensitive. @@ -447,7 +453,7 @@ "label", new Token(label, onDefault1, "label"), "labels", null, "load", new Token(load, varArgCount, "load"), - "molecule", new Token(molecule, 1, "molecule"), + "molecule", new Token(molecule, "molecule"), "monitor", new Token(monitor, varArgCount, "monitor"), "monitors", null, "measure", null, Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-05-02 23:56:23 UTC (rev 5052) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-05-03 00:38:24 UTC (rev 5053) @@ -1052,7 +1052,7 @@ public void loadInline(String strModel) { if (strModel == null) return; - System.out.println(strModel); + //System.out.println(strModel); if (inlineNewlineChar != 0) { int len = strModel.length(); int i; @@ -1062,8 +1062,8 @@ strModel = strModel.substring(i + 1); strModel = strModel.replace(inlineNewlineChar, '\n'); } - System.out.println(strModel); int[] A = new int[4]; + System.out.println("loadinline:"+A); A[1] = (int)ptDefaultLattice.x; A[2] = (int)ptDefaultLattice.y; A[3] = (int)ptDefaultLattice.z; @@ -1559,6 +1559,10 @@ modelManager.calcSelectedMonomersCount(selectionManager.bsSelection); } + void calcSelectedMoleculesCount() { + modelManager.calcSelectedMoleculesCount(selectionManager.bsSelection); + } + String getFileHeader() { return modelManager.getFileHeader(); } @@ -1629,6 +1633,10 @@ return (Vector) getShapeProperty(JmolConstants.SHAPE_MEASURES, "info"); } + public String getMeasurementInfoAsString() { + return (String) getShapeProperty(JmolConstants.SHAPE_MEASURES, "infostring"); + } + public int[] getMeasurementCountPlusIndices(int i) { int[] List = (int[]) getShapeProperty(JmolConstants.SHAPE_MEASURES, "countPlusIndices", i); @@ -3042,6 +3050,7 @@ Point3f ptDefaultLattice = new Point3f(); void setDefaultLattice(Point3f ptLattice) { + System.out.println("SETTINGDEAULTLATT"+ptLattice); ptDefaultLattice.set(ptLattice); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |