From: <ha...@us...> - 2007-12-12 05:10:40
|
Revision: 8774 http://jmol.svn.sourceforge.net/jmol/?rev=8774&view=rev Author: hansonr Date: 2007-12-11 21:10:34 -0800 (Tue, 11 Dec 2007) Log Message: ----------- version=11.3.56_dev set X?, plt reader, new Jmol.js # new feature: set c? -- displays all Jmol parameters starting with "c" or "_c" # set _? -- displays all read-only variables (starting with "_") # new feature: formatted Plt volume data reader. # new Jmol.js for 11.4 Modified Paths: -------------- trunk/Jmol/appletweb/Jmol.js trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java Modified: trunk/Jmol/appletweb/Jmol.js =================================================================== --- trunk/Jmol/appletweb/Jmol.js 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/appletweb/Jmol.js 2007-12-12 05:10:34 UTC (rev 8774) @@ -1,11 +1,10 @@ +/* Jmol 11.4 script library Jmol.js 12:44 PM 12/10/2007 hansonr -/* Jmol 11.0 script library Jmol.js (aka Jmol-11.js) 5:35 PM 8/7/2007 hansonr - checkbox heirarchy -- see http://www.stolaf.edu/academics/jmol/docs/examples-11/check.htm based on: * - * Copyright (C) 2004-2005 Miguel, Jmol Development, www.jmol.org + * Copyright (C) 2004-2007 Miguel, Jmol Development, www.jmol.org * * Contact: ha...@st... * @@ -57,7 +56,11 @@ // bh -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues // bh -- minor fixes suggested by Angel // bh -- adds jmolSetSyncId() and jmolGetSyncId() - + +// bh -- workaround for Mac liveConnect bug not able to match method signature in loadInline: +// ALWAYS USE jmolLoadInlineArray() or jmolLoadInlineString() + + var defaultdir = "." var defaultjar = "JmolApplet.jar" @@ -361,25 +364,57 @@ } } -function jmolLoadInline(model, targetSuffix) { +//Java in MacOS X bug: cannot differentiate properly between signatures String and String[] +//so we have to do these explicitly + +function jmolLoadInlineString(model, script, isAppend, targetSuffix) { if (!model)return + if (!script)script =""; + if (!isAppend)isAppend = false; + if (!targetSuffix)targetSuffix = 0; var applet=_jmolGetApplet(targetSuffix); - if (applet)applet.loadInline(model); + if (!applet)return; + if (applet.loadInlineString) //Jmol 11.4 + applet.loadInlineString(model, script, isAppend); + else //Jmol 11.2 + applet.loadInlineString(model, script); + } -function jmolLoadInlineScript(model, script, targetSuffix) { - if (!model)return +//If the array contains strings that include newline characters, then the array is assumed to +//be a set of models; if not, then the array is assumed to be a set of lines for one model + +function jmolLoadInlineArray(model_or_models, script, isAppend, targetSuffix) { + if (!model_or_models)return + if (!script)script =""; + if (!isAppend)isAppend = false; + if (!targetSuffix)targetSuffix = 0; var applet=_jmolGetApplet(targetSuffix); - if (applet)applet.loadInline(model, script); + if (!applet)return; + if (applet.loadInlineArray) //Jmol 11.4 + applet.loadInlineArray(model_or_models, script, isAppend); + else //Jmol 11.2 + applet.loadInline(model_or_models, script); } -function jmolLoadInlineArray(ModelArray, script, targetSuffix) { + +// modified to work under MAC OS + +function jmolLoadInline(model, targetSuffix) { if (!model)return - if (!script)script="" - var applet=_jmolGetApplet(targetSuffix); - if (applet)applet.loadInlineArray(ModelArray, script); + if (!targetSuffix)targetSuffix = 0; + jmolLoadInlineString(model, "", false, targetSuffix); } +// modified to work under MAC OS + +function jmolLoadInlineScript(model, script, targetSuffix) { + if (!model)return + if (!script)script =""; + if (!targetSuffix)targetSuffix = 0; + jmolLoadInlineString(model, script, false, targetSuffix); +} + function jmolCheckBrowser(action, urlOrMessage, nowOrLater) { if (typeof action == "string") { action = action.toLowerCase(); @@ -1097,10 +1132,10 @@ /////////additional extensions ////////// -function _jmolDomScriptLoad(URL){ +function _jmolDomScriptLoad(URL, target){ //open(URL) //to debug _jmol.servercall=URL - var node = document.getElementById("_jmolScriptNode") + var node = document.getElementById("_jmolScriptNode" + target) if (node && _jmol.browser!="msie"){ document.getElementsByTagName("HEAD")[0].removeChild(node) node=null @@ -1109,7 +1144,7 @@ node.setAttribute("src",URL) } else { node=document.createElement("script") - node.setAttribute("id","_jmolScriptNode") + node.setAttribute("id","_jmolScriptNode" + target) node.setAttribute("type","text/javascript") node.setAttribute("src",URL) document.getElementsByTagName("HEAD")[0].appendChild(node) @@ -1133,7 +1168,7 @@ //overload this function to customize return _jmol.remoteURL=remoteURL if(isError)alert(errorMessage) - jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix) + jmolLoadInlineArray(array,_jmol.optionalscript,false,targetSuffix) } //////////user property/status functions///////// @@ -1304,7 +1339,7 @@ _jmol.thisurl=url _jmol.modelArray = new Array() url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url) - _jmolDomScriptLoad(url) + _jmolDomScriptLoad(url, targetSuffix) return url } @@ -1322,7 +1357,7 @@ _jmol.modelArray = new Array() _jmol.thisurl = url url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url) - _jmolDomScriptLoad(url) + _jmolDomScriptLoad(url, targetSuffix) } @@ -1348,7 +1383,7 @@ _jmol.thisurl=url _jmol.modelArray = new Array() loadModel=_jmolLoadModel - _jmolDomScriptLoad(url) + _jmolDomScriptLoad(url, targetSuffix) return url } @@ -1364,7 +1399,7 @@ _jmol.modelArray = new Array() _jmol.thisurl = url url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix - _jmolDomScriptLoad(url) + _jmolDomScriptLoad(url, targetSuffix) } Added: trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java 2007-12-12 05:10:34 UTC (rev 8774) @@ -0,0 +1,125 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2007-03-30 11:40:16 -0500 (Fri, 30 Mar 2007) $ + * $Revision: 7273 $ + * + * Copyright (C) 2007 Miguel, Bob, Jmol Development + * + * Contact: ha...@st... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jmol.jvxl.readers; + +import java.io.BufferedReader; +import java.io.IOException; + +import org.jmol.util.Logger; +import org.jmol.viewer.Viewer; + +class PltFormattedReader extends VolumeFileReader { + + /* + * free format after the first three lines + 1 2 3 4 5 6 7 +012345678901234567890123456789012345678901234567890123456789012345678901234567890 + + 3 3 + 13 13 12 +-0.41532E+01 0.78468E+01-0.40155E+01 0.79845E+01-0.38912E+01 0.71088E+01 + 0.169508400475E-03 0.234342571007E-03 + 0.310143591477E-03 0.372117502099E-03 + 0.383467878529E-03 0.330699047883E-03 + + */ + + PltFormattedReader(SurfaceGenerator sg, BufferedReader br) { + super(sg, br); + isAngstroms = true; + jvxlData.wasCubic = true; + } + + protected int readVolumetricHeader() { + try { + readTitleLines(); + readAtomCountAndOrigin(); + Logger.info(jvxlFileHeaderBuffer.toString()); + readVoxelVectors(); + Logger.info("voxel grid origin:" + volumetricOrigin); + for (int i = 0; i < 3; ++i) + Logger.info("voxel grid vector:" + volumetricVectors[i]); + JvxlReader.jvxlCreateHeaderWithoutTitleOrAtoms(volumeData, jvxlFileHeaderBuffer); + return readExtraLine(); + } catch (Exception e) { + Logger.error(e.toString()); + throw new NullPointerException(); + } + } + + protected void readTitleLines() throws Exception { + jvxlFileHeaderBuffer = new StringBuffer(); + } + + protected void readAtomCountAndOrigin() throws Exception { + atomCount = 0; + negativeAtomCount = false; + int n1 = parseInt(getLine()); + int n2 = parseInt(); + //yes, it's "Z Y X", but that doesn't matter. Our loop will be (X (Y (Z))) + nPointsX = parseInt(getLine()); + nPointsY = parseInt(); + nPointsZ = parseInt(); + jvxlFileHeaderBuffer.append("Plt formatted data (" + n1 + "," + n2 + ") " + + nPointsX + " x " + nPointsY + " x " + nPointsZ + " \nJmol " + Viewer.getJmolVersion() + '\n'); + volumetricOrigin.set(0, 0, 0); + } + + protected void readVoxelVectors() throws Exception { + +/* 1 2 3 4 5 6 7 + 012345678901234567890123456789012345678901234567890123456789012345678901234567890 + + -0.41532E+01 0.78468E+01-0.40155E+01 0.79845E+01-0.38912E+01 0.71088E+01 +*/ + float xmin = parseFloat(getLine().substring(0, 12)); + float xmax = parseFloat(line.substring(12,24)); + float ymin = parseFloat(line.substring(24,36)); + float ymax = parseFloat(line.substring(36,48)); + float zmin = parseFloat(line.substring(48,60)); + float zmax = parseFloat(line.substring(60,72)); + volumetricOrigin.set(xmin, ymin, zmin); + + voxelCounts[0] = nPointsX; + voxelCounts[1] = nPointsY; + voxelCounts[2] = nPointsZ; + + // because they really are Z, Y, and X ! + + volumetricVectors[0].set(0, 0, (xmax - xmin)/nPointsX); + volumetricVectors[1].set(0, (ymax - ymin)/nPointsY, 0); + volumetricVectors[2].set((zmax - zmin)/nPointsZ, 0, 0); + + Logger.info("boundbox corners {" + + zmin + " " + ymin + " " + xmin + + "} {" + + zmax + " " + ymax + " " + xmax +" }"); + } + + private String getLine() throws IOException { + return line = br.readLine(); + } +} + + Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2007-12-12 05:10:34 UTC (rev 8774) @@ -871,6 +871,8 @@ return new JaguarReader(this, br); if (fileType.equals("Xplor")) return new XplorReader(this, br); + if (fileType.equals("PltFormatted")) + return new PltFormattedReader(this, br); return null; } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java 2007-12-12 05:10:34 UTC (rev 8774) @@ -66,9 +66,20 @@ if (line.indexOf("object 1 class gridpositions counts") == 0) return "Apbs"; - // Jvxl, or Cube + // Jvxl, or Cube, maybe formatted Plt - line = br.readNonCommentLine(); // second line + String[] tokens = Parser.getTokens(line); + line = br.readNonCommentLine();// second line + if (tokens.length == 2 + && Parser.parseInt(tokens[0]) == 3 + && Parser.parseInt(tokens[1])!= Integer.MIN_VALUE) { + tokens = Parser.getTokens(line); + if (tokens.length == 3 + && Parser.parseInt(tokens[0])!= Integer.MIN_VALUE + && Parser.parseInt(tokens[1])!= Integer.MIN_VALUE + && Parser.parseInt(tokens[2])!= Integer.MIN_VALUE) + return "PltFormatted"; + } line = br.readNonCommentLine(); // third line //next line should be the atom line int nAtoms = Parser.parseInt(line); Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-12-12 05:10:34 UTC (rev 8774) @@ -6309,17 +6309,21 @@ */ private void set() throws ScriptException { + String key; if (statementLength == 1) { - showString(viewer.getAllSettings(60)); + showString(viewer.getAllSettings(null)); return; } boolean isJmolSet = (parameterAsString(0).equals("set")); + if (isJmolSet && statementLength == 2 && (key = parameterAsString(1)).indexOf("?") >= 0) { + showString(viewer.getAllSettings(key.substring(0, key.indexOf("?")))); + return; + } boolean showing = (!isSyntaxCheck && !tQuiet && scriptLevel <= scriptReportingLevel && !((String) statement[0].value) .equals("var")); int val = Integer.MAX_VALUE; int n = 0; - String key = null; switch (getToken(1).tok) { // THESE ARE DEPRECATED AND HAVE THEIR OWN COMMAND @@ -8391,7 +8395,7 @@ case Token.set: checkLength2(); if (!isSyntaxCheck) - showString(viewer.getAllSettings(60)); + showString(viewer.getAllSettings(null)); return; case Token.url: // in a new window Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2007-12-12 05:10:34 UTC (rev 8774) @@ -1,5 +1,12 @@ version=11.3.56_dev +# new feature: set c? -- displays all Jmol parameters starting with "c" or "_c" +# set _? -- displays all read-only variables (starting with "_") + +# new feature: formatted Plt volume data reader. + +# new Jmol.js for 11.4 + # ----------------------------------------------------------------------------- #version=11.3.55 Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-12-12 05:10:34 UTC (rev 8774) @@ -832,27 +832,35 @@ return ""; } - String getAllSettings(int nMax) { + String getAllSettings(String prefix) { StringBuffer commands = new StringBuffer(""); Enumeration e; String key; - String[] list = new String[htPropertyFlags.size() + htParameterValues.size()]; + String[] list = new String[htPropertyFlags.size() + + htParameterValues.size()]; //booleans int n = 0; + String _prefix = "_" + prefix; e = htPropertyFlags.keys(); while (e.hasMoreElements()) { key = (String) e.nextElement(); - list[n++] = key + " = " + htPropertyFlags.get(key); + if (prefix == null + || key.indexOf(prefix) == 0 || key.indexOf(_prefix) == 0) + list[n++] = (key.indexOf("_") == 0 ? key + " = " : "set " + key + " ") + + htPropertyFlags.get(key); } //save as _xxxx if you don't want "set" to be there first e = htParameterValues.keys(); while (e.hasMoreElements()) { key = (String) e.nextElement(); - if (key.charAt(0) != '@' && key.charAt(0) != '_') { + if (key.charAt(0) != '@' + && (prefix == null + || key.indexOf(prefix) == 0 || key.indexOf(_prefix) == 0)) { Object value = htParameterValues.get(key); - if (value instanceof String) - value = Escape.escape((String) value); - list[n++] = key + " = " + value; + if (value instanceof String) + value = Escape.escape((String) value); + list[n++] = (key.indexOf("_") == 0 ? key + " = " : "set " + key + " ") + + value; } } Arrays.sort(list, 0, n); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-12-11 21:41:23 UTC (rev 8773) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-12-12 05:10:34 UTC (rev 8774) @@ -4740,8 +4740,8 @@ scriptEcho(str); } - String getAllSettings(int nMax) { - return global.getAllSettings(nMax); + String getAllSettings(String prefix) { + return global.getAllSettings(prefix); } //////// flags and settings //////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |