From: <ha...@us...> - 2007-04-25 01:49:11
|
Revision: 7483 http://svn.sourceforge.net/jmol/?rev=7483&view=rev Author: hansonr Date: 2007-04-24 18:49:07 -0700 (Tue, 24 Apr 2007) Log Message: ----------- version=11.1.29 # code: totally reorganized isosurface code; new org/jmol/jvxl packages # adds (1) isosurface functionxy "file:data.dat" ... # adds (2) isosurface functionxy "functionName" {x0 y0 z0} {-ni ...} ... # adds (3) isosurface functionxy "functionName" {x0 y0 z0} {-ni ...}{-nj ...} ... # (1) "file:" allows reading of xy data from files for graphing f(x,y) # (2) ni<0 indicates JavaScript functionName will return a single string that # should be parsed for numeric data. # (3) ni<0, nj<0 indicates that JavaScript will fill the fourth parameter # of the function with an array of f[nX][nY] data values: # # Jmol: # # isosurface s1 functionXY "xyData" {-2 -2 -2} {21 0.1 0 0} {21 0 0.1 0} {21 0 0 0.1} # # JavaScript: (slow) # # function xyData(app, x, y) { # return func(x, y) # } # # Jmol: # # isosurface s2 functionXY "xyDataAsString" {-2 -2 -2} {-21 0.1 0 0} {21 0 0.1 0} {21 0 0 0.1} # # JavaScript: (much faster) # # function xyDataAsString(app, nX, nY) { # var s # for (var i = 0; i < nX; i++) # for (var j = 0; j < nY; j++) # s += "x_"+i+"\ty_"+j+"\t"+func(i,j)+"\n" # # //non-numeric formatting allowed but not necessary # # return s # } # # Jmol: # # isosurface s3 functionXY "xyDataAsArray" {-2 -2 -2} {-21 0.1 0 0} {-21 0 0.1 0} {21 0 0 0.1} # # JavaScript: (very fast) # # function xyDataAsArray(app, nX, nY, fxy) { # for (var i = 0; i < nX; i++) # for (var j = 0; j < nY; j++) # fxy[i][j] = func(i,j) # } # # (2) and (3) are very fast; (1) is the original method, but it is slow. # MAYSCRIPT expanded # # for the Wiki or any application where absolutely no JavaScript # is to be allowed, simply remove the MAYSCRIPT parameter, which # now covers all aspects of JavaScript interaction from within Jmol # adds applySymmetryToBonds (default: FALSE) # # applySymmetryToBonds # # When set TRUE, this flag instructs Jmol when applying symmetry # to atoms, as in "load xxx.cif {1 1 1}", to also apply symmetry # to the bonds indicated in the file. The flag is useful when # normal Jmol autobonding would not properly connect atoms, but # the model is "molecular" -- the base atom coordinates are correct # for whole molecules. The flag should NOT be used in cases where # the application of symmetry operations creates new bonds that # were not present in the original set, as for quartz.cif, where # there is only one bond initially, and after applying symmetry # new bonds are created that are between atoms that were created # using two different symmetry operations. # adds isosurface HOMO/LUMO [+/- n] # # better isosurface plane rendering, especially in regard to meshes # bug fix in isosurface contour -n going WAY back to before 10.9.60 # refactoring of all isosurface-related classes # support for Spartan MO HOMO # adds isosurface POCKET [cavity] sasurface # adds isosurface INTERIOR [cavity] sasurface # adds load TRAJECTORY -- for a single file with multiple models all with # the same number of atoms. Atom locations can also be updated on the # fly using the data statement. # # adds TRAJECTORY n command -- like FRAME or MODEL, but never more # than one model at a time displayed, because there is only one set # of atoms. # adds script: option for callbacks set from within Jmol. That is, callbacks # can either be to host page JavaScript functions or to Jmol scripts. This # will allow interactive sessions without external JavaScript. # # set pickcallback "script: script doCallback.spt" # adds resizeCallback because certain positioning of echos and sizing of the # structure may require method intervention after the resizing # adds translucency for echo and hover, both text and backgrounds # adds echo script to defined state # adds hourglass cursor during MO/Isosurface operations # fixes inoperative "set pickingstyle measures on" Modified Paths: -------------- trunk/Jmol/src/org/jmol/Jmol.properties trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/applet/Jmol.java trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java trunk/Jmol/src/org/jmol/jvxl/data/MeshData.java trunk/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java trunk/Jmol/src/org/jmol/jvxl/readers/VoxelReader.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Isosurface.java trunk/Jmol/src/org/jmol/viewer/IsosurfaceRenderer.java trunk/Jmol/src/org/jmol/viewer/Mesh.java Modified: trunk/Jmol/src/org/jmol/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/Jmol.properties 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/Jmol.properties 2007-04-25 01:49:07 UTC (rev 7483) @@ -1,7 +1,67 @@ version=11.1.29 +# code: totally reorganized isosurface code; new org/jmol/jvxl packages + +# adds (1) isosurface functionxy "file:data.dat" ... +# adds (2) isosurface functionxy "functionName" {x0 y0 z0} {-ni ...} ... +# adds (3) isosurface functionxy "functionName" {x0 y0 z0} {-ni ...}{-nj ...} ... + +# (1) "file:" allows reading of xy data from files for graphing f(x,y) +# (2) ni<0 indicates JavaScript functionName will return a single string that +# should be parsed for numeric data. +# (3) ni<0, nj<0 indicates that JavaScript will fill the fourth parameter +# of the function with an array of f[nX][nY] data values: +# +# Jmol: +# +# isosurface s1 functionXY "xyData" {-2 -2 -2} {21 0.1 0 0} {21 0 0.1 0} {21 0 0 0.1} +# +# JavaScript: (slow) +# +# function xyData(app, x, y) { +# return func(x, y) +# } +# +# Jmol: +# +# isosurface s2 functionXY "xyDataAsString" {-2 -2 -2} {-21 0.1 0 0} {21 0 0.1 0} {21 0 0 0.1} +# +# JavaScript: (much faster) +# +# function xyDataAsString(app, nX, nY) { +# var s +# for (var i = 0; i < nX; i++) +# for (var j = 0; j < nY; j++) +# s += "x_"+i+"\ty_"+j+"\t"+func(i,j)+"\n" +# +# //non-numeric formatting allowed but not necessary +# +# return s +# } +# +# Jmol: +# +# isosurface s3 functionXY "xyDataAsArray" {-2 -2 -2} {-21 0.1 0 0} {-21 0 0.1 0} {21 0 0 0.1} +# +# JavaScript: (very fast) +# +# function xyDataAsArray(app, nX, nY, fxy) { +# for (var i = 0; i < nX; i++) +# for (var j = 0; j < nY; j++) +# fxy[i][j] = func(i,j) +# } +# +# (2) and (3) are very fast; (1) is the original method, but it is slow. + +# MAYSCRIPT expanded +# +# for the Wiki or any application where absolutely no JavaScript +# is to be allowed, simply remove the MAYSCRIPT parameter, which +# now covers all aspects of JavaScript interaction from within Jmol + + # adds applySymmetryToBonds (default: FALSE) - +# # applySymmetryToBonds # # When set TRUE, this flag instructs Jmol when applying symmetry @@ -16,9 +76,8 @@ # new bonds are created that are between atoms that were created # using two different symmetry operations. - # adds isosurface HOMO/LUMO [+/- n] - +# # better isosurface plane rendering, especially in regard to meshes # bug fix in isosurface contour -n going WAY back to before 10.9.60 # refactoring of all isosurface-related classes @@ -30,26 +89,28 @@ # adds load TRAJECTORY -- for a single file with multiple models all with # the same number of atoms. Atom locations can also be updated on the # fly using the data statement. - +# # adds TRAJECTORY n command -- like FRAME or MODEL, but never more # than one model at a time displayed, because there is only one set # of atoms. -# + # adds script: option for callbacks set from within Jmol. That is, callbacks # can either be to host page JavaScript functions or to Jmol scripts. This # will allow interactive sessions without external JavaScript. # +# set pickcallback "script: script doCallback.spt" + # adds resizeCallback because certain positioning of echos and sizing of the # structure may require method intervention after the resizing -# + # adds translucency for echo and hover, both text and backgrounds -# + # adds echo script to defined state -# + # adds hourglass cursor during MO/Isosurface operations -# -# fixes inoperative set pickingstyle measures on +# fixes inoperative "set pickingstyle measures on" + # ----------------------------------------------------------------------------- #version=11.1.28 Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -244,10 +244,10 @@ int[] params = null; if (htParams != null) { params = (int[]) htParams.get("params"); - if (params == null) - return; applySymmetryToBonds = htParams.containsKey("applySymmetryToBonds"); } + if (params == null) + return; // params is of variable length: 4, 5, or 11 // [desiredModelNumber, i, j, k, Modified: trunk/Jmol/src/org/jmol/applet/Jmol.java =================================================================== --- trunk/Jmol/src/org/jmol/applet/Jmol.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/applet/Jmol.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -41,14 +41,17 @@ import java.util.Hashtable; import org.jmol.util.Logger; +import org.jmol.util.Parser; /* - * these are *required* + * these are *required*: * * [param name="progressbar" value="true" /] [param name="progresscolor" * value="blue" /] [param name="boxmessage" value="your-favorite-message" /] * [param name="boxbgcolor" value="#112233" /] [param name="boxfgcolor" * value="#778899" /] * + * these are *optional*: + * * [param name="loadInline" value=" | do | it | this | way " /] * * [param name="script" value="your-script" /] @@ -57,17 +60,38 @@ * // this is *required* if you want the applet to be able to // call your * callbacks * - * mayscript="true" is required as an applet tag (for true callbacks only) - * but this is being taken over by setTimeout() polling using getPropertyAsString() - * and getPropertyAsJSON() [JavaScript Object Notation] + * mayscript="true" is required as an applet/object for any callback, eval, or text/textarea setting) + * + * To disable ALL access to JavaScript (as, for example, in a Wiki) + * remove the MAYSCRIPT tag or set MAYSCRIPT="false" * - * [param name="AnimFrameCallback" value="yourJavaScriptMethodName" /] [param - * name="LoadStructCallback" value="yourJavaScriptMethodName" /] [param - * name="MessageCallback" value="yourJavaScriptMethodName" /] [param - * name="HoverCallback" value="yourJavaScriptMethodName" /] [param - * name="ResizeCallback" value="yourJavaScriptMethodName" /] [param - * name="PickCallback" value="yourJavaScriptMethodName" /] + * You can check that it is set correctly using * + * [param name="debug" value="true"] + * + * and then checking the console for a message about MAYSCRIPT + * + * In addition, you can turn off JUST EVAL, by setting on the web page + * + * _jmol.noEval = true + * + * This allows callbacks but does not allow the script constructs: + * + * script javascript:... + * javascript ... + * x = eval(...) + * + * callbacks include: + * + * [param name="AnimFrameCallback" value="yourJavaScriptMethodName" /] + * [param name="LoadStructCallback" value="yourJavaScriptMethodName" /] + * [param name="MessageCallback" value="yourJavaScriptMethodName" /] + * [param name="HoverCallback" value="yourJavaScriptMethodName" /] + * [param name="ResizeCallback" value="yourJavaScriptMethodName" /] + * [param name="PickCallback" value="yourJavaScriptMethodName" /] + * + * The use of jmolButtons is NOT recommended. + * */ public class Jmol implements WrappedApplet, JmolAppletInterface { @@ -102,10 +126,9 @@ * Therefore, do *not* call System.out.println("" + jsoWindow); */ JSObject jsoWindow; - JSObject jsoDocument; - boolean mayScript; + boolean haveDocumentAccess; String animFrameCallback; String resizeCallback; @@ -156,36 +179,48 @@ // to enable CDK // viewer = new JmolViewer(this, new CdkJmolAdapter(null)); viewer = JmolViewer.allocateViewer(appletWrapper, new SmarterJmolAdapter()); - viewer.setAppletContext(htmlName, appletWrapper.getDocumentBase(), appletWrapper - .getCodeBase(), getValue("JmolAppletProxy", null)); + viewer.setAppletContext(htmlName, appletWrapper.getDocumentBase(), + appletWrapper.getCodeBase(), getValue("JmolAppletProxy", null)); myStatusListener = new MyStatusListener(); viewer.setJmolStatusListener(myStatusListener); - jvm12orGreater = viewer.isJvm12orGreater(); if (jvm12orGreater) jvm12 = new Jvm12(appletWrapper, viewer); if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug("checking for jsoWindow mayScript="+mayScript); + Logger.debug("checking for jsoWindow mayScript=" + mayScript); } if (mayScript) { + mayScript = haveDocumentAccess = false; try { jsoWindow = JSObject.getWindow(appletWrapper); if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug("jsoWindow="+jsoWindow); + Logger.debug("jsoWindow=" + jsoWindow); } - if (jsoWindow == null) - Logger.error("jsoWindow returned null ... no JavaScript callbacks :-("); + if (jsoWindow == null) { + Logger + .error("jsoWindow returned null ... no JavaScript callbacks :-("); + } else { + mayScript = true; + } jsoDocument = (JSObject) jsoWindow.getMember("document"); - if (jsoDocument == null) - Logger.error("jsoDocument returned null ... no DOM manipulations :-("); + if (jsoDocument == null) { + Logger + .error("jsoDocument returned null ... no DOM manipulations :-("); + } else { + haveDocumentAccess = true; + } } catch (Exception e) { jsoWindow = null; jsoDocument = null; - Logger.error("Microsoft MSIE bug -- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5012558 " + e); + Logger + .error("Microsoft MSIE bug -- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5012558 " + + e); } if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug("jsoWindow:" + jsoWindow+ " jsoDocument:" + jsoDocument); + Logger.debug("jsoWindow:" + jsoWindow + " jsoDocument:" + jsoDocument + + " mayScript:" + mayScript + " haveDocumentAccess:" + + haveDocumentAccess); } } } @@ -312,7 +347,7 @@ // || pauseCallback != null || pickCallback != null || statusForm != null || statusText != null) { if (!mayScript) - Logger.warn("WARNING!! MAYSCRIPT not found"); + Logger.warn("MAYSCRIPT missing -- all applet JavaScript calls disabled"); } if (messageCallback != null || statusForm != null || statusText != null) { if (!haveTranslateFlag) { @@ -350,8 +385,9 @@ } void sendMessageCallback(String strMsg) { + if (!mayScript || messageCallback == null) + return; try { - if (messageCallback != null && jsoWindow != null) if (messageCallback.equals("alert")) jsoWindow.call(messageCallback, new Object[] { strMsg }); else @@ -367,7 +403,7 @@ } void sendJsTextStatus(String message) { - if (statusForm == null || statusText == null) + if (!haveDocumentAccess || statusForm == null || statusText == null) return; try { JSObject jsoForm = (JSObject) jsoDocument.getMember(statusForm); @@ -382,7 +418,7 @@ } void sendJsTextareaStatus(String message) { - if (statusForm == null || statusTextarea == null) + if (!haveDocumentAccess || statusForm == null || statusTextarea == null) return; try { JSObject jsoForm = (JSObject) jsoDocument.getMember(statusForm); @@ -533,31 +569,29 @@ boolean buttonCallbackNotificationPending; String buttonCallback; - String buttonName; - JSObject buttonWindow; public void scriptButton(JSObject buttonWindow, String buttonName, - String script, String buttonCallback) { - Logger.info(htmlName + " JmolApplet.scriptButton(" + buttonWindow - + "," + buttonName + "," + script + "," + buttonCallback); - if (buttonWindow != null && buttonCallback != null) { - if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug("!!!! calling back " + buttonCallback); - } - buttonCallbackBefore[0] = buttonName; - Logger.debug("trying..."); - buttonWindow.call(buttonCallback, buttonCallbackBefore); - Logger.debug("made it"); - - buttonCallbackNotificationPending = true; - this.buttonCallback = buttonCallback; - this.buttonWindow = buttonWindow; - this.buttonName = buttonName; - } else { + String script, String buttonCallback) { + if (!mayScript || buttonWindow == null || buttonCallback == null) { buttonCallbackNotificationPending = false; + return; } + Logger.info(htmlName + " JmolApplet.scriptButton(" + buttonWindow + "," + + buttonName + "," + script + "," + buttonCallback); + if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { + Logger.debug("!!!! calling back " + buttonCallback); + } + buttonCallbackBefore[0] = buttonName; + Logger.debug("trying..."); + buttonWindow.call(buttonCallback, buttonCallbackBefore); + Logger.debug("made it"); + + buttonCallbackNotificationPending = true; + this.buttonCallback = buttonCallback; + this.buttonWindow = buttonWindow; + this.buttonName = buttonName; scriptProcessor(script, null, SCRIPT_NOWAIT); } @@ -713,6 +747,8 @@ } public void loadNodeId(String nodeId) { + if (!haveDocumentAccess) + return; if (nodeId != null) { // Retrieve Node ... // First try to find by ID @@ -780,7 +816,7 @@ public String eval(String strEval) { try { - if(((Boolean)jsoDocument.eval("!!_jmol.noEval")).booleanValue()) + if(!haveDocumentAccess || ((Boolean)jsoDocument.eval("!!_jmol.noEval")).booleanValue()) return "NO EVAL ALLOWED"; } catch (Exception e) { Logger.error("# no _jmol in evaluating " + strEval + ":" + e.toString()); @@ -807,21 +843,21 @@ showStatusAndConsole(GT._("File Error:") + errorMsg); return; } + if (!mayScript || loadStructCallback == null || fullPathName == null) + return; try { - if (fullPathName != null) - if (loadStructCallback != null && jsoWindow != null) - if (loadStructCallback.equals("alert")) - jsoWindow.call(loadStructCallback, new Object[] { fullPathName }); - else - jsoWindow.call(loadStructCallback, new Object[] { htmlName, - fullPathName }); + if (loadStructCallback.equals("alert")) + jsoWindow.call(loadStructCallback, new Object[] { fullPathName }); + else + jsoWindow.call(loadStructCallback, new Object[] { htmlName, + fullPathName }); } catch (Exception e) { if (!haveNotifiedError) if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug( - "loadStructCallback call error to " + loadStructCallback + ": " + e); + Logger.debug("loadStructCallback call error to " + + loadStructCallback + ": " + e); } - haveNotifiedError = true; + haveNotifiedError = true; } // if (jmolpopup != null) @@ -829,48 +865,70 @@ } public void notifyScriptStart(String statusMessage, String additionalInfo) { + if (!mayScript || messageCallback == null) + return; try { - if (messageCallback != null && jsoWindow != null) - if (messageCallback.equals("alert")) - jsoWindow.call(messageCallback, new Object[] { statusMessage - + " ; " + additionalInfo }); - else - jsoWindow.call(messageCallback, new Object[] { htmlName, - statusMessage, additionalInfo }); + if (messageCallback.equals("alert")) + jsoWindow.call(messageCallback, new Object[] { statusMessage + " ; " + + additionalInfo }); + else + jsoWindow.call(messageCallback, new Object[] { htmlName, + statusMessage, additionalInfo }); } catch (Exception e) { if (!haveNotifiedError) if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug( - "messageCallback call error to " + messageCallback + ": " + e); + Logger.debug("messageCallback call error to " + messageCallback + + ": " + e); } - haveNotifiedError = true; + haveNotifiedError = true; } showStatusAndConsole(statusMessage); } public float[][] functionXY(String functionName, int nX, int nY) { - //two options -- using -n for x + /*three options: + * + * nX > 0 and nY > 0 return one at a time, with (slow) individual function calls + * nX < 0 and nY > 0 return a string that can be parsed to give the list of values + * nX < 0 and nY < 0 fill the supplied float[-nX][-nY] array directly in JavaScript + * + */ + + //System.out.println("functionXY" + nX + " " + nY + " " + functionName); + float[][] fxy = new float[Math.abs(nX)][Math.abs(nY)]; - if (nX == 0 || nY == 0) + if (!mayScript || nX == 0 || nY == 0) return fxy; try { - if (nX > 0) { + if (nX > 0 && nY > 0) { // fill with individual function calls (slow) for (int i = 0; i < nX; i++) - for (int j = 0; j < nY; j++) + for (int j = 0; j < nY; j++) { fxy[i][j] = ((Double) jsoWindow.call(functionName, new Object[] { - htmlName, new Integer(nX), new Integer(nY) })).floatValue(); - } else { - Double[][] xy = (Double[][]) jsoWindow.call(functionName, - new Object[] { htmlName, new Integer(nX), new Integer(nY) }); + htmlName, new Integer(i), new Integer(j) })).floatValue(); + } + } else if (nY > 0){ // fill with parsed values from a string (pretty fast) + String data = (String) jsoWindow.call(functionName, new Object[] { + htmlName, new Integer(nX), new Integer(nY) }); + System.out.println(data); nX = Math.abs(nX); - nY = Math.abs(nY); - for (int i = 0; i < nX; i++) - for (int j = 0; j < nY; j++) - fxy[i][j] = (xy[i][j]).floatValue(); + float[] fdata = new float[nX * nY]; + Parser.parseFloatArray(data, null, fdata); + for (int i = 0, ipt = 0; i < nX; i++) { + for (int j = 0; j < nY; j++, ipt++) { + fxy[i][j] = fdata[ipt]; + } + } + } else { // fill float[][] directly using JavaScript + jsoWindow.call(functionName, + new Object[] { htmlName, new Integer(nX), new Integer(nY), fxy }); } } catch (Exception e) { + Logger.error("Exception " + e.getMessage() + " with nX, nY: "+ nX + " " + nY); } + for (int i = 0; i < nX; i++) + for (int j = 0; j < nY; j++) + System.out.println("i j fxy " + i + " " + j + " " + fxy[i][j]); return fxy; } @@ -884,8 +942,9 @@ } public void notifyResized(int newWidth, int newHeight) { + if (!mayScript || resizeCallback == null) + return; try { - if (resizeCallback != null && jsoWindow != null) jsoWindow.call(resizeCallback, new Object[] { htmlName, new Integer(newWidth), new Integer(newHeight)}); } catch (Exception e) { @@ -900,20 +959,20 @@ public void notifyFrameChanged(int frameNo, int fileNo, int modelNo, int firstNo, int lastNo) { + if (!mayScript || animFrameCallback == null) + return; boolean isAnimationRunning = (frameNo <= -2); try { - if (animFrameCallback != null && jsoWindow != null) - jsoWindow.call(animFrameCallback, new Object[] { htmlName, - new Integer(Math.max(frameNo, -2 - frameNo)), - new Integer(fileNo), new Integer(modelNo), new Integer(firstNo), - new Integer(lastNo) }); + jsoWindow.call(animFrameCallback, new Object[] { htmlName, + new Integer(Math.max(frameNo, -2 - frameNo)), new Integer(fileNo), + new Integer(modelNo), new Integer(firstNo), new Integer(lastNo) }); } catch (Exception e) { if (!haveNotifiedError) if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug( - "animFrameCallback call error to " + animFrameCallback + ": " + e); + Logger.debug("animFrameCallback call error to " + animFrameCallback + + ": " + e); } - haveNotifiedError = true; + haveNotifiedError = true; } if (jmolpopup == null || isAnimationRunning) return; @@ -922,38 +981,40 @@ public void notifyAtomPicked(int atomIndex, String strInfo) { showStatusAndConsole(strInfo); + if (!mayScript || pickCallback == null) + return; try { - if (pickCallback != null && jsoWindow != null) - if (pickCallback.equals("alert")) - jsoWindow.call(pickCallback, new Object[] { strInfo }); - else - jsoWindow.call(pickCallback, new Object[] { htmlName, strInfo, - new Integer(atomIndex) }); + if (pickCallback.equals("alert")) + jsoWindow.call(pickCallback, new Object[] { strInfo }); + else + jsoWindow.call(pickCallback, new Object[] { htmlName, strInfo, + new Integer(atomIndex) }); } catch (Exception e) { if (!haveNotifiedError) if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug( - "pickCallback call error to " + pickCallback + ": " + e); + Logger.debug("pickCallback call error to " + pickCallback + ": " + + e); } - haveNotifiedError = true; + haveNotifiedError = true; } } public void notifyAtomHovered(int atomIndex, String strInfo) { + if (!mayScript || hoverCallback == null) + return; try { - if (hoverCallback != null && jsoWindow != null) - if (hoverCallback.equals("alert")) - jsoWindow.call(hoverCallback, new Object[] { strInfo }); - else - jsoWindow.call(hoverCallback, new Object[] { htmlName, strInfo, - new Integer(atomIndex) }); + if (hoverCallback.equals("alert")) + jsoWindow.call(hoverCallback, new Object[] { strInfo }); + else + jsoWindow.call(hoverCallback, new Object[] { htmlName, strInfo, + new Integer(atomIndex) }); } catch (Exception e) { if (!haveNotifiedError) if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug( - "hoverCallback call error to " + hoverCallback + ": " + e); + Logger.debug("hoverCallback call error to " + hoverCallback + ": " + + e); } - haveNotifiedError = true; + haveNotifiedError = true; } } Modified: trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -327,6 +327,7 @@ int vPt = voxelReader.addVertexCopy(vertexXYZ, value, VERTEX_POINT); contourVertexes[contourVertexCount++] = new ContourVertex(x, y, z, vertexXYZ, vPt); + //System.out.println("vertex xyz " + x + " " + y + " " + z + " " + vPt + " coord:" + vertexXYZ); return vPt; } @@ -517,8 +518,11 @@ int insideCount = generateContourData(cutoff); if (lastInside < 0) lastInside = insideCount; - else if (lastInside > insideCount) + else if (lastInside > insideCount) { centerIsLow = false; + lastInside = 0; + } + System.out.println("generatcont " + insideCount + " " + contourIndex + " " + centerIsLow); } return centerIsLow; } @@ -543,7 +547,7 @@ if (Math.abs(contourCutoff) < 0.0001) contourCutoff = (contourCutoff < 0 ? -0.0001f : 0.0001f); - int insideCount = 0, outsideCount = 0, contourCount = 0; + int insideCount = 0, contourCount = 0; for (int x = squareCountX; --x >= 0;) { for (int y = squareCountY; --y >= 0;) { int[] pixelPointIndexes = propagateNeighborPointIndexes2d(x, y, @@ -553,15 +557,14 @@ Point3i offset = squareVertexOffsets[i]; float vertexValue = pixelData[x + offset.x][y + offset.y]; vertexValues2d[i] = vertexValue; - if (isInside2d(vertexValue, contourCutoff)) + //if (contourIndex == 5 || contourIndex==6) + //System.out.println(contourIndex + " xy " + x + " " + y + " " + i + " " + vertexValue + " " + contourCutoff + " " + (isInside2d(vertexValue, contourCutoff))); + if (isInside2d(vertexValue, contourCutoff)) { insideMask |= 1 << i; + ++insideCount; + } } - if (insideMask == 0) { - ++outsideCount; - continue; - } if (insideMask == 0x0F) { - ++insideCount; planarSquares[x * squareCountY + y] .addEdgeMask(contourIndex, 0, 0x0F); continue; @@ -682,6 +685,8 @@ } ContourVertex c = contourVertexes[i]; pt.set(c.vertexXYZ); + //System.out.println("draw pt" + ix + "_" + iy+ " " + org.jmol.viewer.StateManager.escape(pt) + " \"" + pt + " " + ix + " " + iy + "\";"); + } private int findContourVertex(int ix, int iy) { Modified: trunk/Jmol/src/org/jmol/jvxl/data/MeshData.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/data/MeshData.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/jvxl/data/MeshData.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -291,7 +291,6 @@ float val1 = vertexValues[iA]; float val2 = vertexValues[iB]; float val3 = vertexValues[iC]; - return (val1 >= 0 && val2 >= 0 && val3 >= 0 || val1 <= 0 && val2 <= 0 && val3 <= 0); } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -35,24 +35,24 @@ private String functionName; private float[][] data; - private boolean isAngstroms; + //private boolean isAngstroms; NAH! Forget BOHRS! This was silly. private boolean isPlanarMapping; protected void setup() { - isAngstroms = params.isAngstroms; + //isAngstroms = params.isAngstroms; isPlanarMapping = (params.thePlane != null); functionName = (String) params.functionXYinfo.get(0); jvxlFileHeaderBuffer = new StringBuffer(); jvxlFileHeaderBuffer.append("functionXY\n").append(functionName).append("\n"); volumetricOrigin.set((Point3f) params.functionXYinfo.get(1)); - if (!isAngstroms) - volumetricOrigin.scale(ANGSTROMS_PER_BOHR); + //if (!isAngstroms) + //volumetricOrigin.scale(ANGSTROMS_PER_BOHR); for (int i = 0; i < 3; i++) { Point4f info = (Point4f) params.functionXYinfo.get(i + 2); - voxelCounts[i] = (int) info.x; + voxelCounts[i] = Math.abs((int) info.x); volumetricVectors[i].set(info.y, info.z, info.w); - if (!isAngstroms) - volumetricVectors[i].scale(ANGSTROMS_PER_BOHR); + //if (!isAngstroms) + //volumetricVectors[i].scale(ANGSTROMS_PER_BOHR); } data = (float[][]) params.functionXYinfo.get(5); JvxlReader.jvxlCreateHeaderWithoutTitleOrAtoms(volumeData, jvxlFileHeaderBuffer); Modified: trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -354,8 +354,11 @@ } } - if (dataType == Parameters.SURFACE_PROPERTY) - voxelData = property; + if (isProperty) { + volumeData.voxelData = property; + setVolumeData(volumeData); + initializeVolumetricData(); + } if (params.thePlane == null) { for (int x = 0; x < nPointsX; ++x) for (int y = 0; y < nPointsY; ++y) Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -127,6 +127,7 @@ import org.jmol.jvxl.data.MeshData; import org.jmol.jvxl.api.AtomDataServer; import org.jmol.jvxl.api.MeshDataServer; +import org.jmol.jvxl.calc.MarchingSquares; public class SurfaceGenerator { @@ -137,6 +138,8 @@ private VolumeData volumeData; private MeshDataServer meshDataServer; private AtomDataServer atomDataServer; + private MarchingSquares marchingSquares; + VoxelReader voxelReader; public SurfaceGenerator() { @@ -156,20 +159,21 @@ this.colorEncoder = (colorEncoder == null ? new ColorEncoder() : colorEncoder); this.meshData = (meshData == null ? new MeshData() : meshData); + //System.out.println("SurfaceGenerator setup vertexColixs =" + this.meshData.vertexColixes); this.jvxlData = (jvxlData == null ? new JvxlData() : jvxlData); volumeData = new VolumeData(); initializeIsosurface(); } - public MeshDataServer getMeshDataServer() { + MeshDataServer getMeshDataServer() { return meshDataServer; } - public AtomDataServer getAtomDataServer() { + AtomDataServer getAtomDataServer() { return atomDataServer; } - public ColorEncoder getColorEncoder() { + ColorEncoder getColorEncoder() { return colorEncoder; } @@ -177,19 +181,27 @@ this.jvxlData = jvxlData; } - public JvxlData getJvxlData() { + JvxlData getJvxlData() { return jvxlData; } - public MeshData getMeshData() { + MeshData getMeshData() { return meshData; } - +/* public void setMeshData(MeshData meshData) { this.meshData = meshData; } - - public Parameters getParams() { +*/ + void setMarchingSquares(MarchingSquares marchingSquares) { + this.marchingSquares = marchingSquares; + } + + MarchingSquares getMarchingSquares() { + return marchingSquares; + } + + Parameters getParams() { return params; } @@ -197,7 +209,7 @@ return params.script; } - public VolumeData getVolumeData() { + VolumeData getVolumeData() { return volumeData; } @@ -220,11 +232,11 @@ } return 0; } - +/* public void setScript(String script) { params.script = script; } - +*/ public void setModelIndex(int modelIndex) { params.modelIndex = modelIndex; } @@ -663,13 +675,15 @@ meshDataServer.fillMeshData(meshData, MeshData.MODE_PUT_SETS); } params.colorBySets = true; - } else if ((voxelReader = setFileData(value)) == null) { - Logger.error("Could not set the mapping data"); - return true; + } else { + if ((voxelReader = setFileData(value)) == null) { + Logger.error("Could not set the mapping data"); + return true; + } } mapSurface(value); } - return false; + return true; } private void processState() { @@ -740,7 +754,9 @@ voxelReader.applyColorScale(); } voxelReader.jvxlUpdateInfo(); + setMarchingSquares(voxelReader.marchingSquares); voxelReader.discardTempData(false); + voxelReader = null; params.mappedDataMin = Float.MAX_VALUE; } @@ -764,6 +780,7 @@ } voxelReader.colorIsosurface(); voxelReader.jvxlUpdateInfo(); + voxelReader.updateTriangles(); voxelReader.discardTempData(true); if (meshDataServer != null) meshDataServer.notifySurfaceMappingCompleted(); @@ -814,6 +831,7 @@ params.initialize(); colorPtr = 0; voxelReader = null; + marchingSquares = null; initState(); } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/VoxelReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/VoxelReader.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/jvxl/readers/VoxelReader.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -181,7 +181,7 @@ this.sg = sg; this.colorEncoder = sg.getColorEncoder(); this.params = sg.getParams(); - + this.marchingSquares = sg.getMarchingSquares(); assocCutoff = params.assocCutoff; isXLowToHigh = params.isXLowToHigh; this.meshData = sg.getMeshData(); @@ -312,10 +312,10 @@ } void discardTempData(boolean discardAll) { - if (!discardAll) + if (!discardAll) return; voxelData = null; - marchingSquares = null; + sg.setMarchingSquares(marchingSquares = null); marchingCubes = null; } @@ -473,7 +473,8 @@ //////////////////////////////////////////////////////////////// void colorIsosurface() { - if (params.isContoured && !(jvxlDataIs2dContour || params.thePlane != null)) { + if (params.isContoured && marchingSquares == null) { +// if (params.isContoured && !(jvxlDataIs2dContour || params.thePlane != null)) { Logger.error("Isosurface error: Cannot contour this type of data."); return; } @@ -568,15 +569,18 @@ * */ if (params.colorBySets) - datum = value = meshData.vertexSets[vertexIndex]; + value = meshData.vertexSets[vertexIndex]; else if (params.colorByPhase) - datum = value = getPhase(meshData.vertices[vertexIndex]); + value = getPhase(meshData.vertices[vertexIndex]); else if (params.isBicolorMap && !params.isContoured) // will be current mesh only - datum = value = meshData.vertexValues[vertexIndex]; + value = meshData.vertexValues[vertexIndex]; else if (jvxlDataIs2dContour) - datum = value = marchingSquares.getInterpolatedPixelValue(meshData.vertices[vertexIndex]); + value = marchingSquares.getInterpolatedPixelValue(meshData.vertices[vertexIndex]); else - datum = value = volumeData.lookupInterpolatedVoxelValue(meshData.vertices[vertexIndex]); + value = volumeData.lookupInterpolatedVoxelValue(meshData.vertices[vertexIndex]); + + datum = meshData.vertexValues[vertexIndex] = value; + if (minColorIndex >= 0) { if (value <= 0) meshData.vertexColixes[vertexIndex] = minColorIndex; @@ -589,6 +593,8 @@ value = params.valueMappedToRed; if (value >= params.valueMappedToBlue) value = params.valueMappedToBlue; + //if (vertexIndex > 90 && vertexIndex < 100) + //System.out.println("applycolor " + meshData.vertexColixes + " " + getColorIndexFromPalette(value) + " " + vertexIndex + " " + value +" " + params.valueMappedToRed + " " + params.valueMappedToBlue ); meshData.vertexColixes[vertexIndex] = getColorIndexFromPalette(value); } return datum; @@ -679,12 +685,16 @@ params.valueMappedToBlue); } - public void updateSurfaceData() { + void updateTriangles() { if (meshDataServer == null) { meshData.invalidateTriangles(); } else { meshDataServer.invalidateTriangles(); } + } + + void updateSurfaceData() { + updateTriangles(); JvxlReader.jvxlUpdateSurfaceData(jvxlData, meshData.vertexValues, meshData.vertexCount, meshData.vertexIncrement, cJvxlEdgeNaN); } Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -3494,11 +3494,13 @@ if (getToken(1).tok == Token.trajectory) { params[0] = -1; // i = 2; - } else if (theTok == Token.identifier) { + } else if (theTok == Token.identifier || parameterAsString(1).equals("fileset")) { filename = parameterAsString(1); loadScript.append(" " + filename); + if (filename.equals("fileset")) + filename = parameterAsString(2); isMerge = (filename.equalsIgnoreCase("append")); - i = 2; + i = 2; if (isMerge) clearPredefined(); } @@ -5332,7 +5334,7 @@ int pt = m % 1000000; if (pt == 0) { int model1 = viewer.getModelNumberIndex(m + 1, false); - int model2 = viewer.getModelNumberIndex(m + 1000001, false); + int model2 = (m==0 ? modelCount : viewer.getModelNumberIndex(m + 1000001, false)); if (model1 < 0) model1 = 0; if (model2 < 0) @@ -7257,10 +7259,10 @@ viewer.loadShape(JmolConstants.SHAPE_PMESH); if (tokAt(1) == Token.list && listIsosurface(JmolConstants.SHAPE_PMESH)) return; - initIsosurface(JmolConstants.SHAPE_PMESH); Object t; boolean idSeen = false; - for (int i = 1; i < statementLength; ++i) { + initIsosurface(JmolConstants.SHAPE_PMESH); + for (int i = iToken; i < statementLength; ++i) { String propertyName = null; Object propertyValue = null; switch (getToken(i).tok) { @@ -7338,15 +7340,15 @@ viewer.loadShape(JmolConstants.SHAPE_DRAW); if (tokAt(1) == Token.list && listIsosurface(JmolConstants.SHAPE_DRAW)) return; - setShapeProperty(JmolConstants.SHAPE_DRAW, "init", null); boolean havePoints = false; - boolean idSeen = false; boolean isInitialized = false; boolean isTranslucent = false; float translucentLevel = Float.MAX_VALUE; int colorArgb = Integer.MIN_VALUE; int intScale = 0; - for (int i = 1; i < statementLength; ++i) { + boolean idSeen = false; + initIsosurface(JmolConstants.SHAPE_DRAW); + for (int i = iToken; i < statementLength; ++i) { String propertyName = null; Object propertyValue = null; switch (getToken(i).tok) { @@ -7960,14 +7962,30 @@ setShapeProperty(shape, "clear", null); } - void initIsosurface(int iShape) throws ScriptException { + private void initIsosurface(int iShape) throws ScriptException { + + //handle isosurface/mo/pmesh delete and id delete here + setShapeProperty(iShape, "init", thisCommand); - if (!setMeshDisplayProperty(iShape, 0, tokAt(1))) + iToken = 0; + if (tokAt(1) == Token.delete || tokAt(2) == Token.delete + && tokAt(++iToken) == Token.all) { + setShapeProperty(iShape, "delete", null); + iToken += 2; + if (statementLength > iToken) { + setShapeProperty(iShape, "init", thisCommand); + setShapeProperty(iShape, "thisID", Mesh.PREVIOUS_MESH_ID); + } + return; + } + iToken = 1; + if (!setMeshDisplayProperty(iShape, 0, tokAt(1))) { setShapeProperty(iShape, "thisID", Mesh.PREVIOUS_MESH_ID); - setShapeProperty(iShape, "title", new String[] { thisCommand }); + setShapeProperty(iShape, "title", new String[] { thisCommand }); + } } - boolean listIsosurface(int iShape) throws ScriptException { + private boolean listIsosurface(int iShape) throws ScriptException { checkLength2(); if (!isSyntaxCheck) showString((String) viewer.getShapeProperty(iShape, "list")); @@ -7978,13 +7996,11 @@ viewer.loadShape(iShape); if (tokAt(1) == Token.list && listIsosurface(iShape)) return; - initIsosurface(iShape); int colorRangeStage = 0; int signPt = 0; boolean isIsosurface = (iShape == JmolConstants.SHAPE_ISOSURFACE); boolean surfaceObjectSeen = false; boolean planeSeen = false; - boolean idSeen = false; boolean isCavity = false; float[] nlmZ = new float[5]; float[] data = null; @@ -7992,8 +8008,9 @@ int modelIndex = (isSyntaxCheck ? 0 : viewer.getDisplayModelIndex()); if (!isSyntaxCheck) viewer.setCursor(Viewer.CURSOR_WAIT); - - for (int i = 1; i < statementLength; ++i) { + boolean idSeen = false; + initIsosurface(iShape); + for (int i = iToken; i < statementLength; ++i) { String propertyName = null; Object propertyValue = null; switch (getToken(i).tok) { Modified: trunk/Jmol/src/org/jmol/viewer/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Isosurface.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/viewer/Isosurface.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -122,6 +122,8 @@ meshes = isomeshes = (IsosurfaceMesh[])ArrayUtil.ensureLength(isomeshes, meshCount + 1); currentMesh = thisMesh = isomeshes[meshCount++] = new IsosurfaceMesh(thisID, g3d, colix); sg.setJvxlData(jvxlData = thisMesh.jvxlData); + System.out.println("Isosurface allocMesh thisMesh:" + thisMesh.vertexColixes); + } void initShape() { @@ -155,6 +157,13 @@ ////isosurface-only (no calculation required; no calculation parameters to set) + if ("delete" == propertyName) { + setPropertySuper(propertyName, value, bs); + if (!explicitID) + nLCAO = nUnnamed = 0; + return; + } + if ("thisID" == propertyName) { setPropertySuper("thisID", value, null); return; @@ -268,12 +277,6 @@ return; } - if ("delete" == propertyName) { - if (!explicitID) - nLCAO = nUnnamed = 0; - setPropertySuper(propertyName, value, bs); - return; - } /* if ("background" == propertyName) { boolean doHide = !((Boolean) value).booleanValue(); Modified: trunk/Jmol/src/org/jmol/viewer/IsosurfaceRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/IsosurfaceRenderer.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/viewer/IsosurfaceRenderer.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -152,7 +152,8 @@ colixC = vertexColixes[iC]; if (isBicolorMap && (colixA != colixB || colixB != colixC)) continue; - //System.out.println("meshrender " + iA + " " + iB + " " + iC + " " + colixA + " " + colixB + " " + colixC); + //if (iA >90 && iA < 100) + //System.out.println("isosurfacemeshrender " + iA + " " + iB + " " + iC + " " + colixA + " " + colixB + " " + colixC + " " + imesh.vertexValues[iA]+screens[iA] + " " + imesh.vertexValues[iB]+screens[iB] + " " + imesh.vertexValues[iC]+screens[iC]); } else { colixA = colixB = colixC = colix; } Modified: trunk/Jmol/src/org/jmol/viewer/Mesh.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Mesh.java 2007-04-24 17:38:22 UTC (rev 7482) +++ trunk/Jmol/src/org/jmol/viewer/Mesh.java 2007-04-25 01:49:07 UTC (rev 7483) @@ -87,6 +87,11 @@ scale = 1; vertices = null; polygonIndexes = null; + showPoints = false; + drawTriangles = false; + fillTriangles = true; + showTriangles = false; //as distinct entitities + frontOnly = false; this.meshType = meshType; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |