Revision: 18391
          http://sourceforge.net/p/jmol/code/18391
Author:   hansonr
Date:     2013-07-01 15:45:20 +0000 (Mon, 01 Jul 2013)
Log Message:
-----------


Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/modelset/Atom.java
    trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java
    trunk/Jmol/src/org/jmol/util/Tensor.java

Modified: trunk/Jmol/src/org/jmol/modelset/Atom.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Atom.java  2013-07-01 15:37:13 UTC (rev 
18390)
+++ trunk/Jmol/src/org/jmol/modelset/Atom.java  2013-07-01 15:45:20 UTC (rev 
18391)
@@ -292,7 +292,7 @@
 
   public float getADPMinMax(boolean isMax) {
     Tensor[] tensors = getTensors();
-    return (tensors == null || tensors[0] == null || tensors[0].iType != 
Tensor.TYPE_TEMP? 0 : tensors[0].getFactoredValue(isMax ? 2 : 1)); 
+    return (tensors == null || tensors[0] == null || tensors[0].iType != 
Tensor.TYPE_ADP? 0 : tensors[0].getFactoredValue(isMax ? 2 : 1)); 
   }
 
   public Tensor[] getTensors() {

Modified: trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java
===================================================================
--- trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java        2013-07-01 
15:37:13 UTC (rev 18390)
+++ trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java        2013-07-01 
15:45:20 UTC (rev 18391)
@@ -252,50 +252,53 @@
   return false;
 }
 
-//  private void setPoints(P3[] points, BS bs) {
-//    return;
-    // doesn't really work. Just something I was playing with.
-//    if (points == null)
-//      return;
-//    int n = bs.cardinality();
-//    if (n < 3)
-//      return;
-//    P3 ptCenter = new P3();
-//    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))
-//      ptCenter.add(points[i]);
-//    ptCenter.scale(1.0f/n);
-//    double Sxx = 0, Syy = 0, Szz = 0, Sxy = 0, Sxz = 0, Syz = 0;
-//    P3 pt = new P3();
-//    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
-//      pt.setT(points[i]);
-//      pt.sub(ptCenter);
-//      Sxx += (double) pt.x * (double) pt.x;
-//      Sxy += (double) pt.x * (double) pt.y;
-//      Sxz += (double) pt.x * (double) pt.z;
-//      Syy += (double) pt.y * (double) pt.y;
-//      Szz += (double) pt.z * (double) pt.z;
-//      Syz += (double) pt.y * (double) pt.z;      
-//    }
-//    double[][] N = new double[3][3];
-//    N[0][0] = Syy + Szz;
-//    N[1][1] = Sxx + Szz;
-//    N[2][2] = Sxx + Syy;
-//    Eigen eigen = Eigen.newM(N);
-//    ellipsoid.setEigen(ptCenter, eigen, 1f / n / 3);
-//  }
+  //  private void setPoints(P3[] points, BS bs) {
+  //    return;
+  // doesn't really work. Just something I was playing with.
+  //    if (points == null)
+  //      return;
+  //    int n = bs.cardinality();
+  //    if (n < 3)
+  //      return;
+  //    P3 ptCenter = new P3();
+  //    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))
+  //      ptCenter.add(points[i]);
+  //    ptCenter.scale(1.0f/n);
+  //    double Sxx = 0, Syy = 0, Szz = 0, Sxy = 0, Sxz = 0, Syz = 0;
+  //    P3 pt = new P3();
+  //    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
+  //      pt.setT(points[i]);
+  //      pt.sub(ptCenter);
+  //      Sxx += (double) pt.x * (double) pt.x;
+  //      Sxy += (double) pt.x * (double) pt.y;
+  //      Sxz += (double) pt.x * (double) pt.z;
+  //      Syy += (double) pt.y * (double) pt.y;
+  //      Szz += (double) pt.z * (double) pt.z;
+  //      Syz += (double) pt.y * (double) pt.z;      
+  //    }
+  //    double[][] N = new double[3][3];
+  //    N[0][0] = Syy + Szz;
+  //    N[1][1] = Sxx + Szz;
+  //    N[2][2] = Sxx + Syy;
+  //    Eigen eigen = Eigen.newM(N);
+  //    ellipsoid.setEigen(ptCenter, eigen, 1f / n / 3);
+  //  }
 
-
   @Override
   public String getShapeState() {
+    JmolStateCreator sc = viewer.getStateCreator();
+    if (sc == null || !isActive())
+      return "";
     SB sb = new SB();
-    getStateID(sb);
-    getStateAtoms(sb);
+    sb.append("\n");
+    if (!simpleEllipsoids.isEmpty())
+      getStateID(sb);
+    if (!atomEllipsoids.isEmpty())
+      getStateAtoms(sb, sc);
     return sb.toString();
   }
 
   private void getStateID(SB sb) {
-    if (!isActive())
-      return;
     Iterator<Ellipsoid> e = simpleEllipsoids.values().iterator();
     V3 v1 = new V3();
     while (e.hasNext()) {
@@ -318,40 +321,30 @@
     }
   }
 
-  private void getStateAtoms(SB sb) {
-    JmolStateCreator sc = viewer.getStateCreator();
-    if (sc == null)
-      return;
-    String keyDone = "";
+  private void getStateAtoms(SB sb, JmolStateCreator sc) {
+    BS bsDone = new BS();
+    Map<String, BS> temp = new Hashtable<String, BS>();
+    Map<String, BS> temp2 = new Hashtable<String, BS>();
     for (Ellipsoid e : atomEllipsoids.values()) {
-      String type = e.tensor.type;
-      String key = ";" + type + ";";
-      if (keyDone.indexOf(key) >= 0)
+      int iType = e.tensor.iType;
+      if (bsDone.get(iType + 1))
         continue;
-      Map<String, BS> temp = new Hashtable<String, BS>();
-      Map<String, BS> temp2 = new Hashtable<String, BS>();
-      boolean isTemp = (e.tensor.iType == Tensor.TYPE_TEMP);
-      String cmd = "Ellipsoids set " + Escape.eS(type);
-      if (isTemp)
-        sb.append(cmd);
+      bsDone.set(iType + 1);
+      boolean isADP = (e.tensor.iType == Tensor.TYPE_ADP);
+      String cmd = (isADP ? null : "Ellipsoids set " + 
Escape.eS(e.tensor.type));
       for (Ellipsoid e2 : atomEllipsoids.values()) {
-        if (e2.tensor.type.equals(type)) {
-          int i = e2.tensor.atomIndex1;
-          // YES -- "e.percent" here, not "e2.percent" because there is one 
and 
-          //        only one setting for thermal ellipsoid percent
-          String script = (isTemp ? "Ellipsoids " + e.percent : cmd + " scale 
" + e2.scale);
-          if (!isTemp && e2.isOn)  
-            script += " ON";
-          BSUtil.setMapBitSet(temp, i, i, script);
-          if (e2.colix != C.INHERIT_ALL) {
-            BSUtil.setMapBitSet(temp2, i, i, getColorCommand(cmd, e2.pid,
-                e2.colix, translucentAllowed));
-          }
-        }
+        if (e2.tensor.iType != iType || isADP && !e2.isOn)
+          continue;
+        int i = e2.tensor.atomIndex1;
+        // 
+        BSUtil.setMapBitSet(temp, i, i, (isADP ? "Ellipsoids " + e2.percent
+            : cmd + " scale " + e2.scale + (e2.isOn ? " ON" : " OFF")));
+        if (e2.colix != C.INHERIT_ALL)
+          BSUtil.setMapBitSet(temp2, i, i, getColorCommand(cmd, e2.pid,
+              e2.colix, translucentAllowed));
       }
-      sb.append(sc.getCommands(temp, temp2, "select"));
-      keyDone += key;
     }
+    sb.append(sc.getCommands(temp, temp2, "select"));
   }
 
   @Override

Modified: trunk/Jmol/src/org/jmol/util/Tensor.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Tensor.java    2013-07-01 15:37:13 UTC (rev 
18390)
+++ trunk/Jmol/src/org/jmol/util/Tensor.java    2013-07-01 15:45:20 UTC (rev 
18391)
@@ -35,7 +35,7 @@
 
   // factors that give reasonable first views of ellipsoids.
   
-  private static final float TEMPERATURE_FACTOR = (float) (Math.sqrt(0.5) / 
Math.PI);
+  private static final float ADP_FACTOR = (float) (Math.sqrt(0.5) / Math.PI);
   private static final float MAGNETIC_SUSCEPTIBILITY_FACTOR = 0.01f;
   private static final float ELECTRIC_FIELD_GRADIENT_FACTOR = 1f;
   private static final float BORN_EFFECTIVE_CHARGE_FACTOR = 1f;
@@ -50,11 +50,11 @@
   
   // type is an identifier that the reader/creator delivers:
   //
-  // temp   -- crystallographic displacement parameters 
-  //           - "temperature factors"; t.forThermalEllipsoid = true
+  // adp    -- crystallographic displacement parameters 
+  //           - "erature factors"; t.forThermalEllipsoid = true
   //           - either anisotropic (ADP) or isotropic (IDP)
   // iso      -- isotropic displacement parameters; from 
org.jmol.symmetry.UnitCell 
-  //           - changed to "temp" after setting t.isIsotropic = true
+  //           - changed to "adp" after setting t.isIsotropic = true
   // ms       -- magnetic susceptibility
   // isc      -- NMR interaction tensors
   //           - will have both atomIndex1 and atomIndex2 defined when
@@ -63,17 +63,18 @@
   // TLS-U    -- Translation/Libration/Skew tensor (anisotropic)
   // TLS-R    -- Translation/Libration/Skew tensor (residual)
   
-  private static final String KNOWN_TYPES = 
";iso....;temp...;tls-u..;tls-r..;ms.....;efg....;isc....;charge.;";
+  private static final String KNOWN_TYPES = 
";iso....;adp....;tls-u..;tls-r..;ms.....;efg....;isc....;charge.;";
   private static int getType(String type) {
     int pt = KNOWN_TYPES.indexOf(";" + type.toLowerCase() + ".");
     return (pt < 0 ? TYPE_OTHER : pt / 8); 
   }
 
   // these may be augmented, but the order should be kept the same within this 
list 
-
+  // no types  < -1, because these are used in Ellipsoids.getAtomState() as 
bs.get(iType + 1)
+  
   public static final int TYPE_OTHER  = -1;
   public static final int TYPE_ISO    = 0;
-  public static final int TYPE_TEMP   = 1;
+  public static final int TYPE_ADP   = 1;
   public static final int TYPE_TLS_U  = 2;
   public static final int TYPE_TLS_R  = 3;
   public static final int TYPE_MS     = 4;
@@ -325,8 +326,8 @@
     mat[1][2] = mat[2][1] = coefs[5] / 2; //YZ
     Eigen.getUnitVectors(mat, t.eigenVectors, t.eigenValues);
     sortAndNormalize(t.eigenVectors, t.eigenValues);
-    t.typeFactor = TEMPERATURE_FACTOR;
-    return t.setType("temp");
+    t.typeFactor = ADP_FACTOR;
+    return t.setType("adp");
   }
 
   /**
@@ -389,7 +390,7 @@
 
   /**
    * Sets typeFactor, altType, isIsotropic, forThermalEllipsoid;
-   * type "iso" changed to "temp" here.
+   * type "iso" changed to "" here.
    * 
    */
   private void processType() {
@@ -404,11 +405,11 @@
       forThermalEllipsoid = true;
       isIsotropic = true;
       altType = "1";
-      type = "temp";
+      type = "adp";
       break;
-    case TYPE_TEMP:
+    case TYPE_ADP:
       forThermalEllipsoid = true;
-      typeFactor = TEMPERATURE_FACTOR;
+      typeFactor = ADP_FACTOR;
       altType = "1";
       break;
     case TYPE_MS:

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to