Revision: 20275
          http://sourceforge.net/p/jmol/code/20275
Author:   hansonr
Date:     2015-02-09 13:10:40 +0000 (Mon, 09 Feb 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.12_2015.02.09"

new feature: frame align {atoms} FIXED
 -- shifts atom positions in each frame to match first atom in {atoms}
 -- unlike just frame align {atoms}, frame * will still show alignment
 -- objects such as DRAW and ISOSURFACE will NOT be shifted
 -- needs testing
  
new feature: frame align [modelNo] [pt]
 -- FIXED is assumed
 -- used in state; shifts a model by a specific amount after removing any 
current frame alignment
  

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/modelset/Model.java
    trunk/Jmol/src/org/jmol/modelset/ModelSet.java
    trunk/Jmol/src/org/jmol/script/ScriptEval.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/StateCreator.java
    trunk/Jmol/src/org/jmol/viewer/TransformManager.java
    trunk/Jmol/src/org/jmol/viewer/Viewer.java

Modified: trunk/Jmol/src/org/jmol/modelset/Model.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Model.java 2015-02-08 18:38:27 UTC (rev 
20274)
+++ trunk/Jmol/src/org/jmol/modelset/Model.java 2015-02-09 13:10:40 UTC (rev 
20275)
@@ -33,7 +33,9 @@
 
 
 import javajs.util.AU;
+import javajs.util.P3;
 import javajs.util.SB;
+import javajs.util.T3;
 
 import org.jmol.util.BSUtil;
 
@@ -96,6 +98,7 @@
   public Properties properties;
   public SymmetryInterface biosymmetry;
   Map<String, Integer> dataFrames;
+  P3 translation;
 
   int dataSourceFrame = -1;
 

Modified: trunk/Jmol/src/org/jmol/modelset/ModelSet.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelSet.java      2015-02-08 18:38:27 UTC 
(rev 20274)
+++ trunk/Jmol/src/org/jmol/modelset/ModelSet.java      2015-02-09 13:10:40 UTC 
(rev 20275)
@@ -310,17 +310,82 @@
       trajectory.morph(m1, m2, f);
   }  
   
-  public P3[] getFrameOffsets(BS bsAtoms) {
-    if (bsAtoms == null)
+  public P3[] translations;
+  
+  public P3 getTranslation(int iModel) {
+    return (translations == null || iModel >= translations.length ? null : 
translations[iModel]); 
+  }
+  
+  /**
+   * move atoms by vector pt; used for co-centering with FRAME ALIGN {atoms} 
TRUE
+   * 
+   * @param iModel
+   * @param pt
+   */
+  public void translateModel(int iModel, T3 pt) {
+    if (pt == null) {
+      P3 t = getTranslation(iModel);
+      if (t == null)
+        return;
+      pt = P3.newP(t);
+      pt.scale(-1);
+      translateModel(iModel, pt);
+      translations[iModel] = null;
+      return;
+    }
+    if (translations == null || translations.length <= iModel)
+      translations = new P3[mc];
+    if (translations[iModel] == null)
+      translations[iModel] = new P3();
+    translations[iModel].add(pt);
+    BS bs = am[iModel].bsAtoms;
+    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))
+      at[i].add(pt);
+  }
+
+  public P3[] getFrameOffsets(BS bsAtoms, boolean isFull) {
+    if (bsAtoms == null) {
+      if (isFull)
+        for (int i = mc; --i >= 0;) {
+          Model m = am[i];
+          if (!m.isJmolDataFrame && !m.isTrajectory)
+            translateModel(m.modelIndex, null);
+        }
       return null;
+    }
+    int i0 = bsAtoms.nextSetBit(0);
+    if (i0 < 0)
+      return null;
+    if (isFull) {
+      BS bs = BSUtil.copy(bsAtoms);
+      P3 pt = null;
+      P3 pdiff = new P3();
+      for (int i = 0; i < mc; i++) {
+        Model m = am[i];
+        if (!m.isJmolDataFrame && !m.isTrajectory) {
+          int j = bs.nextSetBit(0);
+          if (m.bsAtoms.get(j)) {
+            if (pt == null) {
+              pt = P3.newP(at[j]);
+            } else {
+              pdiff.sub2(pt, at[j]);
+              translateModel(i, pdiff);
+            }
+          }
+        }
+        bs.andNot(m.bsAtoms);
+      }
+      return null;
+    }
     P3[] offsets = new P3[mc];
-    for (int i = 0; i < mc; i++)
+    for (int i = mc; --i >= 0;)
       offsets[i] = new P3();
     int lastModel = 0;
     int n = 0;
     P3 offset = offsets[0];
     boolean asTrajectory = (trajectory != null && trajectory.steps.size() == 
mc);
     int m1 = (asTrajectory ? mc : 1);
+    offsets[0].set(0, 0, 0);
     for (int m = 0; m < m1; m++) {
       if (asTrajectory)
         setTrajectory(m);
@@ -343,7 +408,6 @@
         n++;
       }
     }
-    offsets[0].set(0, 0, 0);
     return offsets;
   }
 

Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-02-08 18:38:27 UTC 
(rev 20274)
+++ trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-02-09 13:10:40 UTC 
(rev 20275)
@@ -5019,9 +5019,14 @@
               : (tokAt(2) == T.varray ? SV.strListValue(st[2]) : 
paramAsStr(2)));
       return;
     case T.align:
-      BS bs = (slen == 2 || tokAt(2) == T.none ? null : atomExpressionAt(2));
+      boolean isNone = (tokAt(2) == T.none);
+      BS bs = (slen == 2 || isNone ? null : atomExpressionAt(2));
+      if (isNone)
+        iToken = 2;
+      boolean isFixed = (tokAt(iToken + 1) == T.fixed);
+      checkLength(iToken + (isFixed ? 2 : 1));
       if (!chk)
-        vwr.setFrameOffsets(bs);
+        vwr.setFrameOffsets(bs, isFixed);
       return;
     }
     if (getToken(offset).tok == T.minus) {
@@ -5042,6 +5047,7 @@
     int[] frameList = new int[] { -1, -1 };
     int nFrames = 0;
     float fFrame = 0;
+    P3 frameAlign = null;
     boolean haveFileSet = vwr.haveFileSet();
     if (isArrayParameter(1)) {
       setFrameSet(1);
@@ -5049,6 +5055,13 @@
     } else {
       for (int i = offset; i < slen; i++) {
         switch (getToken(i).tok) {
+        case T.align:
+          // model 2.3 align {0 0 0}  // from state 
+          if (i != 2)
+            invArg();
+          frameAlign = centerParameter(3);
+          checkLength(i = iToken + 1);
+          break;
         case T.all:
         case T.times:
           checkLength(offset + (isRange ? 2 : 1));
@@ -5088,14 +5101,11 @@
           if (iFrame == Integer.MAX_VALUE) {
             if (i == 1) {
               String id = theToken.value.toString();
-              int modelIndex = (chk ? -1 : vwr.getModelIndexFromId(id));
-              if (modelIndex >= 0) {
-                checkLength(2);
-                vwr.setCurrentModelIndex(modelIndex);
-                return;
-              }
+              iFrame = (chk ? -2 : vwr.getModelIndexFromId(id));
+            } else {
+              iFrame = 0; // frame 0.0
             }
-            iFrame = 0; // frame 0.0
+            useModelNumber = false;
           }
           if (iFrame == -1) {
             checkLength(offset + 1);
@@ -5130,10 +5140,10 @@
         }
       }
     }
+    if (chk)
+      return;
     if (isRange && nFrames == 0)
       isAll = true;
-    if (chk)
-      return;
     if (isAll) {
       vwr.setAnimationOn(false);
       vwr.setAnimationRange(-1, -1);
@@ -5151,7 +5161,13 @@
           frameList[i] %= 1000000;
     int modelIndex = vwr.ms.getModelNumberIndex(frameList[0], useModelNumber,
         false);
-
+    if (frameAlign != null) {
+      if (modelIndex >= 0) {
+        vwr.ms.translateModel(modelIndex, null);
+        vwr.ms.translateModel(modelIndex, frameAlign);
+      }
+      return;
+    }
     int modelIndex2 = -1;
     if (haveFileSet && modelIndex < 0 && frameList[0] != 0) {
       // may have frame 2.0 or frame 2 meaning the range of models in file 2

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-02-08 18:38:27 UTC 
(rev 20274)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-02-09 13:10:40 UTC 
(rev 20275)
@@ -15,8 +15,21 @@
 TODO: remove HTML5 dependency on synchronous file loading (check SCRIPT 
command for problems)
 TODO: add 2D graphics panel for Ramachandran and NBO-style 2D graphics -- send 
to browser as data uri?
 
-Jmol.___JmolVersion="14.3.12_2015.02.07"
+Jmol.___JmolVersion="14.3.12_2015.02.09"
 
+new feature: frame align {atoms} FIXED
+ -- shifts atom positions in each frame to match first atom in {atoms}
+ -- unlike just frame align {atoms}, frame * will still show alignment
+ -- objects such as DRAW and ISOSURFACE will NOT be shifted
+ -- needs testing
+  
+new feature: frame align [modelNo] [pt]
+ -- FIXED is assumed
+ -- used in state; shifts a model by a specific amount after removing any 
current frame alignment
+  
+JmolVersion="14.3.12_2015.02.07"
+released
+
 bug fix: set meshScale is not being applied to isosurface contours
 bug fix: zoomTo{xxx} 0  does not center (broken in 13.1.16_dev_2013.05.23)
 bug fix: appending a model to a model with data can fail
@@ -46,6 +59,7 @@
 
 
 JmolVersion="14.3.12_2015.02.04"
+released
 
 new feature: print data({*},"xyz") 
   -- (lower case) writes only atom data lines

Modified: trunk/Jmol/src/org/jmol/viewer/StateCreator.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2015-02-08 18:38:27 UTC 
(rev 20274)
+++ trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2015-02-09 13:10:40 UTC 
(rev 20275)
@@ -574,8 +574,15 @@
     if (am.backgroundModelIndex >= 0)
       app(commands, "set backgroundModel "
           + vwr.getModelNumberDotted(am.backgroundModelIndex));
-    if (vwr.bsFrameOffsets != null)
-      app(commands, "frame align " + Escape.eBS(vwr.bsFrameOffsets));
+    if (vwr.tm.bsFrameOffsets != null) {
+      app(commands, "frame align " + Escape.eBS(vwr.tm.bsFrameOffsets));
+    } else if (vwr.ms.translations != null) {
+      for (int i = modelCount; --i >= 0;) {
+        P3 t = (vwr.ms.getTranslation(i));
+        if (t != null)
+          app(commands, "frame " + vwr.ms.getModelNumberDotted(i) + " align " 
+ t);          
+      }
+    }
     app(commands, "frame RANGE "
         + am.getModelSpecial(AnimationManager.FRAME_FIRST) + " "
         + am.getModelSpecial(AnimationManager.FRAME_LAST));

Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/TransformManager.java        2015-02-08 
18:38:27 UTC (rev 20274)
+++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java        2015-02-09 
13:10:40 UTC (rev 20275)
@@ -1457,7 +1457,7 @@
     matrixTransform.setIdentity();
 
     // first, translate the coordinates back to the center
-
+    
     vectorTemp.sub2(frameOffset, fixedRotationCenter);
     matrixTransform.setTranslation(vectorTemp);
 
@@ -2351,13 +2351,15 @@
    ****************************************************************/
 
   final P3 frameOffset = new P3();
+  P3[] frameOffsets;
+  public BS bsFrameOffsets;
 
   void setFrameOffset(int modelIndex) {
-    if (vwr.frameOffsets == null || modelIndex < 0
-        || modelIndex >= vwr.frameOffsets.length)
+    if (frameOffsets == null || modelIndex < 0
+        || modelIndex >= frameOffsets.length)
       frameOffset.set(0, 0, 0);
     else
-      frameOffset.setT(vwr.frameOffsets[modelIndex]);
+      frameOffset.setT(frameOffsets[modelIndex]);
   }
 
   /////////// Allow during-rendering mouse operations ///////////
@@ -2643,6 +2645,7 @@
 
   private JmolNavigatorInterface nav;
 
+
   private void navInterrupt() {
     if (nav != null)
       nav.interrupt();

Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java  2015-02-08 18:38:27 UTC (rev 
20274)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java  2015-02-09 13:10:40 UTC (rev 
20275)
@@ -2421,7 +2421,7 @@
   }
 
   public void clearModelDependentObjects() {
-    setFrameOffsets(null);
+    setFrameOffsets(null, false);
     stopMinimization();
     minimizer = null;
     smilesMatcher = null;
@@ -3073,11 +3073,13 @@
     return (ms.trajectory == null ? "" : ms.trajectory.getState());
   }
 
-  BS bsFrameOffsets;
-  P3[] frameOffsets;
-
-  public void setFrameOffsets(BS bsAtoms) {
-    frameOffsets = ms.getFrameOffsets(bsFrameOffsets = bsAtoms);
+  public void setFrameOffsets(BS bsAtoms, boolean isFull) {
+    tm.bsFrameOffsets = null;
+    if (isFull)
+      clearModelDependentObjects();
+    else
+      tm.bsFrameOffsets = bsAtoms;
+    tm.frameOffsets = ms.getFrameOffsets(bsAtoms, isFull);
   }
 
   public void setCurrentModelIndexClear(int modelIndex, boolean 
clearBackground) {
@@ -7954,7 +7956,7 @@
                                BS bsModelAtoms) {
     // called from ModelCollection.deleteModel
     sm.modifySend(-1, modelIndex, 1, "delete atoms " + 
Escape.eBS(bsModelAtoms));
-    BSUtil.deleteBits(bsFrameOffsets, bsModelAtoms);
+    BSUtil.deleteBits(tm.bsFrameOffsets, bsModelAtoms);
     getDataManager().deleteModelAtoms(firstAtomIndex, nAtoms, bsModelAtoms);
     sm.modifySend(-1, modelIndex, -1, "OK");
   }

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


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to