From: <ha...@us...> - 2006-06-13 22:30:56
|
Revision: 5219 Author: hansonr Date: 2006-06-13 15:30:34 -0700 (Tue, 13 Jun 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=5219&view=rev Log Message: ----------- bob200603 adds more isosurface functionality, including isosurface functionXY isosurface center isosurface fixed isosurface modelbased and fixes isosurface visibility for correct multiple model/file display deletes Geodesic3D2.Java note - this adds one function to statusListener Modified Paths: -------------- branches/bob200603/Jmol/src/org/jmol/api/JmolStatusListener.java branches/bob200603/Jmol/src/org/jmol/applet/Jmol.java branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java branches/bob200603/Jmol/src/org/jmol/viewer/Axes.java branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java branches/bob200603/Jmol/src/org/jmol/viewer/StatusManager.java branches/bob200603/Jmol/src/org/jmol/viewer/Token.java branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java branches/bob200603/Jmol/src/org/openscience/jmol/app/Jmol.java Removed Paths: ------------- branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D2.java Modified: branches/bob200603/Jmol/src/org/jmol/api/JmolStatusListener.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/api/JmolStatusListener.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/api/JmolStatusListener.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -62,4 +62,5 @@ public void showConsole(boolean showConsole); + public float functionXY(int x, int y); } Modified: branches/bob200603/Jmol/src/org/jmol/applet/Jmol.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/applet/Jmol.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/applet/Jmol.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -139,12 +139,11 @@ htmlName = getParameter("name"); String ms = getParameter("mayscript"); mayScript = (ms != null) && (!ms.equalsIgnoreCase("false")); - appletRegistry = new JmolAppletRegistry(htmlName, mayScript, appletWrapper); - + appletRegistry = new JmolAppletRegistry(htmlName, mayScript, appletWrapper); initWindows(); initApplication(); } - + String getParameter(String paramName) { return appletWrapper.getParameter(paramName); } @@ -672,6 +671,10 @@ showStatusAndConsole(statusMessage); } + public float functionXY(int x, int y) { + return ((Double) jsoWindow.call("functionXY", new Object[] { htmlName, new Integer(x), new Integer(y)})).floatValue(); + } + public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) { showStatusAndConsole(strMeasure); } Modified: branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -174,15 +174,16 @@ Geodesic3D(Graphics3D g3d) { this.g3d = g3d; - //String msg = "Geodesecs "+ System.currentTimeMillis(); - //System.out.println(msg+" 0"); - initialize(); - //System.out.println(msg+" 1"); + String id = "Geodesecs "+ System.currentTimeMillis(); + //System.out.println(id+" 0"); + initialize(id); + //System.out.println(id+" 1"); } - private static synchronized void initialize() { + private static synchronized void initialize(String id) { if(vertexCounts != null) return; + System.out.println(id + " initializing"); vertexCounts = new short[maxLevel]; neighborVertexesArrays = new short[maxLevel][]; faceVertexesArrays = new short[maxLevel][]; @@ -216,7 +217,7 @@ " edgeCount=" + getEdgeCount(i)); } } - System.out.println("geodesic initialization completed"); + System.out.println(id+" initialization completed"); } static int getVertexCount(int level) { Deleted: branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D2.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D2.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D2.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -1,432 +0,0 @@ -/* $RCSfile$ - * $Author$ - * $Date$ - * $Revision$ - * - * Copyright (C) 2005 Miguel, Jmol Development, www.jmol.org - * - * Contact: mi...@jm... - * - * 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 Public 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.g3d; - -import javax.vecmath.Vector3f; -import org.jmol.util.Int2IntHash; - - /** - * Constructs a canonical geodesic sphere of unit radius. - *<p> - * The Normix3D code quantizes arbitrary vectors to the vectors - * of this unit sphere. normix values are then used for - * high performance surface normal lighting - *<p> - * The vertices of the geodesic sphere can be used for constructing - * vanderWaals and Connolly dot surfaces. - *<p> - * One geodesic sphere is constructed. It is a unit sphere - * with radius of 1.0 - *<p> - * Many times a sphere is constructed with lines of latitude and - * longitude. With this type of rendering, the atom has north and - * south poles. And the faces are not regularly shaped ... at the - * poles they are triangles but elsewhere they are quadrilaterals. - *<p> - * A geodesic sphere is more appropriate for this type - * of application. The geodesic sphere does not have poles and - * looks the same in all orientations ... as a sphere should. All - * faces are triangles. Not equilateral, but close. - *<p> - * The geodesic sphere is constructed by starting with an icosohedron, - * a platonic solid with 12 vertices and 20 equilateral triangles - * for faces. The internal call to the private - * method <code>quadruple</code> will - * split each triangular face into 4 faces by creating a new vertex - * at the midpoint of each edge. These midpoints are still in the - * plane, so they are then 'pushed out' to the surface of the - * enclosing sphere by normalizing their length back to 1.0 - *<p> - * The sequence of vertex counts is 12, 42, 162, 642, 2562. - * These are identified by 'levels', that run from 0 through 4; - * The vertices - * are stored so that when spheres are small they can choose to display - * only the first n bits where n is one of the above vertex counts. - *<code> - * Faces + Vertices = Edges + 2 - * Faces: 20, 80, 320, 1280, 5120, 20480 - * start with 20 faces ... at each level multiply by 4 - * Edges: 30, 120, 480, 1920, 7680, 30720 - * start with 30 edges ... also multipy by 4 ... strange, but true - * Vertices: 12, 42, 162, 642, 2562, 10242 - * start with 12 vertices and 30 edges. - * when you subdivide, each edge contributes one vertex - * 12 + 30 = 42 vertices at the next level - * 80 faces + 42 vertices - 2 = 120 edges at the next level - *</code> - *<p> - * The vertices of the 'one true canonical sphere' are rotated to the - * current molecular rotation at the beginning of the repaint cycle. - * That way, - * individual atoms only need to scale the unit vector to the vdw - * radius for that atom. - *<p> - * - * Notes 27 Sep 2005 <br /> - * If I were to switch the representation to staring with - * a tetrahedron instead of an icosohedron we would get: - *<code> - * Faces: 4, 16, 64, 256, 1024 - * Edges: 6, 24, 96, 384, 1536 - * Vertices: 4, 10, 34, 130, 514 - *</code> - * If I switched to face-centered normixes then I could efficiently - * Regardless, I think that face-centered normixes would also reduce - * ambiguity and would speed up the normal to normix process. - * - * I could also start with an octahedron that placed one triangle - * in each 3D cartesian octant. That would push to 512 faces instead - * of 256 faces, leaving me with shorts. But, it would be easier to quantize - * at the first level because it would be based upon sign. And perhaps - * it would be easier to take advantage of symmetry in the process of - * converting from normal to normix. - * - * Notes 11 Oct 2005 <br /> - * Using an octahedron, the counts come up as follows: - * Faces: 8, 32, 128, 512 - * Edges: 12, 48, 192, 768 - * Vrtxs: 6, 18, 66, 258 - */ - -class Geodesic3D2 { - - Graphics3D g3d; - - private final static boolean DUMP = true; - - final static float halfRoot5 = (float)(0.5 * Math.sqrt(5)); - final static float oneFifth = 2 * (float)Math.PI / 5; - final static float oneTenth = oneFifth / 2; - - // miguel 2005 01 11 - // within the context of this code, the term 'vertex' is used - // to refer to a short which is an index into the tables - // of vertex information. - final static short[] faceVertexesOctant = { - 0, 1, 4, - 0, 5, 1, - 0, 3, 5, - 0, 4, 3, - - 2, 1, 5, - 2, 5, 3, - 2, 3, 4, - 2, 4, 1, - }; - - // every vertex has 6 neighbors ... except at the beginning of the world - final static short[] neighborVertexesOctant = { - 1, 4, 3, 5,-1,-1, // 0 - 0, 5, 2, 4,-1,-1, // 1 - 1, 5, 3, 4,-1,-1, // 2 - 0, 4, 2, 5,-1,-1, // 3 - 0, 1, 2, 3,-1,-1, // 4 - 0, 3, 2, 1,-1,-1, // 5 - }; - - /** - * 5 levels, 0 through 4 - */ - final static int maxLevel = 3; - static short[] vertexCounts; - static short[][] neighborVertexesArrays; - static short[][] faceVertexesArrays; - static Vector3f[][] faceVectorsArrays; - static Vector3f[] vertexVectors = new Vector3f[] { - new Vector3f( 0, 1, 0), - new Vector3f( 0, 0, 1), - new Vector3f( 0,-1, 0), - new Vector3f( 0, 0,-1), - new Vector3f( 1, 0, 0), - new Vector3f(-1, 0, 0) - }; - - - - Geodesic3D2(Graphics3D g3d) { - this.g3d = g3d; - if (vertexCounts == null) - initialize(); - if (DUMP) { - System.out.println("vertexVectors.length=" + vertexVectors.length); - for (int i = 0; i < vertexVectors.length; ++i) - System.out.println("" + i + " : " + vertexVectors[i]); - } - } - - private synchronized void initialize() { - if (vertexCounts != null) - return; - vertexCounts = new short[maxLevel]; - neighborVertexesArrays = new short[maxLevel][]; - faceVertexesArrays = new short[maxLevel][]; - faceVectorsArrays = new Vector3f[maxLevel][]; - - faceVertexesArrays[0] = faceVertexesOctant; - neighborVertexesArrays[0] = neighborVertexesOctant; - vertexCounts[0] = 6; - - for (int i = 0; i < maxLevel - 1; ++i) - quadruple(i); - - if (DUMP) { - for (int i = 0; i < maxLevel; ++i) { - System.out.println("geodesic level " + i + - " vertexCount= " + getVertexCount(i) + - " faceCount=" + getFaceCount(i) + - " edgeCount=" + getEdgeCount(i)); - } - } - for (int i = 0; i < maxLevel; ++i) - faceVectorsArrays[i] = - buildFaceVectors(faceVertexesArrays[i], vertexVectors); - } - - static int getVertexCount(int level) { - return vertexCounts[level]; - } - - static Vector3f[] getVertexVectors() { - return vertexVectors; - } - - static int getFaceCount(int level) { - return faceVertexesArrays[level].length / 3; - } - - static int getEdgeCount(int level) { - return getVertexCount(level) + getFaceCount(level) - 2; - } - - static short[] getNeighborVertexes(int level) { - return neighborVertexesArrays[level]; - } - - static short[] getFaceVertexes(int level) { - return faceVertexesArrays[level]; - } - - static Vector3f[] getFaceVectors(int level) { - return faceVectorsArrays[level]; - } - - - private static short vertexNext; - private static Int2IntHash htVertex; - - private final static boolean VALIDATE = true; - - private static void quadruple(int level) { - if (DUMP) - System.out.println("quadruple(" + level + ")"); - htVertex = new Int2IntHash(); - int oldVertexCount = vertexVectors.length; - short[] oldFaceVertexes = faceVertexesArrays[level]; - int oldFaceVertexesLength = oldFaceVertexes.length; - int oldFaceCount = oldFaceVertexesLength / 3; - int oldEdgesCount = oldVertexCount + oldFaceCount - 2; - int newVertexCount = oldVertexCount + oldEdgesCount; - int newFaceCount = 4 * oldFaceCount; - Vector3f[] newVertexVectors = new Vector3f[newVertexCount]; - System.arraycopy(vertexVectors, 0, newVertexVectors, 0, oldVertexCount); - vertexVectors = newVertexVectors; - - short[] newFacesVertexes = new short[3 * newFaceCount]; - faceVertexesArrays[level + 1] = newFacesVertexes; - short[] neighborVertexes = new short[6 * newVertexCount]; - neighborVertexesArrays[level + 1] = neighborVertexes; - for (int i = neighborVertexes.length; --i >= 0; ) - neighborVertexes[i] = -1; - - vertexCounts[level + 1] = (short)newVertexCount; - - if (DUMP) - System.out.println("oldVertexCount=" + oldVertexCount + - " newVertexCount=" + newVertexCount + - " oldFaceCount=" + oldFaceCount + - " newFaceCount=" + newFaceCount); - - vertexNext = (short)oldVertexCount; - - int iFaceNew = 0; - for (int i = 0; i < oldFaceVertexesLength; ) { - short iA = oldFaceVertexes[i++]; - short iB = oldFaceVertexes[i++]; - short iC = oldFaceVertexes[i++]; - short iAB = getVertex(iA, iB); - short iBC = getVertex(iB, iC); - short iCA = getVertex(iC, iA); - - newFacesVertexes[iFaceNew++] = iA; - newFacesVertexes[iFaceNew++] = iAB; - newFacesVertexes[iFaceNew++] = iCA; - - newFacesVertexes[iFaceNew++] = iB; - newFacesVertexes[iFaceNew++] = iBC; - newFacesVertexes[iFaceNew++] = iAB; - - newFacesVertexes[iFaceNew++] = iC; - newFacesVertexes[iFaceNew++] = iCA; - newFacesVertexes[iFaceNew++] = iBC; - - newFacesVertexes[iFaceNew++] = iCA; - newFacesVertexes[iFaceNew++] = iAB; - newFacesVertexes[iFaceNew++] = iBC; - - addNeighboringVertexes(neighborVertexes, iAB, iA); - addNeighboringVertexes(neighborVertexes, iAB, iCA); - addNeighboringVertexes(neighborVertexes, iAB, iBC); - addNeighboringVertexes(neighborVertexes, iAB, iB); - - addNeighboringVertexes(neighborVertexes, iBC, iB); - addNeighboringVertexes(neighborVertexes, iBC, iCA); - addNeighboringVertexes(neighborVertexes, iBC, iC); - - addNeighboringVertexes(neighborVertexes, iCA, iC); - addNeighboringVertexes(neighborVertexes, iCA, iA); - } - if (VALIDATE) { - int vertexCount = vertexVectors.length; - if (iFaceNew != newFacesVertexes.length) - throw new NullPointerException(); - if (vertexNext != newVertexCount) - throw new NullPointerException(); - for (int i = 0; i < 6; ++i) { - for (int j = 0; j < 4; ++j) { - int neighbor = neighborVertexes[i * 6 + j]; - if (neighbor < 0) - throw new NullPointerException(); - if (neighbor >= vertexCount) - throw new NullPointerException(); - } - if (neighborVertexes[i * 6 + 4] != -1) - throw new NullPointerException(); - if (neighborVertexes[i * 6 + 5] != -1) - throw new NullPointerException(); - } - for (int i = 6 * 6; i < neighborVertexes.length; ++i) { - int neighbor = neighborVertexes[i]; - if (neighbor < 0) - throw new NullPointerException(); - if (neighbor >= vertexCount) - throw new NullPointerException(); - } - for (int i = 0; i < newVertexCount; ++i) { - int neighborCount = 0; - for (int j = neighborVertexes.length; --j >= 0; ) - if (neighborVertexes[j] == i) - ++neighborCount; - if (i < 6) { - if (neighborCount != 4) - throw new NullPointerException(); - } else { - if (neighborCount != 6) - throw new NullPointerException(); - } - int faceCount = 0; - for (int j = newFacesVertexes.length; --j >= 0; ) - if (newFacesVertexes[j] == i) - ++faceCount; - if (i < 6) { - if (faceCount != 4) - throw new NullPointerException(); - } else { - if (faceCount != 6) - throw new NullPointerException(); - } - } - } - htVertex = null; - } - - private static void addNeighboringVertexes(short[] neighborVertexes, - short v1, short v2) { - //System.out.println("addNeighboringVertexes(...," + v1 + "," + v2 + ")"); - for (int i = v1 * 6, iMax = i + 6; i < iMax; ++i) { - if (neighborVertexes[i] == v2) - return; - if (neighborVertexes[i] < 0) { - neighborVertexes[i] = v2; - for (int j = v2 * 6, jMax = j + 6; j < jMax; ++j) { - if (neighborVertexes[j] == v1) - return; - if (neighborVertexes[j] < 0) { - neighborVertexes[j] = v1; - return; - } - } - } - } - throw new NullPointerException(); - } - - /* - short getNeighborVertex(int level, short vertex, int neighborIndex) { - short[] neighborVertexes = neighborVertexesArrays[level]; - int offset = vertex * 6 + neighborIndex; - return neighborVertexes[offset]; - } - */ - - private static short getVertex(short v1, short v2) { - if (v1 > v2) { - short t = v1; - v1 = v2; - v2 = t; - } - int hashKey = (v1 << 16) + v2; - int vertex = htVertex.get(hashKey); - if (vertex != Integer.MIN_VALUE) - return (short)vertex; - Vector3f newVertexVector = vertexVectors[vertexNext] = new Vector3f(); - newVertexVector.add(vertexVectors[v1], vertexVectors[v2]); - newVertexVector.normalize(); - htVertex.put(hashKey, vertexNext); - return vertexNext++; - } - - static boolean isNeighborVertex(short vertex1, short vertex2, int level) { - short[] neighborVertexes = neighborVertexesArrays[level]; - int offset1 = vertex1 * 6; - for (int i = offset1 + (vertex1 < 6 ? 4 : 6); --i >= offset1; ) - if (neighborVertexes[i] == vertex2) - return true; - return false; - } - - private static Vector3f[] buildFaceVectors(short[] faceVertexes, - Vector3f[] vertexVectors) { - int faceCount = faceVertexes.length / 3; - Vector3f faceVectors[] = new Vector3f[faceCount]; - for (int i = 0, j = 0; i < faceCount; ++i, j += 3) { - Vector3f v = faceVectors[i] = new Vector3f(); - v.add(vertexVectors[faceVertexes[j]], - vertexVectors[faceVertexes[j + 1]]); - v.add(vertexVectors[faceVertexes[j + 2]]); - v.normalize(); - } - return faceVectors; - } -} Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Axes.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Axes.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Axes.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -24,11 +24,22 @@ package org.jmol.viewer; +import java.util.BitSet; + import javax.vecmath.Point3f; import javax.vecmath.Vector3f; class Axes extends SelectionIndependentShape { + + void setProperty(String propertyName, Object value, BitSet bs) { + if ("scale" == propertyName) { + setScale(((Float)value).floatValue()); + return; + } + super.setProperty(propertyName, value, bs); + } + final static Point3f[] unitAxisPoints = { new Point3f( 1, 0, 0), new Point3f( 0, 1, 0), @@ -38,6 +49,8 @@ new Point3f( 0, 0,-1) }; + float scale = 1f; + final Point3f originPoint = new Point3f(); final Point3f[] axisPoints = new Point3f[6]; { @@ -78,10 +91,15 @@ if (corner.z < MIN_AXIS_LEN) corner.z = MIN_AXIS_LEN; - axisPoint.x *= corner.x; - axisPoint.y *= corner.y; - axisPoint.z *= corner.z; + axisPoint.x *= corner.x * scale; + axisPoint.y *= corner.y * scale; + axisPoint.z *= corner.z * scale; axisPoint.add(originPoint); } } + + void setScale(float angstroms) { + scale = angstroms; + initShape(); + } } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -187,12 +187,12 @@ if (isFixed) { currentMesh.setPolygonCount(1); currentMesh.ptCenters = null; - currentMesh.visibilityFlags = null; + currentMesh.modelFlags = null; nPoly = setVerticesAndPolygons(-1, nPoly); } else { currentMesh.setPolygonCount(modelCount); currentMesh.ptCenters = new Point3f[modelCount]; - currentMesh.visibilityFlags = new int[modelCount]; + currentMesh.modelFlags = new int[modelCount]; for (int iModel = 0; iModel < modelCount; iModel++) { // int n0 = currentMesh.vertexCount; nPoly = setVerticesAndPolygons(iModel, nPoly); @@ -216,7 +216,7 @@ addPoint(m.vertices[ipt]); } else { for (ipt = 0; ipt < m.drawVertexCount; ipt++) { - System.out.println(nPoints +" "+m.meshID+ " count="+m.drawVertexCount + " length=" + m.vertices.length); + //System.out.println(nPoints +" "+m.meshID+ " count="+m.drawVertexCount + " length=" + m.vertices.length); addPoint(m.vertices[ipt]); } @@ -274,10 +274,11 @@ */ int modelCount = viewer.getModelCount(); for (int i = meshCount; --i >= 0;) { - if (meshes[i].visibilityFlags == null) + meshes[i].visibilityFlags = myVisibilityFlag; + if (meshes[i].modelFlags == null) continue; for (int iModel = modelCount; --iModel >= 0;) - meshes[i].visibilityFlags[iModel] = (bs.get(iModel) ? 1 : 0); + meshes[i].modelFlags[iModel] = (bs.get(iModel) ? 1 : 0); } } @@ -294,7 +295,7 @@ mesh = meshes[i]; if (mesh.drawVertexCount == 2) { for (int iModel = modelCount; --iModel >= 0;) { - if (mesh.visibilityFlags != null && mesh.visibilityFlags[iModel] == 0) + if (mesh.modelFlags != null && mesh.modelFlags[iModel] == 0) continue; for (int iVertex = mesh.polygonIndexes[iModel].length; --iVertex >= 0;) { int d2 = coordinateInRange(x, y, Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -371,7 +371,7 @@ if (logMessages || viewer.getDebugScript()) logDebugScript(); Token token = statement[0]; - //System.out.println(token); + //System.out.println(token + " token/tok " + token.tok + " isosurface:" + Token.isosurface); switch (token.tok) { case Token.backbone: proteinShape(JmolConstants.SHAPE_BACKBONE); @@ -842,10 +842,18 @@ evalError("{ number number number } expected"); } + void coordinateOrNameOrExpressionRequired() throws ScriptException { + evalError(" {x y z} or $name or (atom expression) required"); + } + void tooManyRotationPoints() throws ScriptException { evalError("too many rotation points were specified"); } + void keywordRequired(String what) throws ScriptException { + evalError("keyword required: " + what); + } + void notImplemented(int itoken) { notImplemented(statement[itoken]); } @@ -1580,8 +1588,6 @@ // color $ whatever green String objectName = objectNameParameter(index); int shapeType = viewer.getShapeIdFromObjectName(objectName); - System.out.println("colorIdentifiedObject" + index + " " + shapeType + " " - + objectName); if (shapeType < 0) objectNameExpected(); viewer.setShapeProperty(shapeType, "meshID", objectName); @@ -3054,6 +3060,18 @@ } void setAxes(int cmdPt) throws ScriptException { + if (statement.length == 1) { + viewer.setShapeSize(JmolConstants.SHAPE_AXES, 1); + return; + } + // set axes scale x.xxx + if (statement.length == cmdPt + 2 + && statement[cmdPt].tok == Token.identifier + && ((String) statement[cmdPt].value).equalsIgnoreCase("scale")) { + viewer.setShapeProperty(JmolConstants.SHAPE_AXES, "scale", new Float( + floatParameter(cmdPt + 1))); + return; + } viewer.setShapeSize(JmolConstants.SHAPE_AXES, getSetAxesTypeMad(cmdPt)); } @@ -3980,10 +3998,8 @@ } void isosurface() throws ScriptException { - int fileIndexPt = 0; int signPt = 0; - int contourPt = 0; - int orbitalPt = 0; + boolean isOrbital = false; float[] nlmZR = new float[5]; viewer.loadShape(JmolConstants.SHAPE_ISOSURFACE); viewer.setShapeProperty(JmolConstants.SHAPE_ISOSURFACE, "init", null); @@ -3995,7 +4011,29 @@ String propertyName = null; Object propertyValue = null; Token token = statement[i]; + System.out.println(i + " " + token); switch (token.tok) { + case Token.center: + propertyName = "center"; + switch (statement[++i].tok) { + case Token.dollarsign: + String id = objectNameParameter(++i); + propertyValue = viewer.getDrawObjectCenter(id); + if (propertyValue == null) + drawObjectNotDefined(id); + break; + case Token.expressionBegin: + propertyValue = viewer.getAtomSetCenter(expression(statement, i + 1)); + i = pcLastExpressionInstruction; + break; + case Token.leftbrace: + propertyValue = getCoordinate(i, true); + i = pcLastExpressionInstruction; + break; + default: + coordinateOrNameOrExpressionRequired(); + } + break; case Token.leftbrace: // {X, Y, Z, W} propertyName = "plane"; @@ -4016,12 +4054,22 @@ colorRangeStage++; break; case Token.solvent: - propertyName = "solvent"; - propertyValue = new Float(viewer.getSolventProbeRadius()); - System.out.println (propertyName+" "+propertyValue); + propertyName = "solvent"; + propertyValue = new Float(viewer.getSolventProbeRadius()); break; case Token.identifier: String str = (String) token.value; + if (str.equalsIgnoreCase("FIXED")) { + propertyName = "fixed"; + propertyValue = Boolean.TRUE; + break; + } + if (str.equalsIgnoreCase("MODELBASED")) { + propertyName = "fixed"; + propertyValue = Boolean.FALSE; + break; + } + if (str.equalsIgnoreCase("sign")) { signPt = i + 1; propertyName = "sign"; @@ -4029,15 +4077,22 @@ colorRangeStage = 1; break; } else if (str.equalsIgnoreCase("phase")) { - if (orbitalPt != 0) { + if (isOrbital) { propertyName = "phase"; propertyValue = "_orb"; break; } colorByPhase = true; break; + } else if (str.equalsIgnoreCase("functionXY")) { + propertyName = "functionXY"; + break; + } else if (str.equalsIgnoreCase("insideOut")) { + propertyName = "insideOut"; + break; } else if (str.equalsIgnoreCase("fileIndex")) { - fileIndexPt = i + 1; + propertyName = "fileIndex"; + propertyValue = new Integer(intParameter(++i)); break; } else if (str.equalsIgnoreCase("noBackground")) { propertyName = "background"; @@ -4055,11 +4110,20 @@ propertyName = "gridPoints"; break; } else if (str.equalsIgnoreCase("orbital")) { - orbitalPt = i + nlmZR.length; + nlmZR[0] = intParameter(++i); + nlmZR[1] = intParameter(++i); + nlmZR[2] = intParameter(++i); + nlmZR[3] = (statement[i + 1].tok == Token.integer ? floatParameter(++i) + : 6f); + nlmZR[4] = (statement[i + 1].tok == Token.integer ? floatParameter(++i) + : 10f); + propertyName = "orbital"; + propertyValue = nlmZR; + isOrbital = true; break; } else if (str.equalsIgnoreCase("contour")) { propertyName = "contour"; - contourPt = i + 1; + propertyValue = new Integer(intParameter(++i)); break; } propertyValue = token.value; @@ -4091,41 +4155,13 @@ } break; case Token.decimal: - if (colorRangeStage == 0 && orbitalPt <= 0) { + if (colorRangeStage == 0) { propertyName = "cutoff"; propertyValue = token.value; break; } // fall into case Token.integer: - if (orbitalPt > 0 && i <= orbitalPt) { - int ipt = nlmZR.length - (orbitalPt - i) - 1; - if (ipt < 3 && token.tok != Token.integer) - integerExpected(); - // n l m Znuc ptsPerAngstrom - nlmZR[ipt] = floatParameter(i); - if (i != orbitalPt) - break; - propertyName = "orbital"; - propertyValue = nlmZR; - orbitalPt = -999; - break; - } - if (i == contourPt) { - if (token.tok != Token.integer) - integerExpected(); - propertyName = "contour"; - propertyValue = new Integer(token.intValue); - contourPt = 0; - break; - } - if (i == fileIndexPt) { - if (token.tok != Token.integer) - integerExpected(); - propertyName = "fileIndex"; - propertyValue = new Integer(token.intValue); - break; - } if (colorRangeStage == 0 || colorRangeStage >= 3) invalidArgument(); propertyName = colorRangeStage == 1 ? "red" : "blue"; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -115,9 +115,11 @@ int colorPtr; boolean colorByPhase; int colorPhase; + boolean insideOut; boolean isCalculation; boolean isOrbital; boolean isSolvent; + boolean isFunctionXY; float solventRadius; int edgeFractionBase; @@ -156,10 +158,12 @@ boolean iDoContourPlane; boolean dataIsJvxl2dContour; + Point3f center = new Point3f(); Point4f thePlane; int nContours; int thisContour; boolean dotsOnly; + boolean isFixed; BufferedReader br; @@ -173,6 +177,8 @@ fileIndex = 1; nBytes = 0; nContours = 0; + insideOut = false; + isFixed = false; thePlane = null; iAddGridPoints = false; associateNormals = true; @@ -188,12 +194,19 @@ colorByPhase = false; isOrbital = false; isSolvent = false; + isFunctionXY = false; isCalculation = false; + center.set(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE); cutoff = Float.MAX_VALUE; super.setProperty("meshID", null, null); return; } + if ("center" == propertyName) { + center.set((Point3f) value); + return; + } + if ("sign" == propertyName) { colorBySign = true; colorPtr = 0; @@ -227,6 +240,17 @@ return; } + if ("insideOut" == propertyName) { + insideOut = true; + return; + } + + if ("fixed" == propertyName) { + isFixed = ((Boolean) value).booleanValue(); + setModelIndex(); + return; + } + if ("contour" == propertyName) { if (value instanceof Integer) nContours = ((Integer) value).intValue(); @@ -274,13 +298,13 @@ return; } applyColorScale(); - if (currentMesh != null) - currentMesh.visible = true; + setModelIndex(); return; } if ("solvent" == propertyName) { isSolvent = isCalculation = true; + isOrbital = isFunctionXY = false; solventRadius = ((Float) value).floatValue(); if (solventRadius < 0) solventRadius = defaultSolventRadius; @@ -292,6 +316,8 @@ if ("orbital" == propertyName) { isOrbital = isCalculation = true; + isSolvent = isFunctionXY = false; + float[] nlmZR = (float[]) value; psi_n = (int) nlmZR[0]; psi_l = (int) nlmZR[1]; @@ -307,6 +333,13 @@ } propertyName = "bufferedReader"; } + + if ("functionXY" == propertyName) { + isFunctionXY = true; + isSolvent = isOrbital = isCalculation = false; + return; + } + if ("bufferedReader" == propertyName) { if (!isCalculation) br = (BufferedReader) value; @@ -321,12 +354,13 @@ currentMesh.nBytes = nBytes; if (thePlane == null) System.out.println("\n" + jvxlGetFile(currentMesh, jvxlFileMessage)); - currentMesh.visible = true; + setModelIndex(); return; } if ("colorReader" == propertyName) { isSolvent = false; isOrbital = false; + isFunctionXY = false; System.out.println("mapping data..."); br = (BufferedReader) value; checkFlags(); @@ -341,7 +375,7 @@ discardTempData(true); currentMesh.nBytes = nBytes; System.out.println("\n" + jvxlGetFile(currentMesh, jvxlFileMessage)); - currentMesh.visible = true; + setModelIndex(); return; } @@ -526,6 +560,8 @@ System.out.println("cube axes vector:" + volumetricVectors[i]); } } + if (center.x != Float.MAX_VALUE) + offsetCenter(); setupMatrix(volumetricMatrix, volumetricVectors); readAtoms(); return readExtraLine(); @@ -679,6 +715,8 @@ isJvxlColorMapped = false; isJvxlColorPrecision = false; thisInside = (!isJvxl || thePlane == null); + if(insideOut) + thisInside = !thisInside; nDataPoints = 0; voxelData = new float[nPointsX][][]; @@ -700,6 +738,8 @@ for (int y = 0; y < nPointsY; ++y) { float[] strip = new float[nPointsZ]; plane[y] = strip; + if (isFunctionXY) + getValueZ(x, y); for (int z = 0; z < nPointsZ; ++z) { float voxelValue; /* @@ -714,6 +754,8 @@ voxelValue = getPsi2(x, y, z); else if (isSolvent) voxelValue = getSolventValue(x, y, z); + else if (isFunctionXY) + voxelValue = calcVoxelZDistance(x, y, z); else if (isMapData || thePlane == null) voxelValue = getNextVoxelValue(); else @@ -2787,6 +2829,16 @@ return ptXyz; } + void offsetCenter() { + Point3f ptXyz = new Point3f(); + ptXyz.scaleAdd((voxelCounts[0] - 1) / 2f, volumetricVectors[0], ptXyz); + ptXyz.scaleAdd((voxelCounts[1] - 1) / 2f, volumetricVectors[1], ptXyz); + ptXyz.scaleAdd((voxelCounts[2] - 1) / 2f, volumetricVectors[2], ptXyz); + System.out.println("teset1 "+volumetricOrigin); + volumetricOrigin.sub(center, ptXyz); + System.out.println("teset2 "+volumetricOrigin); + } + Point3f pixelPtToXYZ(int x, int y) { Point3f ptXyz = new Point3f(); ptXyz.scaleAdd(x, planarVectors[0], planarOrigin); @@ -2896,7 +2948,7 @@ int lastFactorial = -1; int psi_gridMax = 60; - Point3f psiOrigin = new Point3f(0, 0, 0); + Point3f psiOrigin = new Point3f(); final static double A0 = 0.52918f; //x10^-10 meters final static double ROOT2 = 1.414214; int psi_n = 2; @@ -2908,7 +2960,10 @@ void setupOrbital() { psi_radiusAngstroms = autoScaleOrbital(); - + if (center.x == Float.MAX_VALUE) + psiOrigin.set(0,0,0); + else + psiOrigin.set(center); for (int i = 0; i < 3; i++) setVoxelRange(i, -psi_radiusAngstroms, psi_radiusAngstroms, psi_ptsPerAngstrom, psi_gridMax); @@ -3057,13 +3112,10 @@ jvxlFileHeader = "solvent accesible surface\nrange " + xyzMin + " to " + xyzMax + "\n"; - int maxGrid = solvent_gridMax / (iAtom > 50 ? 2 : 1); - setVoxelRange(0, xyzMin.x, xyzMax.x, solvent_ptsPerAngstrom, - maxGrid); - setVoxelRange(1, xyzMin.y, xyzMax.y, solvent_ptsPerAngstrom, - maxGrid); - setVoxelRange(2, xyzMin.z, xyzMax.z, solvent_ptsPerAngstrom, - maxGrid); + int maxGrid = solvent_gridMax / (iAtom > 50 ? 2 : 1); + setVoxelRange(0, xyzMin.x, xyzMax.x, solvent_ptsPerAngstrom, maxGrid); + setVoxelRange(1, xyzMin.y, xyzMax.y, solvent_ptsPerAngstrom, maxGrid); + setVoxelRange(2, xyzMin.z, xyzMax.z, solvent_ptsPerAngstrom, maxGrid); jvxlFileHeader += jvxlGetVolumeHeader(); atomCount = 0; @@ -3074,7 +3126,7 @@ solvent_voxel.setValue(x, y, z, Float.MAX_VALUE); float rA, rB; Point3f ptA, ptB; - for (int i = 0; i < solvent_nAtoms && solvent_voxel.value >= -0.5; i++) { + for (int i = 0; i < solvent_nAtoms && solvent_voxel.value >= -0.5; i++) { ptA = solvent_ptAtom[i]; rA = solvent_atomRadius[i]; float v = solvent_voxel.ptXyz.distance(ptA) - rA; @@ -3199,4 +3251,44 @@ * Math.cos(angleBAS - angleVAB)); return dVS; } + + float zValue; + + void getValueZ(int x, int y) { + zValue = viewer.functionXY(x, y); + } + + float calcVoxelZDistance(int x, int y, int z) { + if (x < 2 && y < 2) + System.out.println(x + " " + y + " " + zValue + " " + (z - zValue)); + return z - zValue; + } + + void setModelIndex() { + if (currentMesh == null) + return; + currentMesh.visible = true; + int modelCount = viewer.getModelCount(); + if (modelCount < 2) + isFixed = true; + if (isFixed) { + currentMesh.modelIndex = -1; + } else { + currentMesh.modelIndex = viewer.getDisplayModelIndex(); + } + } + + void setVisibilityFlags(BitSet bs) { + /* + * set all fixed objects visible; others based on model being displayed + * + */ + for (int i = meshCount; --i >= 0;) { + Mesh mesh = meshes[i]; + mesh.visibilityFlags = + (mesh.visible && (mesh.modelIndex < 0 || bs.get(mesh.modelIndex)) ? myVisibilityFlag : 0); + } + } + + } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -39,7 +39,7 @@ // for now, just update this by hand // perhaps use ant filter later ... but mth doesn't like it :-( public final static String copyright = "(C) 2006 Jmol Development"; - public final static String version = "10.x.11(branch bob200603)"; + public final static String version = "10.x.11c(branch bob200603)"; public final static String cvsDate = "$Date$"; public final static String date = cvsDate.substring(7, 23); Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -27,7 +27,6 @@ import org.jmol.g3d.*; -import javax.vecmath.Point3i; import javax.vecmath.Point3f; import javax.vecmath.Point4f; import javax.vecmath.Vector3f; @@ -73,9 +72,10 @@ Vector3f axes[]; String meshType = null; String drawType = null; + int modelIndex = -1; // for Isosurface + int visibilityFlags; + int[] modelFlags = null; //one per POLYGON for DRAW - int[] visibilityFlags = null; - boolean showPoints = false; boolean drawTriangles = false; boolean fillTriangles = true; @@ -155,7 +155,7 @@ } void setPolygonCount(int polygonCount) { - System.out.println("Mesh setPolygonCount" + polygonCount); + //System.out.println("Mesh setPolygonCount" + polygonCount); this.polygonCount = polygonCount; if (polygonIndexes == null || polygonCount > polygonIndexes.length) polygonIndexes = new int[polygonCount][]; @@ -185,6 +185,7 @@ } void checkForDuplicatePoints(float cutoff) { + //not implemented float cutoff2 = cutoff * cutoff; for (int i = vertexCount; --i >= 0; ) for (int j = i; --j >= 0; ) { @@ -202,8 +203,8 @@ } final boolean isPolygonDisplayable(int index) { - return (visibilityFlags == null || - visibilityFlags[index] != 0); + return (modelFlags == null || + modelFlags[index] != 0); } final int setPolygon(Point3f[] ptList, int nVertices, int nPoly, Modified: branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -35,7 +35,7 @@ short backgroundColix; void render1(Mesh mesh) { - if (!mesh.visible) + if (mesh.visibilityFlags == 0) return; int vertexCount = mesh.vertexCount; if (vertexCount == 0) Modified: branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -1282,6 +1282,8 @@ boolean showHydrogens = viewer.getShowHydrogens(); int ballVisibilityFlag = viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_BALLS); int haloVisibilityFlag = viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_HALO); + + //the three isosurface-related objects must be set individually BitSet bs = viewer.getVisibleFramesBitSet(); Draw draw = (Draw) frame.shapes[JmolConstants.SHAPE_DRAW]; if (draw != null) @@ -1289,6 +1291,10 @@ Polyhedra p = (Polyhedra) frame.shapes[JmolConstants.SHAPE_POLYHEDRA]; if (p != null) p.setVisibilityFlags(bs); + Isosurface surf = (Isosurface) frame.shapes[JmolConstants.SHAPE_ISOSURFACE]; + if (surf != null) + surf.setVisibilityFlags(bs); + for (int i = frame.atomCount; --i >= 0; ) { Atom atom = atoms[i]; atom.shapeVisibilityFlags &= ( Modified: branches/bob200603/Jmol/src/org/jmol/viewer/StatusManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/StatusManager.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/StatusManager.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -304,5 +304,9 @@ return msgList; } + float functionXY(int x, int y) { + return (jmolStatusListener == null ? 0 : + jmolStatusListener.functionXY(x, y)); + } } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Token.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Token.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Token.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -181,7 +181,7 @@ final static int pmesh = command | 91; final static int polyhedra = command | 92 | embeddedExpression; final static int centerAt = command | 93; - final static int isosurface = command | 94 | negnums | showparam | colorparam; + final static int isosurface = command | 94 | negnums | showparam | colorparam | embeddedExpression; final static int draw = command | 95 | embeddedExpression; final static int getproperty = command | 96; final static int dipole = command | 97 | embeddedExpression; @@ -546,7 +546,7 @@ // setparams "ambient", new Token(ambient, "ambient"), - "axes", new Token(axes, onDefault1, "axes"), + "axes", new Token(axes, varArgCount, "axes"), "backfade", new Token(backfade, "backfade"), "bondmode", new Token(bondmode, "bondmode"), "bonds", new Token(bonds, "bonds"), Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -3212,5 +3212,8 @@ public void setAtomCoordRelative(int atomIndex, float x, float y, float z) { modelManager.setAtomCoordRelative(atomIndex,x,y,z); } - + + float functionXY(int x, int y) { + return statusManager.functionXY(x, y); + } } Modified: branches/bob200603/Jmol/src/org/openscience/jmol/app/Jmol.java =================================================================== --- branches/bob200603/Jmol/src/org/openscience/jmol/app/Jmol.java 2006-06-13 17:57:57 UTC (rev 5218) +++ branches/bob200603/Jmol/src/org/openscience/jmol/app/Jmol.java 2006-06-13 22:30:34 UTC (rev 5219) @@ -1439,6 +1439,10 @@ scriptWindow.hide(); } + public float functionXY(int x, int y) { + return 0; // for user-defined isosurface functions (testing only -- bob hanson) + } + } class ExecuteScriptAction extends AbstractAction { @@ -1450,4 +1454,5 @@ viewer.evalStringQuiet(e.getActionCommand()); } } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |