Revision: 5142
Author:   hansonr
Date:     2006-05-18 20:25:44 -0700 (Thu, 18 May 2006)
ViewCVS:  http://svn.sourceforge.net/jmol/?rev=5142&view=rev

Log Message:
-----------
bob200603 10.x.03 fractional coordinates finalization/code clean-up.

Modified Paths:
--------------
    branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java
Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java
===================================================================
--- branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java       2006-05-19 
01:36:34 UTC (rev 5141)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java       2006-05-19 
03:25:44 UTC (rev 5142)
@@ -1379,9 +1379,7 @@
 
     if (statement[1].tok == Token.leftbrace) {
       //center { x y z } 
-      Point3f pt = getCoordinate(1);
-      if (coordinatesAreFractional)
-        viewer.convertFractionalCoordinates(pt);
+      Point3f pt = getCoordinate(1, true);
       viewer.setNewRotationCenter(pt);
       return;
     }
@@ -1390,12 +1388,12 @@
   }
   
   boolean coordinatesAreFractional;
-  Point3f getCoordinate(int i) throws ScriptException {
-    coordinatesAreFractional = false;
+  Point3f getCoordinate(int i, boolean allowFractional) throws ScriptException 
{
     // syntax:  {1/2, 1/2, 1/3} or {0.5/, 0.5, 0.5}
     // ONE fractional sign anywhere is enough to make ALL fractional;
     // denominator of 1 can be implied;
     // commas not necessary if denominator is present or not a fraction
+    coordinatesAreFractional = false;
     if (statement[i++].tok != Token.leftbrace)
       coordinateExpected();
     Point3f pt = new Point3f();
@@ -1407,11 +1405,15 @@
           break;
         }
     }
+    if (coordinatesAreFractional && ! allowFractional)
+      evalError("fractional coordinates are not allowed in this context");
     pt.x = coordinateValue(i);
     pt.y = coordinateValue(++pcLastExpressionInstruction);
     pt.z = coordinateValue(++pcLastExpressionInstruction);
     if (statement[++pcLastExpressionInstruction].tok != Token.rightbrace)
       coordinateExpected();
+    if (coordinatesAreFractional)
+      viewer.convertFractionalCoordinates(pt);
     return pt;
   }
 
@@ -1673,7 +1675,7 @@
       if (statement[i].tok == Token.integer)
         params[0] = statement[i++].intValue;
       if (statement[i].tok == Token.leftbrace) {
-        unitCells = getCoordinate(i);
+        unitCells = getCoordinate(i, false);
         params[1] = (int) unitCells.x;
         params[2] = (int) unitCells.y;
         params[3] = (int) unitCells.z;
@@ -1851,9 +1853,14 @@
      *  spin 10 (atomno=1)(atomno=2)
      *  spin 20 {0 0 0} {1 1 1}
      *  
+     *  spin INTERNAL 20 {0 0 0} {1 1 1}
+     *  
      *  The INTERNAL keyword indicates that spins or rotations are to be
      *  carried out in the internal molecular coordinate frame, not the
-     *  fixed room frame. 
+     *  fixed room frame. When fractional coordinates are indicated, 
+     *  INTERNAL is automatically selected and need not be indicated:
+     *   
+     *  spin 20 {0 0 0/} {1 1 1/}
      *  
      *  In association with this, TransformManager and associated functions
      *  are TOTALLY REWRITTEN and consolideated. It is VERY clean now - just
@@ -1914,13 +1921,15 @@
         break;
       case Token.leftbrace:
         // {X, Y, Z}
-        Point3f pt = getCoordinate(i); //fractional spin?
+        Point3f pt = getCoordinate(i, true);
+        if (coordinatesAreFractional)
+          isInternal = true;
         i = pcLastExpressionInstruction;
         if (isAxisAngle) {
-            if (axesOrientationRasmol)
-              pt.y = -pt.y;
-            rotAxis.set(pt);
-            isAxisAngle = false;
+          if (axesOrientationRasmol)
+            pt.y = -pt.y;
+          rotAxis.set(pt);
+          isAxisAngle = false;
         } else {
           points[nPoints++].set(pt);
         }
@@ -2427,9 +2436,7 @@
         break;
       case Token.leftbrace:
         // {X, Y, Z}
-        Point3f pt = getCoordinate(i); //fractional dipole point?
-        if (coordinatesAreFractional)
-          viewer.convertFractionalCoordinates(pt);
+        Point3f pt = getCoordinate(i, true);
         i = pcLastExpressionInstruction;
         propertyName = (iHaveCoord ? "endCoord" : "startCoord");
         propertyValue = pt;
@@ -2949,7 +2956,7 @@
           int i = statement[2].intValue;
           pt = new Point3f(i, i, i);
         } else {
-          pt = getCoordinate(2);
+          pt = getCoordinate(2, false);
         }
         viewer.setDefaultLattice(pt);
       } else if 
(((String)statement[1].value).equalsIgnoreCase("defaultLoadScript")) {
@@ -3490,9 +3497,7 @@
     int i = 2;
     if (statement[2].tok == Token.leftbrace) {
       // {X, Y, Z}
-      pt = getCoordinate(2);
-      if (coordinatesAreFractional)
-        viewer.convertFractionalCoordinates(pt);
+      pt = getCoordinate(2, true);
       i = pcLastExpressionInstruction + 1;
     } else {
       pt = new Point3f(floatParameter(i++), floatParameter(i++),
@@ -3681,9 +3686,7 @@
         break;
       case Token.leftbrace:
         // {X, Y, Z}
-        Point3f pt = getCoordinate(i);
-        if (coordinatesAreFractional)
-          viewer.convertFractionalCoordinates(pt);
+        Point3f pt = getCoordinate(i, true);
         i = pcLastExpressionInstruction;
         propertyName = "coord";
         propertyValue = pt;
@@ -3868,9 +3871,7 @@
       pt.y = floatParameter(3);
       pt.z = floatParameter(4);
     } else if (statement[2].tok == Token.leftbrace) {
-      pt = getCoordinate(2);
-      if (coordinatesAreFractional)
-        viewer.convertFractionalCoordinates(pt);
+      pt = getCoordinate(2, true);
     }
     viewer.setCenter(relativeTo, pt);
   }


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