Revision: 5154
Author:   hansonr
Date:     2006-05-21 09:42:36 -0700 (Sun, 21 May 2006)
ViewCVS:  http://svn.sourceforge.net/jmol/?rev=5154&view=rev

Log Message:
-----------
bob200603 refining rotate/spin; pruning unnecessary code.

I had initially set "spin on" to operate PRECISELY as in Version 10.0,
namely so that it initiated only spinning based on "set spin..."

But in the wider context, this now seems unnecessary. It is 
more natural to have "spin on" restart any previous spinning, 
regardless of its type.

Modified Paths:
--------------
    branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java
    branches/bob200603/Jmol/src/org/jmol/viewer/TransformManager.java
Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java
===================================================================
--- branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java       2006-05-20 
19:03:05 UTC (rev 5153)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java       2006-05-21 
16:42:36 UTC (rev 5154)
@@ -1833,11 +1833,16 @@
   void rotate(boolean isSpin) throws ScriptException {
 
     /*
+     * The Chime spin method:
      * 
+     * set spin x 10;set spin y 30; set spin z 10;
+     * spin | spin ON
+     * spin OFF
+     * 
+     * Jmol does these "first x, then y, then z"
+     * I don't know what Chime does.
+     * 
      * spin and rotate are now consolidated here.
-     * The old "spin x, spin y, spin z" is still there, but 
-     * pretty much deprecated because it is not that useful.
-     * spin on and spin off still work as well -- and are important
      * 
      * far simpler is
      * 
@@ -1853,9 +1858,9 @@
      *  
      *  note that there are many defaults
      *  
-     *  spin
-     *  spin 10
-     *  spin x
+     *  spin     # defaults to spin y 10
+     *  spin 10  # defaults to spin y 10
+     *  spin x   # defaults to spin x 10
      *  
      *  and several new options
      *  
@@ -1864,12 +1869,11 @@
      *  spin 10 (atomno=1)(atomno=2)
      *  spin 20 {0 0 0} {1 1 1}
      *  
-     *  spin MOLECULAR 20 {0 0 0} {1 1 1}
+     *  spin MOLECULAR {0 0 0} 20
      *  
      *  The MOLECULAR keyword indicates that spins or rotations are to be
      *  carried out in the internal molecular coordinate frame, not the
-     *  fixed room frame. When fractional coordinates are indicated, 
-     *  MOLECULAR is automatically selected and need not be indicated:
+     *  fixed room frame. Fractional coordinates may be indicated:
      *   
      *  spin 20 {0 0 0/} {1 1 1/}
      *  
@@ -1879,7 +1883,7 @@
      *  two in TransformManager. All the centering stuff has been carefully
      *  inspected are reorganized as well. 
      *  
-     *  Bob Hanson
+     *  Bob Hanson 5/21/06
      *
      *
      */
@@ -1899,7 +1903,6 @@
     float endDegrees = Float.MAX_VALUE;
     boolean isAxisAngle = false;
     boolean isInternal = false;
-    //rotate INTERNAL nDegrees (coord/atom expression) (coord/atomexpression)
     Point3f[] points = new Point3f[3];
     Point3f rotCenter = null;
     Vector3f rotAxis = new Vector3f(0, 1, 0);
@@ -1945,8 +1948,6 @@
       case Token.leftbrace:
         // {X, Y, Z}
         Point3f pt = getCoordinate(i, true);
-        if (coordinatesAreFractional)
-          isInternal = true;
         i = pcLastExpressionInstruction;
         if (isAxisAngle) {
           if (axesOrientationRasmol)
@@ -2009,28 +2010,28 @@
       // rotate x 10 (atoms)
       // rotate x 10 $object
       // rotate x 10 
-      if (degrees == Integer.MIN_VALUE)
+      if (degrees == Float.MIN_VALUE)
         degrees = 10;
       viewer.rotateAxisAngleAtCenter(rotCenter, rotAxis, degrees, endDegrees,
           isSpin);
       return;
     }
     if (nPoints < 2) {
-      // rotate INTERNAL
-      // rotate INTERNAL (atom1)
-      // rotate INTERNAL x 10 (atom1)
-      // rotate axisangle INTERNAL (atom1)
+      // rotate MOLECULAR
+      // rotate MOLECULAR (atom1)
+      // rotate MOLECULAR x 10 (atom1)
+      // rotate axisangle MOLECULAR (atom1)
       points[1].set(points[0]);
       points[1].sub(rotAxis);
     } else {
       // rotate 10 (atom1) (atom2)
-      // rotate 10 [x y z] [x y z]
-      // rotate 10 (atom1) [x y z]
+      // rotate 10 {x y z} {x y z}
+      // rotate 10 (atom1) {x y z}
     }
 
     if (points[0].distance(points[1]) == 0)
       rotationPointsIdentical();
-    if (degrees == Integer.MIN_VALUE)
+    if (degrees == Float.MIN_VALUE)
       degrees = 10;
     viewer.rotateAboutPointsInternal(points[0], points[1], degrees, endDegrees,
         isSpin);

Modified: branches/bob200603/Jmol/src/org/jmol/viewer/TransformManager.java
===================================================================
--- branches/bob200603/Jmol/src/org/jmol/viewer/TransformManager.java   
2006-05-20 19:03:05 UTC (rev 5153)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/TransformManager.java   
2006-05-21 16:42:36 UTC (rev 5154)
@@ -55,15 +55,15 @@
   }
 
   final static float twoPI = (float) (2 * Math.PI);
-  float spinX, spinY = 30f, spinZ, spinW, spinFps = 30f;
+  float spinX, spinY = 30f, spinZ, spinFps = 30f;
   Point3f fixedRotationCenter = new Point3f(0, 0, 0);
   AxisAngle4f fixedRotationAxis;
   float fixedRotationAngle = 0;
   float fixedRotationAngleFramed = 0;
   boolean haveNotifiedNaN = false;
   boolean haveNotifiedCamera = false;
-  boolean isInternal = false;
-  boolean isFixed = false;
+  boolean isSpinInternal = false;
+  boolean isSpinFixed = false;
   AxisAngle4f internalRotationAxis;
   Point3f internalRotationCenter = new Point3f(0, 0, 0);
   float internalRotationAngle = 0;
@@ -111,7 +111,6 @@
   }
 
   float setRotateInternal(Point3f center, Vector3f axis, float degrees) {
-    isInternal = true;
     checkFixedRotationCenter();
     internalRotationCenter.set(center);
     if (internalRotationAxis == null)
@@ -122,9 +121,6 @@
   }
 
   float setRotateFixed(Point3f center, Vector3f axis, float degrees) {
-    spinW = degrees; //turns off old-stype spinX, spinY, spinZ
-    //spinX = spinY = spinZ = 0;
-    isFixed = true;
     if (center != null)
       fixedRotationCenter.set(center);
     if (fixedRotationAxis == null)
@@ -219,7 +215,7 @@
 
     //*THE* Viewer FIXED frame rotation/spinning entry point
 
-    System.out.println("rotateatcenter "+degrees+" "+endDegrees+" "+isSpin);
+    //System.out.println("rotateatcenter "+degrees+" "+endDegrees+" "+isSpin);
     setSpinOn(false);
 
     if (degrees == 0)
@@ -230,6 +226,8 @@
     }
     float angle = setRotateFixed(rotCenter, rotAxis, degrees);
     if (isSpin) {
+      isSpinInternal = false;
+      isSpinFixed = true;
       setSpinOn(true, endDegrees);
       return;
     }
@@ -254,7 +252,7 @@
 
     // *THE* Viewer INTERNAL frame rotation entry point
 
-    System.out.println("rotateAboutPointsInternal "+degrees+" "+endDegrees+" 
"+isSpin);
+    //System.out.println("rotateAboutPointsInternal "+degrees+" "+endDegrees+" 
"+isSpin);
 
     setSpinOn(false);
 
@@ -268,6 +266,8 @@
     float angle = setRotateInternal(point1, axis, degrees);
 
     if (isSpin) {
+      isSpinInternal = true;
+      isSpinFixed = false;
       setSpinOn(true, endDegrees);
       return;
     }
@@ -1324,42 +1324,26 @@
     sb.append(Math.round(val * 10) / 10f);
   }
 
-  /*
-   static void truncate2(StringBuffer sb, float val) {
-   sb.append(" ");
-   sb.append(Math.round(val * 100) / 100f);
-   }
-
-   static void truncate3(StringBuffer sb, float val) {
-   sb.append(" ");
-   sb.append(Math.round(val * 1000) / 1000f);
-   }
-   */
-
-
   /* ***************************************************************
    * Spin support
    ****************************************************************/
 
   void setSpinX(float degrees) {
     spinX = degrees;
-    spinW = 0;
-    if (isInternal)
-      setSpinOn(false);
+    if (isSpinInternal || isSpinFixed)
+      clearSpin();
   }
 
   void setSpinY(float degrees) {
     spinY = degrees;
-    spinW = 0;
-    if (isInternal)
-      setSpinOn(false);
+    if (isSpinInternal || isSpinFixed)
+      clearSpin();
   }
 
   void setSpinZ(float degrees) {
     spinZ = degrees;
-    spinW = 0;
-    if (isInternal)
-      setSpinOn(false);
+    if (isSpinInternal || isSpinFixed)
+      clearSpin();
   }
 
   void setSpinFps(int value) {
@@ -1372,6 +1356,9 @@
 
   void clearSpin() {
     setSpinOn(false);
+    isSpinInternal = false;
+    isSpinFixed = false;
+    //back to the Chime defaults
   }
 
   boolean spinOn;
@@ -1393,7 +1380,6 @@
       if (spinThread != null) {
         spinThread.interrupt();
         spinThread = null;
-        isInternal = isFixed = false;
       }
     }
     //System.out.println("spinOn=" + spinOn);
@@ -1419,9 +1405,9 @@
           setSpinOn(false);
           return;
         }
-        boolean refreshNeeded = (isInternal && internalRotationAxis.angle != 0
-            || isFixed && fixedRotationAxis != null && fixedRotationAxis.angle 
!= 0 
-            || !isFixed && !isInternal && (spinX + spinY + spinZ != 0));
+        boolean refreshNeeded = (isSpinInternal && internalRotationAxis.angle 
!= 0
+            || isSpinFixed && fixedRotationAxis != null && 
fixedRotationAxis.angle != 0 
+            || !isSpinFixed && !isSpinInternal && (spinX + spinY + spinZ != 
0));
         ++i;
         int targetTime = (int) (i * 1000 / myFps);
         int currentTime = (int) (System.currentTimeMillis() - timeBegin);
@@ -1429,9 +1415,9 @@
         if (sleepTime > 0) {
           if (refreshNeeded && spinOn) {
             float angle = 0;
-            if (isInternal || isFixed) {
-              angle = (isInternal ? internalRotationAxis : 
fixedRotationAxis).angle/ myFps;
-              if (isInternal) {
+            if (isSpinInternal || isSpinFixed) {
+              angle = (isSpinInternal ? internalRotationAxis : 
fixedRotationAxis).angle/ myFps;
+              if (isSpinInternal) {
                 rotateAxisAngleRadiansInternal(angle);
               } else {
                 rotateAxisAngleRadiansFixed(angle);


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



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jmol-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to