From: <ha...@us...> - 2013-07-02 07:17:23
|
Revision: 18402 http://sourceforge.net/p/jmol/code/18402 Author: hansonr Date: 2013-07-02 07:17:11 +0000 (Tue, 02 Jul 2013) Log Message: ----------- {*}.tensor("ms","all") Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/script/T.java trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java trunk/Jmol/src/org/jmol/util/Tensor.java Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2013-07-02 06:54:14 UTC (rev 18401) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2013-07-02 07:17:11 UTC (rev 18402) @@ -3431,6 +3431,7 @@ public JmolList<Tensor> getInteractionTensorList(String type, BS bs) { type = type.toLowerCase(); BS bsModels = getModelBitSet(bs, false); + int iAtom = (bs.cardinality() == 1 ? bs.nextSetBit(0) : -1); JmolList<Tensor> list = new JmolList<Tensor>(); for (int i = bsModels.nextSetBit(0); i >= 0; i = bsModels.nextSetBit(i + 1)) { JmolList<Tensor> tensors = (JmolList<Tensor>) getModelAuxiliaryInfoValue(i, "interactionTensors"); @@ -3439,7 +3440,7 @@ int n = tensors.size(); for (int j = 0; j < n; j++) { Tensor t = tensors.get(j); - if (t.type.equals(type) && t.isSelected(bs)) + if (t.type.equals(type) && t.isSelected(bs, iAtom)) list.addLast(t); } } Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-07-02 06:54:14 UTC (rev 18401) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-07-02 07:17:11 UTC (rev 18402) @@ -838,9 +838,11 @@ // {*}.tensor("efg","eigenvalues") // T.tensor is set to allow exactly 2 parameters // change that in T.java to adjust + if (args.length == 0 || args.length > 2) + return false; BS bs = SV.getBitSet(getX(), false); String tensorType = SV.sValue(args[0]).toLowerCase(); - String infoType = ";" + SV.sValue(args[1]).toLowerCase() + "."; + String infoType = ";" + (args.length == 1 ? "all" : SV.sValue(args[1]).toLowerCase()) + "."; JmolList<Object> data = new JmolList<Object>(); if (tensorType.equals("isc")) { JmolList<Tensor> list = viewer.modelSet.getInteractionTensorList("isc", Modified: trunk/Jmol/src/org/jmol/script/T.java =================================================================== --- trunk/Jmol/src/org/jmol/script/T.java 2013-07-02 06:54:14 UTC (rev 18401) +++ trunk/Jmol/src/org/jmol/script/T.java 2013-07-02 07:17:11 UTC (rev 18402) @@ -695,6 +695,8 @@ public final static int within = 20 | 0 << 9 | mathfunc; final static int write = 21 | 0 << 9 | mathfunc | scriptCommand; final static int cache = 22 | 0 << 9 | mathfunc | scriptCommand; // new in Jmol 13.1.2 + final static int tensor = 23 | 0 << 9 | mathfunc | mathproperty; + // xxx(a) final static int acos = 3 | 1 << 9 | mathfunc; @@ -746,7 +748,6 @@ public final static int add = 1 | 2 << 9 | mathfunc | mathproperty; public final static int distance = 2 | 2 << 9 | mathfunc | mathproperty; final static int replace = 3 | 2 << 9 | mathfunc | mathproperty; - final static int tensor = 4 | 2 << 9 | mathfunc | mathproperty; // xxx(a,b,c) Modified: trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java 2013-07-02 06:54:14 UTC (rev 18401) +++ trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java 2013-07-02 07:17:11 UTC (rev 18402) @@ -78,7 +78,7 @@ Atom[] atoms = modelSet.atoms; for (int i = tensors.size(); --i >= 0;) { Tensor t = tensors.get(i); - if (isAll || t.isSelected(bsSelected)) { + if (isAll || t.isSelected(bsSelected, -1)) { Ellipsoid e = atomEllipsoids.get(t); boolean isNew = (size != 0 && e == null); if (isNew) @@ -214,7 +214,7 @@ if (isOn) setSize(Integer.MAX_VALUE, bs); for (Ellipsoid e : atomEllipsoids.values()) - if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs)) + if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) e.isOn = isOn; return; } @@ -225,7 +225,7 @@ if (selectedAtoms != null) bs = selectedAtoms; for (Ellipsoid e : atomEllipsoids.values()) - if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs)) { + if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) { e.colix = getColixI(colix, pid, e.tensor.atomIndex1); e.pid = pid; } @@ -235,7 +235,7 @@ if ("translucency" == propertyName) { boolean isTranslucent = (value.equals("translucent")); for (Ellipsoid e : atomEllipsoids.values()) - if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs)) + if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) e.colix = C.getColixTranslucent3(e.colix, isTranslucent, translucentLevel); return; Modified: trunk/Jmol/src/org/jmol/util/Tensor.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Tensor.java 2013-07-02 06:54:14 UTC (rev 18401) +++ trunk/Jmol/src/org/jmol/util/Tensor.java 2013-07-02 07:17:11 UTC (rev 18402) @@ -26,6 +26,8 @@ import java.util.Arrays; import java.util.Comparator; +import java.util.Hashtable; +import java.util.Map; /** * @author Bob Hanson ha...@st... 6/30/2013 @@ -113,6 +115,11 @@ public int atomIndex1 = -1; public int atomIndex2 = -1; + private static final String infoList = ";............." + ";eigenvalues.." + ";eigenvectors." + + ";asymmetric..." + ";symmetric...." + ";trace........" + + ";haeberlen...." + ";eulerzyz....." + ";eulerzxz....." + + ";quaternion..." + ";indices......" + ";string......." + + ";type........." + ";all........."; /** * returns an object of the specified type, including "eigenvalues", * "eigenvectors", "asymmetric", "symmetric", "trace", "indices", and "type" @@ -123,11 +130,15 @@ public Object getInfo(String infoType) { if (infoType.charAt(0) != ';') infoType = ";" + infoType + "."; - switch ((";............." + ";eigenvalues.." + ";eigenvectors." - + ";asymmetric..." + ";symmetric...." + ";trace........" - + ";haeberlen...." + ";eulerzyz....." + ";eulerzxz....." - + ";quaternion..." + ";indices......" + ";string......." + ";type.........") - .indexOf(infoType) / 14) { + switch (infoList.indexOf(infoType) / 14) { + default: + Map<String, Object> info = new Hashtable<String, Object>(); + String[] s = Parser.getTokens(TextFormat.replaceAllCharacter(infoList, ";.", ' ').trim()); + Arrays.sort(s); + for (int i = 0; i < s.length; i++) + if (!s[i].equals("all")) + info.put(s[i], getInfo(s[i])); + return info; case 1: return eigenValues; case 2: @@ -173,8 +184,6 @@ return this.toString(); case 12: return type; - default: - return null; } } @@ -361,8 +370,10 @@ atomIndex2 = index2; } - public boolean isSelected(BS bsSelected) { - return bsSelected.get(atomIndex1) && (atomIndex2 < 0 || bsSelected.get(atomIndex2)); + public boolean isSelected(BS bsSelected, int iAtom) { + return (iAtom >= 0 ? (atomIndex1 == iAtom || atomIndex2 == iAtom) + : bsSelected.get(atomIndex1) + && (atomIndex2 < 0 || bsSelected.get(atomIndex2))); } /** @@ -468,7 +479,7 @@ @Override public String toString() { - return (type + "\n" + (eigenVectors == null ? "" + return (type + " " + modelIndex + " " + atomIndex1 + " " + atomIndex2 + "\n" + (eigenVectors == null ? "" + eigenValues[0] : eigenVectors[0] + "\t" + eigenValues[0] + "\t" + "\n" + eigenVectors[1] + "\t" + eigenValues[1] + "\t" + "\n" + eigenVectors[2] + "\t" + eigenValues[2] + "\t" + "\n")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |