From: <ha...@us...> - 2006-11-15 21:43:25
|
Revision: 6218 http://svn.sourceforge.net/jmol/?rev=6218&view=rev Author: hansonr Date: 2006-11-15 13:43:23 -0800 (Wed, 15 Nov 2006) Log Message: ----------- save state: vectors, label defaults, isosurface issues, more Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Draw.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Frame.java trunk/Jmol/src/org/jmol/viewer/Isosurface.java trunk/Jmol/src/org/jmol/viewer/Labels.java trunk/Jmol/src/org/jmol/viewer/LcaoCartoon.java trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java trunk/Jmol/src/org/jmol/viewer/Pmesh.java trunk/Jmol/src/org/jmol/viewer/RepaintManager.java trunk/Jmol/src/org/jmol/viewer/Sticks.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Vectors.java Modified: trunk/Jmol/src/org/jmol/viewer/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Draw.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Draw.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -40,6 +40,7 @@ // bob hanson ha...@st... 3/2006 void initShape() { + super.initShape(); myType = "draw"; } Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -3694,7 +3694,6 @@ negative = true; else if (statement[2].tok != Token.plus) invalidArgument(); - if (statement[3].tok != Token.integer) invalidArgument(); int direction = statement[3].intValue; Modified: trunk/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -3300,6 +3300,9 @@ for (int i = 0; i < len; i++) commands.append(fs.get(i) + "\n"); + viewer.loadShape(JmolConstants.SHAPE_LABELS); + ((Labels)shapes[JmolConstants.SHAPE_LABELS]).getShapeState(commands); + commands.append("\n# model state:\n"); // shape construction Modified: trunk/Jmol/src/org/jmol/viewer/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Isosurface.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Isosurface.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -115,6 +115,7 @@ class Isosurface extends MeshCollection { void initShape() { + super.initShape(); myType = "isosurface"; } @@ -898,9 +899,11 @@ } boolean getScriptBitSets() { - int i; - if ((i = script.indexOf("# ({")) < 0) + if (script == null) return false; + int i = script.indexOf("# ({"); + if (i < 0) + return false; int j = script.indexOf("})", i); bsSelected = StateManager.decodeBitset(script.substring(i + 3, j + 1)); if ((i = script.indexOf("({", j)) < 0) @@ -5043,7 +5046,8 @@ } void setModelIndex() { - script = fixScript(); + if (script != null) + script = fixScript(); setModelIndex(atomIndex); currentMesh.ptCenter.set(center); currentMesh.title = title; Modified: trunk/Jmol/src/org/jmol/viewer/Labels.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Labels.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Labels.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -52,9 +52,9 @@ byte defaultFontId; short defaultColix; short defaultBgcolix; + short defaultPaletteID; int defaultAlignment; int defaultPointer; - int defaultPaletteID; int defaultZpos; byte zeroFontId; int zeroOffset; @@ -90,7 +90,7 @@ setColix(i, colix, pid, n++); if (n == 0 || !defaultsOnlyForNone) { defaultColix = colix; - defaultPaletteID = pid; + defaultPaletteID = (short) pid; } return; } @@ -306,6 +306,7 @@ final static int FLAGS = 0x3F; void setOffsets(int i, int offset, int n) { + //entry is just xxxxxxxxyyyyyyyy // xxxxxxxxyyyyyyyyfgaabp // x-align y-align ||| ||_pointer on // ||| |_background pointer color @@ -388,6 +389,25 @@ } } + void getShapeState(StringBuffer s) { + appendCmd(s, "\n# label defaults:\nselect none"); + appendCmd(s, getColorCommand("label", (short) defaultPaletteID, + defaultColix)); + appendCmd(s, "background label " + encodeColor(defaultBgcolix)); + appendCmd(s, "set labelOffset " + Text.getXOffset(defaultOffset) + " " + + (-Text.getYOffset(defaultOffset))); + String align = Text.getAlignment(defaultAlignment); + appendCmd(s, "set labelAlignment " + (align.length() < 5 ? "left" : align)); + String pointer = Text.getPointer(defaultPointer); + appendCmd(s, "set labelPointer " + + (pointer.length() == 0 ? "off" : pointer)); + if ((defaultOffset & FRONT_FLAG) != 0) + appendCmd(s, "set labelFront"); + if ((defaultOffset & GROUP_FLAG) != 0) + appendCmd(s, "set labelGroup"); + appendCmd(s, getFontCommand("label", Font3D.getFont3D(defaultFontId))); + } + String getShapeState() { Hashtable temp = new Hashtable(); Hashtable temp2 = new Hashtable(); @@ -396,7 +416,8 @@ continue; setStateInfo(temp, i, "label " + formats[i]); if (bsColixSet != null && bsColixSet.get(i)) - setStateInfo(temp2, i, getColorCommand("label", paletteIDs[i], colixes[i])); + setStateInfo(temp2, i, getColorCommand("label", paletteIDs[i], + colixes[i])); if (bsBgColixSet != null && bsBgColixSet.get(i)) setStateInfo(temp2, i, "background label " + encodeColor(bgcolixes[i])); if (offsets != null && offsets.length > i) { @@ -418,9 +439,6 @@ if (bsFontSet != null && bsFontSet.get(i)) setStateInfo(temp2, i, getFontCommand("label", Font3D .getFont3D(fids[i]))); - - // need defaults here as well - // set label none;..... } return getShapeCommands(temp, temp2, frame.atomCount); } Modified: trunk/Jmol/src/org/jmol/viewer/LcaoCartoon.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/LcaoCartoon.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/LcaoCartoon.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -36,6 +36,7 @@ // these are globals, stored here and only passed on when the they are needed. void initShape() { + super.initShape(); myType = "lcaoCartoon"; } Modified: trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -36,9 +36,9 @@ class MolecularOrbital extends Isosurface { void initShape() { + super.initShape(); myType = "molecularOrbital"; super.setProperty("thisID", "mo", null); - return; } // these are globals, stored here and only passed on when the they are needed. Modified: trunk/Jmol/src/org/jmol/viewer/Pmesh.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Pmesh.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Pmesh.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -33,6 +33,7 @@ boolean isOnePerLine; void initShape() { + super.initShape(); myType = "pmesh"; } Modified: trunk/Jmol/src/org/jmol/viewer/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -208,15 +208,23 @@ String getState() { if (modelCount < 2) return ""; - StringBuffer commands = new StringBuffer("# frame states:\n"); - if (displayModelIndex >= 0) - commands.append("frame " + viewer.getModelNumber(displayModelIndex)); - else - commands.append("frame all"); + StringBuffer commands = new StringBuffer("# frame states: (modelCount=" + + modelCount + " first=" + viewer.getModelNumber(0) + " last=" + + viewer.getModelNumber(modelCount - 1) + ")\n"); if (backgroundModelIndex >= 0) - commands.append(";background model " + backgroundModelIndex); - commands.append(";\n"); - // frame range? + commands.append("background model " + backgroundModelIndex + ";\n"); + if (displayModelIndex >= 0) { + commands.append("frame RANGE " + viewer.getModelNumber(firstModelIndex) + + " " + viewer.getModelNumber(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.getModelNumber(displayModelIndex) + ";\n"); + } else { + commands.append("frame ALL;\n"); + } commands.append("\n"); return commands.toString(); } Modified: trunk/Jmol/src/org/jmol/viewer/Sticks.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Sticks.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Sticks.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -152,10 +152,11 @@ for (int i = frame.bondCount; --i >= 0;) { Bond bond = bonds[i]; if (reportAll || bsSizeSet != null && bsSizeSet.get(i)) - setStateInfo(temp, i, "wireframe " + (bond.mad / 2000f)); + setStateInfo(temp, i, "wireframe " + + (bond.mad == 1 ? "on" : "" + (bond.mad / 2000f))); if (reportAll || bsOrderSet != null && bsOrderSet.get(i)) - setStateInfo(temp, i, "bondOrder " - + JmolConstants.getBondOrderNameFromOrder(bond.order)); + setStateInfo(temp, i, "bondOrder " + + JmolConstants.getBondOrderNameFromOrder(bond.order)); if (bsColixSet != null && bsColixSet.get(i)) setStateInfo(temp, i, getColorCommand("bonds", bond.colix)); } Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -94,6 +94,8 @@ } commands.append(";\n"); } + if (vibrationOn) + commands.append("vibration on;\n"); commands.append("\n"); return commands.toString(); } Modified: trunk/Jmol/src/org/jmol/viewer/Vectors.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Vectors.java 2006-11-15 19:45:08 UTC (rev 6217) +++ trunk/Jmol/src/org/jmol/viewer/Vectors.java 2006-11-15 21:43:23 UTC (rev 6218) @@ -25,6 +25,7 @@ package org.jmol.viewer; import java.util.BitSet; +import java.util.Hashtable; import org.jmol.g3d.Graphics3D; @@ -33,6 +34,8 @@ String[] strings; short[] mads; short[] colixes; + BitSet bsSizeSet; + BitSet bsColixSet; void initShape() { if (frame.hasVibrationVectors) { @@ -43,14 +46,17 @@ void setSize(int size, BitSet bsSelected) { if (frame.hasVibrationVectors) { - short mad = (short)size; + if (bsSizeSet == null) + bsSizeSet = new BitSet(); + short mad = (short) size; //Atom[] atoms = frame.atoms; - for (int i = frame.atomCount; --i >= 0; ) { + boolean isVisible = (mad != 0); + for (int i = frame.atomCount; --i >= 0;) if (bsSelected.get(i)) { mads[i] = mad; - frame.atoms[i].setShapeVisibility(myVisibilityFlag, (mad != 0)); + frame.atoms[i].setShapeVisibility(myVisibilityFlag, isVisible); + bsSizeSet.set(i, isVisible); } - } } } @@ -59,10 +65,12 @@ if (frame.hasVibrationVectors) { //Atom[] atoms = frame.atoms; if ("color" == propertyName) { + if (bsColixSet == null) + bsColixSet = new BitSet(); short colix = Graphics3D.getColix(value); for (int i = frame.atomCount; --i >= 0; ) if (bsSelected.get(i)) - colixes[i] = colix; + bsColixSet.set(i, (colixes[i] = colix) != 0); } } } @@ -78,4 +86,16 @@ } } + String getShapeState() { + Hashtable temp = new Hashtable(); + Hashtable temp2 = new Hashtable(); + for (int i = frame.atomCount; --i >= 0;) { + if (bsSizeSet == null || !bsSizeSet.get(i)) + continue; + setStateInfo(temp, i, "vector " + (mads[i] / 1000f)); + if (bsColixSet != null && bsColixSet.get(i)) + setStateInfo(temp2, i, getColorCommand("vector", colixes[i])); + } + return getShapeCommands(temp, temp2, frame.atomCount); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |