From: <ha...@us...> - 2006-12-31 04:26:34
|
Revision: 6555 http://svn.sourceforge.net/jmol/?rev=6555&view=rev Author: hansonr Date: 2006-12-30 20:26:32 -0800 (Sat, 30 Dec 2006) Log Message: ----------- implements -select atomX/atomY/atomZ [<,>,=,<=,>=,!=] x.xx -set navigationPeriodic -set zShade -expanded load "filename" {i j k} Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Frame.java trunk/Jmol/src/org/jmol/viewer/ModelManager.java trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/SticksRenderer.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager10.java trunk/Jmol/src/org/jmol/viewer/TransformManager11.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -30,13 +30,14 @@ class BallsRenderer extends ShapeRenderer { int minX, maxX, minY, maxY, minZ, maxZ; - + boolean isNav; void render() { minX = rectClip.x; maxX = minX + rectClip.width; minY = rectClip.y; maxY = minY + rectClip.height; boolean slabbing = viewer.getSlabEnabled(); + isNav = viewer.getNavigationMode(); if (slabbing) { minZ = g3d.getSlab(); maxZ = g3d.getDepth(); @@ -52,6 +53,11 @@ if (slabbing) { if (g3d.isClippedZ(atom.screenZ)) { atom.clickabilityFlags = 0; + //note that in the case of navigation, + //maxZ is set to Integer.MAX_VALUE. + + if (isNav) + continue; int r = atom.screenDiameter / 2; if (atom.screenZ < minZ - r || atom.screenZ > maxZ + r) continue; @@ -91,7 +97,8 @@ } void renderBall(Atom atom) { - g3d.fillSphereCentered(atom.colixAtom, atom.screenDiameter, + short colix = atom.colixAtom; + g3d.fillSphereCentered(colix, atom.screenDiameter, atom.screenX, atom.screenY, atom.screenZ); } } Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -1304,6 +1304,15 @@ case Token.model: propertyValue = atom.getModelTagNumber(); break; + case Token.atomX: + propertyValue = (int)(atom.x * 100); + break; + case Token.atomY: + propertyValue = (int)(atom.y * 100); + break; + case Token.atomZ: + propertyValue = (int)(atom.z * 100); + break; default: unrecognizedAtomProperty(property); } @@ -1748,9 +1757,9 @@ } else if (pt.z == 0) { pt3.set(pt1.x, 0, 1); } - viewer.convertFractionalCoordinates(pt1); - viewer.convertFractionalCoordinates(pt2); - viewer.convertFractionalCoordinates(pt3); + viewer.toCartesian(pt1); + viewer.toCartesian(pt2); + viewer.toCartesian(pt3); pt1.add(offset); pt2.add(offset); pt3.add(offset); @@ -1931,7 +1940,7 @@ if (getToken(++pcLastExpressionInstruction).tok != Token.rightbrace) coordinateExpected(); if (coordinatesAreFractional && doConvert) - viewer.convertFractionalCoordinates(pt); + viewer.toCartesian(pt); return pt; } Modified: trunk/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -2972,6 +2972,10 @@ unitCell.toFractional(pt); } + void toUnitCell(Point3f pt, Point3f offset) { + unitCell.toUnitCell(pt, offset); + } + void showInfo() { if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) Logger.debug("cellInfos[" + modelIndex + "]:\n" + unitCell.dumpInfo(true)); @@ -2983,7 +2987,7 @@ } } - void convertFractionalCoordinates(int modelIndex, Point3f pt) { + void toCartesian(int modelIndex, Point3f pt) { if (modelIndex < 0) modelIndex = 0; if (cellInfos == null || modelIndex >= cellInfos.length || cellInfos[modelIndex] == null) @@ -2993,6 +2997,14 @@ Logger.info(str + pt); } + void toUnitCell(int modelIndex, Point3f pt, Point3f offset) { + if (modelIndex < 0) + return; + if (cellInfos == null || modelIndex >= cellInfos.length || cellInfos[modelIndex] == null) + return; + cellInfos[modelIndex].toUnitCell(pt, offset); + } + boolean reportFormalCharges = false; void setFormalCharges(BitSet bs, int formalCharge) { for (int i = 0; i < atomCount; i++) Modified: trunk/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ModelManager.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/ModelManager.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -1322,10 +1322,15 @@ return false; } - void convertFractionalCoordinates(int modelIndex, Point3f pt) { - frame.convertFractionalCoordinates(modelIndex, pt); + void toCartesian(int modelIndex, Point3f pt) { + frame.toCartesian(modelIndex, pt); return; } + + void toUnitCell(int modelIndex, Point3f pt, Point3f offset) { + frame.toUnitCell(modelIndex, pt, offset); + return; + } void clearBfactorRange(){ frame.clearBfactorRange(); Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -437,6 +437,7 @@ boolean showMeasurements = true; boolean frankOn = false; boolean centerPointer = true; + boolean zShade = false; //atoms and bonds @@ -479,9 +480,11 @@ // window - int argbBackground = 0xFF000000; - String stereoState = null; - boolean navigationMode = false; + int argbBackground = 0xFF000000; + String stereoState = null; + boolean navigationMode = false; + boolean navigationPeriodic = false; + boolean navigationCentered = false; String getWindowState() { StringBuffer str = new StringBuffer("# window state;\n# height " + viewer.getScreenHeight() Modified: trunk/Jmol/src/org/jmol/viewer/SticksRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/SticksRenderer.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/SticksRenderer.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -53,7 +53,7 @@ short madBond; void render() { - asBits = viewer.getTestFlag2(); + asBits = false;//viewer.getTestFlag2(); endcaps = Graphics3D.ENDCAPS_SPHERICAL; showMultipleBonds = viewer.getShowMultipleBonds(); @@ -63,7 +63,6 @@ hbondsBackbone = viewer.getHbondsBackbone(); bondsBackbone = hbondsBackbone | ssbondsBackbone; hbondsSolid = viewer.getHbondsSolid(); - Bond[] bonds = frame.bonds; for (int i = frame.bondCount; --i >= 0; ) { Bond bond = bonds[i]; @@ -198,9 +197,9 @@ } else { if (lineBond) g3d.drawLine(colixA, colixB, xA, yA, zA, xB, yB, zB); - else if (asBits) // time test shows bitset method to be slower - g3d.fillCylinderBits(colixA, colixB, endcaps, - width, xA, yA, zA, xB, yB, zB); + // else if (asBits) // time test shows bitset method to be slower + // g3d.fillCylinderBits(colixA, colixB, endcaps, + // width, xA, yA, zA, xB, yB, zB); else g3d.fillCylinder(colixA, colixB, endcaps, width, xA, yA, zA, xB, yB, zB); Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -29,6 +29,9 @@ import javax.vecmath.Matrix4f; import javax.vecmath.Matrix3f; import javax.vecmath.AxisAngle4f; + +import org.jmol.util.Logger; + import java.util.Hashtable; abstract class TransformManager { @@ -56,6 +59,13 @@ abstract protected void calcCameraFactors(); /** + * calculate the perspective factor based on z + * @param z + * @return perspectiveFactor + */ + abstract protected float getPerspectiveFactor(float z); + + /** * sets slab and depth, possibly using visual range considerations * for setting the slab-clipping plane. (slab on; slab 0) * @@ -90,6 +100,7 @@ matrixRotate.setIdentity(); // no rotations setZoomEnabled(true); zoomToPercent(100); + zoomPercent = zoomPercentSetting; scaleFitToScreen(); if (isNavigationMode) setNavigationMode(true); @@ -552,20 +563,6 @@ zoomToPercent(percent); } - protected float getPerspectiveFactor(float z) { - // all z's SHOULD be >= 0 - // so the more positive z is, the smaller the screen scale - //new idea: phase out perspective depth when zoom is very large. - //zoomPercent 1000 or larger starts removing this effect - //we can go up to 200000 - float factor = (z <= 0 ? perspectiveScale : perspectiveScale / z); - if (zoomPercent >= MAXIMUM_ZOOM_PERSPECTIVE_DEPTH) - factor += (zoomPercent - MAXIMUM_ZOOM_PERSPECTIVE_DEPTH) - / (MAXIMUM_ZOOM_PERCENTAGE - MAXIMUM_ZOOM_PERSPECTIVE_DEPTH) - * (1 - factor); - return factor; - } - float getZoomPercentFloat() { return zoomPercent; } @@ -843,7 +840,8 @@ */ protected boolean perspectiveDepth = true; - protected float cameraDepth = 3f; + protected float cameraDepth = Float.NaN; + protected float cameraDepthSetting = 3f; protected float visualRange = 5f; protected float observerOffset; protected float cameraDistance = 1000f; // prevent divide by zero on startup @@ -866,10 +864,12 @@ * @param percent */ void setCameraDepthPercent(float percent) { + resetNavigationPoint(); float screenMultiples = (percent < 0 ? -percent / 100 : percent); if (screenMultiples == 0) return; - cameraDepth = screenMultiples; + cameraDepthSetting = screenMultiples; + cameraDepth = Float.NaN; } void setVisualRange(float angstroms) { @@ -967,7 +967,7 @@ } short scaleToScreen(int z, int milliAngstroms) { - if (milliAngstroms == 0) + if (milliAngstroms == 0 || z < 2) return 0; int pixelSize = (int) scaleToPerspective(z, milliAngstroms * scalePixelsPerAngstrom / 1000); return (short) (pixelSize > 0 ? pixelSize : 1); @@ -1010,8 +1010,6 @@ void setNavigationMode(boolean TF) { isNavigationMode = (TF && canNavigate()); resetNavigationPoint(); - if (isNavigationMode) - setPerspectiveDepth(true); } boolean getNavigating() { @@ -1059,6 +1057,9 @@ // note that the image is still centered at 0, 0 in the xy plane + if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) + Logger.debug("modelCenterOffset + matrixTransform: " +modelCenterOffset+matrixTransform); + } void transformPoints(int count, Point3f[] angstroms, Point3i[] screens) { @@ -1729,7 +1730,7 @@ vibrationScale = 0; } - /*private*/ class VibrationThread extends Thread implements Runnable { + private class VibrationThread extends Thread implements Runnable { public void run() { long startTime = System.currentTimeMillis(); Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager10.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager10.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager10.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -45,6 +45,10 @@ //(s) screen coordinates = (m) * screenPixelsPerAngstrom //(p) plane coordinates = (s) / screenPixelCount + if (Float.isNaN(cameraDepth)) { + cameraDepth = cameraDepthSetting; + } + // distance from the front plane of the model at zoom=100, where p=0 cameraDistance = cameraDepth * screenPixelCount; //(s) @@ -72,6 +76,20 @@ observerOffset = 0; //(s) } + protected float getPerspectiveFactor(float z) { + // all z's SHOULD be >= 0 + // so the more positive z is, the smaller the screen scale + //new idea: phase out perspective depth when zoom is very large. + //zoomPercent 1000 or larger starts removing this effect + //we can go up to 200000 + float factor = (z <= 0 ? perspectiveScale : perspectiveScale / z); + if (zoomPercent >= MAXIMUM_ZOOM_PERSPECTIVE_DEPTH) + factor += (zoomPercent - MAXIMUM_ZOOM_PERSPECTIVE_DEPTH) + / (MAXIMUM_ZOOM_PERCENTAGE - MAXIMUM_ZOOM_PERSPECTIVE_DEPTH) + * (1 - factor); + return factor; + } + protected void calcSlabAndDepthValues() { slabValue = 0; depthValue = Integer.MAX_VALUE; Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager11.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager11.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager11.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -53,6 +53,11 @@ //(s) screen coordinates = (m) * screenPixelsPerAngstrom //(p) plane coordinates = (s) / screenPixelCount + if (Float.isNaN(cameraDepth)) { + cameraDepth = cameraDepthSetting; + zoomFactor = Float.NaN; + } + // factor to apply as part of the transform (not used here) cameraScaleFactor = 1; //unitless @@ -98,6 +103,10 @@ } } + protected float getPerspectiveFactor(float z) { + return (z <= 0 ? perspectiveScale : perspectiveScale / z); + } + protected void calcSlabAndDepthValues() { slabValue = 0; depthValue = Integer.MAX_VALUE; @@ -106,9 +115,10 @@ if (perspectiveDepth && visualRange > 0 && slabPercentSetting == 0) { slabValue = (int) observerOffset; depthValue = Integer.MAX_VALUE; + depthValue = (int)(radius + modelCenterOffset); if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) Logger.debug("\n" + "\nperspectiveScale: " + perspectiveScale - + " screenPixelCount: " + screenPixelCount + + " screenPixelCount: " + screenPixelCount + "\nmodelTrailingEdge: " + (modelCenterOffset + radius) + "\nmodelCenterOffset: " + modelCenterOffset + " radius: " + radius + "\nmodelLeadingEdge: " + (modelCenterOffset - radius) @@ -212,12 +222,13 @@ //no release from navigation mode if too far zoomed in! if (zoomPercent < 5 && !isNavigationMode) { - isNavigationMode = true; + isNavigationMode = perspectiveDepth = true; return; } if (isNavigationMode) { navMode = NAV_MODE_RESET; slabPercentSetting = 0; + perspectiveDepth = true; } else { slabPercentSetting = 100; } @@ -254,7 +265,7 @@ navMode = NAV_MODE_NEWXYZ; break; } - navigationZOffset -= 5 * multiplier; + navigationZOffset -= 5 *(viewer.getNavigationPeriodic() ? 1 : multiplier); navMode = NAV_MODE_NEWZ; break; case KeyEvent.VK_DOWN: @@ -268,7 +279,7 @@ navMode = NAV_MODE_NEWXYZ; break; } - navigationZOffset += 5 * multiplier; + navigationZOffset += 5 *(viewer.getNavigationPeriodic() ? 1 : multiplier); navMode = NAV_MODE_NEWZ; break; case KeyEvent.VK_LEFT: @@ -398,7 +409,7 @@ case NAV_MODE_NONE: //update fixed rotation offset and find the new 3D navigation center fixedRotationOffset.set(fixedTranslation); - //fall through + //fall through case NAV_MODE_NEWXY: // redefine the navigation center based on its old screen position findCenterAt(fixedRotationCenter, navigationOffset, navigationCenter); @@ -420,12 +431,39 @@ unTransformPoint(navigationOffset, navigationCenter); break; } + if (viewer.getNavigationCentered()) { + fixedRotationOffset.set(navigationCenter); + } matrixTransform(navigationCenter, referenceOffset); + if (viewer.getNavigationPeriodic()) { + // but if periodic, then the navigationCenter may have to be moved back a notch + viewer.toUnitCell(navigationCenter, null); + if (pointT.distance(navigationCenter) > 0.01) { + matrixTransform(navigationCenter, pointT); + float dz = referenceOffset.z - pointT.z; + //the new navigation center determines the navigationZOffset + navigationZOffset += dz; + calcCameraFactors(); + calcTransformMatrix(); + matrixTransform(navigationCenter, referenceOffset); + } + } transformPoint(fixedRotationCenter, fixedTranslation); + /* + if (viewer.getNavigationCentered()) { + fixedRotationCenter.set(navigationCenter); + navigationZOffset -= referenceOffset.z; + calcCameraFactors(); + calcTransformMatrix(); + matrixTransform(navigationCenter, referenceOffset); + transformPoint(fixedRotationCenter, fixedTranslation); + } + */ fixedRotationOffset.set(fixedTranslation); transformPoint(navigationCenter, navigationOffset); navigationOffset.z = observerOffset; navMode = NAV_MODE_NONE; + } /** Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-12-31 04:18:19 UTC (rev 6554) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-12-31 04:26:32 UTC (rev 6555) @@ -310,6 +310,7 @@ setSpecularPercent(global.specularPercent); setSpecularExponent(global.specularExponent); setSpecularPower(global.specularPower); + setZShade(false); } String listSavedStates() { @@ -670,7 +671,7 @@ //FrameRenderer transformManager.finalizeTransformParameters(); g3d.setSlabAndDepthValues(transformManager.slabValue, - transformManager.depthValue); + transformManager.depthValue, global.zShade); } Point3i transformPoint(Point3f pointAngstroms) { @@ -929,6 +930,14 @@ return global.getSpecularState(); } + private void setZShade(boolean TF) { + global.zShade = TF; + } + + boolean getZShade() { + return global.zShade; + } + private void setAmbientPercent(int ambientPercent) { //Eval colorManager.setAmbientPercent(ambientPercent); @@ -1727,13 +1736,20 @@ return modelManager.findAtomsInRectangle(rectRubberBand); } - void convertFractionalCoordinates(Point3f pt) { + void toCartesian(Point3f pt) { int modelIndex = getCurrentModelIndex(); if (modelIndex < 0) return; - modelManager.convertFractionalCoordinates(modelIndex, pt); + modelManager.toCartesian(modelIndex, pt); } + void toUnitCell(Point3f pt, Point3f offset) { + int modelIndex = getCurrentModelIndex(); + if (modelIndex < 0) + return; + modelManager.toUnitCell(modelIndex, pt, offset); + } + public void setCenterSelected() { //depricated setCenterBitSet(selectionManager.bsSelection, true); @@ -3420,6 +3436,18 @@ boolean notFound = false; while (true) { ///11.1/// + if (key.equalsIgnoreCase("navigationCentered")) { + setNavigationCentered(value); + break; + } + if (key.equalsIgnoreCase("navigationPeriodic")) { + setNavigationPeriodic(value); + break; + } + if (key.equalsIgnoreCase("zShade")) { + setZShade(value); + break; + } if (key.equalsIgnoreCase("drawHover")) { setDrawHover(value); break; @@ -3960,6 +3988,22 @@ global.hideNameInPopup = hideNameInPopup; } + private void setNavigationPeriodic(boolean TF) { + global.navigationPeriodic = TF; + } + + boolean getNavigationPeriodic() { + return global.navigationPeriodic; + } + + private void setNavigationCentered(boolean TF) { + global.navigationCentered = TF; + } + + boolean getNavigationCentered() { + return global.navigationCentered; + } + private void setNavigationMode(boolean TF) { global.navigationMode = TF; if (TF && !transformManager.canNavigate()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |