Revision: 18316 http://sourceforge.net/p/jmol/code/18316 Author: hansonr Date: 2013-06-08 20:27:11 +0000 (Sat, 08 Jun 2013) Log Message: ----------- ___JmolVersion="13.1.17_dev_2013.06.07"
TODO: PyMOL uniqueAtomSettings for transparency -- will require by-vertex translucent option bug fix: PyMOL volume map data saved from PyMOL 1.6 has slightly different data structure Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java trunk/Jmol/src/org/jmol/adapter/readers/pymol/JmolObject.java trunk/Jmol/src/org/jmol/adapter/readers/pymol/PickleReader.java trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOL.java trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java trunk/Jmol/src/org/jmol/jvxl/readers/PyMOLMeshReader.java trunk/Jmol/src/org/jmol/shapebio/BioShape.java trunk/Jmol/src/org/jmol/shapebio/BioShapeCollection.java trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java trunk/Jmol/src/org/jmol/util/C.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -1795,9 +1795,6 @@ + L[0][1] * xz - S[1][1] * x + S[2][2] * x + S[0][1] * y - S[0][2] * z; anisou[6] = 12; // macromolecular Cartesian anisou[7] = bresidual; - if (Float.isNaN(bresidual)) - System.out.println("hmm"); - if (tlsU == null) tlsU = new Hashtable<Atom, float[]>(); tlsU.put(atom, anisou); Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/JmolObject.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pymol/JmolObject.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/JmolObject.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -230,6 +230,7 @@ case JC.SHAPE_CARTOON: case JC.SHAPE_BACKBONE: case JC.SHAPE_TRACE: + case JC.SHAPE_ISOSURFACE: if (info instanceof Object[]) { sm.loadShape(id); sm.setShapePropertyBs(id, "params", info, bsAtoms); Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PickleReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PickleReader.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PickleReader.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -369,7 +369,7 @@ if (doCheck && markCount >= 6 || markCount == 3 && inMovie) return; memo.put(Integer.valueOf(i), o); - System.out.println("caching string " + o + " at " + binaryDoc.getPosition()); + //System.out.println("caching string " + o + " at " + binaryDoc.getPosition()); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOL.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOL.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOL.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -6263,6 +6263,8 @@ Logger.info("PyMOL " + pymolVersion + " does not have setting " + i); //$FALL-THROUGH$ case ellipsoid_transparency: + case ribbon_transparency: + case nonbonded_transparency: return 0; } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -44,16 +44,16 @@ // ellipsoid_scale // label_color // label_position +// mesh_color // nonbonded_transparency // ribbon_color // sphere_color // sphere_scale // sphere_transparency +// surface_color // //TODO: // -// mesh_color -// surface_color // transparency (surface) // //special (probably) PyMOL-only: @@ -900,7 +900,7 @@ float getUniqueFloatDef(int id, int key, float defaultValue) { JmolList<Object> setting; - if (id < 0 + if (id <= 0 || (setting = uniqueSettings.get(Integer.valueOf((id << 10) + key))) == null) return defaultValue; float v = ((Number) setting.get(2)).floatValue(); @@ -912,7 +912,7 @@ @SuppressWarnings("unchecked") P3 getUniquePoint(int id, int key, P3 pt) { JmolList<Object> setting; - if (id < 0 + if (id <= 0 || (setting = uniqueSettings.get(Integer.valueOf((id << 10) + key))) == null) return pt; pt = new P3(); @@ -1397,6 +1397,25 @@ case PyMOL.REP_DOTS: setUniqueObjects(JC.SHAPE_DOTS, bs, PyMOL.dot_color, dotColor, 0, 0, PyMOL.sphere_scale, sphereScale, 1); break; + case PyMOL.REP_SURFACE: // = 2; + // unique translucency here involves creating ghost surfaces + float withinDistance = floatSetting(PyMOL.surface_carve_cutoff); + jo = addJmolObject(T.isosurface, bs, new Object[] { + booleanSetting(PyMOL.two_sided_lighting) ? "FULLYLIT" : "FRONTLIT", + (surfaceMode == 3 || surfaceMode == 4) ? " only" : "", + bsCarve, Float.valueOf(withinDistance)}); + jo.setSize(floatSetting(PyMOL.solvent_radius) * (solventAccessible ? -1 : 1)); + jo.translucency = transparency; + if (surfaceColor >= 0) + jo.argb = PyMOL.getRGB(surfaceColor); + setUniqueObjects(JC.SHAPE_ISOSURFACE, bs, PyMOL.surface_color, surfaceColor, PyMOL.transparency, transparency, 0, 0, 0); + break; + case PyMOL.REP_MESH: // = 8; + jo = addJmolObject(T.isosurface, bs, null); + jo.setSize(floatSetting(PyMOL.solvent_radius)); + jo.translucency = transparency; + setUniqueObjects(JC.SHAPE_ISOSURFACE, bs, PyMOL.surface_color, surfaceColor, PyMOL.transparency, transparency, 0, 0, 0); + break; case PyMOL.REP_LABELS: // = 3; bs.and(bsLabeled); if (bs.isEmpty()) @@ -1434,55 +1453,37 @@ case PyMOL.REP_RIBBON: // backbone or trace, depending createRibbonObject(bs); break; - case PyMOL.REP_SURFACE: // = 2; - // unique translucency here involves creating ghost surfaces - float withinDistance = floatSetting(PyMOL.surface_carve_cutoff); - jo = addJmolObject(T.isosurface, bs, new Object[] { - booleanSetting(PyMOL.two_sided_lighting) ? "FULLYLIT" : "FRONTLIT", - (surfaceMode == 3 || surfaceMode == 4) ? " only" : "", - bsCarve, Float.valueOf(withinDistance)}); - jo.setSize(floatSetting(PyMOL.solvent_radius) * (solventAccessible ? -1 : 1)); - jo.translucency = transparency; - if (surfaceColor >= 0) - jo.argb = PyMOL.getRGB(surfaceColor); - break; - case PyMOL.REP_MESH: // = 8; - jo = addJmolObject(T.isosurface, bs, null); - jo.setSize(floatSetting(PyMOL.solvent_radius)); - jo.translucency = transparency; - break; default: Logger.error("Unprocessed representation type " + shapeID); } } - private JmolObject setUniqueObjects(int shape, BS bs, - int setColor, int color, - int setTrans, float trans, - int setSize, float size, float f) { + private JmolObject setUniqueObjects(int shape, BS bs, int setColor, + int color, int setTrans, float trans, + int setSize, float size, float f) { int n = bs.cardinality(); short[] colixes = (setColor == 0 ? null : new short[n]); float[] atrans = (setTrans == 0 ? null : new float[n]); float[] sizes = new float[n]; - for (int pt=0, i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1), pt++) { - int id = (uniqueIDs == null ? -1 : uniqueIDs[i]); + for (int pt = 0, i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1), pt++) { + int id = (reader == null ? uniqueIDs[i] : reader.getUniqueID(i)); if (colixes != null) { int c = (int) getUniqueFloatDef(id, setColor, color); if (c > 0) colixes[pt] = getColix(c, 0); } if (atrans != null) { - atrans[pt] = getUniqueFloatDef(id, setTrans, trans); + atrans[pt] = getUniqueFloatDef(id, setTrans, trans); } sizes[pt] = getUniqueFloatDef(id, setSize, size) * f; } - return addJmolObject(shape, bs, new Object[] {colixes, atrans, sizes}); + return addJmolObject(shape, bs, new Object[] { colixes, atrans, sizes }); -// case PyMOL.REP_DOTS: - // addJmolObject(JC.SHAPE_DOTS, bs, null).rd = new RadiusData(null, + // case PyMOL.REP_DOTS: + // addJmolObject(JC.SHAPE_DOTS, bs, null).rd = new RadiusData(null, // value1, RadiusData.EnumType.FACTOR, EnumVdw.AUTO); -// case PyMOL.REP_NONBONDED: - // addJmolObject(JC.SHAPE_STARS, bs, null).rd = new RadiusData(null, + // case PyMOL.REP_NONBONDED: + // addJmolObject(JC.SHAPE_STARS, bs, null).rd = new RadiusData(null, // f / 2, RadiusData.EnumType.FACTOR, EnumVdw.AUTO); } @@ -1701,9 +1702,12 @@ public void addMesh(int tok, JmolList<Object> obj, String objName, boolean isMep) { JmolObject jo = addJmolObject(tok, null, obj); setSceneObject(objName, -1); + int meshColor = (int) floatSetting(PyMOL.mesh_color); + if (meshColor < 0) + meshColor = intAt(listAt(obj, 0), 2); if (!isMep) { jo.setSize(meshWidth); - jo.argb = PyMOL.getRGB(intAt(listAt(obj, 0), 2)); + jo.argb = PyMOL.getRGB(meshColor); } jo.translucency = transparency; } Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -1031,6 +1031,7 @@ public void setEllipsoids() { if (!haveAnisou) return; + getSymmetry(); int iAtomFirst = getLastAtomSetAtomIndex(); for (int i = iAtomFirst; i < atomCount; i++) atoms[i].setEllipsoid(symmetry.getEllipsoid(atoms[i].anisoBorU)); Modified: trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -166,7 +166,10 @@ jvxlEncodeContourData(jvxlData.vContours, data); } if (jvxlData.vertexColorMap != null) { - XmlUtil.openTag(data, "jvxlVertexColorData"); + if (jvxlData.baseColor == null) + XmlUtil.openTag(data, "jvxlVertexColorData"); + else + XmlUtil.openTagAttr(data, "jvxlVertexColorData", new String[] {"baseColor", jvxlData.baseColor}); for (Map.Entry<String, BS> entry : jvxlData.vertexColorMap.entrySet()) appendEncodedBitSetTag(data, "jvxlColorMap", entry.getValue(), -1, new Object[] { "color", entry.getKey() }); jvxlData.vertexColorMap = null; Modified: trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -171,6 +171,7 @@ public boolean allowVolumeRender; public float voxelVolume; public P3 mapLattice; + public String baseColor; public void clear() { allowVolumeRender = true; Modified: trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -130,10 +130,13 @@ if (haveContourData) jvxlDecodeContourData(jvxlData, xr.getXmlData("jvxlContourData", null, false, false)); - if (jvxlData.nVertexColors > 0) { + if (jvxlDataIsColorMapped && jvxlData.nVertexColors > 0) { jvxlData.vertexColorMap = new Hashtable<String, BS>(); + String vdata = xr.getXmlData("jvxlVertexColorData", null, true, false); + String baseColor = XmlReader.getXmlAttrib(vdata, "baseColor"); + jvxlData.baseColor = (baseColor.length() > 0 ? baseColor : null); for (int i = 0; i < jvxlData.nVertexColors; i++) { - String s = xr.getXmlData("jvxlColorMap", null, true, false); + String s = xr.getXmlData("jvxlColorMap", vdata, true, false); String color = XmlReader.getXmlAttrib(s, "color"); BS bs = JvxlCoder.jvxlDecodeBitSet(xr.getXmlData("jvxlColorMap", s, false, false)); @@ -352,37 +355,37 @@ } protected void jvxlSetColorRanges(float dataMin, float dataMax, float red, - float blue, boolean insideOut) { + float blue, boolean insideOut) { if (jvxlDataIsColorMapped) { - if (!Float.isNaN(dataMin) && !Float.isNaN(dataMax)) { - if (dataMax == 0 && dataMin == 0) { - //set standard -1/1; bit of a hack - dataMin = -1; - dataMax = 1; - } - params.mappedDataMin = dataMin; - params.mappedDataMax = dataMax; - Logger.info("JVXL read: data_min/max " + params.mappedDataMin + "/" - + params.mappedDataMax); - } - if (!params.rangeDefined) - if (!Float.isNaN(red) && !Float.isNaN(blue)) { - if (red == 0 && blue == 0) { + if (!Float.isNaN(dataMin) && !Float.isNaN(dataMax)) { + if (dataMax == 0 && dataMin == 0) { //set standard -1/1; bit of a hack - red = -1; - blue = 1; + dataMin = -1; + dataMax = 1; } - params.valueMappedToRed = Math.min(red, blue); - params.valueMappedToBlue = Math.max(red, blue); - params.isColorReversed = (red > blue); - params.rangeDefined = true; - } else { - params.valueMappedToRed = 0f; - params.valueMappedToBlue = 1f; - params.rangeDefined = true; + params.mappedDataMin = dataMin; + params.mappedDataMax = dataMax; + Logger.info("JVXL read: data_min/max " + params.mappedDataMin + "/" + + params.mappedDataMax); } - Logger.info("JVXL read: color red/blue: " + params.valueMappedToRed + "/" - + params.valueMappedToBlue); + if (!params.rangeDefined) + if (!Float.isNaN(red) && !Float.isNaN(blue)) { + if (red == 0 && blue == 0) { + //set standard -1/1; bit of a hack + red = -1; + blue = 1; + } + params.valueMappedToRed = Math.min(red, blue); + params.valueMappedToBlue = Math.max(red, blue); + params.isColorReversed = (red > blue); + params.rangeDefined = true; + } else { + params.valueMappedToRed = 0f; + params.valueMappedToBlue = 1f; + params.rangeDefined = true; + } + Logger.info("JVXL read: color red/blue: " + params.valueMappedToRed + "/" + + params.valueMappedToBlue); } jvxlData.valueMappedToRed = params.valueMappedToRed; jvxlData.valueMappedToBlue = params.valueMappedToBlue; @@ -578,6 +581,8 @@ @Override protected String readColorData() { + if (!jvxlDataIsColorMapped) + return ""; // overloads SurfaceReader // standard jvxl file read for color Modified: trunk/Jmol/src/org/jmol/jvxl/readers/PyMOLMeshReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/PyMOLMeshReader.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/jvxl/readers/PyMOLMeshReader.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -76,7 +76,7 @@ surfaceName = (String) data.get(data.size() - 1); } voxelList = getList(getList(getList(surfaceList, 14), 2), 6); - System.out.println("Number of grid points = " + voxelList.size() + " " + params.sigma); + System.out.println("Number of grid points = " + voxelList.size()); allowSigma = true; } @@ -95,11 +95,15 @@ jvxlFileHeaderBuffer.append(surfaceName + " (" + params.calculationType + ")\n"); // cell parameters - t = getList(getList(surfaceList, 1), 0); + JmolList<Object> s = getList(surfaceList, 1); + t = getList(s, 0); + // change in format between PyMOL versions + if (t.size() < 3) + t = getList(s = getList(s, 0), 0); a = getFloat(t, 0); b = getFloat(t, 1); c = getFloat(t, 2); - t = getList(getList(surfaceList, 1), 1); + t = getList(s, 1); alpha = getFloat(t, 0); beta = getFloat(t, 1); gamma = getFloat(t, 2); Modified: trunk/Jmol/src/org/jmol/shapebio/BioShape.java =================================================================== --- trunk/Jmol/src/org/jmol/shapebio/BioShape.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/shapebio/BioShape.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -313,15 +313,11 @@ } } - public void setParams(Object[] data, BS bsSelected) { + public void setParams(Object[] data, int[] atomMap, BS bsSelected) { if (monomerCount == 0) return; // only implemented for simple colixes, really. short[] c = (short[]) data[0]; - int n = bsSelected.length(); - int[] atomMap = new int[n]; - for (int pt = 0, i = bsSelected.nextSetBit(0); i >= 0; i = bsSelected.nextSetBit(i + 1), pt++) - atomMap[i] = pt; // would have to do something like this here as well; float[] atrans = (float[]) data[1]; //float[] sizes = (float[]) data[2]; @@ -329,6 +325,7 @@ isActive = true; if (bsColixSet == null) bsColixSet = new BS(); + int n = atomMap.length; for (int i = monomerCount; --i >= 0;) { int atomIndex = leadAtomIndices[i]; if (bsSelected.get(atomIndex) && i < colixes.length && atomIndex < n) { Modified: trunk/Jmol/src/org/jmol/shapebio/BioShapeCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/shapebio/BioShapeCollection.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/shapebio/BioShapeCollection.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -142,8 +142,12 @@ return; } if ("params" == propertyName) { + int n = bsSelected.length(); + int[] atomMap = new int[n]; + for (int pt = 0, i = bsSelected.nextSetBit(0); i >= 0; i = bsSelected.nextSetBit(i + 1), pt++) + atomMap[i] = pt; for (int i = bioShapes.length; --i >= 0;) - bioShapes[i].setParams((Object[]) value, bsSelected); + bioShapes[i].setParams((Object[]) value, atomMap, bsSelected); return; } Modified: trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -92,21 +92,36 @@ package org.jmol.shapesurface; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Hashtable; +import java.util.Map; + +import org.jmol.api.JmolDocument; +import org.jmol.io.JmolBinary; +import org.jmol.jvxl.api.MeshDataServer; +import org.jmol.jvxl.data.JvxlCoder; +import org.jmol.jvxl.data.JvxlData; +import org.jmol.jvxl.data.MeshData; +import org.jmol.jvxl.readers.Parameters; +import org.jmol.jvxl.readers.SurfaceGenerator; +import org.jmol.script.T; import org.jmol.shape.Mesh; import org.jmol.shape.MeshCollection; import org.jmol.shape.Shape; import org.jmol.util.Escape; - import org.jmol.util.AxisAngle4f; import org.jmol.util.BS; import org.jmol.util.C; import org.jmol.util.ColorEncoder; import org.jmol.util.ArrayUtil; import org.jmol.util.ColorUtil; +import org.jmol.util.JmolList; import org.jmol.util.Logger; import org.jmol.util.Matrix3f; import org.jmol.util.Matrix4f; -//import org.jmol.util.Measure; import org.jmol.util.MeshSurface; import org.jmol.util.Parser; import org.jmol.util.P3; @@ -118,30 +133,9 @@ import org.jmol.util.V3; import org.jmol.viewer.ActionManager; import org.jmol.viewer.JC; -import org.jmol.script.T; import org.jmol.viewer.Viewer; -//import org.jmol.viewer.StateManager.Orientation; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.OutputStream; -import org.jmol.util.JmolList; -import java.util.Hashtable; - -import java.util.Map; - - -import org.jmol.api.JmolDocument; -import org.jmol.io.JmolBinary; -import org.jmol.jvxl.api.MeshDataServer; -import org.jmol.jvxl.data.JvxlCoder; -import org.jmol.jvxl.data.JvxlData; -import org.jmol.jvxl.data.MeshData; -import org.jmol.jvxl.readers.Parameters; -import org.jmol.jvxl.readers.SurfaceGenerator; - public class Isosurface extends MeshCollection implements MeshDataServer { private IsosurfaceMesh[] isomeshes = new IsosurfaceMesh[4]; @@ -228,8 +222,9 @@ setPropI("modelIndex", Integer.valueOf(imodel), null); setPropI("fileName", "cache://isosurface_" + id, null); setPropI("readFile", null, null); - setPropI("finalize", "isosurface ID " + Escape.eS(id) + (imodel >= 0 ? " modelIndex " + imodel : "") - + " /*file*/" + Escape.eS("cache://isosurface_" + id), null); + setPropI("finalize", "isosurface ID " + Escape.eS(id) + + (imodel >= 0 ? " modelIndex " + imodel : "") + " /*file*/" + + Escape.eS("cache://isosurface_" + id), null); setPropI("clear", null, null); return; } @@ -263,39 +258,37 @@ return; } + if ("params" == propertyName) { + if (thisMesh != null) { + ensureMeshSource(); + thisMesh.checkAllocColixes(); + Object[] data = (Object[]) value; + short[] colixes = (short[]) data[0]; + int[] atomMap = null; + //float[] atrans = (float[]) data[1]; + if (colixes != null) { + for (int i = 0; i < colixes.length; i++) { + short colix = colixes[i]; + float f = 0;//(atrans == null ? 0 : atrans[pt]); + if (f > 0.01f) + colix = C.getColixTranslucent3(colix, true, f); + colixes[i] = colix; + } + atomMap = new int[bs.length()]; + for (int pt = 0, i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1), pt++) + atomMap[i] = pt; + } + thisMesh.setVertexColixesForAtoms(viewer, colixes, atomMap, bs); + thisMesh.setVertexColorMap(); + } + return; + } if ("atomcolor" == propertyName) { // color $id red ({0:30 ....}) (atoms) // color $id red [{0:30 ....}] (vertices) if (thisMesh != null) { - boolean haveColors = (thisMesh.vertexSource != null); - if (haveColors) - for (int i = thisMesh.vertexCount; --i >= 0;) - if (thisMesh.vertexSource[i] < 0) { - haveColors = false; - break; - } - if (!haveColors) { - int[] source = thisMesh.vertexSource; - short[] vertexColixes = thisMesh.vertexColixes; - short colix = (!thisMesh.isColorSolid ? 0 : thisMesh.colix); - setProperty("init", null, null); - setProperty("map", Boolean.FALSE, null); - setProperty("property", new float[viewer.getAtomCount()], null); - if (source == null) { - if (colix != 0) { - thisMesh.colorCommand = "color isosurface " - + C.getHexCode(colix); - setProperty("color", Integer.valueOf(C.getArgb(colix)), null); - } - } else { - for (int i = thisMesh.vertexCount; --i >= 0;) - if (source[i] < 0) - source[i] = thisMesh.vertexSource[i]; - thisMesh.vertexSource = source; - thisMesh.vertexColixes = vertexColixes; - } - } - thisMesh.colorAtoms(C.getColixO(value), bs); + ensureMeshSource(); + thisMesh.colorVertices(C.getColixO(value), bs, true); } return; } @@ -309,7 +302,7 @@ if ("vertexcolor" == propertyName) { if (thisMesh != null) { - thisMesh.colorVertices(C.getColixO(value), bs); + thisMesh.colorVertices(C.getColixO(value), bs, false); } return; } @@ -331,8 +324,10 @@ return; } if ("color" == propertyName) { + String color = C.getHexCode(C.getColixO(value)); if (thisMesh != null) { // thisMesh.vertexColixes = null; + thisMesh.jvxlData.baseColor = color; thisMesh.isColorSolid = true; thisMesh.polygonColixes = null; thisMesh.colorEncoder = null; @@ -340,6 +335,7 @@ } else if (!TextFormat.isWild(previousMeshID)) { for (int i = meshCount; --i >= 0;) { // isomeshes[i].vertexColixes = null; + isomeshes[i].jvxlData.baseColor = color; isomeshes[i].isColorSolid = true; isomeshes[i].polygonColixes = null; isomeshes[i].colorEncoder = null; @@ -638,7 +634,7 @@ && sg != null) { sg.getParams().testFlags = (viewer.getTestFlag(2) ? 2 : 0); } else if ("solvent" == propertyName) { - sg.getParams().testFlags = (viewer.getTestFlag(1) ? 1 : 0); + sg.getParams().testFlags = (viewer.getTestFlag(1) ? 1 : 0); } // surface Export3D only (return TRUE) or shared (return FALSE) @@ -717,6 +713,36 @@ setPropertySuper(propertyName, value, bs); } + private void ensureMeshSource() { + boolean haveColors = (thisMesh.vertexSource != null); + if (haveColors) + for (int i = thisMesh.vertexCount; --i >= 0;) + if (thisMesh.vertexSource[i] < 0) { + haveColors = false; + break; + } + if (!haveColors) { + int[] source = thisMesh.vertexSource; + short[] vertexColixes = thisMesh.vertexColixes; + short colix = (thisMesh.isColorSolid ? thisMesh.colix : 0); + setProperty("init", null, null); + setProperty("map", Boolean.FALSE, null); + setProperty("property", new float[viewer.getAtomCount()], null); + if (colix != 0) { + thisMesh.colorCommand = "color isosurface " + + C.getHexCode(colix); + setProperty("color", Integer.valueOf(C.getArgb(colix)), null); + } + if (source != null) { + for (int i = thisMesh.vertexCount; --i >= 0;) + if (source[i] < 0) + source[i] = thisMesh.vertexSource[i]; + thisMesh.vertexSource = source; + thisMesh.vertexColixes = vertexColixes; + } + } + } + protected void slabPolygons(Object[] slabInfo) { thisMesh.slabPolygons(slabInfo, false); thisMesh.reinitializeLightingAndColor(viewer); Modified: trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -487,24 +487,40 @@ jvxlData.vContours = null; } - /** - * color a specific set of vertices based on a set of atoms - * - * @param colix - * @param bs - */ - void colorAtoms(short colix, BS bs) { - colorVertices2(colix, bs, true); + void setVertexColorMap() { + vertexColorMap = new Hashtable<String, BS>(); + short lastColix = -999; + BS bs = null; + for (int i = vertexCount; --i >= 0;) { + short c = vertexColixes[i]; + if (c != lastColix) { + String color = C.getHexCode(lastColix = c); + bs = vertexColorMap.get(color); + if (bs == null) + vertexColorMap.put(color, bs = new BS()); + } + bs.set(i); + } } - /** - * color a specific set of vertices - * - * @param colix - * @param bs - */ - void colorVertices(short colix, BS bs) { - colorVertices2(colix, bs, false); + void setVertexColixesForAtoms(Viewer viewer, short[] colixes, int[] atomMap, + BS bs) { + jvxlData.vertexDataOnly = true; + jvxlData.vertexColors = new int[vertexCount]; + jvxlData.nVertexColors = vertexCount; + Atom[] atoms = viewer.modelSet.atoms; + for (int i = mergeVertexCount0; i < vertexCount; i++) { + int iAtom = vertexSource[i]; + if (iAtom < 0 || !bs.get(iAtom)) + continue; + jvxlData.vertexColors[i] = viewer.getColorArgbOrGray(vertexColixes[i] = C + .copyColixTranslucency(colix, atoms[iAtom].getColix())); + + short colix = (colixes == null ? C.INHERIT_ALL : colixes[atomMap[iAtom]]); + if (colix == C.INHERIT_ALL) + colix = atoms[iAtom].getColix(); + vertexColixes[i] = C.copyColixTranslucency(this.colix, colix); + } } /** @@ -514,17 +530,12 @@ * @param bs * @param isAtoms */ - private void colorVertices2(short colix, BS bs, boolean isAtoms) { + void colorVertices(short colix, BS bs, boolean isAtoms) { if (vertexSource == null) return; colix = C.copyColixTranslucency(this.colix, colix); BS bsVertices = (isAtoms ? new BS() : bs); - if (vertexColixes == null || vertexColorMap == null && isColorSolid) { - vertexColixes = new short[vertexCount]; - for (int i = 0; i < vertexCount; i++) - vertexColixes[i] = this.colix; - } - isColorSolid = false; + checkAllocColixes(); // TODO: color translucency? if (isAtoms) for (int i = 0; i < vertexCount; i++) { @@ -533,7 +544,8 @@ continue; if (bs.get(pt)) { vertexColixes[i] = colix; - bsVertices.set(i); + if (bsVertices != null) + bsVertices.set(i); } } else @@ -552,6 +564,12 @@ addColorToMap(vertexColorMap, color, bs); } + void checkAllocColixes() { + if (vertexColixes == null || vertexColorMap == null && isColorSolid) + allocVertexColixes(); + isColorSolid = false; + } + /** * adds a set of specifically-colored vertices to the map, * ensuring that no vertex is in two maps. @@ -674,6 +692,10 @@ remapColors(null, null, Float.NaN); } } else { + if (jvxlData.baseColor != null) { + for (int i = vertexCount; --i >= 0;) + vertexColixes[i] = colix; + } for (Map.Entry<String, BS> entry : jvxlData.vertexColorMap.entrySet()) { BS bsMap = entry.getValue(); short colix = C.copyColixTranslucency(this.colix, C.getColixS(entry @@ -718,11 +740,12 @@ boolean inherit = (vertexSource != null && ce.currentPalette == ColorEncoder.INHERIT); vertexColorMap = null; polygonColixes = null; + jvxlData.baseColor = null; jvxlData.vertexCount = vertexCount; if (vertexValues == null || jvxlData.vertexCount == 0) return; if (vertexColixes == null || vertexColixes.length != vertexCount) - vertexColixes = new short[vertexCount]; + allocVertexColixes(); if (inherit) { jvxlData.vertexDataOnly = true; jvxlData.vertexColors = new int[vertexCount]; Modified: trunk/Jmol/src/org/jmol/util/C.java =================================================================== --- trunk/Jmol/src/org/jmol/util/C.java 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/util/C.java 2013-06-08 20:27:11 UTC (rev 18316) @@ -110,7 +110,7 @@ */ - public final static short INHERIT_ALL = 0; + public final static short INHERIT_ALL = 0; // do not change this from 0; new colix[n] must be this public final static short INHERIT_COLOR = 1; public final static short USE_PALETTE = 2; public final static short RAW_RGB = 3; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-06-08 12:30:43 UTC (rev 18315) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-06-08 20:27:11 UTC (rev 18316) @@ -11,10 +11,10 @@ ___JmolVersion="13.1.17_dev_2013.06.07" -TODO: PyMOL EDM data saved from PyMOL 1.6? -TODO: PyMOL uniqueAtomSettings for mesh_color, surface_color, and transparency - -- color isosurface {xxxx} red translucent 0.5 ?? +TODO: PyMOL uniqueAtomSettings for transparency + -- will require by-vertex translucent option +bug fix: PyMOL volume map data saved from PyMOL 1.6 has slightly different data structure bug fix: jvxl reader ignores jvxlVertexColorData bug fix: ellipsoid rendering problems This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits