From: <ha...@us...> - 2010-01-12 23:23:18
|
Revision: 12105 http://jmol.svn.sourceforge.net/jmol/?rev=12105&view=rev Author: hansonr Date: 2010-01-12 23:23:11 +0000 (Tue, 12 Jan 2010) Log Message: ----------- version=11.9.18_dev # bug fix: connected(0, {carbon}) not working # new feature: set slabByMolecule # new feature: set zshadePower -- log_2(p) in f = [(zDepth - z) / (zDepth - zSlab)]^p # Modified Paths: -------------- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java trunk/Jmol/src/org/jmol/g3d/Shade3D.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/modelset/Molecule.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/shape/BallsRenderer.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager11.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/g3d/Graphics3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -805,8 +805,11 @@ int pG = (p & 0xFF00) >> 8; int pB = (p & 0xFF0000) >> 16; int pA = (p & 0xFF000000); - float f = zDepth - z; - f /= (zDepth - zSlab); + float f = (float)(zDepth - z) / (zDepth - zSlab); + if (Shade3D.zPower > 1) { + for (int i = 0; i < Shade3D.zPower; i++) + f *= f; + } pR = zShadeR + (int) (f * (pR - zShadeR)); pG = zShadeG + (int) (f * (pG - zShadeG)); pB = zShadeB + (int) (f * (pB - zShadeB)); @@ -2281,6 +2284,19 @@ * * @param val */ + public synchronized static void setZShadePower(int val) { + Shade3D.zPower = val; + } + + public static int getZShadePower() { + return Shade3D.zPower; + } + + /** + * fractional distance from black for ambient color + * + * @param val + */ public synchronized static void setAmbientPercent(int val) { if (Shade3D.ambientPercent == val) return; Modified: trunk/Jmol/src/org/jmol/g3d/Shade3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Shade3D.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/g3d/Shade3D.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -50,6 +50,7 @@ static final byte shadeIndexNormal = 52; final static byte shadeIndexNoisyLimit = 56; + public static int zPower = 1; // the power for the zShading -- higher number --> more depth of fog // the viewer vector is always {0 0 1} Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -1586,8 +1586,10 @@ int n = 0; if (moleculeCount == 0) getMolecules(); + if (modelIndex < 0) + return moleculeCount; for (int i = 0; i < modelCount; i++) { - if (modelIndex == i || modelIndex < 0) + if (modelIndex == i) n += models[i].moleculeCount; } return n; @@ -1611,9 +1613,9 @@ } } - private void getMolecules() { + public Molecule[] getMolecules() { if (moleculeCount > 0) - return; + return molecules; if (molecules == null) molecules = new Molecule[4]; moleculeCount = 0; @@ -1623,12 +1625,14 @@ int modelIndex = -1; int indexInModel = -1; int moleculeCount0 = -1; + Model m = null; for (int i = 0; i < atomCount; i++) if (!atomlist.get(i) && !bs.get(i)) { modelIndex = atoms[i].modelIndex; if (modelIndex != thisModelIndex) { indexInModel = -1; - models[modelIndex].firstMolecule = moleculeCount; + m = models[modelIndex]; + m.firstMolecule = moleculeCount; moleculeCount0 = moleculeCount - 1; thisModelIndex = modelIndex; } @@ -1639,10 +1643,10 @@ molecules = (Molecule[]) ArrayUtil.setLength(molecules, moleculeCount * 2); molecules[moleculeCount] = new Molecule((ModelSet) this, moleculeCount, - bs, thisModelIndex, indexInModel); - getModel(thisModelIndex).moleculeCount = moleculeCount - moleculeCount0; - moleculeCount++; + i, bs, thisModelIndex, indexInModel); + m.moleculeCount = moleculeCount++ - moleculeCount0; } + return molecules; } public BitSet getBranchBitSet(int atomIndex, int atomIndexNot) { @@ -2537,7 +2541,7 @@ } } } - boolean nonbonded = (min == 0 && max == 0); + boolean nonbonded = (min == 0); for (i = atomCount; --i >= 0;) { int n = nBonded[i]; if (n < min || n > max) Modified: trunk/Jmol/src/org/jmol/modelset/Molecule.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Molecule.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/modelset/Molecule.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -30,24 +30,26 @@ import java.util.BitSet; import java.util.Hashtable; -class Molecule { +public class Molecule { ModelSet modelSet; int moleculeIndex; int modelIndex; int indexInModel; - int nAtoms; + public int firstAtomIndex; + public int nAtoms; int nElements; int[] elementCounts = new int[JmolConstants.elementNumberMax]; int[] altElementCounts = new int[JmolConstants.altElementMax]; int elementNumberMax; int altElementMax; String mf; - BitSet atomList; + public BitSet atomList; - Molecule(ModelSet modelSet, int moleculeIndex, BitSet atomList, int modelIndex, + Molecule(ModelSet modelSet, int moleculeIndex, int firstAtomIndex, BitSet atomList, int modelIndex, int indexInModel) { this.modelSet = modelSet; + this.firstAtomIndex = firstAtomIndex; this.atomList = atomList; this.moleculeIndex = moleculeIndex; this.modelIndex = modelIndex; Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -1889,7 +1889,7 @@ return false; if (min == Integer.MIN_VALUE) { - min = Math.max(n, 1); + min = Math.max(n, 0); fmin = f; } else { max = n; Modified: trunk/Jmol/src/org/jmol/shape/BallsRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/BallsRenderer.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/shape/BallsRenderer.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -25,8 +25,11 @@ package org.jmol.shape; +import java.util.BitSet; + import org.jmol.g3d.*; import org.jmol.modelset.Atom; +import org.jmol.modelset.Molecule; import org.jmol.viewer.JmolConstants; import javax.vecmath.*; @@ -63,48 +66,79 @@ Atom[] atoms = modelSet.atoms; int atomCount = modelSet.getAtomCount(); + BitSet bsOK = new BitSet(); for (int i = atomCount; --i >= 0;) { Atom atom = atoms[i]; if ((atom.getShapeVisibilityFlags() & JmolConstants.ATOM_IN_FRAME) == 0) continue; + bsOK.set(i); atom.transform(viewer); - if (slabbing) { - if (g3d.isClippedZ(atom.screenZ)) { - atom.setClickable(0); - // note that in the case of navigation, - // maxZ is set to Integer.MAX_VALUE. - - int r = atom.screenDiameter / 2; - if (atom.screenZ < minZ - r || atom.screenZ > maxZ + r) - continue; - if (!g3d.isInDisplayRange(atom.screenX, atom.screenY)) - continue; + } + boolean slabByMolecule = viewer.getSlabByMolecule(); + if (slabByMolecule && slabbing) { + Molecule[] molecules = modelSet.getMolecules(); + int moleculeCount = modelSet.getMoleculeCountInModel(-1); + for (int i = 0; i < moleculeCount; i++) { + Molecule m = molecules[i]; + int j = 0; + int pt = m.firstAtomIndex; + if (!bsOK.get(pt)) + continue; + for (; j < m.nAtoms; j++, pt++) + if (g3d.isClippedZ(atoms[pt].screenZ - (atoms[pt].screenDiameter >> 1))) + break; + if (j != m.nAtoms) { + pt = m.firstAtomIndex; + for (int k = 0; k < m.nAtoms; k++) { + bsOK.clear(pt); + atoms[pt++].screenZ = 0; + } } } - // note: above transform is required for all other renderings + } + for (int i = atomCount; --i >= 0;) + if (bsOK.get(i)) { + Atom atom = atoms[i]; + if (slabbing) { - if (renderBalls && atom.screenDiameter > 0 - && (atom.getShapeVisibilityFlags() & myVisibilityFlag) != 0 - && g3d.setColix(atom.getColix())) { - if (renderCrosshairs) { - if (atom.screenX < minX) - minX = atom.screenX; - if (atom.screenX > maxX) - maxX = atom.screenX; - if (atom.screenY < minY) - minY = atom.screenY; - if (atom.screenY > maxY) - maxY = atom.screenY; + if (g3d.isClippedZ(atom.screenZ)) { + + atom.setClickable(0); + // note that in the case of navigation, + // maxZ is set to Integer.MAX_VALUE. + + int r = atom.screenDiameter / 2; + if (atom.screenZ + r < minZ || atom.screenZ - r > maxZ) + continue; + if (!g3d.isInDisplayRange(atom.screenX, atom.screenY)) + continue; + } } - g3d.drawAtom(atom); + // note: above transform is required for all other renderings + + if (renderBalls && atom.screenDiameter > 0 + && (atom.getShapeVisibilityFlags() & myVisibilityFlag) != 0 + && g3d.setColix(atom.getColix())) { + if (renderCrosshairs) { + if (atom.screenX < minX) + minX = atom.screenX; + if (atom.screenX > maxX) + maxX = atom.screenX; + if (atom.screenY < minY) + minY = atom.screenY; + if (atom.screenY > maxY) + maxY = atom.screenY; + } + g3d.drawAtom(atom); + } } - } // this is the square and crosshairs for the navigator if (renderCrosshairs) { boolean antialiased = g3d.isAntialiased(); float navDepth = viewer.getNavigationDepthPercent(); - g3d.setColix(navDepth < 0 ? Graphics3D.RED : navDepth > 100 ? Graphics3D.GREEN : Graphics3D.GOLD); + g3d.setColix(navDepth < 0 ? Graphics3D.RED + : navDepth > 100 ? Graphics3D.GREEN : Graphics3D.GOLD); int x = Math.max(Math.min(viewer.getScreenWidth(), (int) navOffset.x), 0); int y = Math .max(Math.min(viewer.getScreenHeight(), (int) navOffset.y), 0); @@ -113,19 +147,19 @@ int off = (antialiased ? 8 : 4); int h = (antialiased ? 20 : 10); int w = (antialiased ? 2 : 1); - g3d.drawRect(x - off, y, z, 0, h, w); - g3d.drawRect(x, y - off, z, 0, w, h); - g3d.drawRect(x - off, y - off, z, 0, h, h); - off = h; - h = h >> 1; - g3d.setColix(maxX < navOffset.x ? Graphics3D.YELLOW : Graphics3D.GREEN); - g3d.drawRect(x - off, y, z, 0, h, w); - g3d.setColix(minX > navOffset.x ? Graphics3D.YELLOW : Graphics3D.GREEN); - g3d.drawRect(x + h, y, z, 0, h, w); - g3d.setColix(maxY < navOffset.y ? Graphics3D.YELLOW : Graphics3D.GREEN); - g3d.drawRect(x, y - off, z, 0, w, h); - g3d.setColix(minY > navOffset.y ? Graphics3D.YELLOW : Graphics3D.GREEN); - g3d.drawRect(x, y + h, z, 0, w, h); + g3d.drawRect(x - off, y, z, 0, h, w); + g3d.drawRect(x, y - off, z, 0, w, h); + g3d.drawRect(x - off, y - off, z, 0, h, h); + off = h; + h = h >> 1; + g3d.setColix(maxX < navOffset.x ? Graphics3D.YELLOW : Graphics3D.GREEN); + g3d.drawRect(x - off, y, z, 0, h, w); + g3d.setColix(minX > navOffset.x ? Graphics3D.YELLOW : Graphics3D.GREEN); + g3d.drawRect(x + h, y, z, 0, h, w); + g3d.setColix(maxY < navOffset.y ? Graphics3D.YELLOW : Graphics3D.GREEN); + g3d.drawRect(x, y - off, z, 0, w, h); + g3d.setColix(minY > navOffset.y ? Graphics3D.YELLOW : Graphics3D.GREEN); + g3d.drawRect(x, y + h, z, 0, w, h); } } } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-01-12 23:23:11 UTC (rev 12105) @@ -3,6 +3,10 @@ version=11.9.18_dev +# bug fix: connected(0, {carbon}) not working +# new feature: set slabByMolecule +# new feature: set zshadePower -- log_2(p) in f = [(zDepth - z) / (zDepth - zSlab)]^p +# # new feature: VASP vasprun.xml reader http://cms.mpi.univie.ac.at/vasp/ # # new feature: math function measure({exp1},{exp}[,{exp}[,{exp}]],min, max, format, units, "CONNECTED") Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -554,7 +554,7 @@ + ";minimizationsteps;minimizationrefresh;minimizationcriterion;navigationmode;" + ";perspectivedepth;phongexponent;visualrange;perspectivemodel;refreshing;rotationradius" + ";showaxes;showaxis1;showaxis2;showaxis3;showboundbox;showfrank;showunitcell" - + ";slabenabled;zshade;specular;specularexponent;specularpercent;specularpower;stateversion" + + ";slabenabled;zshade;zshadepower;specular;specularexponent;specularpercent;specularpower;stateversion" + ";statusreporting;stereo;stereostate" + ";unitcellcolor;windowcentered;zerobasedxyzrasmol;zoomenabled" + @@ -616,6 +616,9 @@ int phongExponent = 64; // 2^specularExponent int specularPercent = 22; int specularPower = 40; + int zShadePower = 1; + + boolean slabByMolecule = false; //file loading @@ -880,6 +883,7 @@ appendCmd(str, "set specularExponent " + se); else appendCmd(str, "set phongExponent " + pe); + appendCmd(str, "set zShadePower " + Graphics3D.getZShadePower()); return str.toString(); } @@ -1367,6 +1371,7 @@ setParameterValue("showNavigationPointAlways", showNavigationPointAlways); setParameterValue("showScript", scriptDelay); setParameterValue("showUnitcell", false); + setParameterValue("slabByMolecule", slabByMolecule); setParameterValue("slabEnabled", false); setParameterValue("smartAromatic", smartAromatic); setParameterValue("solventProbe", solventOn); @@ -1409,6 +1414,7 @@ setParameterValue("zoomEnabled", true); setParameterValue("zoomLarge", zoomLarge); setParameterValue("zShade", false); + setParameterValue("zShade", zShadePower); setParameterValue("zeroBasedXyzRasmol", zeroBasedXyzRasmol); } Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager11.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager11.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager11.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -434,6 +434,8 @@ synchronized void navigate(int keyCode, int modifiers) { // 0 0 here means "key released" + String key = null; + float value = 0; if (mode != MODE_NAVIGATION) return; if (keyCode == 0) { @@ -467,8 +469,12 @@ if (navOn) { if (isAltKey) { navY += multiplier; + value = navY; + key = "navY"; } else { navZ += multiplier; + value = navZ; + key = "navZ"; } break; } @@ -493,8 +499,12 @@ if (navOn) { if (isAltKey) { navY -= multiplier; + value = navY; + key = "navY"; } else { navZ -= multiplier; + value = navZ; + key = "navZ"; } break; } @@ -518,6 +528,8 @@ case KeyEvent.VK_LEFT: if (navOn) { navX -= multiplier; + value = navX; + key = "navX"; break; } if (navigateSurface) { @@ -534,6 +546,8 @@ case KeyEvent.VK_RIGHT: if (navOn) { navX += multiplier; + value = navX; + key = "navX"; break; } if (navigateSurface) { @@ -552,6 +566,8 @@ navMode = NAV_MODE_NONE; return; } + if (key != null) + viewer.getGlobalSettings().setParameterValue(key, value); navigating = true; finalizeTransformParameters(); } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-01-12 21:06:01 UTC (rev 12104) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-01-12 23:23:11 UTC (rev 12105) @@ -603,7 +603,7 @@ Graphics3D.setSpecularPower(-global.specularExponent); Graphics3D.setPhongExponent(global.phongExponent); Graphics3D.setSpecularPower(global.specularPower); - + Graphics3D.setZShadePower(global.zShadePower); if (modelSet != null) animationManager.setAnimationOn(false); animationManager.setAnimationFps(global.animationFps); @@ -1065,6 +1065,10 @@ return transformManager.slabEnabled; } + public boolean getSlabByMolecule() { + return global.slabByMolecule; + } + void slabByPixels(int pixels) { // MouseManager.mouseSinglePressDrag transformManager.slabByPercentagePoints(pixels); @@ -5370,6 +5374,10 @@ Graphics3D.setAmbientPercent(value); break; } + if (key.equalsIgnoreCase("zshadePower")) { + Graphics3D.setZShadePower(Math.min(value, 1)); + break; + } if (key.equalsIgnoreCase("ribbonAspectRatio")) { global.ribbonAspectRatio = value; @@ -5440,6 +5448,12 @@ boolean doRepaint = true; while (true) { + // 11.9.18 + if (key.equalsIgnoreCase("slabByMolecule")) { + global.slabByMolecule = value; + break; + } + // 11.9.15 if (key.equalsIgnoreCase("saveProteinStructureState")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |