Revision: 18317
          http://sourceforge.net/p/jmol/code/18317
Author:   hansonr
Date:     2013-06-10 02:47:10 +0000 (Mon, 10 Jun 2013)
Log Message:
-----------
___JmolVersion="13.1.17_dev_2013.06.08"

TODO: PyMOL uniqueAtomSettings for transparency
        -- will require by-vertex translucent option

code: color/translucent/opaque clean up in ScriptEvaluator
bug fix: load :2-butanone fails

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java
    trunk/Jmol/src/org/jmol/rendersurface/IsosurfaceRenderer.java
    trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/Viewer.java

Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java       
2013-06-08 20:27:11 UTC (rev 18316)
+++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java       
2013-06-10 02:47:10 UTC (rev 18317)
@@ -787,18 +787,18 @@
   }
 
   private void setGroupVisibilities() {
-    if (groups != null) {
-      Collection<PyMOLGroup> list = groups.values();
-      BS bsAll = new BS();
-      for (PyMOLGroup g : list) {
-        bsAll.or(g.bsAtoms);
-        if (g.parent == null) // top
-          setGroupVisible(g, true);
-        else if (g.list.isEmpty()) // bottom
-          g.addGroupAtoms(new BS());
-      }
-      defineAtoms("all", bsAll);
+    if (groups == null)
+      return;
+    Collection<PyMOLGroup> list = groups.values();
+    BS bsAll = new BS();
+    for (PyMOLGroup g : list) {
+      bsAll.or(g.bsAtoms);
+      if (g.parent == null) // top
+        setGroupVisible(g, true);
+      else if (g.list.isEmpty()) // bottom
+        g.addGroupAtoms(new BS());
     }
+    defineAtoms("all", bsAll);
   }
 
   private void defineAtoms(String name, BS bs) {

Modified: trunk/Jmol/src/org/jmol/rendersurface/IsosurfaceRenderer.java
===================================================================
--- trunk/Jmol/src/org/jmol/rendersurface/IsosurfaceRenderer.java       
2013-06-08 20:27:11 UTC (rev 18316)
+++ trunk/Jmol/src/org/jmol/rendersurface/IsosurfaceRenderer.java       
2013-06-10 02:47:10 UTC (rev 18317)
@@ -167,7 +167,7 @@
       }
     }
     boolean tcover = g3d.getTranslucentCoverOnly();
-    g3d.setTranslucentCoverOnly(imesh.frontOnly);
+    g3d.setTranslucentCoverOnly(imesh.frontOnly || 
!viewer.getBoolean(T.translucent));
     thePlane = imesh.jvxlData.jvxlPlane;
     vertexValues = imesh.vertexValues;
     boolean isOK;

Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-06-08 20:27:11 UTC 
(rev 18316)
+++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-06-10 02:47:10 UTC 
(rev 18317)
@@ -7545,13 +7545,19 @@
     return matches;
   }
 
+  /**
+   * 
+   * @param index  0 is this is the hbond command
+   * 
+   * @throws ScriptException
+   */
   private void connect(int index) throws ScriptException {
 
     final float[] distances = new float[2];
     BS[] atomSets = new BS[2];
     atomSets[0] = atomSets[1] = viewer.getSelectionSet(false);
     float radius = Float.NaN;
-    int color = Integer.MIN_VALUE;
+    colorArgb[0] = Integer.MIN_VALUE;
     int distanceCount = 0;
     int bondOrder = JmolEdge.BOND_ORDER_NULL;
     int bo;
@@ -7559,7 +7565,6 @@
     boolean isDelete = false;
     boolean haveType = false;
     boolean haveOperation = false;
-    String translucency = null;
     float translucentLevel = Float.MAX_VALUE;
     boolean isColorOrRadius = false;
     int nAtomSets = 0;
@@ -7634,19 +7639,11 @@
         addGroup = true;
         break;
       case T.color:
-        int tok = tokAt(i + 1);
-        if (tok != T.translucent && tok != T.opaque)
-          ptColor = i + 1;
-        continue;
       case T.translucent:
       case T.opaque:
-        if (translucency != null)
-          error(ERROR_invalidArgument);
         isColorOrRadius = true;
-        translucency = parameterAsString(i);
-        if (theTok == T.translucent && isFloatParameter(i + 1))
-          translucentLevel = getTranslucentLevel(++i);
-        ptColor = i + 1;
+        translucentLevel = getColorTrans(i);
+        i = iToken;
         break;
       case T.pdb:
         boolean isAuto = (tokAt(2) == T.auto);
@@ -7671,8 +7668,7 @@
         break;
       case T.struts:
         if (!isColorOrRadius) {
-          color = 0xFFFFFF;
-          translucency = "translucent";
+          colorArgb[0] = 0xFFFFFF;
           translucentLevel = 0.5f;
           radius = viewer.getFloat(T.strutdefaultradius);
           isColorOrRadius = true;
@@ -7682,16 +7678,16 @@
         haveOperation = true;
         //$FALL-THROUGH$
       case T.identifier:
+        if (isColorParam(i)) {
+          ptColor = -i;
+          break;
+        }
+        //$FALL-THROUGH$
       case T.aromatic:
       case T.hbond:
         if (i > 0) {
-          if (ptColor == i)
-            break;
+          // not hbond command
           // I know -- should have required the COLOR keyword
-          if (isColorParam(i)) {
-            ptColor = -i;
-            break;
-          }
         }
         String cmd = parameterAsString(i);
         if ((bo = getBondOrderFromString(cmd)) == JmolEdge.BOND_ORDER_NULL) {
@@ -7742,9 +7738,9 @@
       // now check for color -- -i means we've already checked
       if (i > 0) {
         if (ptColor == -i || ptColor == i && isColorParam(i)) {
-          color = getArgbParam(i);
+          isColorOrRadius = true;
+          colorArgb[0] = getArgbParam(i);
           i = iToken;
-          isColorOrRadius = true;
         } else if (ptColor == i) {
           error(ERROR_invalidArgument);
         }
@@ -7758,8 +7754,7 @@
       distances[1] = distances[0];
       distances[0] = JC.DEFAULT_MIN_CONNECT_DISTANCE;
     }
-    if (translucency != null || !Float.isNaN(radius)
-        || color != Integer.MIN_VALUE) {
+    if (isColorOrRadius) {
       if (!haveType)
         bondOrder = JmolEdge.BOND_ORDER_ANY;
       if (!haveOperation)
@@ -7798,17 +7793,7 @@
       viewer.selectBonds(bsBonds);
       if (!Float.isNaN(radius))
         setShapeSizeBs(JC.SHAPE_STICKS, Math.round(radius * 2000), null);
-      if (color != Integer.MIN_VALUE)
-        setShapePropertyBs(JC.SHAPE_STICKS, "color", Integer
-            .valueOf(color), bsBonds);
-      if (translucency != null) {
-        if (translucentLevel == Float.MAX_VALUE)
-          translucentLevel = viewer.getFloat(T.defaulttranslucent);
-        setShapeProperty(JC.SHAPE_STICKS, "translucentLevel", Float
-            .valueOf(translucentLevel));
-        setShapePropertyBs(JC.SHAPE_STICKS, "translucency",
-            translucency, bsBonds);
-      }
+      finalizeObject(JC.SHAPE_STICKS, colorArgb[0], translucentLevel, 0, 
false, null, 0, bsBonds);
       viewer.selectBonds(null);
     }
     if (!(tQuiet || scriptLevel > scriptReportingLevel))
@@ -8184,10 +8169,10 @@
           prefix = "vertex";
         } else {
           bs = atomExpressionAt(index);
-          // don't allow isosurface partial translucency (yet)
           prefix = "atom";
         }
-        translucentLevel = Float.MIN_VALUE;
+        // don't allow isosurface partial translucency (yet)
+        //translucentLevel = Float.MIN_VALUE;
         getToken(index = iToken + 1);
         break;
       }
@@ -11623,6 +11608,7 @@
   private void ellipsoid() throws ScriptException {
     int mad = 0;
     int i = 1;
+    float translucentLevel = Float.MAX_VALUE;
     switch (getToken(1).tok) {
     case T.on:
       mad = 50;
@@ -11648,7 +11634,7 @@
       while (++i < slen) {
         String key = parameterAsString(i);
         Object value = null;
-        switch (tokAt(i)) {
+        switch (getToken(i).tok) {
         case T.dollarsign:
           key = "points";
           Object[] data = new Object[3];
@@ -11678,31 +11664,11 @@
           i = iToken;
           break;
         case T.color:
-          float translucentLevel = Float.NaN;
-          if (tokAt(i) == T.color)
-            i++;
-          if ((theTok = tokAt(i)) == T.translucent) {
-            value = "translucent";
-            if (isFloatParameter(++i))
-              translucentLevel = getTranslucentLevel(i++);
-            else
-              translucentLevel = viewer.getFloat(T.defaulttranslucent);
-          } else if (theTok == T.opaque) {
-            value = "opaque";
-            i++;
-          }
-          if (isColorParam(i)) {
-            setShapeProperty(JC.SHAPE_ELLIPSOIDS, "color", Integer
-                .valueOf(getArgbParam(i)));
-            i = iToken;
-          }
-          if (value == null)
-            continue;
-          if (!Float.isNaN(translucentLevel))
-            setShapeProperty(JC.SHAPE_ELLIPSOIDS,
-                "translucentLevel", Float.valueOf(translucentLevel));
-          key = "translucency";
-          break;
+        case T.translucent:
+        case T.opaque:
+          translucentLevel = getColorTrans(i);
+          i = iToken;
+          continue;
         case T.delete:
           value = Boolean.TRUE;
           checkLength(3);
@@ -11726,6 +11692,7 @@
         setShapeProperty(JC.SHAPE_ELLIPSOIDS, key.toLowerCase(),
             value);
       }
+      finalizeObject(JC.SHAPE_ELLIPSOIDS, colorArgb[0], translucentLevel, 0, 
false, null, 0, null);
       setShapeProperty(JC.SHAPE_ELLIPSOIDS, "thisID", null);
       return;
     default:
@@ -15546,6 +15513,8 @@
     return (String) getShapePropertyIndex(JC.SHAPE_MO, "showMO", ptMO);
   }
 
+  private int[] colorArgb = new int[] {Integer.MIN_VALUE};
+  
   private void cgo() throws ScriptException {
     sm.loadShape(JC.SHAPE_CGO);
     if (tokAt(1) == T.list && listIsosurface(JC.SHAPE_CGO))
@@ -15554,11 +15523,10 @@
     String thisId = initIsosurface(JC.SHAPE_CGO);
     boolean idSeen = (thisId != null);
     boolean isWild = (idSeen && getShapeProperty(JC.SHAPE_CGO, "ID") == null);
-    boolean isTranslucent = false;
     boolean isInitialized = false;
     JmolList<Object> data = null;
     float translucentLevel = Float.MAX_VALUE;
-    int colorArgb = Integer.MIN_VALUE;
+    colorArgb[0] = Integer.MIN_VALUE;
     int intScale = 0;
     for (int i = iToken; i < slen; ++i) {
       String propertyName = null;
@@ -15588,24 +15556,8 @@
       case T.color:
       case T.translucent:
       case T.opaque:
-        if (theTok != T.color)
-          --i;
-        if (tokAt(i + 1) == T.translucent) {
-          i++;
-          isTranslucent = true;
-          if (isFloatParameter(i + 1))
-            translucentLevel = getTranslucentLevel(++i);
-        } else if (tokAt(i + 1) == T.opaque) {
-          i++;
-          isTranslucent = true;
-          translucentLevel = 0;
-        }
-        if (isColorParam(i + 1)) {
-          colorArgb = getArgbParam(++i);
-          i = iToken;
-        } else if (!isTranslucent) {
-          error(ERROR_invalidArgument);
-        }
+        translucentLevel = getColorTrans(i);
+        i = iToken;
         idSeen = true;
         continue;
       case T.id:
@@ -15637,22 +15589,56 @@
       if (propertyName != null)
         setShapeProperty(JC.SHAPE_CGO, propertyName, propertyValue);
     }
-    finalizeObject(JC.SHAPE_CGO, colorArgb, isTranslucent ? translucentLevel
-        : Float.MAX_VALUE, intScale, data != null, data, iptDisplayProperty);
+    finalizeObject(JC.SHAPE_CGO, colorArgb[0], translucentLevel, intScale, 
data != null, data, iptDisplayProperty, null);
   }
-  
+
+  /**
+   * Checks color, translucent, opaque parameters.
+   * 
+   * @param i
+   * @return translucentLevel and sets iToken and colorArgb[0]
+   * 
+   * @throws ScriptException
+   */
+  private float getColorTrans(int i) throws ScriptException {
+    float translucentLevel = Float.MAX_VALUE;
+    if (theTok != T.color)
+      --i;
+    switch (tokAt(i + 1)) {
+    case T.translucent:
+      i++;
+      translucentLevel = (isFloatParameter(i + 1) ? getTranslucentLevel(++i)
+          : viewer.getFloat(T.defaulttranslucent));
+      break;
+    case T.opaque:
+      i++;
+      translucentLevel = 0;
+      break;
+    }
+    if (isColorParam(i + 1)) {
+      colorArgb[0] = getArgbParam(++i);
+      i = iToken;
+    } else if (translucentLevel == Float.MAX_VALUE) {
+      error(ERROR_invalidArgument);
+    } else {
+      colorArgb[0] = Integer.MIN_VALUE;
+    }
+    i = iToken;
+    return translucentLevel;
+  }
+
   private void finalizeObject(int shapeID, int colorArgb,
                               float translucentLevel, int intScale,
-                              boolean havePoints, Object data, int 
iptDisplayProperty) throws ScriptException {
-    if (havePoints) {
+                              boolean doSet, Object data, int 
iptDisplayProperty, BS bs) throws ScriptException {
+    if (doSet) {
       setShapeProperty(shapeID, "set", data);
     }
     if (colorArgb != Integer.MIN_VALUE)
-      setShapeProperty(shapeID, "color", Integer
-          .valueOf(colorArgb));
+      setShapePropertyBs(shapeID, "color", Integer
+          .valueOf(colorArgb), bs);
     if (translucentLevel != Float.MAX_VALUE)
       setShapeTranslucency(shapeID, "", "translucent",
-          translucentLevel, null);
+          translucentLevel, bs);
     if (intScale != 0) {
       setShapeProperty(shapeID, "scale", Integer
           .valueOf(intScale));
@@ -15683,13 +15669,12 @@
     boolean havePoints = false;
     boolean isInitialized = false;
     boolean isSavedState = false;
-    boolean isTranslucent = false;
     boolean isIntersect = false;
     boolean isFrame = false;
     P4 plane;
     int tokIntersect = 0;
     float translucentLevel = Float.MAX_VALUE;
-    int colorArgb = Integer.MIN_VALUE;
+    colorArgb[0] = Integer.MIN_VALUE;
     int intScale = 0;
     String swidth = "";
     int iptDisplayProperty = 0;
@@ -16084,25 +16069,9 @@
       case T.color:
       case T.translucent:
       case T.opaque:
-        if (theTok != T.color)
-          --i;
-        if (tokAt(i + 1) == T.translucent) {
-          i++;
-          isTranslucent = true;
-          if (isFloatParameter(i + 1))
-            translucentLevel = getTranslucentLevel(++i);
-        } else if (tokAt(i + 1) == T.opaque) {
-          i++;
-          isTranslucent = true;
-          translucentLevel = 0;
-        }
-        if (isColorParam(i + 1)) {
-          colorArgb = getArgbParam(++i);
-          i = iToken;
-        } else if (!isTranslucent) {
-          error(ERROR_invalidArgument);
-        }
         idSeen = true;
+        translucentLevel = getColorTrans(i);
+        i = iToken;
         continue;
       default:
         if (!setMeshDisplayProperty(JC.SHAPE_DRAW, 0, theTok)) {
@@ -16130,8 +16099,8 @@
       if (propertyName != null)
         setShapeProperty(JC.SHAPE_DRAW, propertyName, propertyValue);
     }
-    finalizeObject(JC.SHAPE_DRAW, colorArgb, isTranslucent ? translucentLevel 
: Float.MAX_VALUE, 
-        intScale, havePoints, connections, iptDisplayProperty);
+    finalizeObject(JC.SHAPE_DRAW, colorArgb[0], translucentLevel, 
+        intScale, havePoints, connections, iptDisplayProperty, null);
   }
 
   private void polyhedra() throws ScriptException {
@@ -16156,9 +16125,8 @@
     setShapeProperty(JC.SHAPE_POLYHEDRA, "init", null);
     String setPropertyName = "centers";
     String decimalPropertyName = "radius_";
-    boolean isTranslucent = false;
     float translucentLevel = Float.MAX_VALUE;
-    int color = Integer.MIN_VALUE;
+    colorArgb[0] = Integer.MIN_VALUE;
     for (int i = 1; i < slen; ++i) {
       String propertyName = null;
       Object propertyValue = null;
@@ -16247,24 +16215,8 @@
       case T.color:
       case T.translucent:
       case T.opaque:
-        isTranslucent = false;
-        if (theTok != T.color)
-          --i;
-        if (tokAt(i + 1) == T.translucent) {
-          i++;
-          isTranslucent = true;
-          if (isFloatParameter(i + 1))
-            translucentLevel = getTranslucentLevel(++i);
-        } else if (tokAt(i + 1) == T.opaque) {
-          i++;
-          isTranslucent = true;
-          translucentLevel = 0;
-        }
-        if (isColorParam(i + 1)) {
-          color = getArgbParam(i);
-          i = iToken;
-        } else if (!isTranslucent)
-          error(ERROR_invalidArgument);
+        translucentLevel = getColorTrans(i);
+        i = iToken;
         continue;
       case T.collapsed:
       case T.flat:
@@ -16288,7 +16240,7 @@
         continue;
       default:
         if (isColorParam(i)) {
-          color = getArgbParam(i);
+          colorArgb[0] = getArgbParam(i);
           i = iToken;
           continue;
         }
@@ -16303,10 +16255,10 @@
       error(ERROR_insufficientArguments);
     if (needsGenerating)
       setShapeProperty(JC.SHAPE_POLYHEDRA, "generate", null);
-    if (color != Integer.MIN_VALUE)
+    if (colorArgb[0] != Integer.MIN_VALUE)
       setShapeProperty(JC.SHAPE_POLYHEDRA, "colorThis", Integer
-          .valueOf(color));
-    if (isTranslucent)
+          .valueOf(colorArgb[0]));
+    if (translucentLevel != Float.MAX_VALUE)
       setShapeTranslucency(JC.SHAPE_POLYHEDRA, "", "translucentThis",
           translucentLevel, null);
     if (lighting != 0)

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-06-08 20:27:11 UTC 
(rev 18316)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-06-10 02:47:10 UTC 
(rev 18317)
@@ -9,11 +9,13 @@
 #  The quotes above look odd for a parameter file, but they are 
 #  important for the JavaScript version of Jmol.
 
-___JmolVersion="13.1.17_dev_2013.06.07"
+___JmolVersion="13.1.17_dev_2013.06.08"
 
 TODO: PyMOL uniqueAtomSettings for transparency
         -- will require by-vertex translucent option
 
+code: color/translucent/opaque clean up in ScriptEvaluator
+bug fix: load :2-butanone fails
 bug fix: PyMOL volume map data saved from PyMOL 1.6 has slightly different 
data structure 
 bug fix: jvxl reader ignores jvxlVertexColorData 
 bug fix: ellipsoid rendering problems

Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java  2013-06-08 20:27:11 UTC (rev 
18316)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java  2013-06-10 02:47:10 UTC (rev 
18317)
@@ -4554,7 +4554,12 @@
     case ':': // PubChem
       format = global.pubChemFormat;
       String fl = f.toLowerCase();
-      int fi = Parser.parseInt(f);
+      int fi = Integer.MIN_VALUE;
+      try {
+        fi = Integer.parseInt(f);
+      } catch (Exception e) {
+        //
+      }
       if (fi != Integer.MIN_VALUE) {
         f = "cid/" + fi;
       } else {
@@ -5751,6 +5756,8 @@
       return global.strutsMultiple;
     case T.tracealpha:
       return global.traceAlpha;
+    case T.translucent:
+      return global.translucent;
     case T.twistedsheets:
       return global.twistedSheets;
     case T.vectorsymmetry:

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


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to