From: <ha...@us...> - 2006-11-19 19:00:50
|
Revision: 6272 http://svn.sourceforge.net/jmol/?rev=6272&view=rev Author: hansonr Date: 2006-11-19 11:00:48 -0800 (Sun, 19 Nov 2006) Log Message: ----------- displayModelIndex/currentModelIndex refactoring and adjustments for better background model action Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Dipole.java trunk/Jmol/src/org/jmol/viewer/Dipoles.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/Mps.java trunk/Jmol/src/org/jmol/viewer/RepaintManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/viewer/Dipole.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Dipole.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/Dipole.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -74,9 +74,7 @@ Dipole(Viewer viewer, String thisID, String dipoleInfo, Graphics3D g3d, short colix, short mad, boolean visible) { this.viewer = viewer; - this.modelIndex = viewer.getDisplayModelIndex(); - if (this.modelIndex < -1) - this.modelIndex = -2 - this.modelIndex; + this.modelIndex = viewer.getCurrentModelIndex(); this.thisID = thisID; this.dipoleInfo = dipoleInfo; this.g3d = g3d; Modified: trunk/Jmol/src/org/jmol/viewer/Dipoles.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Dipoles.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/Dipoles.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -481,7 +481,7 @@ if (currentDipole == null) return; currentDipole.visible = true; - currentDipole.modelIndex = viewer.getDisplayModelIndex(); + currentDipole.modelIndex = viewer.getCurrentModelIndex(); } void setVisibilityFlags(BitSet bs) { Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -3462,10 +3462,12 @@ void configuration() throws ScriptException { if (viewer.getDisplayModelIndex() <= -2) evalError(GT._("{0} not allowed with background model displayed", - "\"CONFIGURATION\"")); + "\"CONFIGURATION\"")); BitSet bsConfigurations; if (statementLength == 1) { bsConfigurations = viewer.setConformation(); + viewer.addStateScript("select " + + StateManager.escape(viewer.getSelectionSet())); viewer.addStateScript("configuration;"); } else { checkLength2(); @@ -3903,13 +3905,13 @@ if (offset == statementLength - 1) { if (isAll) { viewer.setAnimationRange(-1, -1); - viewer.setDisplayModelIndex(-1); + viewer.setCurrentModelIndex(-1); return; } int modelIndex = (useModelNumber ? viewer .getModelNumberIndex(frameNumber) : frameNumber - 1); if (!isPlay && !isRange || modelIndex >= 0) { - viewer.setDisplayModelIndex(modelIndex); + viewer.setCurrentModelIndex(modelIndex); } if (isPlay || isRange) { if (isRange || frameNumber2 >= 0) { Modified: trunk/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -1710,7 +1710,7 @@ int thisFrame = 0; void addStateScript(String script) { - int iFrame = viewer.getDisplayModelIndex(); + int iFrame = viewer.getCurrentModelIndex(); if (thisFrame != iFrame) { thisFrame = iFrame; script = "frame " + this.getModelNumber(iFrame) +";\n" + script; Modified: trunk/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ModelManager.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/ModelManager.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -1322,7 +1322,7 @@ } String getUnitCellInfoText() { - int modelIndex = viewer.getDisplayModelIndex(); + int modelIndex = viewer.getCurrentModelIndex(); if (modelIndex < 0) return "no single current model"; if (frame.cellInfos == null) @@ -1333,7 +1333,7 @@ String getSpaceGroupInfoText(String spaceGroup) { SpaceGroup sg; String strOperations = ""; - int modelIndex = viewer.getDisplayModelIndex(); + int modelIndex = viewer.getCurrentModelIndex(); if (spaceGroup == null) { if (modelIndex < 0) return "no single current model"; Modified: trunk/Jmol/src/org/jmol/viewer/Mps.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Mps.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/Mps.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -169,7 +169,7 @@ } void setModelClickability() { - int displayModelIndex = viewer.getDisplayModelIndex(); + int displayModelIndex = viewer.getCurrentModelIndex(); modelVisibilityFlags = (displayModelIndex >= 0 && displayModelIndex != modelIndex ? 0 : myVisibilityFlag); Modified: trunk/Jmol/src/org/jmol/viewer/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -41,16 +41,16 @@ frameRenderer = new FrameRenderer(viewer); } - int displayModelIndex = 0; - void setDisplayModelIndex(int modelIndex) { + int currentModelIndex = 0; + void setCurrentModelIndex(int modelIndex) { Frame frame = viewer.getFrame(); if (frame == null || modelIndex < 0 || modelIndex >= frame.getModelCount()) - displayModelIndex = -1; + currentModelIndex = -1; else - displayModelIndex = modelIndex; - if (displayModelIndex == -1) + currentModelIndex = modelIndex; + if (currentModelIndex == -1) setBackgroundModelIndex(-1); viewer.setTainted(true); setStatusFrameChanged(); @@ -58,7 +58,7 @@ } void setStatusFrameChanged() { - viewer.setStatusFrameChanged(animationOn ? -2 - displayModelIndex : displayModelIndex); + viewer.setStatusFrameChanged(animationOn ? -2 - currentModelIndex : currentModelIndex); } int backgroundModelIndex = -1; @@ -66,7 +66,7 @@ // no background unless only a SINGLE model is being displayed (for now) Frame frame = viewer.getFrame(); if (frame == null || modelIndex < 0 || modelIndex >= frame.getModelCount() || - displayModelIndex == -1) + currentModelIndex == -1) modelIndex = -1; backgroundModelIndex = modelIndex; viewer.setTainted(true); @@ -80,8 +80,8 @@ private void setFrameRangeVisible() { bsVisibleFrames.clear(); - if (displayModelIndex >= 0) { - bsVisibleFrames.set(displayModelIndex); + if (currentModelIndex >= 0) { + bsVisibleFrames.set(currentModelIndex); if (backgroundModelIndex >= 0) bsVisibleFrames.set(backgroundModelIndex); return; @@ -179,7 +179,7 @@ void clearAnimation() { setAnimationOn(false); - setDisplayModelIndex(0); + setCurrentModelIndex(0); setAnimationDirection(1); setAnimationFps(10); setAnimationReplayMode(0, 0, 0); @@ -192,9 +192,9 @@ info.put("lastModelIndex", new Integer(lastModelIndex)); info.put("animationDirection", new Integer(animationDirection)); info.put("currentDirection", new Integer(currentDirection)); - info.put("displayModelIndex", new Integer(displayModelIndex)); - info.put("displayModelNumber", new Integer(displayModelIndex >=0 ? viewer.getModelNumber(displayModelIndex) : 0)); - info.put("displayModelName", (displayModelIndex >=0 ? viewer.getModelName(displayModelIndex) : "")); + info.put("displayModelIndex", new Integer(currentModelIndex)); + info.put("displayModelNumber", new Integer(currentModelIndex >=0 ? viewer.getModelNumber(currentModelIndex) : 0)); + info.put("displayModelName", (currentModelIndex >=0 ? viewer.getModelName(currentModelIndex) : "")); info.put("animationFps", new Integer(animationFps)); info.put("animationReplayMode", new Integer(animationReplayMode)); info.put("firstFrameDelay", new Float(firstFrameDelay)); @@ -212,7 +212,7 @@ + viewer.getModelNumber(modelCount - 1) + ";\n"); if (backgroundModelIndex >= 0) commands.append("background model " + backgroundModelIndex + ";\n"); - if (displayModelIndex >= 0) { + if (currentModelIndex >= 0) { commands.append("frame RANGE " + viewer.getModelNumber(firstModelIndex) + " " + viewer.getModelNumber(lastModelIndex) + ";\n"); commands.append("animation DIRECTION " @@ -220,7 +220,7 @@ commands.append("animation " + (animationOn ? "ON" : "OFF") + ";\n"); if (animationOn && animationPaused) commands.append("animation PAUSE;\n"); - commands.append("frame " + viewer.getModelNumber(displayModelIndex) + ";\n"); + commands.append("frame " + viewer.getModelNumber(currentModelIndex) + ";\n"); } else { commands.append("frame ALL;\n"); } @@ -309,7 +309,7 @@ int intAnimThread = 0; void resumeAnimation() { - if(displayModelIndex < 0) + if(currentModelIndex < 0) setAnimationRange(firstModelIndex, lastModelIndex); if (modelCount <= 1) { animationOn = false; @@ -329,7 +329,7 @@ } void rewindAnimation() { - setDisplayModelIndex(animationDirection > 0 ? firstModelIndex : lastModelIndex); + setCurrentModelIndex(animationDirection > 0 ? firstModelIndex : lastModelIndex); currentDirection = 1; } @@ -339,7 +339,7 @@ boolean setAnimationRelative(int direction) { int frameStep = this.frameStep * direction * currentDirection; - int modelIndexNext = displayModelIndex + frameStep; + int modelIndexNext = currentModelIndex + frameStep; boolean isDone = (modelIndexNext > firstModelIndex && modelIndexNext > lastModelIndex || modelIndexNext < firstModelIndex && modelIndexNext < lastModelIndex); @@ -372,7 +372,7 @@ //Logger.debug("next="+modelIndexNext+" dir="+currentDirection+" isDone="+isDone); if (modelIndexNext < 0 || modelIndexNext >= modelCount) return false; - setDisplayModelIndex(modelIndexNext); + setCurrentModelIndex(modelIndexNext); return true; } @@ -398,14 +398,14 @@ if (sleepTime > 0) Thread.sleep(sleepTime); while (! isInterrupted()) { - if (displayModelIndex == framePointer) { + if (currentModelIndex == framePointer) { targetTime += firstFrameDelayMs; sleepTime = targetTime - (int)(System.currentTimeMillis() - timeBegin); if (sleepTime > 0) Thread.sleep(sleepTime); } - if (displayModelIndex == framePointer2) { + if (currentModelIndex == framePointer2) { targetTime += lastFrameDelayMs; sleepTime = targetTime - (int)(System.currentTimeMillis() - timeBegin); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-11-19 18:24:01 UTC (rev 6271) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-11-19 19:00:48 UTC (rev 6272) @@ -1332,7 +1332,7 @@ setShapeSize(JmolConstants.SHAPE_VECTORS, global.defaultVectorMad); setFrankOn(global.frankOn); repaintManager.initializePointers(1); - setDisplayModelIndex(0); + setCurrentModelIndex(0); setBackgroundModelIndex(-1); setTainted(true); } @@ -1602,7 +1602,7 @@ } void convertFractionalCoordinates(Point3f pt) { - int modelIndex = getDisplayModelIndex(); + int modelIndex = getCurrentModelIndex(); if (modelIndex < 0) return; modelManager.convertFractionalCoordinates(modelIndex, pt); @@ -1820,7 +1820,7 @@ // AKA "configuration" public BitSet setConformation(int conformationIndex) { - return modelManager.setConformation(getDisplayModelIndex(), + return modelManager.setConformation(getCurrentModelIndex(), conformationIndex); } @@ -1837,7 +1837,7 @@ } boolean hbondsAreVisible() { - return modelManager.hbondsAreVisible(getDisplayModelIndex()); + return modelManager.hbondsAreVisible(getCurrentModelIndex()); } public boolean havePartialCharges() { @@ -1853,14 +1853,14 @@ } void setCurrentUnitCellOffset(int offset) { - int modelIndex = getDisplayModelIndex(); + int modelIndex = getCurrentModelIndex(); if (modelManager.setUnitCellOffset(modelIndex, offset)) global.setParameterValue("_frame " + getModelNumber(modelIndex) + "; set unitcell", offset); } void setCurrentUnitCellOffset(Point3f pt) { - int modelIndex = getDisplayModelIndex(); + int modelIndex = getCurrentModelIndex(); if (modelManager.setUnitCellOffset(modelIndex, pt)) global.setParameterValue("_frame " + getModelNumber(modelIndex) + "; set unitcell", StateManager.escape(pt)); @@ -2102,19 +2102,19 @@ refresh(0, "Viewer:rewindAnimation()"); } - void setDisplayModelIndex(int modelIndex) { + void setCurrentModelIndex(int modelIndex) { //Eval //initializeModel - repaintManager.setDisplayModelIndex(modelIndex); + repaintManager.setCurrentModelIndex(modelIndex); } int getCurrentModelIndex() { - return repaintManager.displayModelIndex; + return repaintManager.currentModelIndex; } public int getDisplayModelIndex() { // modified to indicate if there is also a background model index - int modelIndex = repaintManager.displayModelIndex; + int modelIndex = repaintManager.currentModelIndex; int backgroundIndex = getBackgroundModelIndex(); return (backgroundIndex >= 0 ? -2 - modelIndex : modelIndex); } @@ -2279,7 +2279,7 @@ g3d.beginRendering(rectClip.x, rectClip.y, rectClip.width, rectClip.height, matrixRotate, antialias); repaintManager.render(g3d, rectClip, modelManager.getFrame(), - repaintManager.displayModelIndex); + repaintManager.currentModelIndex); // mth 2003-01-09 Linux Sun JVM 1.4.2_02 // Sun is throwing a NullPointerExceptions inside graphics routines // while the window is resized. @@ -2291,13 +2291,13 @@ g3d.beginRendering(rectClip.x, rectClip.y, rectClip.width, rectClip.height, transformManager.getStereoRotationMatrix(true), antialias); repaintManager.render(g3d, rectClip, modelManager.getFrame(), - repaintManager.displayModelIndex); + repaintManager.currentModelIndex); g3d.endRendering(); g3d.snapshotAnaglyphChannelBytes(); g3d.beginRendering(rectClip.x, rectClip.y, rectClip.width, rectClip.height, transformManager.getStereoRotationMatrix(false), antialias); repaintManager.render(g3d, rectClip, modelManager.getFrame(), - repaintManager.displayModelIndex); + repaintManager.currentModelIndex); g3d.endRendering(); switch (stereoMode) { case JmolConstants.STEREO_REDCYAN: @@ -4211,11 +4211,11 @@ } Point3f getDrawObjectCenter(String axisID) { - return modelManager.getSpinCenter(axisID, repaintManager.displayModelIndex); + return modelManager.getSpinCenter(axisID, repaintManager.currentModelIndex); } Vector3f getDrawObjectAxis(String axisID) { - return modelManager.getSpinAxis(axisID, repaintManager.displayModelIndex); + return modelManager.getSpinAxis(axisID, repaintManager.currentModelIndex); } Vector3f getModelDipole() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |