From: <ha...@us...> - 2009-10-26 17:00:05
|
Revision: 11629 http://jmol.svn.sourceforge.net/jmol/?rev=11629&view=rev Author: hansonr Date: 2009-10-26 16:59:50 +0000 (Mon, 26 Oct 2009) Log Message: ----------- version=11.9.7_dev # new feature: now() function, with now(fromWhen) # for example: # i = now(); # ... # print now(i); # reports milliseconds # # bug fix: loglevel 3 still sending messages Modified Paths: -------------- trunk/Jmol/src/org/jmol/jvxl/api/VertexDataServer.java trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/script/Token.java trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceRenderer.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/jvxl/api/VertexDataServer.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/api/VertexDataServer.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/jvxl/api/VertexDataServer.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -97,8 +97,9 @@ * @param check2 TODO * @param isAbsolute * @param color + * @return polygon index or -1 */ - public abstract void addTriangleCheck(int iA, int iB, int iC, int check, + public abstract int addTriangleCheck(int iA, int iB, int iC, int check, int check2, boolean isAbsolute, int color); /** Modified: trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -309,7 +309,7 @@ // (2) calculate the grid points private int contourVertexCount; - private ContourVertex[] contourVertexes; + protected ContourVertex[] contourVertexes; private static class ContourVertex extends Point3f { Point3i voxelLocation; @@ -397,21 +397,24 @@ continue; int vi = (nSquares < 2 ? -1 : c.vertexIndex); if (x != squareCountX && y != squareCountY) { - planarSquares[x * squareCountY + y].setVertex(0, vi); + planarSquares[x * squareCountY + y].setVertex(0, vi, i); } if (x != 0 && y != squareCountY) { - planarSquares[(x - 1) * squareCountY + y].setVertex(1, vi); + planarSquares[(x - 1) * squareCountY + y].setVertex(1, vi, i); } if (y != 0 && x != squareCountX) { - planarSquares[x * squareCountY + y - 1].setVertex(3, vi); + planarSquares[x * squareCountY + y - 1].setVertex(3, vi, i); } if (y != 0 && x != 0) { - planarSquares[(x - 1) * squareCountY + y - 1].setVertex(2,vi); + planarSquares[(x - 1) * squareCountY + y - 1].setVertex(2, vi, i); } } else { Logger.error("loadPixelData out of bounds: " + pt.x + " " + pt.y + "?"); } } + for (int i = 0; i < nSquares; i++) { + planarSquares[i].checkVertices(); + } } public float getInterpolatedPixelValue(Point3f ptXYZ) { @@ -458,6 +461,7 @@ //int x, y; //Point3f origin; final int[] vertexes = new int[] {-1, -1, -1, -1 }; + final int[] contourIndexes = new int[4]; final float[] values = new float[4]; float[][] fractions; int[][] intersectionPoints; @@ -481,13 +485,33 @@ } } - void setVertex(int iV, int pt) { + void setVertex(int iV, int pt, int contourIndex) { if (vertexes[iV] != -1 && vertexes[iV] != pt) Logger .error("iV IS NOT -1 or pt:" + iV + " " + vertexes[iV] + "!=" + pt); vertexes[iV] = pt; + contourIndexes[iV] = contourIndex; } + void checkVertices() { + /* + int iNaN = -1; + for (int i = 0; i < 4; i++) + if (vertexes[i] < 0) { + if (iNaN >= 0) { + iNaN = -1; + break; + } + iNaN = i; + } + if (iNaN >= 0) { + System.out.println(iNaN + " " + vertexes[iNaN] + " " + ); + vertexes[iNaN] = vertexes[(iNaN + 1) % 4]; + values[iNaN] = values[(iNaN + 1) % 4]; + } + */ + } + void addEdgeMask(int contourIndex, int edgeMask4, int insideMask) { /* * binary abcd abcd vvvv where abcd is edge intersection mask and @@ -553,11 +577,12 @@ contourValuesUsed = new float[nContourSegments]; for (int i = 0; i < nContourSegments; i++) { contourIndex = i; - float cutoff = (contoursDiscrete != null ? contoursDiscrete[i] : - contourFromZero ? min + (i * 1f / nContourSegments) * diff : - i == 0 ? -Float.MAX_VALUE : i == nContourSegments - 1 ? Float.MAX_VALUE - : min + ((i - 1) * 1f / (nContourSegments-1)) * diff); - + float cutoff = ( + contoursDiscrete != null ? contoursDiscrete[i] + : contourFromZero ? min + (i * 1f / nContourSegments) * diff + : i == 0 ? -Float.MAX_VALUE + : i == nContourSegments - 1 ? Float.MAX_VALUE + : min + ((i - 1) * 1f / (nContourSegments-1)) * diff); /* * cutoffs right near zero cause problems, so we adjust just a tad * @@ -591,7 +616,7 @@ int[][] isoPointIndexes2d = new int[squareCountY][4]; float[][] squareFractions2d = new float[squareCountY][4]; - + for (int i = squareCountY; --i >= 0;) isoPointIndexes2d[i][0] = isoPointIndexes2d[i][1] = isoPointIndexes2d[i][2] = isoPointIndexes2d[i][3] = -1; @@ -754,8 +779,9 @@ private float calcContourPoint(float cutoff, float valueA, float valueB, Point3f contourPoint) { - float fraction = (Float.isNaN(valueA) ? 1 - : Float.isNaN(valueB) ? 0 + //TODO - re-enable? problem is that this causes many overlapping triangles on edge of surface + float fraction = (false && Float.isNaN(valueA) ? 1 + : false && Float.isNaN(valueB) ? 0 : (cutoff - valueA) / (valueB - valueA)); edgeVector.sub(pointB, pointA); contourPoint.scaleAdd(fraction, edgeVector, pointA); @@ -1166,7 +1192,7 @@ && bsMesh1.get(i3) ? 2 : bsMesh1.get(i3) && bsMesh1.get(i1) ? 4 : 0); int check2 = (check > 0 ? 0 : bsMesh2.get(i1) && bsMesh2.get(i2) ? 1 : bsMesh2.get(i2) && bsMesh2.get(i3) ? 2 : bsMesh2.get(i3) && bsMesh2.get(i1) ? 4 : 0); - surfaceReader.addTriangleCheck(iA, iB, iC, Math.max(check, check2), (check > 0 ? contourIndex : contourIndex2), false, 0); + /*index=*/ surfaceReader.addTriangleCheck(iA, iB, iC, Math.max(check, check2), (check > 0 ? contourIndex : contourIndex2), false, 0); } if (iC >= 0) i2 = i3; Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -682,6 +682,15 @@ } if ("fullPlane" == propertyName) { + // fullPlane == true --> params.contourFromZero is false + // fullPlane == false --> params.contourFromZero is true + // this only relates to projections onto a plane + // the default is contourFromZero TRUE + // but MEP default is contourFromZero FALSE + // the setting is ignored when discrete contours + // are specified, because in that case we just + // define the triangle color by their centers + params.contourFromZero = !((Boolean) value).booleanValue(); return true; } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -514,12 +514,12 @@ private int lastColor; private short lastColix; - public void addTriangleCheck(int iA, int iB, int iC, int check, int check2, - boolean isAbsolute, int color) { + public int addTriangleCheck(int iA, int iB, int iC, int check, int check2, + boolean isAbsolute, int color) { if (meshDataServer == null) { if (isAbsolute && !MeshData.checkCutoff(iA, iB, iC, meshData.vertexValues)) - return; + return -1; int i = meshData.addTriangleCheck(iA, iB, iC, check, check2); if (i >= 0 && color != 0) { if (i == 0) @@ -528,10 +528,10 @@ .getColix(lastColor = color))); meshData.addPolygonColix(i, colix); } - } else { - meshDataServer.addTriangleCheck(iA, iB, iC, check, check2, isAbsolute, - color); + return i; } + return meshDataServer.addTriangleCheck(iA, iB, iC, check, check2, + isAbsolute, color); } //////////////////////////////////////////////////////////////////// Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -612,6 +612,7 @@ return evaluateReplace(args); case Token.array: return evaluateArray(args); + case Token.now: case Token.abs: case Token.acos: case Token.cos: @@ -1412,6 +1413,10 @@ q = new Quaternion(p4); return addX(q.toPoint4f()); } + if (tok == Token.now) { + return addX(((int) System.currentTimeMillis() & 0x7FFFFFFF) + - (args.length == 0 ? 0 : ScriptVariable.iValue(args[0]))); + } if (args.length != 1) return false; if (isSyntaxCheck) Modified: trunk/Jmol/src/org/jmol/script/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/script/Token.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/script/Token.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -600,7 +600,9 @@ final static int within = 13 | 0 << 9 | mathfunc; public final static int connected = 14 | 0 << 9 | mathfunc; public final static int helix = 15 | 0 << 9 | mathfunc | predefinedset; - + + final static int now = 16 | 0 << 9 | mathfunc; + // xxx(a) final static int substructure = 1 | 1 << 9 | mathfunc; @@ -1160,6 +1162,7 @@ "noContourLines", new Token(nocontourlines), "notFrontOnly", new Token(notfrontonly), "noTriangles", new Token(notriangles), + "now", new Token(now), "nucleic", new Token(nucleic), "occupancy", new Token(occupancy), "off", tokenOff, Modified: trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -849,11 +849,11 @@ associateNormals); } - public void addTriangleCheck(int iA, int iB, int iC, int check, + public int addTriangleCheck(int iA, int iB, int iC, int check, int check2, boolean isAbsolute, int color) { if (isAbsolute && !MeshData.checkCutoff(iA, iB, iC, thisMesh.vertexValues)) - return; - thisMesh.addTriangleCheck(iA, iB, iC, check, check2, color); + return -1; + return thisMesh.addTriangleCheck(iA, iB, iC, check, check2, color); } //////////////////////////////////////////////////////////////////// Modified: trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -153,7 +153,7 @@ private int lastColor; private short lastColix; - void addTriangleCheck(int vertexA, int vertexB, int vertexC, int check, int check2, + int addTriangleCheck(int vertexA, int vertexB, int vertexC, int check, int check2, int color) { if (vertices == null || vertexValues != null @@ -163,23 +163,25 @@ || Float.isNaN(vertices[vertexA].x) || Float.isNaN(vertices[vertexB].x) || Float.isNaN(vertices[vertexC].x)) - return; - if (polygonCount == 0) + return -1; + int n = polygonCount; + if (n == 0) polygonIndexes = new int[SEED_COUNT][]; - else if (polygonCount == polygonIndexes.length) + else if (n == polygonIndexes.length) polygonIndexes = (int[][]) ArrayUtil.doubleLength(polygonIndexes); if (color != 0) { if (polygonColixes == null) { polygonColixes = new short[SEED_COUNT]; lastColor = 0; - } else if (polygonCount == polygonColixes.length) { + } else if (n == polygonColixes.length) { polygonColixes = (short[]) ArrayUtil.doubleLength(polygonColixes); } - polygonColixes[polygonCount] = (color == lastColor ? lastColix + polygonColixes[n] = (color == lastColor ? lastColix : (lastColix = Graphics3D.getColix(lastColor = color))); } polygonIndexes[polygonCount++] = new int[] { vertexA, vertexB, vertexC, check, check2 }; + return n; } void invalidateTriangles() { Modified: trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceRenderer.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceRenderer.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -149,8 +149,11 @@ int incr = imesh.vertexIncrement; int diam = 4; boolean showNumbers = viewer.getTestFlag2(); + int cX = (showNumbers ? viewer.getScreenWidth()/2 : 0); + int cY = (showNumbers ? viewer.getScreenHeight()/2 : 0); + if (showNumbers) - g3d.setFont(g3d.getFontFid("Monospaced", 10)); + g3d.setFont(g3d.getFontFid("Monospaced", 24)); for (int i = (!imesh.hasGridPoints || imesh.firstRealVertex < 0 ? 0 : imesh.firstRealVertex); i < vertexCount; i += incr) { if (vertexValues != null && Float.isNaN(vertexValues[i]) || frontOnly @@ -158,11 +161,18 @@ continue; if (imesh.vertexColixes != null) g3d.setColix(imesh.vertexColixes[i]); + if (showNumbers && screens[i].z > 10 + && Math.abs(screens[i].x - cX) < 50 + && Math.abs(screens[i].y - cY) < 50 + ) { + String s = i + (imesh.isColorSolid ? "" : " " + imesh.vertexValues[i]); + System.out.println("IsoSurfaceRenderer i=" + s + " " + + imesh.vertices[i] + " " + imesh.vertexValues[i]); + g3d.drawStringNoSlab(s, null, + screens[i].x, screens[i].y, screens[i].z); + } + diam = (i == 1066 ? 8 : 4); g3d.fillSphereCentered(diam, screens[i]); - if (showNumbers && screens[i].z > 10) - g3d.drawStringNoSlab(i - + (imesh.isColorSolid ? "" : " " + imesh.vertexValues[i]), null, - screens[i].x, screens[i].y, screens[i].z); } if (incr != 3) return; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-10-26 16:59:50 UTC (rev 11629) @@ -3,6 +3,14 @@ version=11.9.7_dev +# new feature: now() function, with now(fromWhen) +# for example: +# i = now(); +# ... +# print now(i); # reports milliseconds +# +# bug fix: loglevel 3 still sending messages +# # new feature: isosurface/pmesh commands accept unquoted file names. # new feature: Jvxl 2.0 -- XML format for JVXL files # here, initially, only being used for writing contour or triangle data Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-10-26 06:16:52 UTC (rev 11628) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-10-26 16:59:50 UTC (rev 11629) @@ -4411,6 +4411,8 @@ */ public void scriptEcho(String strEcho) { + if (!Logger.isActiveLevel(Logger.LEVEL_INFO)) + return; statusManager.setScriptEcho(strEcho, isScriptQueued); if (listCommands && strEcho != null && strEcho.indexOf("$[") == 0) Logger.info(strEcho); @@ -5961,7 +5963,7 @@ public void showString(String str, boolean isPrint) { if (isScriptQueued && (!isSilent || isPrint)) - Logger.warn(str); + Logger.info(str); scriptEcho(str); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |