Revision: 18535
          http://sourceforge.net/p/jmol/code/18535
Author:   hansonr
Date:     2013-08-11 00:05:54 +0000 (Sun, 11 Aug 2013)
Log Message:
-----------
___JmolVersion="13.3.4_dev_2013.08.10"

new feature: MODULATION command -- for modulated structures 
  -- operates on currently selected set of atoms
  -- MODULATION ON
  -- MODULATION OFF
  -- MODULATION t
    -- sets modulation "t" of selected atoms
  -- MODULATION PLAY t1 t2
    -- animates a once-through sequence of t from t1 to t2
  -- MODULATION FPS x.x  // may be < 1
    -- sets speed of animation

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java
    trunk/Jmol/src/org/jmol/api/JmolViewer.java
    trunk/Jmol/src/org/jmol/modelset/AtomCollection.java
    trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
    trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java
    trunk/Jmol/src/org/jmol/script/T.java
    trunk/Jmol/src/org/jmol/thread/MoveToThread.java
    trunk/Jmol/src/org/jmol/util/Modulation.java
    trunk/Jmol/src/org/jmol/util/ModulationSet.java
    trunk/Jmol/src/org/jmol/viewer/AnimationManager.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/PropertyManager.java
    trunk/Jmol/src/org/jmol/viewer/StateCreator.java
    trunk/Jmol/src/org/jmol/viewer/TransformManager.java
    trunk/Jmol/src/org/jmol/viewer/Viewer.java
    trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/AtomSetChooser.java

Added Paths:
-----------
    trunk/Jmol/src/org/jmol/thread/ModulationThread.java

Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java   
2013-08-10 14:03:58 UTC (rev 18534)
+++ trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java   
2013-08-11 00:05:54 UTC (rev 18535)
@@ -68,7 +68,6 @@
   
   private P3 q1;  
   private V3 q1Norm;  
-  private Matrix3f rot;
   private Map<String, P3> htModulation;
   private Map<String, JmolList<Modulation>> htAtomMods;
   private int modT;
@@ -77,7 +76,7 @@
   
   protected void initializeMod() throws Exception {
     modAxes = getFilter("MODAXES=");
-    modVib = checkFilterKey("MODVIB");
+    modVib = checkFilterKey("MODVIB"); // then use MODULATION ON  to see 
modulation
     modAverage = checkFilterKey("MODAVE");
     checkSpecial = !checkFilterKey("NOSPECIAL");
     atomSetCollection.setCheckSpecial(checkSpecial);
@@ -239,7 +238,6 @@
       return;
     atoms = atomSetCollection.getAtoms();
     symmetry = atomSetCollection.getSymmetry();
-    rot = new Matrix3f();
     SB sb = new SB();
     for (int i = atomSetCollection.getLastAtomSetAtomIndex(); i < n; i++)
       modulateAtom(atoms[i], sb);
@@ -273,9 +271,10 @@
     float epsilon = symmetry.getModParam(iop, 0);
     float delta = symmetry.getModParam(iop, 1);
     delta -= modT;
+    Matrix3f rot = new Matrix3f();
     symmetry.getSpaceGroupOperation(iop).getRotationScale(rot);
-    //System.out.println("=========MR i=" + a.index + " " + a.atomName + " " + 
a + " " + a.occupancy);
-    //System.out.println("op=" + (iop + 1) + " " + 
symmetry.getSpaceGroupXyz(iop, false) + " ep=" + epsilon + " de=" + delta);
+    System.out.println("=========MR i=" + a.index + " " + a.atomName + " " + a 
+ " " + a.occupancy);
+    System.out.println("op=" + (iop + 1) + " " + 
symmetry.getSpaceGroupXyz(iop, false) + " ep=" + epsilon + " de=" + delta);
     ModulationSet ms = new ModulationSet(list);
     a.vib = ms;
     ms.epsilon = epsilon;
@@ -312,7 +311,7 @@
     // displace the atom and reverse the vector only if not filter "MODVIB"
     if (!modVib) {
       a.add(ms);
-      ms.scale(-1);
+      ms.setModT(true, Integer.MAX_VALUE);
     }
     symmetry.toCartesian(ms, true);
     //System.out.println("a.vib(xyz)=" + a.vib);

Modified: trunk/Jmol/src/org/jmol/api/JmolViewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/api/JmolViewer.java 2013-08-10 14:03:58 UTC (rev 
18534)
+++ trunk/Jmol/src/org/jmol/api/JmolViewer.java 2013-08-11 00:05:54 UTC (rev 
18535)
@@ -617,6 +617,7 @@
    * @return string from ScriptEvaluator#outputBuffer
    */
   abstract public String runScript(String script);
+  abstract public int modelGetLastVibrationIndex(int i, int tok);
 
 }
 

Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java        2013-08-10 
14:03:58 UTC (rev 18534)
+++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java        2013-08-11 
00:05:54 UTC (rev 18535)
@@ -2660,6 +2660,5 @@
   }
   
 
-
 }
 

Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java       2013-08-10 
14:03:58 UTC (rev 18534)
+++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java       2013-08-11 
00:05:54 UTC (rev 18535)
@@ -53,6 +53,7 @@
 import org.jmol.util.BS;
 import org.jmol.util.BoxInfo;
 import org.jmol.util.Elements;
+import org.jmol.util.ModulationSet;
 import org.jmol.util.P3;
 import org.jmol.util.P4;
 import org.jmol.util.Tensor;
@@ -1499,13 +1500,15 @@
     return unitCells[modelIndex].getCellRange();
   }
 
-  public boolean modelHasVibrationVectors(int modelIndex) {
+  public int getLastVibrationVector(int modelIndex, int tok) {
     if (vibrations != null)
       for (int i = atomCount; --i >= 0;)
         if ((modelIndex < 0 || atoms[i].modelIndex == modelIndex)
-            && vibrations[i] != null && vibrations[i].length() > 0)
-          return true;
-    return false;
+            && vibrations[i] != null
+            && vibrations[i].length() > 0
+            && (tok == 0 || (tok == T.modulation) == (vibrations[i] instanceof 
ModulationSet)))
+          return i;
+    return -1;
   }
 
   public BS getElementsPresentBitSet(int modelIndex) {
@@ -2705,8 +2708,7 @@
           sb.append(" name=").append(Escape.eS(getModelName(i)))
           .append(" title=").append(Escape.eS(
               getModelTitle(i)))
-           .append(" hasVibrationVectors=\"").appendB(
-              modelHasVibrationVectors(i)).append("\" />");
+           .append(" 
hasVibrationVectors=\"").appendB(viewer.modelHasVibrationVectors(i)).append("\" 
/>");
     }
     sb.append("\n</models>");
     return sb.toString();
@@ -3438,4 +3440,42 @@
     return ilist;
   }
 
+  public void setModulation(BS bs, boolean isOn, int t) {
+    //System.out.println("setModulation " + isOn + " " + t);
+    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
+      Vibration v = getVibration(i, false);
+      if (!(v instanceof ModulationSet))
+        continue;
+      ModulationSet ms = (ModulationSet) v;
+      Atom a = atoms[i];
+      boolean wasEnabled = ms.enabled;
+      //System.out.println(a.x + " " + a.y + " " + a.z + " ms was " + ms + " " 
+ wasEnabled + " " + ms.t);
+      switch (ms.setModT(isOn, t)) {
+      case 0:
+        continue;
+      case 1: // now off
+      case 2: // now on
+        a.sub(ms);
+        break;
+      case 3: // new t
+        // will turn on modulation
+        // must convert to Cartesians
+        getUnitCell(a.modelIndex).toCartesian(ms, true);
+        //System.out.println("ms now1 " + ms + " " + ms.enabled + " " + ms.t);
+        if (wasEnabled)
+          a.add(ms.prevSetting);
+        ms.setModT(true, Integer.MAX_VALUE);
+        a.sub(ms);
+        //System.out.println(a.x + " " + a.y + " " + a.z + " ms now " + ms + " 
" + ms.enabled + " " + ms.t);
+        break;
+      case 4: // unchanged t
+        ms.setModT(true, Integer.MAX_VALUE);
+        if (!wasEnabled)
+          a.sub(ms);
+        break;
+      }
+      //System.out.println(a.x + " " + a.y + " " + a.z + " ms is " + ms + " " 
+ ms.enabled + " " + ms.t);
+    }
+  }
+
 }

Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -5773,6 +5773,9 @@
         case T.minimize:
           minimize();
           break;
+        case T.modulation:
+          modulation();
+          break;
         case T.move:
           move();
           break;
@@ -12524,6 +12527,31 @@
     setShapeSizeBs(shapeType, mad, null);
   }
 
+  private void modulation() throws ScriptException {
+    boolean mod = false;
+    switch (getToken(1).tok) {
+    case T.on:
+      mod = true;
+      //$FALL-THROUGH$
+    case T.off:
+      if (!chk)
+        viewer.setModulation(mod, Integer.MAX_VALUE, Integer.MAX_VALUE, false);
+      break;
+    case T.integer:
+      if (!chk)
+        viewer.setModulation(true, intParameter(1), Integer.MAX_VALUE, false);
+      break;
+    case T.fps:
+      if (!chk)
+        viewer.setModulationFps(floatParameter(2));
+      break;
+    case T.play:
+      if (!chk)
+        viewer.setModulation(true, intParameter(2), intParameter(3), false);
+      break;
+    } 
+  }
+  
   private void animation() throws ScriptException {
     boolean animate = false;
     switch (getToken(1).tok) {

Modified: trunk/Jmol/src/org/jmol/script/T.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/T.java       2013-08-10 14:03:58 UTC (rev 
18534)
+++ trunk/Jmol/src/org/jmol/script/T.java       2013-08-11 00:05:54 UTC (rev 
18535)
@@ -700,6 +700,7 @@
   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;
+  public final static int modulation       = 24 | 0 << 9 | mathfunc | 
scriptCommand;
   
   // xxx(a)
   
@@ -1645,6 +1646,7 @@
       "mo",                T.t(mo),
       "model",             T.t(model),
       "models",            null,
+      "modulation",        T.t(modulation),
       "move",              T.t(move),
       "moveTo",            T.t(moveto),
       "navigate",          T.t(navigate),

Added: trunk/Jmol/src/org/jmol/thread/ModulationThread.java
===================================================================
--- trunk/Jmol/src/org/jmol/thread/ModulationThread.java                        
        (rev 0)
+++ trunk/Jmol/src/org/jmol/thread/ModulationThread.java        2013-08-11 
00:05:54 UTC (rev 18535)
@@ -0,0 +1,115 @@
+/* $RCSfile$
+ * $Author$
+ * $Date$
+ * $Revision$
+ *
+ * Copyright (C) 2011  The Jmol Development Team
+ *
+ * Contact: jmol-develop...@lists.sf.net
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ *  02110-1301, USA.
+ */
+
+package org.jmol.thread;
+
+import org.jmol.util.Logger;
+import org.jmol.viewer.AnimationManager;
+import org.jmol.viewer.Viewer;
+
+public class ModulationThread extends JmolThread {
+  /**
+   * 
+   */
+  private int modT;
+  private final int modT2;
+
+  private AnimationManager animationManager;
+  
+
+  public ModulationThread(AnimationManager animationManager, Viewer viewer, 
int modT1, int modT2) {
+    super();
+    setViewer(viewer, "ModulationThread");
+    modT = modT1;
+    this.modT2 = modT2;
+    this.animationManager = animationManager;
+    viewer.startHoverWatcher(false);
+  }
+
+  @Override
+  public void interrupt() {
+    if (stopped)
+      return;
+    stopped = true;
+    if (Logger.debugging)
+      Logger.debug("animation thread interrupted!");
+    animationManager.modulationPlay = false;
+    try {
+    } catch (Exception e) {
+      // null pointer -- don't care;
+    }
+    super.interrupt();
+  }
+  
+  @Override
+  protected void run1(int mode) throws InterruptedException {
+    while (true) {
+      //System.out.println("AnimationThread " + mode  + " "  + this + " " + 
sleepTime);
+      switch (mode) {
+      case INIT:
+        if (Logger.debugging)
+          Logger.debug("modulation thread running");
+        viewer.requestRepaintAndWait();
+        viewer.startHoverWatcher(false);
+        mode = MAIN;
+        break;
+      case MAIN:
+        //System.out.println("anim thred " + 
animationManager.getCurrentFrame() +" "+ framePointer);
+        if (checkInterrupted() || !animationManager.modulationPlay || modT > 
modT2) {
+          mode = FINISH;
+          break;
+        }
+        mode = CHECK1;
+        break;
+      case CHECK1:
+        viewer.setModulation(true, modT++, Integer.MAX_VALUE, true);
+        mode = CHECK2;
+        break;
+      case CHECK2:
+        targetTime += (int) (1000f / animationManager.modulationFps);
+        mode = CHECK3;
+        break;
+      case CHECK3:
+        while (animationManager.modulationPlay && !checkInterrupted()
+            && !viewer.getRefreshing()) {
+          if (!runSleep(10, CHECK3))
+            return;
+        }
+        viewer.refresh(1, "modulationThread");
+        sleepTime = (int) (targetTime - (System.currentTimeMillis() - 
startTime));
+        if (!runSleep(sleepTime, MAIN))
+          return;
+        mode = MAIN;
+        break;
+      case FINISH:
+        if (Logger.debugging)
+          Logger.debug("modulation thread exiting");
+        animationManager.stopModulationThread();
+        return;
+      }
+    }
+  }
+
+}
\ No newline at end of file

Modified: trunk/Jmol/src/org/jmol/thread/MoveToThread.java
===================================================================
--- trunk/Jmol/src/org/jmol/thread/MoveToThread.java    2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/thread/MoveToThread.java    2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -226,10 +226,14 @@
   }
 
   private void setValues(float fStep) {
+    if (cameraDepth != null)
+      transformManager.setCameraDepthPercent(cameraDepth.getVal(fStep), false);
+    if (cameraX != null && cameraY != null)
+      transformManager.setCamera(cameraX.getVal(fStep), cameraY.getVal(fStep));
+    if (zoom != null)
+      transformManager.zoomToPercent(zoom.getVal(fStep));
     transformManager.modelRadius = rotationRadius.getVal(fStep);
     transformManager.scaleDefaultPixelsPerAngstrom = pixelScale.getVal(fStep);
-    if (zoom != null)
-      transformManager.zoomToPercent(zoom.getVal(fStep));
     if (xTrans != null && yTrans != null) {
       transformManager.translateToPercent('x', xTrans.getVal(fStep));
       transformManager.translateToPercent('y', yTrans.getVal(fStep));
@@ -239,10 +243,6 @@
           .getVal(fStep));
     if (navDepth != null)
       transformManager.setNavigationDepthPercent(navDepth.getVal(fStep));
-    if (cameraDepth != null)
-      transformManager.setCameraDepthPercent(cameraDepth.getVal(fStep), false);
-    if (cameraX != null && cameraY != null)
-      transformManager.setCamera(cameraX.getVal(fStep), cameraY.getVal(fStep));
   }
 
   @Override

Modified: trunk/Jmol/src/org/jmol/util/Modulation.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Modulation.java        2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/util/Modulation.java        2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -19,6 +19,8 @@
   private double left, right;
 
   private V3 nq; // wave vector
+  private double nqlen;
+
   private int fn; // power
   private char axis;
   private final int type;
@@ -50,6 +52,7 @@
    */
   public Modulation(P3 nq, char axis, int type, int fn, P3 params, String 
utens) {
     this.nq = V3.newV(nq);
+    nqlen  = nq.length();
     this.axis = axis;
     this.type = type;
     this.fn = fn;
@@ -120,7 +123,7 @@
     //if (type == TYPE_OCC_CRENEL)
     //delta = 0;
     
-    double x4 = ms.epsilon * (nq.dot(ms.r) - fn * ms.delta + fn * ms.t);
+    double x4 = ms.epsilon * (nq.dot(ms.r) - fn * ms.delta + nqlen * ms.t);
 
     switch (type) {
     case TYPE_DISP_FOURIER:
@@ -131,6 +134,7 @@
         v += a1 * Math.cos(theta);
       if (a2 != 0)
         v += a2 * Math.sin(theta);
+      //System.out.println("MOD v " + v + " a1 a2 " + a1 + " " + a2 + " / " + 
theta + " " +  ms.t);
       break;
     case TYPE_OCC_CRENEL:
 

Modified: trunk/Jmol/src/org/jmol/util/ModulationSet.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/ModulationSet.java     2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/util/ModulationSet.java     2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -21,6 +21,7 @@
   public float v = Float.NaN;
   public int t;
   public Map<String, Float> htValues;
+  public boolean enabled = false;
   
   public ModulationSet(JmolList<Modulation> list) {
     mods = list;
@@ -46,4 +47,33 @@
     htValues.put(utens, Float.valueOf(f == null ? v : f.floatValue() + v));
   }
 
+  public V3 prevSetting;
+  
+  /**
+   * Set modulation "t" value, which sets which unit cell in sequence we are 
looking at.
+   * 
+   * @param isOn
+   * @param t
+   * @return 0 (no change), 1 (disabled), 2 (enabled), 3 (new t), 4 (same t)
+   * 
+   */
+  public int setModT(boolean isOn, int t) {
+    if (t == Integer.MAX_VALUE) {
+      if (enabled == isOn)
+        return 0;
+      enabled = isOn;
+      scale(-1);
+      return (enabled ? 2 : 1);
+    }
+    if (t == this.t)
+      return 4;
+    if (prevSetting == null)
+      prevSetting = new V3(); 
+    prevSetting.setT(this);
+    this.t = t;
+    calculate();
+    enabled = false;
+    return 3;
+  }
+
 }

Modified: trunk/Jmol/src/org/jmol/viewer/AnimationManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/AnimationManager.java        2013-08-10 
14:03:58 UTC (rev 18534)
+++ trunk/Jmol/src/org/jmol/viewer/AnimationManager.java        2013-08-11 
00:05:54 UTC (rev 18535)
@@ -27,6 +27,7 @@
 import java.util.Map;
 
 import org.jmol.thread.AnimationThread;
+import org.jmol.thread.ModulationThread;
 import org.jmol.util.BS;
 import org.jmol.util.BSUtil;
 //import org.jmol.util.JmolList;
@@ -37,6 +38,7 @@
 public class AnimationManager {
 
   private AnimationThread animationThread;
+  private ModulationThread modulationThread;
   private Viewer viewer;
   
   AnimationManager(Viewer viewer) {
@@ -70,7 +72,9 @@
     if (!viewer.getSpinOn())
       viewer.refresh(3, "Viewer:setAnimationOff");
     animation(false);
+    stopModulationThread();
     viewer.setStatusFrameChanged(false);
+    
   }
 
   public boolean setAnimationNext() {
@@ -300,6 +304,18 @@
     lastFramePainted = currentAnimationFrame;
   }
   
+  public void setModulationPlay(int modT1, int modT2) {
+    if (modT1 == Integer.MAX_VALUE || !viewer.haveModelSet() || 
viewer.isHeadless()) {
+      stopThread(false);
+      return;
+    }
+    if (modulationThread == null) {
+      modulationPlay = true;
+      modulationThread = new ModulationThread(this, viewer, modT1, modT2);
+      modulationThread.start();
+    }
+  }
+  
   void resumeAnimation() {
     if(currentModelIndex < 0)
       setAnimationRange(firstFrameIndex, lastFrameIndex);
@@ -411,7 +427,17 @@
   private int lastFramePainted;
   private int lastModelPainted;
   private int intAnimThread;
+  public boolean modulationPlay;
+  public float modulationFps = 1;
+  public BS bsModulating;
   
+  public void setModulationFps(float fps) {
+    if (fps > 0)
+      modulationFps = fps;
+    else
+      stopModulationThread();
+  }
+  
   private void setViewer(boolean clearBackgroundModel) {
     viewer.setTrajectory(currentModelIndex);
     viewer.setFrameOffset(currentModelIndex);
@@ -511,5 +537,13 @@
     return frameStep * direction * currentDirection;
   }
 
+  public void stopModulationThread() {
+    if (modulationThread != null) {
+      modulationThread.interrupt();
+      modulationThread = null;
+    }
+    modulationPlay = false;
+  }
 
+
 }

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -11,8 +11,21 @@
 #  The quotes above look odd for a parameter file, but they are 
 #  important for the JavaScript version of Jmol.
 
-___JmolVersion="13.3.4_dev_2013.08.09"
+___JmolVersion="13.3.4_dev_2013.08.10"
 
+new feature: MODULATION command -- for modulated structures 
+  -- operates on currently selected set of atoms
+  -- MODULATION ON
+  -- MODULATION OFF
+  -- MODULATION t
+    -- sets modulation "t" of selected atoms
+  -- MODULATION PLAY t1 t2
+    -- animates a once-through sequence of t from t1 to t2
+  -- MODULATION FPS x.x  // may be < 1
+    -- sets speed of animation
+               
+bug fix: zoom setting lost in state
+
 code: incommensurate crystal work -- Uiso, preliminary Uij and subsystems
 code: incommensurate crystal work -- occupancy Crenel, displacive sawtooths
 

Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -642,8 +642,7 @@
       s = (String) m.getModelAuxiliaryInfoValue(i, "modelID");
       if (s != null)
         model.put("id", s);
-      model.put("vibrationVectors", Boolean.valueOf(m
-          .modelHasVibrationVectors(i)));
+      model.put("vibrationVectors", 
Boolean.valueOf(viewer.modelHasVibrationVectors(i)));
       Model mi = m.models[i];
       model.put("atomCount", Integer.valueOf(mi.atomCount));
       model.put("bondCount", Integer.valueOf(mi.getBondCount()));

Modified: trunk/Jmol/src/org/jmol/viewer/StateCreator.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2013-08-10 14:03:58 UTC 
(rev 18534)
+++ trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2013-08-11 00:05:54 UTC 
(rev 18535)
@@ -79,6 +79,7 @@
 import org.jmol.util.JmolEdge;
 import org.jmol.util.JmolFont;
 import org.jmol.util.Logger;
+import org.jmol.util.ModulationSet;
 import org.jmol.util.Parser;
 import org.jmol.util.P3;
 import org.jmol.util.SB;
@@ -290,8 +291,7 @@
       if (bs.isEmpty())
         ms.haveHiddenBonds = false;
       else
-        commands.append("  hide ").append(Escape.eBond(bs)).append(
-            ";\n");
+        commands.append("  hide ").append(Escape.eBond(bs)).append(";\n");
     }
 
     // shape construction
@@ -317,12 +317,12 @@
         String s = (String) ms.getModelAuxiliaryInfoValue(i, "modelID");
         if (s != null
             && !s.equals(ms.getModelAuxiliaryInfoValue(i, "modelID0")))
-          commands.append(fcmd).append("; frame ID ").append(
-              Escape.eS(s)).append(";\n");
+          commands.append(fcmd).append("; frame ID ").append(Escape.eS(s))
+              .append(";\n");
         String t = ms.frameTitles[i];
         if (t != null && t.length() > 0)
-          commands.append(fcmd).append("; frame title ").append(
-              Escape.eS(t)).append(";\n");
+          commands.append(fcmd).append("; frame title ").append(Escape.eS(t))
+              .append(";\n");
         if (needOrientations && models[i].orientation != null
             && !ms.isTrajectorySubFrame(i))
           commands.append(fcmd).append("; ").append(
@@ -339,6 +339,7 @@
       }
 
       if (ms.unitCells != null) {
+        boolean haveModulation = false;
         for (int i = 0; i < modelCount; i++) {
           SymmetryInterface symmetry = ms.getUnitCell(i);
           if (symmetry == null)
@@ -351,12 +352,30 @@
           if (pt != null)
             commands.append("; set unitcell ").append(Escape.eP(pt));
           commands.append(";\n");
+          haveModulation |= (viewer.modelGetLastVibrationIndex(i, 
T.modulation) >= 0);
         }
         getShapeState(commands, isAll, JC.SHAPE_UCCAGE);
         //        if (viewer.getObjectMad(StateManager.OBJ_UNITCELL) == 0)
         //        commands.append("  unitcell OFF;\n");
+        if (haveModulation) {
+          //commands.append("  modulation fps "
+            //  + viewer.animationManager.modulationFps + ";\n");
+          Map<String, BS> temp = new Hashtable<String, BS>();
+          int ivib;
+          for (int i = modelCount; --i >= 0;) {
+            if ((ivib = viewer.modelGetLastVibrationIndex(i, T.modulation)) >= 
0)
+              for (int j = models[i].firstAtomIndex; j <= ivib; j++) {
+                ModulationSet mset = (ModulationSet) viewer.getVibration(j);
+                if (mset.enabled)
+                  BSUtil.setMapBitSet(temp, j, j, "modulation " + mset.t);
+              }
+          }
+          String s = getCommands(temp, null, "select");
+          commands.append(s);
+        }
       }
-      commands.append("  set fontScaling " + viewer.getBoolean(T.fontscaling) 
+ ";\n");
+      commands.append("  set fontScaling " + viewer.getBoolean(T.fontscaling)
+          + ";\n");
       if (viewer.getBoolean(T.modelkitmode))
         commands.append("  set modelKitMode true;\n");
     }

Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/TransformManager.java        2013-08-10 
14:03:58 UTC (rev 18534)
+++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java        2013-08-11 
00:05:54 UTC (rev 18535)
@@ -2064,8 +2064,7 @@
         return;
       period = -period;
     }
-    setVibrationOn(period > 0
-        && viewer.modelHasVibrationVectors(viewer.getCurrentModelIndex()));
+    setVibrationOn(period > 0 && 
viewer.modelGetLastVibrationIndex(viewer.getCurrentModelIndex(), 0) >= 0);
   }
 
   public void setVibrationT(float t) {

Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java  2013-08-10 14:03:58 UTC (rev 
18534)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java  2013-08-11 00:05:54 UTC (rev 
18535)
@@ -3130,8 +3130,13 @@
   }
 
   @Override
+  public int modelGetLastVibrationIndex(int modelIndex, int tok) {
+    return modelSet.getLastVibrationVector(modelIndex, tok);
+  }
+
+  @Override
   public boolean modelHasVibrationVectors(int modelIndex) {
-    return modelSet.modelHasVibrationVectors(modelIndex);
+    return (modelSet.getLastVibrationVector(modelIndex, T.vibration) >= 0);
   }
 
   @Override
@@ -10174,4 +10179,20 @@
     return (!getTestFlag(1));
   }
 
+  public void setModulation(boolean isOn, int t1, int t2, boolean isThread) {
+    if (t2 == Integer.MAX_VALUE) {
+      if (!isThread)
+        animationManager.setModulationPlay(Integer.MAX_VALUE, 0);
+      if (t1 != Integer.MAX_VALUE)
+        global.setI("_modt", t1);
+      modelSet.setModulation(getSelectionSet(false), isOn, t1);
+    } else {
+      animationManager.setModulationPlay(t1, t2);
+    }
+  }
+
+  public void setModulationFps(float fps) {
+    animationManager.setModulationFps(fps);
+  }
+
 }

Modified: trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/AtomSetChooser.java
===================================================================
--- trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/AtomSetChooser.java       
2013-08-10 14:03:58 UTC (rev 18534)
+++ trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/AtomSetChooser.java       
2013-08-11 00:05:54 UTC (rev 18535)
@@ -588,7 +588,7 @@
     
     // search till get to either end of found a frequency
     while (index >= 0 && index < maxIndex 
-        && !(foundFrequency=viewer.modelHasVibrationVectors(indexes[index]))) {
+        && 
!(foundFrequency=(viewer.modelHasVibrationVectors(indexes[index])))) {
       index+=increment;
     }
     

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


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to