Revision: 5230
Author: hansonr
Date: 2006-06-16 16:28:15 -0700 (Fri, 16 Jun 2006)
ViewCVS: http://svn.sourceforge.net/jmol/?rev=5230&view=rev
Log Message:
-----------
bob200603 eval fix for dipoles
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-06-16
23:27:41 UTC (rev 5229)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-06-16
23:28:15 UTC (rev 5230)
@@ -923,9 +923,8 @@
return (String) statement[index].value;
}
- float getSetAngstroms() throws ScriptException {
- checkLength3();
- Token token = statement[2];
+ float getRasmolAngstroms(int i) throws ScriptException {
+ Token token = statement[i];
switch (token.tok) {
case Token.integer:
return token.intValue / 250f;
@@ -934,7 +933,7 @@
default:
numberExpected();
}
- return -1;
+ return -1; //impossible return
}
boolean getSetBoolean() throws ScriptException {
@@ -1509,7 +1508,7 @@
int tok = statement[1].tok;
outer: switch (tok) {
case Token.dollarsign:
- colorIdentifiedObject(2);
+ colorNamedObject(2);
return;
case Token.colorRGB:
case Token.none:
@@ -1539,6 +1538,10 @@
case Token.identifier:
case Token.hydrogen:
String str = (String) statement[1].value;
+ if (str.equalsIgnoreCase("unitcell")) {
+ colorShape(JmolConstants.SHAPE_UCCAGE, 2, "");
+ return;
+ }
int argb = getArgbOrNoneParam(2);
if (str.equalsIgnoreCase("dotsConvex")) {
viewer.setShapePropertyArgb(JmolConstants.SHAPE_DOTS, "colorConvex",
@@ -1559,10 +1562,6 @@
viewer.setSelectionArgb(argb);
return;
}
- if (str.equalsIgnoreCase("unitcell")) {
- viewer.setShapePropertyArgb(JmolConstants.SHAPE_UCCAGE, "color", argb);
- return;
- }
for (int i = JmolConstants.elementNames.length; --i >= 0;) {
if (str.equalsIgnoreCase(JmolConstants.elementNames[i])) {
viewer.setElementArgb(i, getArgbParam(2));
@@ -1590,22 +1589,22 @@
}
}
- void colorIdentifiedObject(int index) throws ScriptException {
+ void colorNamedObject(int index) throws ScriptException {
// color $ whatever green
String objectName = objectNameParameter(index);
int shapeType = viewer.getShapeIdFromObjectName(objectName);
if (shapeType < 0)
objectNameExpected();
- viewer.setShapeProperty(shapeType, "meshID", objectName);
- colorShape(shapeType, index + 1);
+ viewer.setShapeProperty(shapeType, "thisID", objectName);
+ colorShape(shapeType, index + 1, "");
}
void colorObject(int tokObject, int itoken) throws ScriptException {
int shapeType = getShapeType(tokObject);
- colorShape(shapeType, itoken);
+ colorShape(shapeType, itoken, "");
}
- void colorShape(int shapeType, int itoken) throws ScriptException {
+ void colorShape(int shapeType, int itoken, String modifier) throws
ScriptException {
if (itoken >= statementLength)
badArgumentCount();
String translucentOrOpaque = null;
@@ -1662,10 +1661,10 @@
invalidArgument();
}
viewer.loadShape(shapeType);
- viewer.setShapeProperty(shapeType, colorOrBgcolor, colorvalue);
+ viewer.setShapeProperty(shapeType, colorOrBgcolor+modifier, colorvalue);
}
if (translucentOrOpaque != null)
- viewer.setShapeProperty(shapeType, "translucency", translucentOrOpaque);
+ viewer.setShapeProperty(shapeType, "translucency"+modifier,
translucentOrOpaque);
}
Hashtable variables = new Hashtable();
@@ -2516,97 +2515,106 @@
void dipole() throws ScriptException {
//dipole intWidth floatMagnitude OFFSET floatOffset {atom1} {atom2}
- viewer.loadShape(JmolConstants.SHAPE_DIPOLES);
String propertyName = null;
Object propertyValue = null;
boolean iHaveAtoms = false;
boolean iHaveCoord = false;
- boolean iHaveCoord2 = false;
boolean isOffset = false;
+ boolean isOffsetSide = false;
boolean isWidth = false;
- boolean isNeg = false;
- if (statementLength == 0) {
- viewer.setShapeProperty(JmolConstants.SHAPE_DIPOLES, "on", null);
+ viewer.loadShape(JmolConstants.SHAPE_DIPOLES);
+ viewer.setShapeProperty(JmolConstants.SHAPE_DIPOLES, "init", null);
+ if (statementLength == 1) {
+ viewer.setShapeProperty(JmolConstants.SHAPE_DIPOLES, "thisID", null);
return;
}
- viewer.setShapeProperty(JmolConstants.SHAPE_DIPOLES, "init", null);
for (int i = 1; i < statementLength; ++i) {
propertyName = null;
propertyValue = null;
Token token = statement[i];
switch (token.tok) {
case Token.on:
- if (statementLength == 2)
propertyName = "on";
break;
case Token.off:
- if (statementLength == 2)
propertyName = "off";
break;
case Token.delete:
- if (statementLength == 2)
propertyName = "delete";
break;
- case Token.hyphen:
- isNeg = true;
- continue;
case Token.integer:
if (isOffset) {
- if (isNeg)
- token.intValue = -token.intValue;
propertyName = "dipoleOffsetPercent";
propertyValue = new Integer(token.intValue);
isOffset = false;
isWidth = false;
- isNeg = false;
+ isOffsetSide = false;
+ break;
}
- break;
+ // fall through
case Token.decimal:
- propertyName = (isWidth ? "dipoleWidth" : isOffset ? "dipoleOffset"
+ propertyName = (isWidth ? "dipoleWidth"
+ : isOffset ? "dipoleOffset"
+ : isOffsetSide ? "offsetSide"
: "dipoleValue");
- propertyValue = new Float((isNeg ? -1 : 1) * floatParameter(i));
+ propertyValue = new Float(getRasmolAngstroms(i));
isOffset = false;
isWidth = false;
- isNeg = false;
+ isOffsetSide = false;
break;
case Token.expressionBegin:
propertyValue = expression(statement, i);
i = pcLastExpressionInstruction;
- propertyName = (iHaveAtoms ? "endSet" : "startSet");
+ propertyName = (iHaveAtoms || iHaveCoord ? "endSet" : "startSet");
iHaveAtoms = true;
break;
case Token.leftbrace:
// {X, Y, Z}
Point3f pt = getCoordinate(i, true);
i = pcLastExpressionInstruction;
- propertyName = (iHaveCoord ? "endCoord" : "startCoord");
+ propertyName = (iHaveAtoms || iHaveCoord ? "endCoord" : "startCoord");
propertyValue = pt;
- iHaveCoord2 = iHaveCoord;
iHaveCoord = true;
break;
+ case Token.bond:
case Token.bonds:
propertyName = "bonds";
break;
case Token.identifier:
String cmd = (String) token.value;
+ if (cmd.equalsIgnoreCase("cross")) {
+ propertyName = "cross";
+ propertyValue = Boolean.TRUE;
+ break;
+ }
+ if (cmd.equalsIgnoreCase("noCross")) {
+ propertyName = "cross";
+ propertyValue = Boolean.FALSE;
+ break;
+ }
+ if (cmd.equalsIgnoreCase("calculate")) { //ignored
+ continue;
+ }
if (cmd.equalsIgnoreCase("offset")) {
isOffset = true;
- break;
+ isOffsetSide = false;
+ isWidth = false;
+ continue;
}
+ if (cmd.equalsIgnoreCase("offsetSide")) {
+ isOffsetSide = true;
+ isOffset = false;
+ isWidth = false;
+ continue;
+ }
if (cmd.equalsIgnoreCase("width")) {
isWidth = true;
- break;
+ isOffset = false;
+ isOffsetSide = false;
+ continue;
}
- if (cmd.equalsIgnoreCase("molecular")) {
- propertyValue = viewer.getModelDipole();
- if (propertyValue == null)
- break;
- iHaveCoord2 = iHaveCoord = true;
- propertyName = "molecular";
- break;
- }
- propertyName = "dipoleID";
+ propertyName = "thisID";
propertyValue = ((String) token.value).toLowerCase();
break;
default:
@@ -2616,7 +2624,7 @@
viewer.setShapeProperty(JmolConstants.SHAPE_DIPOLES, propertyName,
propertyValue);
}
- if (iHaveCoord2 || iHaveAtoms)
+ if (iHaveCoord || iHaveAtoms)
viewer.setShapeProperty(JmolConstants.SHAPE_DIPOLES, "set", null);
}
@@ -2911,8 +2919,8 @@
Token.dots, Token.backbone, Token.trace, Token.cartoon, Token.strands,
Token.meshRibbon, Token.ribbon, Token.rocket, Token.star, Token.axes,
Token.boundbox, Token.unitcell, Token.frank, Token.echo, Token.hover,
- Token.polyhedra, Token.prueba, Token.pmesh, Token.sasurface,
- Token.isosurface, Token.draw, Token.dipole };
+ Token.polyhedra, Token.prueba, Token.dipole,
+ Token.pmesh, Token.sasurface, Token.isosurface, Token.draw };
static {
if (shapeToks.length != JmolConstants.SHAPE_MAX) {
@@ -3306,7 +3314,8 @@
}
void setRadius() throws ScriptException {
- viewer.setSolventProbeRadius(getSetAngstroms());
+ checkLength3();
+ viewer.setSolventProbeRadius(getRasmolAngstroms(2));
}
void setStrands() throws ScriptException {
@@ -3451,6 +3460,7 @@
pickingMode = JmolConstants.PICKING_COORD;
break;
case Token.bond:
+ case Token.bonds:
pickingMode = JmolConstants.PICKING_BOND;
break;
case Token.atom:
@@ -3758,7 +3768,7 @@
propertyValue = Boolean.FALSE;
break;
}
- propertyName = "meshID";
+ propertyName = "thisID";
break;
case Token.string:
String filename = (String) statement[i].value;
@@ -3835,7 +3845,7 @@
//System.out.println("draw: "+statement[i]);
switch (token.tok) {
case Token.identifier:
- propertyName = "meshID";
+ propertyName = "thisID";
propertyValue = token.value;
String str = (String) token.value;
if (str.equalsIgnoreCase("FIXED")) {
@@ -4142,6 +4152,10 @@
i = pcLastExpressionInstruction;
break;
}
+ if (str.equalsIgnoreCase("REMAPPABLE")) {
+ propertyName = "remappable";
+ break;
+ }
if (str.equalsIgnoreCase("EXCENTRICITY")) {
propertyName = "anisotropy";
propertyValue = getCoordinate(i + 1, false);
@@ -4217,7 +4231,7 @@
propertyValue = token.value;
//fall through
case Token.all:
- propertyName = "meshID";
+ propertyName = "thisID";
break;
case Token.string:
String filename = (String) token.value;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Jmol-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-commits