From: <ha...@us...> - 2011-12-02 18:11:49
|
Revision: 16546 http://jmol.svn.sourceforge.net/jmol/?rev=16546&view=rev Author: hansonr Date: 2011-12-02 18:11:42 +0000 (Fri, 02 Dec 2011) Log Message: ----------- version=12.3.8_dev # bug fix: set picking DRAW does not work on polygon sets # bug fix: set picking DRAW does not report position change Modified Paths: -------------- trunk/Jmol/src/org/jmol/shape/Mesh.java trunk/Jmol/src/org/jmol/shape/MeshRenderer.java trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/shapespecial/DrawRenderer.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/ShapeManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/shape/Mesh.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/Mesh.java 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/shape/Mesh.java 2011-12-02 18:11:42 UTC (rev 16546) @@ -66,7 +66,7 @@ public float scale = 1; public boolean haveXyPoints; - public boolean isPolygonSet; // just a set of flat polygons + public boolean isTriangleSet; // just a set of flat polygons public int diameter; public float width; public Point3f ptCenter = new Point3f(0,0,0); @@ -133,7 +133,7 @@ drawTriangles = false; fillTriangles = true; showTriangles = false; //as distinct entities - isPolygonSet = false; + isTriangleSet = false; frontOnly = false; title = null; normixes = null; @@ -169,7 +169,7 @@ } public Vector3f[] getNormals(Point3f[] vertices, Point4f plane) { - normixCount = (isPolygonSet ? polygonCount : vertexCount); + normixCount = (isTriangleSet ? polygonCount : vertexCount); Vector3f[] normals = new Vector3f[normixCount]; for (int i = normixCount; --i >= 0;) normals[i] = new Vector3f(); @@ -180,7 +180,7 @@ for (int i = normixCount; --i >= 0;) normals[i] = normal; } - if (!isPolygonSet) + if (!isTriangleSet) for (int i = normixCount; --i >= 0;) normals[i].normalize(); return normals; @@ -241,7 +241,7 @@ || vA.distanceSquared(vC) < 0.0001) continue; Measure.calcNormalizedNormal(vA, vB, vC, vTemp, vAB, vAC); - if (isPolygonSet) { + if (isTriangleSet) { normals[i].set(vTemp); continue; } Modified: trunk/Jmol/src/org/jmol/shape/MeshRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/MeshRenderer.java 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/shape/MeshRenderer.java 2011-12-02 18:11:42 UTC (rev 16546) @@ -195,7 +195,7 @@ } protected void renderPoints() { - if (mesh.isPolygonSet) { + if (mesh.isTriangleSet) { int[][] polygonIndexes = mesh.polygonIndexes; BitSet bsPoints = new BitSet(mesh.vertexCount); if (haveBsDisplay) { @@ -254,7 +254,7 @@ continue; } int check; - if (mesh.isPolygonSet) { + if (mesh.isTriangleSet) { short normix = normixes[i]; if (!g3d.isDirectedTowardsCamera(normix)) continue; Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2011-12-02 18:11:42 UTC (rev 16546) @@ -552,7 +552,7 @@ if (polygon != null) { if (polygon.size() == 0) return false; - thisMesh.isPolygonSet = true; + thisMesh.isTriangleSet = true; thisMesh.vertices = (Point3f[]) polygon.get(0); thisMesh.polygonIndexes = (int[][]) polygon.get(1); thisMesh.drawVertexCount = thisMesh.vertexCount = thisMesh.vertices.length; @@ -1210,7 +1210,8 @@ y <<= 1; } Point3f pt = new Point3f(); - Point3f coord = new Point3f(mesh.vertices[vertexes[iVertex]]); + int ptVertex = vertexes[iVertex]; + Point3f coord = new Point3f(mesh.vertices[ptVertex]); Point3f newcoord = new Point3f(); Vector3f move = new Vector3f(); viewer.transformPoint(coord, pt); @@ -1219,21 +1220,21 @@ viewer.unTransformPoint(pt, newcoord); move.set(newcoord); move.sub(coord); - int klast = -1; - for (int i = (moveAll ? 0 : iVertex); i < vertexes.length; i++) + if (mesh.isTriangleSet) + iVertex = ptVertex; // operate on entire set of vertices, not just the + // one for this model + int n = (!moveAll ? iVertex + 1 + : mesh.isTriangleSet ? mesh.vertices.length : vertexes.length); + BitSet bsMoved = new BitSet(); + for (int i = (moveAll ? 0 : iVertex); i < n; i++) if (moveAll || i == iVertex) { - int k = vertexes[i]; - if (k == klast) - break; + int k = (mesh.isTriangleSet ? i : vertexes[i]); + if (bsMoved.get(k)) + continue; + bsMoved.set(k); mesh.vertices[k].add(move); - if (!moveAll) - break; - klast = k; } mesh.setCenters(); - if (Logger.debugging) - Logger.debug(getDrawCommand(mesh)); - viewer.refresh(3, "draw"); } /** @@ -1256,16 +1257,17 @@ pickedMesh = null; for (int i = 0; i < meshCount; i++) { DrawMesh m = dmeshes[i]; - if (m.drawType == EnumDrawType.POLYGON) - continue; if (m.visibilityFlags != 0) { - int mCount = (m.modelFlags == null ? 1 : viewer.getModelCount()); + int mCount = (m.isTriangleSet ? m.polygonCount + : m.modelFlags == null ? 1 + : viewer.getModelCount()); for (int iModel = mCount; --iModel >= 0;) { if (m.modelFlags != null && !m.modelFlags.get(iModel) || m.polygonIndexes == null - || iModel >= m.polygonIndexes.length || m.polygonIndexes[iModel] == null) + || !m.isTriangleSet && (iModel >= m.polygonIndexes.length || m.polygonIndexes[iModel] == null) + ) continue; - for (int iVertex = m.polygonIndexes[iModel].length; --iVertex >= 0;) { + for (int iVertex = (m.isTriangleSet ? 3 : m.polygonIndexes[iModel].length); --iVertex >= 0;) { try{ int d2 = coordinateInRange(x, y, m.vertices[m.polygonIndexes[iModel][iVertex]], dmin2, ptXY); Modified: trunk/Jmol/src/org/jmol/shapespecial/DrawRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/DrawRenderer.java 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/shapespecial/DrawRenderer.java 2011-12-02 18:11:42 UTC (rev 16546) @@ -23,6 +23,7 @@ */ package org.jmol.shapespecial; +import java.util.BitSet; import java.util.List; import javax.vecmath.AxisAngle4f; @@ -421,6 +422,8 @@ g3d.fillCylinderScreen(Graphics3D.ENDCAPS_OPENEND, diameter, pt0i, pt1i); } + private final BitSet bsHandles = new BitSet(); + private void renderHandles() { int diameter = (int) (10 * imageFontScaling); switch (drawType) { @@ -429,19 +432,23 @@ default: short colixFill = Graphics3D.getColixTranslucent(Graphics3D.GOLD, true, 0.5f); + bsHandles.clear(); for (int i = dmesh.polygonCount; --i >= 0;) { if (!isPolygonDisplayable(i)) continue; int[] vertexIndexes = dmesh.polygonIndexes[i]; if (vertexIndexes == null) continue; - for (int j = vertexIndexes.length; --j >= 0;) { + for (int j = (dmesh.isTriangleSet ? 3 : vertexIndexes.length); --j >= 0;) { int k = vertexIndexes[j]; + if (bsHandles.get(k)) + continue; + bsHandles.set(k); g3d.drawFilledCircle(Graphics3D.GOLD, colixFill, diameter, screens[k].x, screens[k].y, screens[k].z); } - break; } + break; } } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2011-12-02 18:11:42 UTC (rev 16546) @@ -3,6 +3,8 @@ version=12.3.8_dev +# bug fix: set picking DRAW does not work on polygon sets +# bug fix: set picking DRAW does not report position change # bug fix: MPJmolApp (Molecular Playground) problems when navigation is on # bug fix: CifReader (molecular type, with GEOM_BOND records) adds # extra atoms when embedded in JMOL or PNGJ file or part load FILES command Modified: trunk/Jmol/src/org/jmol/viewer/ShapeManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2011-12-02 18:11:42 UTC (rev 16546) @@ -235,10 +235,11 @@ int modifiers, BitSet bsVisible, int iShape) { for (int i = iShape; i < JmolConstants.SHAPE_MAX; ++i) { Shape shape = shapes[i]; - if (shape != null - && shape.checkObjectDragged(prevX, prevY, x, y, modifiers, bsVisible) - || iShape > 0) - return true; + if (shape == null) + continue; + boolean found = shape.checkObjectDragged(prevX, prevY, x, y, modifiers, bsVisible); + if (found || iShape > 0) + return found; } return false; } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2011-12-02 18:11:03 UTC (rev 16545) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2011-12-02 18:11:42 UTC (rev 16546) @@ -7812,9 +7812,12 @@ break; } if (shapeManager.checkObjectDragged(prevX, prevY, x, y, action, - getVisibleFramesBitSet(), iShape)) - refresh(1, "checkObjectDragged"); - + getVisibleFramesBitSet(), iShape)) { + refresh(1, "checkObjectDragged"); + if (iShape == JmolConstants.SHAPE_DRAW) + scriptEcho((String) getShapeProperty(JmolConstants.SHAPE_DRAW, + "command")); + } // TODO: refresh 1 or 2? } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |