From: <ha...@us...> - 2006-06-15 02:25:38
|
Revision: 5226 Author: hansonr Date: 2006-06-14 19:25:22 -0700 (Wed, 14 Jun 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=5226&view=rev Log Message: ----------- bob200603 full support now for multiple models/files with all mesh-related objects, including pmesh, isosurface, draw, and polyhedra. Visibility and FIXED issues resolved. Modified Paths: -------------- branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java branches/bob200603/Jmol/src/org/jmol/viewer/DrawRenderer.java branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java branches/bob200603/Jmol/src/org/jmol/viewer/Frame.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/MeshCollection.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/Pmesh.java branches/bob200603/Jmol/src/org/jmol/viewer/PmeshRenderer.java branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Draw.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -30,39 +30,47 @@ class Draw extends MeshCollection { + // bob hanson ha...@st... 3/2006 + final static int MAX_POINTS = 256; // a few extras here Point3f[] ptList = new Point3f[MAX_POINTS]; int[] ptIdentifiers = new int[MAX_POINTS]; boolean[] reversePoints = new boolean[MAX_POINTS]; boolean[] useVertices = new boolean[MAX_POINTS]; BitSet[] ptBitSets = new BitSet[MAX_POINTS]; + BitSet bsAllAtoms = new BitSet(); + Point3f xyz = new Point3f(); int ipt; - int nPoints = -1; - int nbitsets = 0; - int ncoord = 0; - int nidentifiers = 0; + int nPoints; + int nbitsets; + int ncoord; + int nidentifiers; float newScale; - float length = Float.MAX_VALUE; - boolean isFixed = false; - boolean isVisible = true; - boolean isPerpendicular = false; - boolean isVertices = false; - boolean isPlane = false; - boolean isReversed = false; - boolean isRotated45 = false; - boolean isCrossed = false; + float length; + boolean isFixed; + boolean isVisible; + boolean isPerpendicular; + boolean isVertices; + boolean isPlane; + boolean isReversed; + boolean isRotated45; + boolean isCrossed; + boolean isValid; + void setProperty(String propertyName, Object value, BitSet bs) { // System.out.println("draw "+propertyName+" "+value); - if ("meshID" == propertyName) { + if ("init" == propertyName) { nPoints = -1; + ipt = ncoord = nbitsets = nidentifiers = 0; isFixed = isReversed = isRotated45 = isCrossed = false; isPlane = isVertices = isPerpendicular = false; - isVisible = true; + isVisible = isValid = true; length = Float.MAX_VALUE; - //let pass through + super.setProperty("meshID", null, null); + return; } if ("length" == propertyName) { @@ -106,7 +114,7 @@ } if ("points" == propertyName) { - ipt = nPoints = ncoord = nbitsets = nidentifiers = 0; + nPoints = 0; newScale = ((Integer) value).floatValue() / 100; if (newScale == 0) newScale = 1; @@ -137,6 +145,7 @@ isReversed = isVertices = false; } else { System.out.println("draw identifier " + value + " not found"); + isValid = false; } return; } @@ -150,13 +159,13 @@ if (viewer.cardinalityOf((BitSet) value) == 0) return; ptBitSets[nbitsets++] = (BitSet) value; + bsAllAtoms.or((BitSet) value); nPoints++; - // System.out.println(nPoints + " " + ptBitSets[nbitsets-1]); return; } if ("set" == propertyName) { - isValid = setDrawing(); - if (isValid) { + currentMesh.isValid = (isValid ? setDrawing() : false); + if (currentMesh.isValid) { currentMesh.scaleDrawing(newScale); currentMesh.initialize(); currentMesh.setAxes(); @@ -182,89 +191,100 @@ return false; int nPoly = 0; int modelCount = viewer.getModelCount(); - if (nbitsets == 0 && nidentifiers == 0 || modelCount < 2) - isFixed = true; if (isFixed) { + // make just ONE copy currentMesh.setPolygonCount(1); currentMesh.ptCenters = null; currentMesh.modelFlags = null; - nPoly = setVerticesAndPolygons(-1, nPoly); + addFixedPoints(); + nPoly = setPolygons(nPoly); } else { + // multiple copies, one for each model involved + BitSet bsAllModels = new BitSet(); + if (nbitsets > 0) + bsAllModels = viewer.getModelBitSet(bsAllAtoms); + else + bsAllModels = viewer.getVisibleFramesBitSet(); currentMesh.setPolygonCount(modelCount); currentMesh.ptCenters = new Point3f[modelCount]; currentMesh.modelFlags = new int[modelCount]; for (int iModel = 0; iModel < modelCount; iModel++) { - // int n0 = currentMesh.vertexCount; - nPoly = setVerticesAndPolygons(iModel, nPoly); - currentMesh.setCenter(iModel); + if (bsAllModels.get(iModel)) { + // int n0 = currentMesh.vertexCount; + addModelPoints(iModel); + nPoly = setPolygons(nPoly); + currentMesh.setCenter(iModel); + } } } currentMesh.setCenter(-1); return true; } - private int setVerticesAndPolygons(int iModel, int nPoly) { + private void addFixedPoints() { nPoints = ncoord; - // [x,y,z] points are already defined in ptList - if (iModel < 0) { - // add in [drawID] references as overall centers - for (int i = 0; i < nidentifiers; i++) { - Mesh m = meshes[ptIdentifiers[i]]; - if (isPlane || isPerpendicular || useVertices[i]) { - if (reversePoints[i]) { - for (ipt = m.drawVertexCount; --ipt >= 0;) - 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); - addPoint(m.vertices[ipt]); - - } - } + // {x,y,z} points are already defined in ptList + // add in $drawID references as overall centers or individual points + // under certain circumstances + for (int i = 0; i < nidentifiers; i++) { + Mesh m = meshes[ptIdentifiers[i]]; + if (isPlane || isPerpendicular || useVertices[i]) { + if (reversePoints[i]) { + for (ipt = m.drawVertexCount; --ipt >= 0;) + addPoint(m.vertices[ipt]); } else { - addPoint(m.ptCenter); + for (ipt = 0; ipt < m.drawVertexCount; ipt++) + addPoint(m.vertices[ipt]); } + } else { + addPoint(m.ptCenter); } - // add in (atom set) references as overall centers - for (int i = 0; i < nbitsets; i++) - addPoint(viewer.getAtomSetCenter(ptBitSets[i])); - } else { - // [drawID] references may be fixed or not - for (int i = 0; i < nidentifiers; i++) { - if (meshes[ptIdentifiers[i]].ptCenters == null - || meshes[ptIdentifiers[i]].ptCenters[iModel] == null) { - addPoint(meshes[ptIdentifiers[i]].ptCenter); - } else { - addPoint(meshes[ptIdentifiers[i]].ptCenters[iModel]); - } + } + // add in (atom set) references as overall average centers + for (int i = 0; i < nbitsets; i++) + addPoint(viewer.getAtomSetCenter(ptBitSets[i])); + } + + void addPoint(Point3f newPt) { + ptList[nPoints++] = new Point3f(newPt); + if (nPoints > MAX_POINTS) + nPoints = MAX_POINTS; + } + + private void addModelPoints(int iModel) { + nPoints = ncoord; + // {x,y,z} points are already defined in ptList + // $drawID references may be fixed or not + for (int i = 0; i < nidentifiers; i++) { + if (meshes[ptIdentifiers[i]].ptCenters == null + || meshes[ptIdentifiers[i]].ptCenters[iModel] == null) { + addPoint(meshes[ptIdentifiers[i]].ptCenter); + } else { + addPoint(meshes[ptIdentifiers[i]].ptCenters[iModel]); } - // (atom set) references must be filtered for relevant model - // note that if a model doesn't have a relevant point, one may - // get a line instead of a plane, a point instead of a line, etc. - BitSet bsModel = viewer.getModelAtomBitSet(iModel); - for (int i = 0; i < nbitsets; i++) { - BitSet bs = (BitSet) ptBitSets[i].clone(); - bs.and(bsModel); - if (viewer.cardinalityOf(bs) > 0) { - addPoint(viewer.getAtomSetCenter(bs)); - } + } + // (atom set) references must be filtered for relevant model + // note that if a model doesn't have a relevant point, one may + // get a line instead of a plane, a point instead of a line, etc. + BitSet bsModel = viewer.getModelAtomBitSet(iModel); + for (int i = 0; i < nbitsets; i++) { + BitSet bs = (BitSet) ptBitSets[i].clone(); + bs.and(bsModel); + if (viewer.cardinalityOf(bs) > 0) { + addPoint(viewer.getAtomSetCenter(bs)); } } + } + + private int setPolygons(int nPoly) { if (nPoints ==4 && isCrossed) { Point3f pt = new Point3f(ptList[1]); ptList[1].set(ptList[2]); ptList[2].set(pt); } - return currentMesh.setPolygon(ptList, nPoints, nPoly, isPlane, isPerpendicular, isRotated45, length); } - - void addPoint(Point3f newPt) { - ptList[nPoints++] = new Point3f(newPt); - if (nPoints > MAX_POINTS) - nPoints = MAX_POINTS; - } void setVisibilityFlags(BitSet bs) { /* @@ -274,11 +294,13 @@ */ int modelCount = viewer.getModelCount(); for (int i = meshCount; --i >= 0;) { - meshes[i].visibilityFlags = myVisibilityFlag; - if (meshes[i].modelFlags == null) + Mesh m = meshes[i]; + m.visibilityFlags = (m.isValid ? myVisibilityFlag : 0); + if (m.modelFlags == null) continue; - for (int iModel = modelCount; --iModel >= 0;) - meshes[i].modelFlags[iModel] = (bs.get(iModel) ? 1 : 0); + for (int iModel = modelCount; --iModel >= 0;) { + m.modelFlags[iModel] = (bs.get(iModel) ? 1 : 0); + } } } @@ -289,19 +311,19 @@ int dmin2 = MAX_OBJECT_CLICK_DISTANCE_SQUARED; int nearestModel = 0; int nearestVertex = 0; - Mesh mesh = null; Mesh pickedMesh = null; for (int i = meshCount; --i >= 0;) { - mesh = meshes[i]; - if (mesh.drawVertexCount == 2) { - for (int iModel = modelCount; --iModel >= 0;) { - if (mesh.modelFlags != null && mesh.modelFlags[iModel] == 0) + Mesh m = meshes[i]; + if (m.drawVertexCount == 2 && m.visibilityFlags != 0) { + int mCount = (m.modelFlags == null ? 1 : modelCount); + for (int iModel = mCount; --iModel >= 0;) { + if (m.modelFlags != null && m.modelFlags[iModel] == 0) continue; - for (int iVertex = mesh.polygonIndexes[iModel].length; --iVertex >= 0;) { + for (int iVertex = m.polygonIndexes[iModel].length; --iVertex >= 0;) { int d2 = coordinateInRange(x, y, - mesh.vertices[mesh.polygonIndexes[iModel][iVertex]], dmin2); + m.vertices[m.polygonIndexes[iModel][iVertex]], dmin2); if (d2 >= 0) { - pickedMesh = mesh; + pickedMesh = m; dmin2 = d2; nearestModel = iModel; nearestVertex = iVertex; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/DrawRenderer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/DrawRenderer.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/DrawRenderer.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -33,10 +33,7 @@ * */ Draw draw = (Draw) shape; - if (!draw.isValid) - return; - for (int i = draw.meshCount; --i >= 0;) { + for (int i = draw.meshCount; --i >= 0;) render1(draw.meshes[i]); - } } } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Eval.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -1907,6 +1907,7 @@ } void refresh() { + viewer.setTainted(true); viewer.requestRepaintAndWait(); } @@ -2246,7 +2247,7 @@ default: numberExpected(); } - viewer.requestRepaintAndWait(); + refresh(); millis -= System.currentTimeMillis() - timeBegin; if (millis > 0) { viewer.popHoldRepaint(); @@ -3734,15 +3735,26 @@ void pmesh() throws ScriptException { viewer.loadShape(JmolConstants.SHAPE_PMESH); - viewer.setShapeProperty(JmolConstants.SHAPE_PMESH, "meshID", null); + viewer.setShapeProperty(JmolConstants.SHAPE_PMESH, "init", null); Object t; for (int i = 1; i < statementLength; ++i) { String propertyName = null; Object propertyValue = null; switch (statement[i].tok) { case Token.identifier: + propertyValue = statement[i].value; + String str = ((String) propertyValue); + if (str.equalsIgnoreCase("FIXED")) { + propertyName = "fixed"; + propertyValue = Boolean.TRUE; + break; + } + if (str.equalsIgnoreCase("MODELBASED")) { + propertyName = "fixed"; + propertyValue = Boolean.FALSE; + break; + } propertyName = "meshID"; - propertyValue = statement[i].value; break; case Token.string: String filename = (String) statement[i].value; @@ -3760,7 +3772,8 @@ data = viewer.simpleReplace(data, "}", " "); data = viewer.simpleReplace(data, "|", "\n"); data = viewer.simpleReplace(data, "\n\n", "\n"); - System.out.println("pmesh inline data:\n" + data); + if (logMessages) + System.out.println("pmesh inline data:\n" + data); t = viewer.getBufferedReaderForString(data); } else { stringOrIdentifierExpected(); @@ -3805,12 +3818,11 @@ void draw() throws ScriptException { viewer.loadShape(JmolConstants.SHAPE_DRAW); - viewer.setShapeProperty(JmolConstants.SHAPE_DRAW, "meshID", null); + viewer.setShapeProperty(JmolConstants.SHAPE_DRAW, "init", null); boolean havePoints = false; boolean isInitialized = false; int intScale = 0; - boolean isFixed = false; for (int i = 1; i < statementLength; ++i) { //System.out.println(statement[i]); String propertyName = null; @@ -3821,27 +3833,34 @@ case Token.identifier: propertyName = "meshID"; propertyValue = token.value; - if (((String) propertyValue).equalsIgnoreCase("FIXED")) { - isFixed = true; - continue; + String str = (String) token.value; + if (str.equalsIgnoreCase("FIXED")) { + propertyName = "fixed"; + propertyValue = Boolean.TRUE; + break; } - if (((String) propertyValue).equalsIgnoreCase("PLANE")) { + if (str.equalsIgnoreCase("MODELBASED")) { + propertyName = "fixed"; + propertyValue = Boolean.FALSE; + break; + } + if (str.equalsIgnoreCase("PLANE")) { propertyName = "plane"; } - if (((String) propertyValue).equalsIgnoreCase("CROSSED")) { + if (str.equalsIgnoreCase("CROSSED")) { propertyName = "crossed"; } - if (((String) propertyValue).equalsIgnoreCase("VERTICES")) { + if (str.equalsIgnoreCase("VERTICES")) { propertyName = "vertices"; } - if (((String) propertyValue).equalsIgnoreCase("REVERSE")) { + if (str.equalsIgnoreCase("REVERSE")) { propertyName = "reverse"; } - if (((String) propertyValue).equalsIgnoreCase("ROTATE45")) { + if (str.equalsIgnoreCase("ROTATE45")) { propertyName = "rotate45"; } - if (((String) propertyValue).equalsIgnoreCase("PERP") - || ((String) propertyValue).equalsIgnoreCase("PERPENDICULAR")) { + if (str.equalsIgnoreCase("PERP") + || str.equalsIgnoreCase("PERPENDICULAR")) { propertyName = "perp"; } break; @@ -3903,9 +3922,6 @@ if (havePoints && !isInitialized) { viewer.setShapeProperty(JmolConstants.SHAPE_DRAW, "points", new Integer(intScale)); - if (isFixed || viewer.getModelCount() == 1) - viewer.setShapeProperty(JmolConstants.SHAPE_DRAW, "fixed", - Boolean.TRUE); isInitialized = true; } if (propertyName != null) @@ -4122,6 +4138,12 @@ i = pcLastExpressionInstruction; break; } + if (str.equalsIgnoreCase("EXCENTRICITY")) { + propertyName = "anisotropy"; + propertyValue = getCoordinate(i + 1, false); + i = pcLastExpressionInstruction; + break; + } if (str.equalsIgnoreCase("FIXED")) { propertyName = "fixed"; propertyValue = Boolean.TRUE; @@ -4132,7 +4154,6 @@ propertyValue = Boolean.FALSE; break; } - if (str.equalsIgnoreCase("sign")) { signPt = i + 1; propertyName = "sign"; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Frame.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -2077,6 +2077,14 @@ return bs; } + BitSet getModelBitSet(BitSet atomList) { + BitSet bs = new BitSet(); + for (int i = 0; i < atomCount; i++) + if (atomList.get(i)) + bs.set(atoms[i].modelIndex); + return bs; + } + void setLabel(String label, int atomIndex) { } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/JmolConstants.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -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.13(branch bob200603)"; + public final static String version = "10.x.13b(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-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -34,7 +34,7 @@ class Mesh { Viewer viewer; String meshID; - + boolean isValid = true; String jvxlFileHeader; String jvxlDefinitionLine; String jvxlSurfaceData; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -35,8 +35,7 @@ int meshCount; Mesh[] meshes = new Mesh[4]; Mesh currentMesh; - boolean isValid = false; - + void initShape() { colix = Graphics3D.ORANGE; } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/MeshRenderer.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -35,7 +35,7 @@ short backgroundColix; void render1(Mesh mesh) { - if (mesh.visibilityFlags == 0) + if (mesh.visibilityFlags == 0 || !mesh.isValid) 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-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/ModelManager.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -528,6 +528,10 @@ return (frame == null) ? null : frame.getModelAtomBitSet(modelIndex); } + BitSet getModelBitSet(BitSet atomList) { + return (frame == null) ? null : frame.getModelBitSet(atomList); + } + BitSet getMoleculeBitSet(int modelIndex) { return (frame == null) ? null : frame.getMoleculeBitSet(modelIndex); } @@ -1283,17 +1287,20 @@ int ballVisibilityFlag = viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_BALLS); int haloVisibilityFlag = viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_HALO); - //the three isosurface-related objects must be set individually + //the four mesh-related objects must be set individually BitSet bs = viewer.getVisibleFramesBitSet(); 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); + Polyhedra poly = (Polyhedra) frame.shapes[JmolConstants.SHAPE_POLYHEDRA]; + if (poly != null) + poly.setVisibilityFlags(bs); Isosurface surf = (Isosurface) frame.shapes[JmolConstants.SHAPE_ISOSURFACE]; if (surf != null) surf.setVisibilityFlags(bs); + Pmesh pmesh = (Pmesh) frame.shapes[JmolConstants.SHAPE_PMESH]; + if (pmesh != null) + pmesh.setVisibilityFlags(bs); for (int i = frame.atomCount; --i >= 0; ) { Atom atom = atoms[i]; Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Pmesh.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Pmesh.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Pmesh.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -30,25 +30,44 @@ class Pmesh extends MeshCollection { - boolean isOnePerLine = false; + boolean isOnePerLine; + boolean isFixed; + void setProperty(String propertyName, Object value, BitSet bs) { - isOnePerLine = false; + //System.out.println(propertyName + " "+ value); + + if ("init" == propertyName) { + isFixed = false; + isOnePerLine = false; + super.setProperty("meshID", null, null); + return; + } + + if ("fixed" == propertyName) { + isFixed = ((Boolean) value).booleanValue(); + setModelIndex(); + return; + } + if ("bufferedReaderOnePerLine" == propertyName) { propertyName = "bufferedReader"; isOnePerLine = true; } + if ("bufferedReader" == propertyName) { BufferedReader br = (BufferedReader)value; if (currentMesh == null) allocMesh(null); currentMesh.clear("pmesh"); - isValid = readPmesh(br); - if(isValid) { + currentMesh.isValid = readPmesh(br); + if(currentMesh.isValid) { currentMesh.initialize(); currentMesh.visible = true; } + setModelIndex(); } + super.setProperty(propertyName, value, bs); } @@ -120,7 +139,7 @@ int vertexIndexCount = parseInt(br.readLine()); if (vertexIndexCount < 2) { viewer.scriptStatus("pmesh ERROR: each polygon must have at least two verticies indicated"); - isValid = false; + currentMesh.isValid = false; return null; } int vertexCount = vertexIndexCount - 1; @@ -134,9 +153,37 @@ if (extraVertex != vertices[0]) { // System.out.println("?Que? polygon is not complete"); viewer.scriptStatus("pmesh Error: last polygon point reference (" + extraVertex + ") is not the same as the first (" + vertices[0] + ")"); - isValid = false; + currentMesh.isValid = false; throw new NullPointerException(); } return vertices; } + + 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/PmeshRenderer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/PmeshRenderer.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/PmeshRenderer.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -26,11 +26,8 @@ class PmeshRenderer extends MeshRenderer { void render() { - Pmesh pmesh = (Pmesh)shape; - if (!pmesh.isValid) - return; - for (int i = pmesh.meshCount; --i >= 0; ) { + Pmesh pmesh = (Pmesh) shape; + for (int i = pmesh.meshCount; --i >= 0;) render1(pmesh.meshes[i]); - } } } Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-06-14 21:50:13 UTC (rev 5225) +++ branches/bob200603/Jmol/src/org/jmol/viewer/Viewer.java 2006-06-15 02:25:22 UTC (rev 5226) @@ -1227,6 +1227,10 @@ BitSet getModelAtomBitSet(int modelIndex) { return modelManager.getModelAtomBitSet(modelIndex); } + + BitSet getModelBitSet(BitSet atomList) { + return modelManager.getModelBitSet(atomList); + } Object getClientFile() { // DEPRECATED - use getExportJmolAdapter() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |