From: <ha...@us...> - 2010-01-30 19:19:49
|
Revision: 12267 http://jmol.svn.sourceforge.net/jmol/?rev=12267&view=rev Author: hansonr Date: 2010-01-30 19:19:42 +0000 (Sat, 30 Jan 2010) Log Message: ----------- version=11.9.24_dev # code: ScriptEvaluator.set()/.show() clean up; all set parameters as tokens; deprecatedparam tok # bug fix: some show parameters lost in 11.9.22 Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/ModelLoader.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/Token.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/modelset/ModelLoader.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2010-01-30 16:22:06 UTC (rev 12266) +++ trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2010-01-30 19:19:42 UTC (rev 12267) @@ -1201,7 +1201,7 @@ JmolAdapter adapter = viewer.getModelAdapter(); Point3f pt = new Point3f(); Point3f v = new Point3f(); - float tolerance = ((Float) viewer.getParameter("loadAtomDataTolerance")).floatValue(); + float tolerance = viewer.getLoadAtomDataTolerance(); int i = -1; int n = 0; int imax = (tokType == Token.xyz ? BitSetUtil.length(bsSelected) : 0); Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-01-30 16:22:06 UTC (rev 12266) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-01-30 19:19:42 UTC (rev 12267) @@ -4296,7 +4296,7 @@ throws ScriptException { if (val == Integer.MAX_VALUE) val = intSetting(pt); - if (val < min || val > max) + if (val != Integer.MIN_VALUE && val < min || val > max) integerOutOfRange(min, max); return val; } @@ -5993,7 +5993,8 @@ return; case Token.string: String strColor = stringParameter(1); - setStringProperty("propertyColorSchemeOverLoad", strColor); + if (!isSyntaxCheck) + viewer.setPropertyColorScheme(strColor, true); if (tokAt(2) == Token.range || tokAt(2) == Token.absolute) { float min = floatParameter(3); float max = floatParameter(4); @@ -9541,14 +9542,33 @@ scaleAngstromsPerPixel)); } - /* - * **************************************************************************** - * ============================================================== SET - * implementations - * ============================================================== - */ - private void set() throws ScriptException { + /* + * The SET command now allows only the following: + * + * SET + * SET xxx? + * SET [valid Jmol Token.setparam keyword] + * SET labelxxxx + * SET xxxxCallback + * + * All other variables must be assigned using + * + * x = .... + * + * The processing goes as follows: + * + * check for SET + * check for SET xx? + * check for SET xxxx where xxxx is a command --- deprecated + * (all other settings may alternatively start with x = y) + * check for SET xxxx where xxxx requires special checking + * (all other settings may alternatively start with x = (math expression) + * check for context variables var x = ... + * check for deprecated SET words such as "radius" + * + * + */ if (statementLength == 1) { showString(viewer.getAllSettings(null)); return; @@ -9632,13 +9652,6 @@ font(JmolConstants.SHAPE_LABELS, checkLength23() == 2 ? 0 : floatParameter(2)); return; - case Token.formalcharge: - ival = intSetting(2); - if (ival == Integer.MIN_VALUE) - error(ERROR_invalidArgument); - if (!isSyntaxCheck) - viewer.setFormalCharges(ival); - return; case Token.hbond: setHbond(); return; @@ -9646,14 +9659,9 @@ Logger.setLogFile(stringParameter(2)); return; case Token.measure: + case Token.measurements: setMonitor(); return; - case Token.navigate: - setNav(parameterAsString(2), (int) floatParameter(checkLast(3))); - return; - case Token.spin: - setSpin(parameterAsString(2), (int) floatParameter(checkLast(3))); - return; case Token.ssbond: // ssBondsBackbone setSsbond(); return; @@ -9663,20 +9671,14 @@ case Token.togglelabel: setLabel("toggle"); return; - case Token.trajectory: - Token token = tokenSetting(2); // if an expression, we are done - if (isSyntaxCheck) - return; - if (token.tok == Token.decimal) // if a number, we just set its - // trajectory - viewer.getModelNumberIndex(token.intValue, false, true); - return; case Token.usercolorscheme: setUserColors(); return; } - // these next will report a value but require special checks + // these next may report a value + // require special checks + // math expressions are allowed in most cases. boolean justShow = true; @@ -9704,10 +9706,11 @@ } break; case Token.defaultvdw: + // allows unquoted string for known vdw type if (statementLength > 2) { sval = (statementLength == 3 - && JmolConstants.getVdwType(parameterAsString(2)) == JmolConstants.VDW_UNKNOWN ? stringSetting( - 2, false) + && JmolConstants.getVdwType(parameterAsString(2)) == JmolConstants.VDW_UNKNOWN + ? stringSetting(2, false) : parameterAsString(2)); if (JmolConstants.getVdwType(sval) < 0) error(ERROR_invalidArgument); @@ -9736,6 +9739,7 @@ break; case Token.defaults: case Token.defaultcolorscheme: + // allows unquoted "jmol" or "rasmol" if (statementLength > 2) { if ((theTok = tokAt(2)) == Token.jmol || theTok == Token.rasmol) { sval = parameterAsString(checkLast(2)).toLowerCase(); @@ -9750,6 +9754,13 @@ case Token.dipolescale: setFloatProperty("dipoleScale", floatSetting(2, -10, 10)); break; + case Token.formalcharge: + ival = intSetting(2); + if (ival == Integer.MIN_VALUE) + error(ERROR_invalidArgument); + if (!isSyntaxCheck) + viewer.setFormalCharges(ival); + return; case Token.historylevel: // save value locally as well ival = intSetting(2); @@ -9769,6 +9780,9 @@ if (statementLength > 2) setMeasurementUnits(stringSetting(2, isJmolSet)); break; + case Token.phongexponent: + setIntProperty(key, intSetting(2, Integer.MAX_VALUE, 0, 1000)); + break; case Token.picking: if (statementLength > 2) { setPicking(); @@ -9782,11 +9796,6 @@ } break; case Token.property: // compiler may give different values to this token - key = key.toLowerCase(); - if (!key.startsWith("property_")) { - setProperty(); - return; - } // set property_xxxx will be handled in setVariable break; case Token.scriptreportinglevel: @@ -9803,42 +9812,34 @@ break; case Token.specular: case Token.specularpercent: - case Token.specularpower: - case Token.specularexponent: case Token.ambientpercent: case Token.diffusepercent: - case Token.phongexponent: + ival = intSetting(2); if (tok == Token.specular) { - if (tokAt(2) != Token.integer) { + if (ival == Integer.MIN_VALUE || ival == 0 || ival == 1) { justShow = false; break; } tok = Token.specularpercent; key = "specularPercent"; } + setIntProperty(key, intSetting(2, ival, 0, 100)); + break; + case Token.specularpower: + case Token.specularexponent: ival = intSetting(2); - if (ival == Integer.MIN_VALUE) - break; - if (tok == Token.phongexponent) { - setIntProperty(key, intSetting(2, ival, 0, 1000)); - break; - } if (tok == Token.specularpower) { if (ival >= 0) { justShow = false; break; } + tok = Token.specularexponent; + key = "specularExponent"; if (ival < -10 || ival > -1) integerOutOfRange(-10, -1); ival = -ival; - tok = Token.specularexponent; - key = "specularExponent"; } - if (tok == Token.specularexponent) { - setIntProperty(key, intSetting(2, ival, 0, 10)); - } else { - setIntProperty(key, intSetting(2, ival, 0, 100)); - } + setIntProperty(key, intSetting(2, ival, 0, 10)); break; case Token.strands: case Token.strandcount: @@ -9875,10 +9876,13 @@ case Token.hydrogen: newTok = Token.selecthydrogen; break; + case Token.measurementnumbers: + newTok = Token.measurementlabels; + break; case Token.radius: - tok = Token.solventproberadius; - key = "solventProbeRadius"; - setFloatProperty(key, floatSetting(2, 0, 10)); + newTok = Token.solventproberadius; + setFloatProperty("solventProbeRadius", floatSetting(2, 0, 10)); + justShow = true; break; case Token.scale3d: newTok = Token.scaleangstromsperinch; @@ -9889,6 +9893,28 @@ case Token.color: newTok = Token.defaultcolorscheme; break; + case Token.spin: + sval = parameterAsString(2).toLowerCase(); + switch ("x;y;z;fps".indexOf(sval + ";")) { + case 0: + newTok = Token.spinx; + break; + case 2: + newTok = Token.spiny; + break; + case 4: + newTok = Token.spinz; + break; + case 6: + newTok = Token.spinfps; + break; + default: + error(ERROR_unrecognizedParameter, "set SPIN ", sval); + } + if (!isSyntaxCheck) + viewer.setSpin(sval, (int) floatParameter(checkLast(3))); + justShow = true; + break; } } @@ -10298,6 +10324,7 @@ return true; } + /* private void setProperty() throws ScriptException { // what possible good is this? // set property foo bar is identical to @@ -10326,27 +10353,8 @@ parameterAsString(3)); } } + */ - private void setSpin(String key, int value) throws ScriptException { - key = key.toLowerCase(); - if (Parser.isOneOf(key, "x;y;z;fps")) { - if (!isSyntaxCheck) - viewer.setSpin(key, value); - return; - } - error(ERROR_unrecognizedParameter, "set SPIN ", parameterAsString(2)); - } - - private void setNav(String key, int value) throws ScriptException { - key = key.toUpperCase(); - if (Parser.isOneOf(key, "X;Y;Z;FPS")) { - if (!isSyntaxCheck) - viewer.setSpin(key, value); - return; - } - error(ERROR_unrecognizedParameter, "set NAV ", parameterAsString(2)); - } - private void setSsbond() throws ScriptException { boolean ssbondsBackbone = false; // viewer.loadShape(JmolConstants.SHAPE_SSSTICKS); @@ -11691,7 +11699,7 @@ if (!isSyntaxCheck) msg = viewer.getModelInfoAsString(); break; - case Token.measure: + case Token.measurements: if (!isSyntaxCheck) msg = viewer.getMeasurementInfoAsString(); break; Modified: trunk/Jmol/src/org/jmol/script/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/script/Token.java 2010-01-30 16:22:06 UTC (rev 12266) +++ trunk/Jmol/src/org/jmol/script/Token.java 2010-01-30 19:19:42 UTC (rev 12267) @@ -309,7 +309,7 @@ //final static int measure see mathfunc final static int move = scriptCommand | 35; public final static int moveto = scriptCommand | 36; - final static int navigate = scriptCommand | 37 | setparam; + public final static int navigate = scriptCommand | 37; //final static int quaternion see mathfunc final static int quit = scriptCommand | 41 | noArgs; final static int ramachandran = scriptCommand | 42 | expression; @@ -492,7 +492,7 @@ // ___.xxx math properties and all atom properties public final static int atoms = 1 | mathproperty; - public final static int bonds = 2 | mathproperty | booleanparam; + public final static int bonds = 2 | mathproperty | deprecatedparam; final static int length = 3 | mathproperty; final static int lines = 4 | mathproperty; public final static int reverse = 5 | mathproperty; @@ -697,20 +697,21 @@ // deprecated or handled specially in ScriptEvaluator - final static int bondmode = deprecatedparam | 1; - final static int fontsize = deprecatedparam | 2; - final static int scale3d = deprecatedparam | 4; - final static int togglelabel = deprecatedparam | 5; + final static int bondmode = deprecatedparam | 1; + final static int fontsize = deprecatedparam | 2; + final static int measurementnumbers = deprecatedparam | 3; + final static int scale3d = deprecatedparam | 4; + final static int togglelabel = deprecatedparam | 5; // handled specially in ScriptEvaluator public final static int backgroundmodel = setparam | 2; public final static int debug = setparam | 4; public final static int defaultlattice = setparam | 6; + public final static int measurements = setparam | 7; public final static int showscript = setparam | 8; public final static int specular = setparam | 10; public final static int timeout = setparam | 12; - public final static int trajectory = setparam | 14; public final static int usercolorscheme = setparam | 16; // full set of all Jmol "set" parameters @@ -744,7 +745,6 @@ public final static int pickingstyle = strparam | 50; public final static int picklabel = strparam | 52; public final static int propertycolorscheme = strparam | 54; - public final static int propertycolorschemeoverload = strparam | 56; public final static int quaternionframe = strparam | 58; public final static int unitcellcolor = strparam | 60; @@ -758,6 +758,7 @@ public final static int hbondsangleminimum = floatparam | 16; public final static int hbondsdistancemaximum = floatparam | 18; public final static int hoverdelay = floatparam | 20; + public final static int loadatomdatatolerance = floatparam | 21; public final static int minbonddistance = floatparam | 22; public final static int navfps = floatparam | 24; public final static int navigationdepth = floatparam | 26; @@ -1098,12 +1099,13 @@ final static int state = misc | 182; final static int steps = misc | 183;// new final static int stop = misc | 184;// new - final static int ticks = misc | 188; // new - final static int title = misc | 189;// new - final static int titleformat = misc | 190;// new - final static int to = misc | 191 | expression;// new - final static int top = misc | 192 | expression; - final static int torsion = misc | 193; + final static int ticks = misc | 185; // new + final static int title = misc | 186;// new + final static int titleformat = misc | 187;// new + final static int to = misc | 188 | expression;// new + final static int top = misc | 189 | expression; + final static int torsion = misc | 190; + final static int trajectory = misc | 193; final static int transform = misc | 194; public final static int translation = misc | 195; public final static int translucent = misc | 196; @@ -1428,8 +1430,6 @@ "log", new Token(log), "loop", new Token(loop), "measure", new Token(measure), - "measurement", null, - "measurements", null, "measures", null, "monitor", null, "monitors", null, @@ -1723,6 +1723,8 @@ "ticks", new Token(ticks), "top", new Token(top), "torsion", new Token(torsion), + "trajectory", new Token(trajectory), + "trajectories", null, "translucent", new Token(translucent), "triangles", new Token(triangles), "trim", new Token(trim), @@ -1865,13 +1867,13 @@ "backgroundModel", new Token(backgroundmodel), "debug", new Token(debug), "defaultLattice", new Token(defaultlattice), + "measurements", new Token(measurements), + "measurement", null, "scale3D", new Token(scale3d), "toggleLabel", new Token(togglelabel), "userColorScheme", new Token(usercolorscheme), "timeout", new Token(timeout), "timeouts", null, - "trajectory", new Token(trajectory), - "trajectories", null, // string @@ -1907,7 +1909,6 @@ "pickingStyle", new Token(pickingstyle), "pickLabel", new Token(picklabel), "propertyColorScheme", new Token(propertycolorscheme), - "propertyColorSchemeOverload", new Token(propertycolorschemeoverload), "quaternionFrame", new Token(quaternionframe), "unitCellColor", new Token(unitcellcolor), @@ -1923,6 +1924,7 @@ "hbondsAngleMinimum", new Token(hbondsangleminimum), "hbondsDistanceMaximum", new Token(hbondsdistancemaximum), "hoverDelay", new Token(hoverdelay), + "loadAtomDataTolerance", new Token(loadatomdatatolerance), "minBondDistance", new Token(minbonddistance), "navFPS", new Token(navfps), "navigationDepth", new Token(navigationdepth), @@ -1970,7 +1972,7 @@ "perspectiveModel", new Token(perspectivemodel), "phongExponent", new Token(phongexponent), "pickingSpinRate", new Token(pickingspinrate), - "propertyAtomNumberField", new Token(propertyatomnumberfield), + "propertyAtomNumberField", new Token(propertyatomnumberfield), "propertyAtomNumberColumnCount", new Token(propertyatomnumbercolumncount), "propertyDataColumnCount", new Token(propertydatacolumncount), "propertyDataField", new Token(propertydatafield), @@ -1980,6 +1982,7 @@ "specular", new Token(specular), "specularExponent", new Token(specularexponent), "specularPercent", new Token(specularpercent), + "specPercent", null, "specularPower", new Token(specularpower), "specpower", null, "strandCount", new Token(strandcount), @@ -2049,7 +2052,7 @@ "languageTranslation", new Token(languagetranslation), "measureAllModels", new Token(measureallmodels), "measurementLabels", new Token(measurementlabels), - "measurementNumbers", null, + "measurementNumbers", new Token(measurementnumbers), "messageStyleChime", new Token(messagestylechime), "navigateSurface", new Token(navigatesurface), "navigationMode", new Token(navigationmode), Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-01-30 16:22:06 UTC (rev 12266) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-01-30 19:19:42 UTC (rev 12267) @@ -5025,9 +5025,6 @@ case Token.propertycolorscheme: setPropertyColorScheme(value, false); return; - case Token.propertycolorschemeoverload: - setPropertyColorScheme(value, true); - return; case Token.hoverlabel: setShapeProperty(JmolConstants.SHAPE_HOVER, "atomLabel", value); break; @@ -5131,6 +5128,9 @@ return true; setSpin("FPS", (int) value); break; + case Token.loadatomdatatolerance: + global.loadAtomDataTolerance = value; + break; case Token.hbondsangleminimum: // 11.7.9 global.hbondsAngleMinimum = value; @@ -5338,9 +5338,8 @@ // public method -- no need to set return; case Token.specular: - key = "specularPercent"; - Graphics3D.setSpecularPercent(value); - break; + setBooleanProperty(key, tok, value == 1, true); + return; case Token.specularpercent: Graphics3D.setSpecularPercent(value); break; @@ -7959,4 +7958,8 @@ return global.dragSelected; } + public float getLoadAtomDataTolerance() { + return global.loadAtomDataTolerance; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |