From: <ha...@us...> - 2007-03-23 10:44:24
|
Revision: 7206 http://svn.sourceforge.net/jmol/?rev=7206&view=rev Author: hansonr Date: 2007-03-23 03:44:22 -0700 (Fri, 23 Mar 2007) Log Message: ----------- 11.1.27 fixes two state bugs: 1) dots/geosurface not being saved properly in state 2) animation parameters not being saved properly in state Modified Paths: -------------- trunk/Jmol/build.xml trunk/Jmol/src/org/jmol/viewer/Dots.java trunk/Jmol/src/org/jmol/viewer/EnvelopeCalculation.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/JmolConstants.java trunk/Jmol/src/org/jmol/viewer/Mmset.java trunk/Jmol/src/org/jmol/viewer/RepaintManager.java Modified: trunk/Jmol/build.xml =================================================================== --- trunk/Jmol/build.xml 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/build.xml 2007-03-23 10:44:22 UTC (rev 7206) @@ -14,7 +14,7 @@ <property name="deprecation" value="off" /> <property name="optimization" value="off" /> - <property name="version" value="11.1.26" /> + <property name="version" value="11.1.27" /> <property name="tests.source.dir" value="source-tests" /> <property name="lib.dir" value="jars" /> Modified: trunk/Jmol/src/org/jmol/viewer/Dots.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Dots.java 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/src/org/jmol/viewer/Dots.java 2007-03-23 10:44:22 UTC (rev 7206) @@ -78,41 +78,47 @@ initialize(); return; } - + if ("translucency" == propertyName) { - return; // no translucent dots + return; // no translucent dots } if ("ignore" == propertyName) { - ec.setIgnore((BitSet)value); + ec.setIgnore((BitSet) value); return; } if ("select" == propertyName) { - bsSelected = (BitSet)value; + bsSelected = (BitSet) value; return; } // next four are for serialization if ("radius" == propertyName) { - thisRadius = ((Float)value).floatValue(); + thisRadius = ((Float) value).floatValue(); return; } if ("colorRGB" == propertyName) { - thisArgb = ((Integer)value).intValue(); + thisArgb = ((Integer) value).intValue(); return; } if ("atom" == propertyName) { - thisAtom = ((Integer)value).intValue(); + thisAtom = ((Integer) value).intValue(); atoms[thisAtom].setShapeVisibility(myVisibilityFlag, true); ec.dotsConvexMax = Math.max(thisAtom + 1, ec.dotsConvexMax); - return; + return; } if ("dots" == propertyName) { isActive = true; - ec.setFromBits(thisAtom, (BitSet)value); - if (mads == null) + ec.setFromBits(thisAtom, (BitSet) value); + atoms[thisAtom].setShapeVisibility(myVisibilityFlag, true); + if (mads == null) { mads = new short[atomCount]; + for (int i = 0; i < atomCount; i++) + if (atoms[i].isShapeVisible(myVisibilityFlag)) + mads[i] = (short) (ec.getAppropriateRadius(atoms[i]) * 1000); + ec.setMads(mads); + } mads[thisAtom] = (short) (thisRadius * 1000f); if (colixes == null) { colixes = new short[atomCount]; @@ -121,7 +127,7 @@ colixes[thisAtom] = Graphics3D.getColix(thisArgb); //all done! return; - } + } super.setProperty(propertyName, value, bs); } @@ -204,8 +210,8 @@ atoms[i].setShapeVisibility(myVisibilityFlag, bsOn.get(i)); } if (newSet) { + mads = null; ec.newSet(); - mads = null; lastSolventRadius = addRadius; } // always delete old surfaces for selected atoms @@ -255,19 +261,24 @@ int atomCount = viewer.getAtomCount(); String type = (isSurface ? "geoSurface " : "dots "); for (int i = 0; i < atomCount; i++) { - if (ec.dotsConvexMaps[i] == null) + if (ec.dotsConvexMaps[i] == null + || !atoms[i].isShapeVisible(myVisibilityFlag)) continue; if (!isSurface && bsColixSet != null && bsColixSet.get(i)) - setStateInfo(temp, i, getColorCommand(type, paletteIDs[i], colixes[i])); + setStateInfo(temp, i, getColorCommand(type, paletteIDs[i], colixes[i])); BitSet bs = new BitSet(); int[] map = ec.dotsConvexMaps[i]; int iDot = map.length << 5; + int n = 0; while (--iDot >= 0) - if (EnvelopeCalculation.getBit(map, iDot)) + if (EnvelopeCalculation.getBit(map, iDot)) { + n++; bs.set(iDot); - appendCmd(s, type + i + " radius " - + ec.getAppropriateRadius(atoms[i]) + " " - + StateManager.escape(bs)); + } + if (n > 0) { + appendCmd(s, type + i + " radius " + ec.getAppropriateRadius(atoms[i]) + + " " + StateManager.escape(bs)); + } } s.append(getShapeCommands(temp, null, atomCount)); return s.toString(); Modified: trunk/Jmol/src/org/jmol/viewer/EnvelopeCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/EnvelopeCalculation.java 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/src/org/jmol/viewer/EnvelopeCalculation.java 2007-03-23 10:44:22 UTC (rev 7206) @@ -185,6 +185,10 @@ boolean isCalcOnly; + void setMads(short[] mads) { + this.mads = mads; + } + void setFromBits(int index, BitSet bs) { setAllBits(geodesicMap, geodesicCount); for (int iDot = geodesicCount; --iDot >= 0;) @@ -199,7 +203,7 @@ System.arraycopy(geodesicMap, 0, map, 0, count); } dotsConvexMaps[index] = map; - + dotsConvexMax = Math.max(dotsConvexMax, index); } void setIgnore(BitSet value) { @@ -223,6 +227,7 @@ dotsConvexMax = 0; dotsConvexMaps = null; radiusP = diameterP = 0; + mads = null; } void calculate(float addRadius, float setRadius, float scale, Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-03-23 10:44:22 UTC (rev 7206) @@ -4906,10 +4906,10 @@ float startDelay = 1, endDelay = 1; if (statementLength > 5) badArgumentCount(); - int animationMode = 0; + int animationMode = RepaintManager.ANIMATION_ONCE; switch (getToken(2).tok) { case Token.loop: - ++animationMode; + animationMode = RepaintManager.ANIMATION_LOOP; break; case Token.identifier: String cmd = parameterAsString(2); @@ -4918,7 +4918,7 @@ break; } if (cmd.equalsIgnoreCase("palindrome")) { - animationMode = 2; + animationMode = RepaintManager.ANIMATION_PALINDROME; break; } invalidArgument(); Modified: trunk/Jmol/src/org/jmol/viewer/JmolConstants.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2007-03-23 10:44:22 UTC (rev 7206) @@ -34,13 +34,19 @@ // for now, just update this by hand // perhaps use ant filter later ... but mth doesn't like it :-( public final static String copyright = "(C) 2007 Jmol Development"; - public final static String version = "11.1.26"; + public final static String version = "11.1.27"; /* * * * * + 11.1.27 + fixes two state bugs: + 1) dots/geosurface not being saved properly in state + 2) animation parameters not being saved properly in state + + 11.1.26 fixes two nasty bugs relating to isosurfaces and JVXL files. -- JVXL files created from molecular orbitals will show up with no color Modified: trunk/Jmol/src/org/jmol/viewer/Mmset.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Mmset.java 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/src/org/jmol/viewer/Mmset.java 2007-03-23 10:44:22 UTC (rev 7206) @@ -327,6 +327,7 @@ if (models[0].modelNumber < 1000000) { for (int i = 0; i < baseModelCount; i++) { models[i].modelNumber = 1000000 + i + 1; + models[i].modelNumberDotted = "1." + (i + 1); models[i].modelTag = "" + models[i].modelNumber; } } @@ -336,6 +337,7 @@ modelnumber += 1000000; for (int i = baseModelCount; i < modelCount; i++) { models[i].modelNumber += modelnumber; + models[i].modelNumberDotted = (modelnumber / 1000000) + "." + (modelnumber % 1000000); models[i].modelTag = "" + models[i].modelNumber; } } Modified: trunk/Jmol/src/org/jmol/viewer/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2007-03-23 07:28:46 UTC (rev 7205) +++ trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2007-03-23 10:44:22 UTC (rev 7206) @@ -163,12 +163,11 @@ int firstModelIndex; int lastModelIndex; int frameStep; - int modelCount; + void initializePointers(int frameStep) { firstModelIndex = 0; - modelCount = (frameStep == 0 ? 0 : viewer.getModelCount()); - lastModelIndex = modelCount - 1; - this.frameStep = frameStep; + lastModelIndex = (frameStep == 0 ? 0 : viewer.getModelCount()) - 1; + this.frameStep = frameStep; } void clear() { @@ -195,7 +194,7 @@ info.put("displayModelNumber", new Integer(currentModelIndex >=0 ? viewer.getModelNumberDotted(currentModelIndex) : "0")); info.put("displayModelName", (currentModelIndex >=0 ? viewer.getModelName(currentModelIndex) : "")); info.put("animationFps", new Integer(animationFps)); - info.put("animationReplayMode", new Integer(animationReplayMode)); + info.put("animationReplayMode", getAnimationModeName()); info.put("firstFrameDelay", new Float(firstFrameDelay)); info.put("lastFrameDelay", new Float(lastFrameDelay)); info.put("animationOn", new Boolean(animationOn)); @@ -204,26 +203,32 @@ } String getState() { + int modelCount = viewer.getModelCount(); if (modelCount < 2) return ""; - StringBuffer commands = new StringBuffer("# frame state;\n# modelCount "). - append(modelCount).append(";\n# first "). - append(viewer.getModelNumberDotted(0)).append(";\n# last "). - append(viewer.getModelNumberDotted(modelCount - 1)).append(";\n"); + StringBuffer commands = new StringBuffer("# frame state;\n# modelCount ") + .append(modelCount).append(";\n# first ").append( + viewer.getModelNumberDotted(0)).append(";\n# last ").append( + viewer.getModelNumberDotted(modelCount - 1)).append(";\n"); if (backgroundModelIndex >= 0) - commands.append("background model ").append(backgroundModelIndex).append(";\n"); - if (true || currentModelIndex >= 0) { - commands.append("frame RANGE " + viewer.getModelNumberDotted(firstModelIndex) - + " " + viewer.getModelNumberDotted(lastModelIndex) + ";\n"); - commands.append("animation DIRECTION " - + (animationDirection == 1 ? "+1" : "-1") + ";\n"); - commands.append("animation " + (animationOn ? "ON" : "OFF") + ";\n"); - if (animationOn && animationPaused) - commands.append("animation PAUSE;\n"); - commands.append("frame " + viewer.getModelNumberDotted(currentModelIndex) + ";\n"); - } else { - commands.append("frame ALL;\n"); - } + commands.append("background model ").append(backgroundModelIndex).append( + ";\n"); + commands.append( + "frame RANGE " + viewer.getModelNumberDotted(firstModelIndex) + " " + + viewer.getModelNumberDotted(lastModelIndex)).append(";\n"); + commands.append( + "animation DIRECTION " + (animationDirection == 1 ? "+1" : "-1")) + .append(";\n"); + commands.append("animation MODE " + getAnimationModeName()).append(" ") + .append(firstFrameDelay).append(" ").append(lastFrameDelay).append( + ";\n"); + commands.append("frame " + viewer.getModelNumberDotted(currentModelIndex) + + ";\n"); + commands.append( + "animation " + (!animationOn ? "OFF" : currentDirection == 1 ? "PLAY" + : "PLAYREV")).append(";\n"); + if (animationOn && animationPaused) + commands.append("animation PAUSE;\n"); commands.append("\n"); return commands.toString(); } @@ -246,6 +251,11 @@ // 0 = once // 1 = loop // 2 = palindrome + + final static int ANIMATION_ONCE = 0; + final static int ANIMATION_LOOP = 1; + final static int ANIMATION_PALINDROME = 2; + int animationReplayMode = 0; float firstFrameDelay, lastFrameDelay; int firstFrameDelayMs, lastFrameDelayMs; @@ -256,14 +266,14 @@ firstFrameDelayMs = (int)(this.firstFrameDelay * 1000); this.lastFrameDelay = lastFrameDelay > 0 ? lastFrameDelay : 0; lastFrameDelayMs = (int)(this.lastFrameDelay * 1000); - if (animationReplayMode >= 0 && animationReplayMode <= 2) + if (animationReplayMode >= ANIMATION_ONCE && animationReplayMode <= ANIMATION_PALINDROME) this.animationReplayMode = animationReplayMode; else Logger.error("invalid animationReplayMode:" + animationReplayMode); } void setAnimationRange(int framePointer, int framePointer2) { - modelCount = viewer.getModelCount(); + int modelCount = viewer.getModelCount(); if (framePointer < 0) framePointer = 0; if (framePointer2 < 0) framePointer2 = modelCount; if (framePointer >= modelCount) framePointer = modelCount - 1; @@ -311,7 +321,7 @@ void resumeAnimation() { if(currentModelIndex < 0) setAnimationRange(firstModelIndex, lastModelIndex); - if (modelCount <= 1) { + if (viewer.getModelCount() <= 1) { animationOn = false; return; } @@ -346,39 +356,49 @@ int modelIndexNext = currentModelIndex + frameStep; boolean isDone = (modelIndexNext > firstModelIndex && modelIndexNext > lastModelIndex || modelIndexNext < firstModelIndex && modelIndexNext < lastModelIndex); - - /* Logger.debug("setAnimationRelative: " + " firstModelIndex=" + firstModelIndex + " displayModelIndex=" + displayModelIndex + " lastModelIndex=" + lastModelIndex + " currentDirection=" + currentDirection + + " animationDirection=" + animationDirection + " direction=" + direction + " isDone="+isDone + " modelIndexNext=" + modelIndexNext + - " modelCount=" + modelCount + + " modelCount=" + viewer.getModelCount() + " animationReplayMode=" + animationReplayMode + " animationDirection=" + animationDirection); */ if (isDone) { switch (animationReplayMode) { - case 0: //once through + case ANIMATION_ONCE: return false; - case 1: //repeat + case ANIMATION_LOOP: modelIndexNext = (animationDirection > 0 ? firstModelIndex : lastModelIndex); break; - case 2: //palindrome + case ANIMATION_PALINDROME: currentDirection = -currentDirection; modelIndexNext -= 2 * frameStep; } } //Logger.debug("next="+modelIndexNext+" dir="+currentDirection+" isDone="+isDone); - if (modelIndexNext < 0 || modelIndexNext >= modelCount) + if (modelIndexNext < 0 || modelIndexNext >= viewer.getModelCount()) return false; setCurrentModelIndex(modelIndexNext); return true; } + + String getAnimationModeName() { + switch (animationReplayMode) { + case ANIMATION_LOOP: + return "LOOP"; + case ANIMATION_PALINDROME: + return "PALINDROME"; + default: + return "ONCE"; + } + } class AnimationThread extends Thread implements Runnable { final int framePointer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |