From: <ha...@us...> - 2006-05-15 02:53:28
|
Revision: 5119 Author: hansonr Date: 2006-05-14 19:53:23 -0700 (Sun, 14 May 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=5119&view=rev Log Message: ----------- bob200603 integrating visibility flags into polyhedra code Modified Paths: -------------- branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java branches/bob200603/Jmol/src/org/jmol/viewer/Polyhedra.java branches/bob200603/Jmol/src/org/jmol/viewer/PolyhedraRenderer.java Modified: branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-05-14 20:40:14 UTC (rev 5118) +++ branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-05-15 02:53:23 UTC (rev 5119) @@ -1282,6 +1282,9 @@ Draw draw = (Draw) frame.shapes[JmolConstants.SHAPE_DRAW]; if (draw != null) draw.setVisibilityFlags(bs); + Polyhedra p = (Polyhedra) frame.shapes[JmolConstants.SHAPE_POLYHEDRA]; + if (p != null) + p.setVisibilityFlags(bs); for (int i = frame.atomCount; --i >= 0; ) { Atom atom = atoms[i]; atom.shapeVisibilityFlags &= ( Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Polyhedra.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Polyhedra.java 2006-05-14 20:40:14 UTC (rev 5118) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Polyhedra.java 2006-05-15 02:53:23 UTC (rev 5119) @@ -279,6 +279,20 @@ short[] normixesT = new short[FACE_COUNT_MAX]; byte[] planesT = new byte[256]; + + void setVisibilityFlags(BitSet bs) { + /* + * set all fixed objects visible; others based on model being displayed note + * that this is NOT done with atoms and bonds, because they have mads. When + * you say "frame 0" it is just turning on all the mads. + */ + for (int i = polyhedronCount; --i >= 0;) { + Polyhedron p = polyhedrons[i]; + p.visibilityFlags = (p.visible && bs.get(p.centralAtom.modelIndex) ? myVisibilityFlag : 0); + } + } + + Polyhedron validatePolyhedronNew(Atom centralAtom, int vertexCount, Atom[] otherAtoms) { Vector3f normal = new Vector3f(); @@ -362,6 +376,7 @@ short polyhedronColix; byte[] planes; int planeCount; + int visibilityFlags = 0; Polyhedron(Atom centralAtom, int nPoints, int planeCount, Atom[] otherAtoms, short[] normixes, byte[] planes) { @@ -380,4 +395,5 @@ this.planes[i] = planes[i]; } } + } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/PolyhedraRenderer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/PolyhedraRenderer.java 2006-05-14 20:40:14 UTC (rev 5118) +++ branches/bob200603/Jmol/src/org/jmol/viewer/PolyhedraRenderer.java 2006-05-15 02:53:23 UTC (rev 5119) @@ -29,6 +29,12 @@ int drawEdges; + int myVisibilityFlag; + + void initRenderer() { + myVisibilityFlag = viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_POLYHEDRA); + } + void render() { Polyhedra polyhedra = (Polyhedra) shape; Polyhedra.Polyhedron[] polyhedrons = polyhedra.polyhedrons; @@ -38,8 +44,13 @@ } void render1(Polyhedra.Polyhedron p) { - if (! p.visible) + if ((p.visibilityFlags & myVisibilityFlag) == 0) return; + /*System.out.println("\npolynomialrenderer" + p.planeCount+" "+p.centralAtom.getIdentity()); + for (int i = 0; i < p.vertices.length; i++) { + System.out.println("atom "+p.vertices[i].getIdentity()); + } + */ short colix = Graphics3D.inheritColix(p.polyhedronColix, p.centralAtom.colixAtom); Atom[] vertices = p.vertices; @@ -50,12 +61,15 @@ if (vertices[i].isSimple) vertices[i].transform(viewer); } - + + boolean isAll = (drawEdges == Polyhedra.EDGES_ALL); + boolean isFrontOnly = (drawEdges == Polyhedra.EDGES_FRONT); + for (int i = 0, j = 0; j < planes.length; ) { drawFace(colix, p.normixes[i++], vertices[planes[j++]], vertices[planes[j++]], - vertices[planes[j++]]); + vertices[planes[j++]], isAll, isFrontOnly); } for (int i = 0, j = 0; j < planes.length; ) @@ -66,10 +80,8 @@ } void drawFace(short colix, short normix, - Atom atomA, Atom atomB, Atom atomC) { - if (drawEdges == Polyhedra.EDGES_ALL || - (drawEdges == Polyhedra.EDGES_FRONT && - g3d.isDirectedTowardsCamera(normix))) { + Atom atomA, Atom atomB, Atom atomC, boolean isAll, boolean isFrontOnly) { + if (isAll || isFrontOnly && g3d.isDirectedTowardsCamera(normix)) { g3d.drawCylinderTriangle(Graphics3D.getOpaqueColix(colix), atomA.screenX, atomA.screenY, atomA.screenZ, atomB.screenX, atomB.screenY, atomB.screenZ, @@ -80,6 +92,11 @@ void fillFace(short colix, short normix, Atom atomA, Atom atomB, Atom atomC) { + /* + * System.out.println("fillFace "+atomA.screenX+" "+ atomA.screenY+" "+ atomA.screenZ+" "+ + atomB.screenX+" "+ atomB.screenY+" "+ atomB.screenZ+" "+ + atomC.screenX+" "+ atomC.screenY+" "+ atomC.screenZ); + */ g3d.fillTriangle(colix, normix, atomA.screenX, atomA.screenY, atomA.screenZ, atomB.screenX, atomB.screenY, atomB.screenZ, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |