Revision: 18356
          http://sourceforge.net/p/jmol/code/18356
Author:   hansonr
Date:     2013-06-23 16:34:18 +0000 (Sun, 23 Jun 2013)
Log Message:
-----------
fixing recently broken write IMAGE width height TYPE quality...

Preliminary org.jmol.util.Modulation

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java
    trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java
    trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java
    trunk/Jmol/src/org/jmol/modelset/Atom.java
    trunk/Jmol/src/org/jmol/modelset/AtomCollection.java
    trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
    trunk/Jmol/src/org/jmol/renderspecial/VectorsRenderer.java
    trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java
    trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
    trunk/Jmol/src/org/jmol/util/P3.java
    trunk/Jmol/src/org/jmol/viewer/ActionManager.java
    trunk/Jmol/src/org/jmol/viewer/JC.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/PropertyManager.java
    trunk/Jmol/src/org/jmol/viewer/ShapeManager.java
    trunk/Jmol/src/org/jmol/viewer/TransformManager.java
    trunk/Jmol/src/org/jmol/viewer/Viewer.java

Added Paths:
-----------
    trunk/Jmol/src/org/jmol/util/Modulation.java
    trunk/Jmol/src/org/jmol/util/Vibration.java

Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java 
2013-06-20 15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java 
2013-06-23 16:34:18 UTC (rev 18356)
@@ -38,6 +38,7 @@
 
 import org.jmol.api.JmolAdapter;
 import org.jmol.util.ArrayUtil;
+import org.jmol.util.BS;
 import org.jmol.util.Escape;
 import org.jmol.util.Logger;
 import org.jmol.util.Parser;
@@ -78,6 +79,7 @@
   private int stepNumber;
 
   private int moModelSet = -1;
+  private BS namedSets = new BS();
 
 
   /**
@@ -216,7 +218,7 @@
     energyString = tokens[2] + " " + tokens[3];
     // now set the names for the last equivalentAtomSets
     atomSetCollection.setAtomSetNames(energyKey + " = " + energyString,
-        equivalentAtomSets);
+        equivalentAtomSets, namedSets);
     // also set the properties for them
     atomSetCollection.setAtomSetPropertyForSets(energyKey, energyString,
         equivalentAtomSets);
@@ -242,7 +244,7 @@
     String tokens[] = getTokens();
     energyKey = "Energy";
     energyString = tokens[1];
-    atomSetCollection.setAtomSetNames("Energy = "+tokens[1], 
equivalentAtomSets);
+    atomSetCollection.setAtomSetNames("Energy = "+tokens[1], 
equivalentAtomSets, namedSets);
     atomSetCollection.setAtomSetEnergy(energyString, 
parseFloatStr(energyString));
   }
   
@@ -280,7 +282,8 @@
     // this is needed for the last structure in an optimization
     // if energy information is found for this structure the reader
     // will overwrite this setting later.
-    atomSetCollection.setAtomSetName(energyKey + " = " + energyString);
+    if (energyKey.length() != 0)
+      atomSetCollection.setAtomSetName(energyKey + " = " + energyString);
     atomSetCollection.setAtomSetEnergy(energyString, 
parseFloatStr(energyString));
 //  atomSetCollection.setAtomSetName("Last read atomset.");
     String path = getTokens()[0]; // path = type of orientation
@@ -628,7 +631,9 @@
           continue;  
         atomSetCollection.cloneLastAtomSet();
         // set the properties
-        atomSetCollection.setAtomSetFrequency("Calculation " + 
calculationNumber, symmetries[i], frequencies[i], null);
+        String name = atomSetCollection.setAtomSetFrequency("Calculation " + 
calculationNumber, symmetries[i], frequencies[i], null);
+        appendLoadNote("model " + atomSetCollection.getAtomSetCount() + ": " + 
name);
+        namedSets.set(atomSetCollection.getCurrentAtomSetIndex());
         atomSetCollection.setAtomSetModelProperty("ReducedMass",
             red_masses[i]+" AMU");
         atomSetCollection.setAtomSetModelProperty("ForceConstant",

Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java   
2013-06-20 15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java   
2013-06-23 16:34:18 UTC (rev 18356)
@@ -218,7 +218,7 @@
     atomSetCollection.setAtomSetPropertyForSets(energyKey, energyValue,
         equivalentAtomSets);
     atomSetCollection.setAtomSetNames(energyKey + " = " + energyValue,
-        equivalentAtomSets);
+        equivalentAtomSets, null);
     atomSetCollection.setAtomSetEnergy(value, parseFloatStr(value));
     haveEnergy = true;
   }

Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java      
2013-06-20 15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java      
2013-06-23 16:34:18 UTC (rev 18356)
@@ -1695,6 +1695,7 @@
       setTrajectoryName(atomSetName);
       return;
     }
+    System.out.println(currentAtomSetIndex + " " + atomSetName);
     setAtomSetAuxiliaryInfoForSet("name", atomSetName, currentAtomSetIndex);
     // TODO -- trajectories could have different names. Need this for 
vibrations?
     if (!allowMultiple)
@@ -1719,10 +1720,12 @@
    *          The name
    * @param n
    *          The number of last AtomSets that needs these set
+   * @param namedSets 
    */
-  public void setAtomSetNames(String atomSetName, int n) {
-    for (int idx = currentAtomSetIndex; --n >= 0 && idx >= 0; --idx)
-      setAtomSetAuxiliaryInfoForSet("name", atomSetName, idx);
+  public void setAtomSetNames(String atomSetName, int n, BS namedSets) {
+    for (int i = currentAtomSetIndex; --n >= 0 && i >= 0; --i)
+      if (namedSets == null || !namedSets.get(i))
+        setAtomSetAuxiliaryInfoForSet("name", atomSetName, i);
   }
 
   /**
@@ -1919,15 +1922,17 @@
     setAtomSetModelProperty("Energy", "" + value);
   }
 
-  public void setAtomSetFrequency(String pathKey, String label, String freq, 
String units) {
+  public String setAtomSetFrequency(String pathKey, String label, String freq, 
String units) {
     freq += " " + (units == null ? "cm^-1" : units);
-    setAtomSetName((label == null ? "" : label + " ") + freq);
+    String name = (label == null ? "" : label + " ") + freq;
+    setAtomSetName(name);
     setAtomSetModelProperty("Frequency", freq);
     if (label != null)
       setAtomSetModelProperty("FrequencyLabel", label);
     setAtomSetModelProperty(SmarterJmolAdapter.PATH_KEY, (pathKey == null ? ""
         : pathKey + SmarterJmolAdapter.PATH_SEPARATOR + "Frequencies")
         + "Frequencies");
+    return name;
   }
 
   void toCartesian(SymmetryInterface symmetry) {

Modified: trunk/Jmol/src/org/jmol/modelset/Atom.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Atom.java  2013-06-20 15:05:19 UTC (rev 
18355)
+++ trunk/Jmol/src/org/jmol/modelset/Atom.java  2013-06-23 16:34:18 UTC (rev 
18356)
@@ -1053,7 +1053,7 @@
   }
 
   public V3 getVibrationVector() {
-    return group.chain.model.modelSet.getVibrationVector(index, false);
+    return group.chain.model.modelSet.getVibration(index, false);
   }
 
   public float getVibrationCoord(char ch) {

Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java        2013-06-20 
15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java        2013-06-23 
16:34:18 UTC (rev 18356)
@@ -56,6 +56,7 @@
 import org.jmol.util.Parser;
 import org.jmol.util.Rectangle;
 import org.jmol.util.V3;
+import org.jmol.util.Vibration;
 
 import org.jmol.util.Measure;
 import org.jmol.util.Quaternion;
@@ -84,7 +85,7 @@
     atomNames = null;
     atomTypes = null;
     atomSerials = null;
-    vibrationVectors = null;
+    vibrations = null;
     occupancies = null;
     bfactor100s = null;
     partialCharges = null;
@@ -97,7 +98,7 @@
     atomNames = mergeModelSet.atomNames;
     atomTypes = mergeModelSet.atomTypes;
     atomSerials = mergeModelSet.atomSerials;
-    vibrationVectors = mergeModelSet.vibrationVectors;
+    vibrations = mergeModelSet.vibrations;
     occupancies = mergeModelSet.occupancies;
     bfactor100s = mergeModelSet.bfactor100s;
     ionicRadii = mergeModelSet.ionicRadii;
@@ -145,7 +146,7 @@
   String[] atomNames;
   String[] atomTypes;
   int[] atomSerials;
-  public V3[] vibrationVectors;
+  public Vibration[] vibrations;
   byte[] occupancies;
   short[] bfactor100s;
   float[] partialCharges;
@@ -158,7 +159,7 @@
   protected boolean haveStraightness;
 
   public boolean modelSetHasVibrationVectors(){
-    return (vibrationVectors != null);
+    return (vibrations != null);
   }
   
   public String[] getAtomTypes() {
@@ -672,39 +673,36 @@
   }
 
   public float getVibrationCoord(int atomIndex, char c) {
-    if (vibrationVectors == null || vibrationVectors[atomIndex] == null)
+    if (vibrations == null || vibrations[atomIndex] == null)
       return 0;
     switch (c) {
     case 'X':
-      return vibrationVectors[atomIndex].x;
+      return vibrations[atomIndex].x;
     case 'Y':
-      return vibrationVectors[atomIndex].y;
+      return vibrations[atomIndex].y;
     default:
-      return vibrationVectors[atomIndex].z;
+      return vibrations[atomIndex].z;
     }
   }
 
-  public V3 getVibrationVector(int atomIndex, boolean forceNew) {
-    V3 v = (vibrationVectors == null ? null : vibrationVectors[atomIndex]);
-    return (v == null && forceNew ? new V3() : v);
+  public Vibration getVibration(int atomIndex, boolean forceNew) {
+    Vibration v = (vibrations == null ? null : vibrations[atomIndex]);
+    return (v == null && forceNew ? new Vibration() : v);
   }
 
   protected void setVibrationVector(int atomIndex, float x, float y, float z) {
     if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z))
       return;
-    if (vibrationVectors == null || vibrationVectors.length < atomIndex)
-      vibrationVectors = new V3[atoms.length];
-    if (vibrationVectors[atomIndex] == null)
-      vibrationVectors[atomIndex] = V3.new3(x, y, z);
-    else
-      vibrationVectors[atomIndex].set(x, y, z);
+    if (vibrations == null || vibrations.length < atomIndex)
+      vibrations = new Vibration[atoms.length];
+    if (vibrations[atomIndex] == null)
+      vibrations[atomIndex] = new Vibration();
+    vibrations[atomIndex].set(x, y, z);
     atoms[atomIndex].setVibrationVector();
   }
 
   private void setVibrationVector2(int atomIndex, int tok, float fValue) {
-    V3 v = getVibrationVector(atomIndex, true);
-    if (v == null)
-      v = new V3();
+    Vibration v = getVibration(atomIndex, true);
     switch(tok) {
     case T.vibx:
       v.x = fValue;
@@ -2519,7 +2517,7 @@
         firstAtomIndex, nAtoms);
     ellipsoids = (Quadric[][]) ArrayUtil.deleteElements(ellipsoids,
         firstAtomIndex, nAtoms);
-    vibrationVectors = (V3[]) ArrayUtil.deleteElements(vibrationVectors,
+    vibrations = (Vibration[]) ArrayUtil.deleteElements(vibrations,
         firstAtomIndex, nAtoms);
     nSurfaceAtoms = 0;
     bsSurface = null;

Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java       2013-06-20 
15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java       2013-06-23 
16:34:18 UTC (rev 18356)
@@ -66,6 +66,7 @@
 import org.jmol.util.TextFormat;
 import org.jmol.util.TriangleData;
 import org.jmol.util.V3;
+import org.jmol.util.Vibration;
 import org.jmol.viewer.JC;
 import org.jmol.viewer.ShapeManager;
 import org.jmol.io.OutputStringBuilder;
@@ -1499,10 +1500,10 @@
   }
 
   public boolean modelHasVibrationVectors(int modelIndex) {
-    if (vibrationVectors != null)
+    if (vibrations != null)
       for (int i = atomCount; --i >= 0;)
         if ((modelIndex < 0 || atoms[i].modelIndex == modelIndex)
-            && vibrationVectors[i] != null && vibrationVectors[i].length() > 0)
+            && vibrations[i] != null && vibrations[i].length() > 0)
           return true;
     return false;
   }
@@ -3079,9 +3080,9 @@
         m.firstAtomIndex = i;
       m.bsAtoms.set(i);
     }
-    if (vibrationVectors != null)
+    if (vibrations != null)
       for (int i = i0; i < atomCount; i++)
-        vibrationVectors[i] = vibrationVectors[map[i]];
+        vibrations[i] = vibrations[map[i]];
     if (occupancies != null)
       for (int i = i0; i < atomCount; i++)
         occupancies[i] = occupancies[map[i]];
@@ -3107,8 +3108,8 @@
 
   protected void growAtomArrays(int newLength) {
     atoms = (Atom[]) ArrayUtil.arrayCopyObject(atoms, newLength);
-    if (vibrationVectors != null)
-      vibrationVectors = (V3[]) ArrayUtil.arrayCopyObject(vibrationVectors,
+    if (vibrations != null)
+      vibrations = (Vibration[]) ArrayUtil.arrayCopyObject(vibrations,
           newLength);
     if (occupancies != null)
       occupancies = ArrayUtil.arrayCopyByte(occupancies, newLength);

Modified: trunk/Jmol/src/org/jmol/renderspecial/VectorsRenderer.java
===================================================================
--- trunk/Jmol/src/org/jmol/renderspecial/VectorsRenderer.java  2013-06-20 
15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/renderspecial/VectorsRenderer.java  2013-06-23 
16:34:18 UTC (rev 18356)
@@ -35,11 +35,11 @@
 import org.jmol.util.P3;
 import org.jmol.util.P3i;
 import org.jmol.util.V3;
+import org.jmol.util.Vibration;
 
 public class VectorsRenderer extends ShapeRenderer {
 
   private final static float arrowHeadOffset = -0.2f;
-  private final V3 vector2 = new V3();
   private final P3 pointVectorEnd = new P3();
   private final P3 pointArrowHead = new P3();
   private final P3i screenVectorEnd = new P3i();
@@ -53,6 +53,7 @@
   private boolean vectorSymmetry;
   private float headScale;
   private boolean doShaft;
+  private Vibration vibTemp;
 
 
   @Override
@@ -73,7 +74,7 @@
       Atom atom = atoms[i];
       if (!atom.isVisible(myVisibilityFlag))
         continue;
-      V3 vibrationVector = viewer.getVibrationVector(i);
+      Vibration vibrationVector = viewer.getVibration(i);
       if (vibrationVector == null)
         continue;
       if (!transform(mads[i], atom, vibrationVector))
@@ -84,16 +85,18 @@
       }
       renderVector(atom);
       if (vectorSymmetry) {
-        vector2.setT(vibrationVector);
-        vector2.scale(-1);
-        transform(mads[i], atom, vector2);
+        if (vibTemp == null)
+          vibTemp = new Vibration();
+        vibTemp.setT(vibrationVector);
+        vibTemp.scale(-1);
+        transform(mads[i], atom, vibTemp);
         renderVector(atom);
       }
     }
     return needTranslucent;
   }
 
-  private boolean transform(short mad, Atom atom, V3 vibrationVector) {
+  private boolean transform(short mad, Atom atom, Vibration vibrationVector) {
     float len = vibrationVector.length();
     // to have the vectors move when vibration is turned on
     if (Math.abs(len * vectorScale) < 0.01)

Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-06-20 15:05:19 UTC 
(rev 18355)
+++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-06-23 16:34:18 UTC 
(rev 18356)
@@ -11065,17 +11065,15 @@
   }
 
   private void delete() throws ScriptException {
-    if (slen == 1) {
-      zap(true);
-      return;
-    }
     if (tokAt(1) == T.dollarsign) {
       setObjectProperty();
       return;
     }
-    BS bs = atomExpression(st, 1, 0, true, false, true, false);
+    BS bs = (slen == 1 ? null : atomExpression(st, 1, 0, true, false, true, 
false));
     if (chk)
       return;
+    if (bs == null)
+      bs = viewer.getModelUndeletedAtomsBitSet(-1);
     int nDeleted = viewer.deleteAtoms(bs, false);
     if (!(tQuiet || scriptLevel > scriptReportingLevel))
       scriptStatusOrBuffer(GT._("{0} atoms deleted", nDeleted));
@@ -14707,14 +14705,13 @@
           isExport = true;
           if (isCommand)
             fileName = "Jmol." + type.toLowerCase();
-        } else if (type.equals("ZIP")) {
+          break;
+        } else if (type.equals("ZIP") || type.equals("ZIPALL")) {
           pt++;
-        } else if (type.equals("ZIPALL")) {
-          pt++;
+          break;
         } else {
           type = "(image)";
         }
-        break;
       }
       if (tokAtArray(pt, args) == T.integer) {
         width = SV.iValue(tokenAt(pt++, args));

Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2013-06-20 
15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2013-06-23 
16:34:18 UTC (rev 18356)
@@ -1072,6 +1072,17 @@
 
   }
 
+  /**
+   * 
+   * {xxx}.symop()
+   * 
+   * symop({xxx}
+   * 
+   * @param args
+   * @param haveBitSet
+   * @return true/false
+   * @throws ScriptException
+   */
   private boolean evaluateSymop(SV[] args, boolean haveBitSet)
       throws ScriptException {
     if (args.length == 0)

Added: trunk/Jmol/src/org/jmol/util/Modulation.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Modulation.java                                
(rev 0)
+++ trunk/Jmol/src/org/jmol/util/Modulation.java        2013-06-23 16:34:18 UTC 
(rev 18356)
@@ -0,0 +1,44 @@
+package org.jmol.util;
+
+/**
+ * A class to allow for more complex vibrations and associated 
+ * phenomena, such as modulated crystals.
+ * 
+ * @author Bob Hanson hans...@stolaf.edu
+ * 
+ */
+
+public class Modulation extends V3 {
+
+  private double ccos; 
+  private double csin;
+  private int f; // usually f[0] = 1, f[1] = 2, etc. 
+  private V3 wv; // wave vectors
+  private double twoPIx4;
+
+  public static float getPointAndOffset(Modulation[] mods, P3 pt, double t, 
double scale) {
+    // f(x4) = x1 + A1 cos(2pi * x4 * t) + B1 sin(2pi * x4 * t)
+    //            + A2 cos(2pi * x4 * t * 2) + B2 sin(2pi * x4 * t * 2);
+    //            + A3 cos(2pi * x4 * t * 3) + B3 sin(2pi * x4 * t * 3);
+    // however, more generally, we allow any number of independent wave
+    // vectors with any number of orders.
+    // x' = x1 + sum_i[ ccos[i] cos(2pi * x4[i] * f[i] * t)
+    //                    +csin[i] sin(2pi * x4[i] * f[i] * t) ] * wv[i] * 
scale
+    P3 pt0 = P3.newP(pt);
+    for (int i = mods.length; --i >= 0;) {
+      mods[i].addTo(pt, t, scale);
+    }
+    return pt.distance(pt0);
+  }
+
+  private void addTo(P3 pt, double t, double scale) {
+    double theta = t * twoPIx4 * f;
+    double v = 0;
+    if (ccos != 0)
+      v += ccos * Math.cos(theta);
+    if (csin != 0)
+      v += csin * Math.sin(theta);
+    pt.scaleAdd2((float) (v * scale), wv, pt);
+  }
+
+}

Modified: trunk/Jmol/src/org/jmol/util/P3.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/P3.java        2013-06-20 15:05:19 UTC (rev 
18355)
+++ trunk/Jmol/src/org/jmol/util/P3.java        2013-06-23 16:34:18 UTC (rev 
18356)
@@ -55,7 +55,7 @@
    *        the other point
    * @return the square of distance between these two points as a float
    */
-  public final float distanceSquared(P3 p1) {
+  public final float distanceSquared(Tuple3f p1) {
     double dx = x - p1.x;
     double dy = y - p1.y;
     double dz = z - p1.z;
@@ -69,7 +69,7 @@
    *        the other point
    * @return the distance between these two points
    */
-  public final float distance(P3 p1) {
+  public final float distance(Tuple3f p1) {
     return (float) Math.sqrt(distanceSquared(p1));
   }
 

Added: trunk/Jmol/src/org/jmol/util/Vibration.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Vibration.java                         (rev 0)
+++ trunk/Jmol/src/org/jmol/util/Vibration.java 2013-06-23 16:34:18 UTC (rev 
18356)
@@ -0,0 +1,19 @@
+package org.jmol.util;
+
+/**
+ * A class to allow for more complex vibrations and associated 
+ * phenomena, such as modulated crystals.
+ * 
+ * @author Bob Hanson hans...@stolaf.edu
+ * 
+ */
+
+public class Vibration extends V3 {
+
+  protected final static double twoPI = 2 * Math.PI;
+
+  public void setTempPoint(P3 pt, double t, double scale) {
+    pt.scaleAdd2((float) (Math.cos(t * twoPI) * scale), this, pt); 
+  }
+
+}

Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/ActionManager.java   2013-06-20 15:05:19 UTC 
(rev 18355)
+++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java   2013-06-23 16:34:18 UTC 
(rev 18356)
@@ -212,6 +212,7 @@
   public final static int PICKING_ASSIGN_BOND      = 33;
   public final static int PICKING_ROTATE_BOND      = 34;
   public final static int PICKING_IDENTIFY_BOND    = 35;
+  public final static int PICKING_DRAG_LIGAND      = 36;
   
 
 
@@ -224,7 +225,7 @@
     "navigate", 
     "connect", "struts", 
     "dragselected", "dragmolecule", "dragatom", "dragminimize", 
"dragminimizemolecule",
-    "invertstereo", "assignatom", "assignbond", "rotatebond", "identifybond"
+    "invertstereo", "assignatom", "assignbond", "rotatebond", "identifybond", 
"dragligand"
   };
  
   public final static String getPickingModeName(int pickingMode) {
@@ -704,7 +705,7 @@
       if (!isBound(action, ACTION_rotate))
         viewer.setRotateBondIndex(-1);
     }
-    BS bs;
+    BS bs = null;
     if (dragAtomIndex >= 0) {
       switch (atomPickingMode) {
       case PICKING_DRAG_SELECTED:
@@ -719,26 +720,27 @@
               Integer.MIN_VALUE, Integer.MIN_VALUE, null, true, false);
         }
         return;
+      case PICKING_DRAG_LIGAND:
       case PICKING_DRAG_MOLECULE:
+      case PICKING_DRAG_MINIMIZE_MOLECULE:
+        bs = viewer.getAtomBits(T.molecule, 
BSUtil.newAndSetBit(dragAtomIndex));
+        if (atomPickingMode == PICKING_DRAG_LIGAND)
+          bs.and(viewer.getAtomBitSet("ligand"));
+        //$FALL-THROUGH$
       case PICKING_DRAG_ATOM:
       case PICKING_DRAG_MINIMIZE:
-      case PICKING_DRAG_MINIMIZE_MOLECULE:
         if (dragGesture.getPointCount() == 1)
           viewer.undoMoveActionClear(dragAtomIndex, AtomCollection.TAINT_COORD,
               true);
         checkMotion(JC.CURSOR_MOVE);
         if (isBound(action, ACTION_rotateSelected)) {
-          bs = viewer.getAtomBits(T.molecule, BSUtil
-              .newAndSetBit(dragAtomIndex));
           viewer.rotateSelected(getDegrees(deltaX, 0), getDegrees(deltaY, 1),
               bs);
         } else {
-          bs = null;
           switch (atomPickingMode) {
+          case PICKING_DRAG_LIGAND:
           case PICKING_DRAG_MOLECULE:
           case PICKING_DRAG_MINIMIZE_MOLECULE:
-            bs = viewer.getAtomBits(T.molecule, BSUtil
-                .newAndSetBit(dragAtomIndex));
             viewer.select(bs, false, 0, true);
             break;
           }
@@ -1410,6 +1412,7 @@
             || isBound(action, ACTION_dragZ);
         break;
       case PICKING_DRAG_SELECTED:
+      case PICKING_DRAG_LIGAND:
       case PICKING_DRAG_MOLECULE:
         isBound = isBound(action, ACTION_dragAtom)
             || isBound(action, ACTION_rotateSelected)

Modified: trunk/Jmol/src/org/jmol/viewer/JC.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/JC.java      2013-06-20 15:05:19 UTC (rev 
18355)
+++ trunk/Jmol/src/org/jmol/viewer/JC.java      2013-06-23 16:34:18 UTC (rev 
18356)
@@ -784,6 +784,8 @@
     "UREA",// 45 urea, a cosolvent
     "PO4", // 46 phosphate ions  -- from here on is "ligand"
     "SO4", // 47 sulphate ions
+    "UNL", // 48 unknown ligand
+    
 
   };
   
@@ -1215,7 +1217,7 @@
     "@water _g>=" + GROUPID_WATER + " & _g<" + GROUPID_SOLVENT_MIN
         + ", oxygen & connected(2) & connected(2, hydrogen), (hydrogen) & 
connected(oxygen & connected(2) & connected(2, hydrogen))",
     "@solvent water, (_g>=" + GROUPID_SOLVENT_MIN + " & _g<" + GROUPID_ION_MAX 
+ ")", // water, other solvent or ions
-    "@ligand !(_g<"+ GROUPID_ION_MIN + ",protein,nucleic,water)",
+    "@ligand _g=0|!(_g<"+ GROUPID_ION_MIN + ",protein,nucleic,water)", // 
includes UNL
 
     // structure
     "@turn structure=1",

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-06-20 15:05:19 UTC 
(rev 18355)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-06-23 16:34:18 UTC 
(rev 18356)
@@ -9,11 +9,16 @@
 #  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.20"
+___JmolVersion="13.1.17_dev_2013.06.21"
 
 TODO: PyMOL uniqueAtomSettings for transparency
         -- will require by-vertex translucent option
         
+new feature: set picking DRAGLIGAND
+  -- won't move the protein
+  
+bug fix: "ligand" should include all _g=0 (nonPDB atoms)
+
 new feature: isosurface SLAB TRANSLUCENT 0.x color  
         -- inherits color of isosurface when color parameter is absent
         -- TODO - properly save in JVXL file

Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2013-06-20 15:05:19 UTC 
(rev 18355)
+++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2013-06-23 16:34:18 UTC 
(rev 18356)
@@ -841,7 +841,7 @@
         mol.appendC('\n');
         for (int j = bsTemp.nextSetBit(0); j >= 0; j = bsTemp.nextSetBit(j + 
1))
           mol.append(LabelToken.formatLabelAtomArray(viewer, atoms[j],
-              (ms.getVibrationVector(j, false) == null ? tokens2 : tokens1), 
'\0',
+              (ms.getVibration(j, false) == null ? tokens2 : tokens1), '\0',
               null));
       }
     } else {
@@ -1166,8 +1166,8 @@
     info.put("y", Float.valueOf(atom.y));
     info.put("z", Float.valueOf(atom.z));
     info.put("coord", P3.newP(atom));
-    if (ms.vibrationVectors != null && ms.vibrationVectors[i] != null) {
-      info.put("vibVector", V3.newV(ms.vibrationVectors[i]));
+    if (ms.vibrations != null && ms.vibrations[i] != null) {
+      info.put("vibVector", V3.newV(ms.vibrations[i]));
     }
     info.put("bondCount", Integer.valueOf(atom.getCovalentBondCount()));
     info.put("radius", Float.valueOf((float) (atom.getRasMolRadius() / 
120.0)));

Modified: trunk/Jmol/src/org/jmol/viewer/ShapeManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java    2013-06-20 15:05:19 UTC 
(rev 18355)
+++ trunk/Jmol/src/org/jmol/viewer/ShapeManager.java    2013-06-23 16:34:18 UTC 
(rev 18356)
@@ -48,7 +48,7 @@
 import org.jmol.util.P3;
 import org.jmol.util.P3i;
 import org.jmol.util.SB;
-import org.jmol.util.V3;
+import org.jmol.util.Vibration;
 
 public class ShapeManager {
 
@@ -434,7 +434,7 @@
   }
 
   public int[] transformAtoms() {
-    V3[] vibrationVectors = modelSet.vibrationVectors;
+    Vibration[] vibrationVectors = modelSet.vibrations;
     Atom[] atoms = modelSet.atoms;
     for (int i = bsRenderableAtoms.nextSetBit(0); i >= 0; i = 
bsRenderableAtoms.nextSetBit(i + 1)) {
       // note that this vibration business is not compatible with

Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/TransformManager.java        2013-06-20 
15:05:19 UTC (rev 18355)
+++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java        2013-06-23 
16:34:18 UTC (rev 18356)
@@ -45,6 +45,7 @@
 import org.jmol.util.SB;
 import org.jmol.util.Tuple3f;
 import org.jmol.util.V3;
+import org.jmol.util.Vibration;
 
 import org.jmol.util.Quaternion;
 
@@ -56,7 +57,6 @@
 
   Viewer viewer;
 
-  final static double twoPI = 2 * Math.PI;
   public final static double degreesPerRadian = 180 / Math.PI;
 
   static final int DEFAULT_NAV_FPS = 10;
@@ -956,14 +956,6 @@
         + (isDepth ? depthValue : slabValue));
   }
 
-  boolean checkInternalSlab(P3 pt) {
-    return (slabPlane != null
-        && pt.x * slabPlane.x + pt.y * slabPlane.y + pt.z * slabPlane.z
-            + slabPlane.w > 0 || depthPlane != null
-        && pt.x * depthPlane.x + pt.y * depthPlane.y + pt.z * depthPlane.z
-            + depthPlane.w < 0);
-  }
-
   /* ***************************************************************
    * PERSPECTIVE
    ****************************************************************/
@@ -1359,7 +1351,7 @@
   protected final P3 point3fScreenTemp = new P3();
   protected final P3i point3iScreenTemp = new P3i();
 
-  private final P3 point3fVibrationTemp = new P3();
+  private final P3 ptVibTemp = new P3();
 
   public boolean navigating = false;
   protected final static int MODE_STANDARD = 0;
@@ -1518,9 +1510,7 @@
     if (pointAngstroms.z == Float.MAX_VALUE
         || pointAngstroms.z == -Float.MAX_VALUE)
       return transformScreenPoint(pointAngstroms);
-    getTemporaryScreenPoint(pointAngstroms);
-    if (internalSlab && checkInternalSlab(pointAngstroms))
-      point3iScreenTemp.z = 1;
+    getTemporaryScreenPoint(pointAngstroms, (internalSlab ? pointAngstroms : 
null));
     //if (!(pointAngstroms instanceof Atom))
       //System.out.println("pt=" + pointAngstroms + " " + point3iScreenTemp + 
" " + Thread.currentThread());
     return point3iScreenTemp;
@@ -1554,30 +1544,25 @@
    * @return POINTER TO point3iScreenTemp
    */
   synchronized P3 transformPointNoClip(P3 pointAngstroms) {
-    getTemporaryScreenPoint(pointAngstroms);
+    getTemporaryScreenPoint(pointAngstroms, null);
     return point3fScreenTemp;
   }
 
   /**
    * @param pointAngstroms
-   * @param vibrationVector
+   * @param v
    * @return POINTER TO TEMPORARY VARIABLE (caution!) point3iScreenTemp
    */
-  P3i transformPointVib(P3 pointAngstroms, V3 vibrationVector) {
-    point3fVibrationTemp.setT(pointAngstroms);
-    if (vibrationOn && vibrationVector != null)
-      point3fVibrationTemp.scaleAdd2(vibrationAmplitude, vibrationVector,
-          pointAngstroms);
-    getTemporaryScreenPoint(point3fVibrationTemp);
-    if (internalSlab && checkInternalSlab(pointAngstroms))
-      point3iScreenTemp.z = 1;
+  P3i transformPointVib(P3 pointAngstroms, Vibration v) {
+    ptVibTemp.setT(pointAngstroms);
+    if (vibrationOn && v != null)
+      v.setTempPoint(ptVibTemp, vibrationT, vibrationScale);
+    getTemporaryScreenPoint(ptVibTemp, pointAngstroms);
     return point3iScreenTemp;
   }
 
   public void transformPoint2(P3 pointAngstroms, P3 screen) {
-    getTemporaryScreenPoint(pointAngstroms);
-    if (internalSlab && checkInternalSlab(pointAngstroms))
-      point3fScreenTemp.z = 1;
+    getTemporaryScreenPoint(pointAngstroms, pointAngstroms);
     screen.setT(point3fScreenTemp);
   }
 
@@ -2051,9 +2036,8 @@
   boolean vibrationOn;
   float vibrationPeriod;
   public int vibrationPeriodMs;
-  private float vibrationAmplitude;
-  private float vibrationRadians;
   private float vibrationScale;
+  private double vibrationT;
 
   void setVibrationScale(float scale) {
     vibrationScale = scale;
@@ -2086,10 +2070,9 @@
   }
 
   public void setVibrationT(float t) {
-    vibrationRadians = (float) (t * twoPI);
+    vibrationT = t;    
     if (vibrationScale == 0)
       vibrationScale = viewer.global.vibrationScale;
-    vibrationAmplitude = (float) Math.cos(vibrationRadians) * vibrationScale;
   }
 
   private VibrationThread vibrationThread;
@@ -2412,10 +2395,12 @@
 
   /**
    * adjusts the temporary point for perspective and offsets
-   * @param pointAngstroms 
    * 
+   * @param pointAngstroms
+   * @param pt0
+   * 
    */
-  protected void getTemporaryScreenPoint(P3 pointAngstroms) {
+  protected void getTemporaryScreenPoint(P3 pointAngstroms, P3 pt0) {
 
     matrixTransform.transform2(pointAngstroms, point3fScreenTemp);
 
@@ -2432,12 +2417,11 @@
       if (!haveNotifiedNaN && Logger.debugging)
         Logger.debug("NaN seen in TransformPoint");
       haveNotifiedNaN = true;
-      z = 1;
+      z = point3fScreenTemp.z = 1;
     } else if (z <= 0) {
       // just don't let z go past 1 BH 11/15/06
-      z = 1;
+      z = point3fScreenTemp.z = 1;
     }
-    point3fScreenTemp.z = z;
 
     // x and y are moved inward (generally) relative to 0, which
     // is either the fixed rotation center or the navigation center
@@ -2475,7 +2459,6 @@
       point3fScreenTemp.y += fixedRotationOffset.y;
       break;
     }
-
     if (Float.isNaN(point3fScreenTemp.x) && !haveNotifiedNaN) {
       if (Logger.debugging)
         Logger.debug("NaN found in transformPoint ");
@@ -2484,6 +2467,16 @@
 
     point3iScreenTemp.set((int) point3fScreenTemp.x, (int) point3fScreenTemp.y,
         (int) point3fScreenTemp.z);
+
+    if (pt0 != null
+        && (slabPlane != null
+            && pt0.x * slabPlane.x + pt0.y * slabPlane.y + pt0.z * slabPlane.z
+                + slabPlane.w > 0 
+                || depthPlane != null
+            && pt0.x * depthPlane.x + pt0.y * depthPlane.y + pt0.z
+                * depthPlane.z + depthPlane.w < 0))
+      point3iScreenTemp.z = 1;
+
   }
 
   public void unTransformPoint(P3 screenPt, P3 coordPt) {

Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java  2013-06-20 15:05:19 UTC (rev 
18355)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java  2013-06-23 16:34:18 UTC (rev 
18356)
@@ -113,6 +113,7 @@
 import org.jmol.util.SB;
 import org.jmol.util.Tuple3f;
 import org.jmol.util.V3;
+import org.jmol.util.Vibration;
 
 import org.jmol.util.Measure;
 import org.jmol.util.Quaternion;
@@ -1306,7 +1307,7 @@
     return transformManager.transformPoint(pointAngstroms);
   }
 
-  public P3i transformPtVib(P3 pointAngstroms, V3 vibrationVector) {
+  public P3i transformPtVib(P3 pointAngstroms, Vibration vibrationVector) {
     return transformManager.transformPointVib(pointAngstroms, vibrationVector);
   }
 
@@ -8659,8 +8660,8 @@
     return modelSet.getBondAtom2(i);
   }
 
-  public V3 getVibrationVector(int atomIndex) {
-    return modelSet.getVibrationVector(atomIndex, false);
+  public Vibration getVibration(int atomIndex) {
+    return modelSet.getVibration(atomIndex, false);
   }
 
   public int getVanderwaalsMar(int i) {

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