Revision: 18594 http://sourceforge.net/p/jmol/code/18594 Author: hansonr Date: 2013-08-19 04:38:29 +0000 (Mon, 19 Aug 2013) Log Message: ----------- incommensurate work; bug fix for not reading state after translation.
Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/minimize/MinimizationThread.java trunk/Jmol/src/org/jmol/script/CommandWatcherThread.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/symmetry/SymmetryOperation.java trunk/Jmol/src/org/jmol/thread/AnimationThread.java trunk/Jmol/src/org/jmol/thread/JmolThread.java trunk/Jmol/src/org/jmol/thread/ModulationThread.java trunk/Jmol/src/org/jmol/thread/MoveThread.java trunk/Jmol/src/org/jmol/thread/MoveToThread.java trunk/Jmol/src/org/jmol/thread/SpinThread.java trunk/Jmol/src/org/jmol/thread/VibrationThread.java trunk/Jmol/src/org/jmol/util/Modulation.java trunk/Jmol/src/org/jmol/util/ModulationSet.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateCreator.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -71,6 +71,7 @@ protected String modType; protected boolean checkSpecial = true; protected boolean modDebug; + protected int modSelected = -1; protected int modDim; protected boolean incommensurate; @@ -89,6 +90,7 @@ modDebug = checkFilterKey("MODDEBUG"); modAxes = getFilter("MODAXES="); modType = getFilter("MODTYPE="); //ODU + modSelected = parseIntStr("" + getFilter("MOD=")); modVib = checkFilterKey("MODVIB"); // then use MODULATION ON to see modulation modAverage = checkFilterKey("MODAVE"); if (!modVib && !modAverage) @@ -102,13 +104,13 @@ if (modAverage) return; modDim = ndim; - if (modDim > 1) { + if (modDim > 3) { // not ready for dim=2 appendLoadNote("Too high modulation dimension (" + modDim + ") -- reading average structure"); modDim = 0; modAverage = true; } else { - appendLoadNote("Modulation dimension = " + modDim); + appendLoadNote("Modulation dimension = " + modDim + (modDim > 1 ? " NOT IMPLEMENTED YET " : "")); htModulation = new Hashtable<String, P3>(); } incommensurate = (modDim > 0); @@ -124,10 +126,23 @@ case 'O': case 'D': case 'U': - if (modType.indexOf(id.charAt(0)) < 0) + if (modType.indexOf(id.charAt(0)) < 0 || modSelected > 0 + && modSelected != 1) return; break; } + if (modSelected > 0 && id.contains("_q_")) + switch (modSelected) { + case 1: + pt.y = pt.z = 0; + break; + case 2: + pt.x = pt.z = 0; + break; + case 3: + pt.x = pt.y = 0; + break; + } if (map == null) map = htModulation; id += "@" @@ -144,10 +159,10 @@ if (!incommensurate || htModulation == null) return; if (modDebug) - Logger.debugging = Logger.debuggingHigh = false; + Logger.debugging = Logger.debuggingHigh = true; setModulationForStructure(atomSetCollection.getCurrentAtomSetIndex()); if (modDebug) - Logger.debugging = Logger.debuggingHigh = true; + Logger.debugging = Logger.debuggingHigh = false; } private String suffix; @@ -155,15 +170,26 @@ return htModulation.get(key + suffix); } + private P3[] q123; + private double[] qlen; + private void setModulationForStructure(int iModel) { suffix = "@" + iModel; String key; if (htModulation.containsKey("X_" + suffix)) return; htModulation.put("X_" +suffix, new P3()); - q1 = getMod("W_1"); - if (q1 == null) - return; + q123 = new P3[modDim]; + qlen = new double[modDim]; + for (int i = 0; i < modDim; i++) { + q123[i] = getMod("W_" + (i + 1)); + if (q123[i] == null) { + Logger.info("Not enough cell wave vectors for d=" + modDim); + return; + } + qlen[i] = q123[i].length(); + } + q1 = q123[0]; q1Norm = V3.new3(q1.x == 0 ? 0 : 1, q1.y == 0 ? 0 : 1, q1.z == 0 ? 0 : 1); P3 pt; int n = atomSetCollection.getAtomCount(); @@ -190,10 +216,16 @@ Logger.info("msCIF setting " + key + " " + pt); } break; - case 'F': + case 'W': + if (modDim > 1) { + continue; + } + //$FALL-THROUGH$ + case 'F': // convert JAVA Fourier descriptions to standard descriptions if (key.indexOf("_q_") >= 0) { - // this will fail until we set up fn for multiple q. + // d > 1 -- already set + appendLoadNote("Wave vector " + key + "(n=" + (modDim == 1 ? Integer.valueOf((int)pt.x) : pt)+")"); P3 pf = new P3(); if (pt.x != 0) pf.scaleAdd2(pt.x, getMod("W_1"), pf); @@ -249,15 +281,12 @@ if (htAtomMods == null) htAtomMods = new Hashtable<String, JmolList<Modulation>>(); int fn = (id == 'S' ? 0 : parseIntStr(key.substring(2))); - key = (fn == 0 ? "W_1" : "F_" + fn); - //TODO -- THIS IS WRONG. n is just a label. It will break in 2D - // but I don't know to determine "n" any other way in a CIF file. - P3 nq = getMod(key); - fn = (fn == 0 ? 1 : (int) getMod(key + "_q_").x); - JmolList<Modulation> list = htAtomMods.get(atomName); - if (list == null) - htAtomMods.put(atomName, list = new JmolList<Modulation>()); - list.addLast(new Modulation(nq, axis, type, fn, params, utens)); + if (fn == 0) { + addAtomModulation(atomName, axis, type, 1, params, utens, new int[] {1}); + } else { + P3 qlist = getMod("F_" + fn + "_q_"); + addAtomModulation(atomName, axis, type, 1, params, utens, new int[] { (int) qlist.x, (int) qlist.y, (int) qlist.z } ); + } haveAtomMods = true; break; } @@ -274,6 +303,15 @@ atomSetCollection.setAtomSetAtomProperty("modt", sb.toString(), -1); htAtomMods = null; } + + private void addAtomModulation(String atomName, char axis, int type, + int fn, P3 params, String utens, int[] qcoefs) { + JmolList<Modulation> list = htAtomMods.get(atomName); + if (list == null) + htAtomMods.put(atomName, list = new JmolList<Modulation>()); + list.addLast(new Modulation(axis, type, fn, params, utens, qcoefs)); + } + private String checkKey(String key) { int pt_ = key.indexOf(suffix); return (pt_ < 0 ? null : key.substring(0, pt_)); @@ -282,7 +320,8 @@ private int iopLast = -1; private Matrix3f rot; private float[] f4; - private float epsilon, delta; + float[] epsilon = new float[3]; + float[] delta = new float[3]; /** * The displacement will be set as the atom vibration vector; the string @@ -296,49 +335,61 @@ * @param sb */ public void modulateAtom(Atom a, SB sb) { + JmolList<Modulation> list = htAtomMods.get(a.atomName); if (list == null || symmetry == null || a.bsSymmetry == null) return; int iop = a.bsSymmetry.nextSetBit(0); if (iop < 0) iop = 0; - // now set to - int mdim = 0; // just the first row -- assuming d=1 here + //Logger.debugging = Logger.debuggingHigh = (iop == 2); + //if (a.index == 5 || a.index == 7 || Logger.debugging) + // Logger.debugging = Logger.debuggingHigh = true; - //if (a.index == 40) - //Logger.debuggingHigh = Logger.debugging = true; - if (Logger.debuggingHigh) - Logger.debug("setModulation: i=" + a.index + " " + a.atomName + " xyz=" + Logger.debug("\nsetModulation: i=" + a.index + " " + a.atomName + " xyz=" + a + " occ=" + a.occupancy); if (iop != iopLast) { - symmetry.getMod456Row(iop, mdim, f4); //System.out.println("mdim=" + mdim + " op=" + (iop + 1) + " " + symmetry.getSpaceGroupOperation(iop) + " " + symmetry.getSpaceGroupXyz(iop, false)); iopLast = iop; rot = new Matrix3f(); - epsilon = f4[0]; //symmetry.getModParam(iop, 0); - delta = f4[3] - modT; //symmetry.getModParam(iop, 1); + for (int i = 0; i < modDim; i++) { + symmetry.getMod456Row(iop, i, f4); + epsilon[i] = 0; + if (modSelected > 0) { + if (i == modSelected - 1) + epsilon[i] = f4[i] * modSelected; + continue; + } + for (int j = 0; j < modDim; j++) + epsilon[i] += f4[j] * (j + 1); + delta[i] = f4[3] - modT; + } } symmetry.getSpaceGroupOperation(iop).getRotationScale(rot); if (Logger.debugging) { Logger.debug("setModulation iop = " + iop + " " + symmetry.getSpaceGroupXyz(iop, false) + " " + a.bsSymmetry); } - ModulationSet ms = new ModulationSet(a.index + " " + a.atomName, list); + ModulationSet ms = new ModulationSet(a.index + " " + a.atomName, list, + modDim, q123, qlen); a.vib = ms; ms.epsilon = epsilon; ms.delta = delta; ms.r = P3.newP(a); - ms.v0 = a.occupancy / 100f; + ms.vocc0 = a.occupancy / 100f; ms.rot = rot; ms.calculate(); - if (modVib && !Float.isNaN(ms.v0)) { - a.occupancy = (int) ((ms.v0 + ms.v) * 100); - } else if (ms.v < 0.5f) { - a.occupancy = 0; - bsAtoms.clear(a.index); - } else if (ms.v >= 0.5f) { - a.occupancy = 100; + if (!Float.isNaN(ms.vocc)) { + if (modVib && !Float.isNaN(ms.vocc0)) { + a.occupancy = (int) ((ms.vocc0 + ms.vocc) * 100); + } else if (ms.vocc < 0.5f) { + a.occupancy = 0; + if (bsAtoms != null) + bsAtoms.clear(a.index); + } else if (ms.vocc >= 0.5f) { + a.occupancy = 100; + } } if (ms.htValues != null) { // Uiso or Uij. We add the displacements, create the tensor, then rotate it, Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -258,8 +258,8 @@ for (int j = 0; j < nOcc; j++) { if (haveCrenel) { float[][] data = readM40FloatLines(2, 1, r); - a1 = data[0][0]; - a2 = data[1][0]; + a1 = data[1][0]; + a2 = data[0][0]; } else { wv = j + 1; readM40Floats(r); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -926,17 +926,13 @@ symmetry.setLattice(latt); } - void applySymmetry() throws Exception { + void applySymmetry(SymmetryInterface symmetry) throws Exception { + if (symmetry != null) + getSymmetry().setSpaceGroupS(symmetry); //parameters are counts of unit cells as [a b c] applySymmetryLattice(latticeCells[0], latticeCells[1], Math.abs(latticeCells[2])); } - void applySymmetryUsing(SymmetryInterface symmetry) throws Exception { - getSymmetry().setSpaceGroupS(symmetry); - //parameters are counts of unit cells as [a b c] - applySymmetryLattice(latticeCells[0], latticeCells[1], Math.abs(latticeCells[2])); - } - boolean doNormalize = true; boolean doPackUnitCell = false; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -742,7 +742,6 @@ for (i = 0; i < 6; i++) notionalUnitCell[i] = -1; } - iHaveUnitCell = checkUnitCell(15); } @@ -1054,10 +1053,10 @@ (spaceGroup.indexOf("!") >= 0 ? "P1" : spaceGroup), notionalUnitCell)) { atomSetCollection.setAtomSetSpaceGroupName(symmetry .getSpaceGroupName()); - atomSetCollection.applySymmetryUsing(symmetry); + atomSetCollection.applySymmetry(symmetry); } } else { - atomSetCollection.applySymmetry(); + atomSetCollection.applySymmetry(null); } } if (iHaveFractionalCoordinates && merging && symmetry != null) { Modified: trunk/Jmol/src/org/jmol/minimize/MinimizationThread.java =================================================================== --- trunk/Jmol/src/org/jmol/minimize/MinimizationThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/minimize/MinimizationThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -37,9 +37,10 @@ public MinimizationThread() {} @Override - public void setManager(Object manager, Viewer viewer, Object options) { + public int setManager(Object manager, Viewer viewer, Object options) { minimizer = (Minimizer) manager; setViewer(viewer, "MinimizationThread"); + return 0; } @Override Modified: trunk/Jmol/src/org/jmol/script/CommandWatcherThread.java =================================================================== --- trunk/Jmol/src/org/jmol/script/CommandWatcherThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/script/CommandWatcherThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -39,9 +39,10 @@ @Override - public void setManager(Object manager, Viewer viewer, Object params) { + public int setManager(Object manager, Viewer viewer, Object params) { scriptManager = (ScriptManager) manager; setViewer(viewer, "CommmandWatcherThread"); + return 0; } private final static int commandDelay = 50; // was 200 Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -248,11 +248,7 @@ boolean allowThreads) { boolean tempOpen = this.isCmdLine_C_Option; this.isCmdLine_C_Option = isCmdLine_C_Option; - executionStopped = executionPaused = false; - executionStepping = false; - executing = true; chk = this.isCmdLine_c_or_C_Option = isCmdLine_c_or_C_Option; - timeBeginExecution = System.currentTimeMillis(); this.historyDisabled = historyDisabled; this.outputBuffer = outputBuffer; currentThread = Thread.currentThread(); @@ -268,6 +264,10 @@ } private void startEval() { + timeBeginExecution = System.currentTimeMillis(); + executionStopped = executionPaused = false; + executionStepping = false; + executing = true; viewer.pushHoldRepaint("runEval"); setScriptExtensions(); executeCommands(false); @@ -2767,6 +2767,7 @@ boolean isPopContext, boolean isFlowCommand, boolean statementOnly) { + executing = !chk; if (context == null) return; if (debugScript || isCmdLine_c_or_C_Option) @@ -11999,11 +12000,11 @@ //$FALL-THROUGH$ case T.off: if (!chk) - viewer.setModulation(mod, Integer.MAX_VALUE, Integer.MAX_VALUE, false); + viewer.setModulation(mod, null, Integer.MAX_VALUE, false); break; case T.integer: if (!chk) - viewer.setModulation(true, intParameter(1), Integer.MAX_VALUE, false); + viewer.setModulation(true, new int[] {intParameter(1)}, Integer.MAX_VALUE, false); break; case T.fps: if (!chk) @@ -12011,7 +12012,7 @@ break; case T.play: if (!chk) - viewer.setModulation(true, intParameter(2), intParameter(3), false); + viewer.setModulation(true, new int[] {intParameter(2)}, intParameter(3), false); break; } } Modified: trunk/Jmol/src/org/jmol/symmetry/SymmetryOperation.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/SymmetryOperation.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/symmetry/SymmetryOperation.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -178,13 +178,7 @@ this.modDim = modDim; if (modDim > 0) { n = 32; // x4, x5, x6, and twelfths - if (modDim == 1) { - myLabels = labelsX1_6; - } else { - myLabels = new String[modDim + 3]; - for (int i = modDim + 3; --i >= 0;) - myLabels[i] = "x" + (i + 1); - } + myLabels = labelsX1_6; } rotTransMatrix = new float[n]; boolean isReverse = (xyz.startsWith("!")); @@ -1322,9 +1316,7 @@ } public void getMod456Row(int rowPt, float[] f4) { - for (int i = 0, pt = 16 + rowPt * 4; i < 4; i++, pt++) - f4[i] = rotTransMatrix[pt]; - f4[3] /= 12; + mod456.getRow(rowPt, f4); } } Modified: trunk/Jmol/src/org/jmol/thread/AnimationThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/AnimationThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/AnimationThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -42,7 +42,7 @@ public AnimationThread() {} @Override - public void setManager(Object manager, Viewer viewer, Object params) { + public int setManager(Object manager, Viewer viewer, Object params) { int[] options = (int[]) params; framePointer1 = options[0]; framePointer2 = options[1]; @@ -50,6 +50,7 @@ animationManager = (AnimationManager) manager; setViewer(viewer, "AnimationThread"); viewer.startHoverWatcher(false); + return 0; } @Override Modified: trunk/Jmol/src/org/jmol/thread/JmolThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/JmolThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/JmolThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -40,8 +40,9 @@ * @param manager * @param viewer * @param params + * @return TODO */ - public void setManager(Object manager, Viewer viewer, Object params){} + public int setManager(Object manager, Viewer viewer, Object params){return 0;} public void setViewer(Viewer viewer, String name) { setName(name); Modified: trunk/Jmol/src/org/jmol/thread/ModulationThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/ModulationThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/ModulationThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -43,13 +43,14 @@ } @Override - public void setManager(Object manager, Viewer viewer, Object params) { + public int setManager(Object manager, Viewer viewer, Object params) { int[] options = (int[]) params; modT = options[0]; modT2 = options[1]; animationManager = (AnimationManager) manager; setViewer(viewer, "ModulationThread"); viewer.startHoverWatcher(false); + return 0; } @Override @@ -88,7 +89,7 @@ mode = CHECK1; break; case CHECK1: - viewer.setModulation(true, modT++, Integer.MAX_VALUE, true); + viewer.setModulation(true, new int[] {modT++}, Integer.MAX_VALUE, true); mode = CHECK2; break; case CHECK2: Modified: trunk/Jmol/src/org/jmol/thread/MoveThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/MoveThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/MoveThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -53,7 +53,7 @@ public MoveThread() {} @Override - public void setManager(Object manager, Viewer viewer, Object params) { + public int setManager(Object manager, Viewer viewer, Object params) { Object[] options = (Object[]) params; setViewer(viewer, "MoveThread"); transformManager = (TransformManager) manager; @@ -80,6 +80,7 @@ radiansZStep = radiansPerDegreePerStep * dRot.z; zoomPercent0 = transformManager.zoomPercent; iStep = 0; + return totalSteps; } Modified: trunk/Jmol/src/org/jmol/thread/MoveToThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/MoveToThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/MoveToThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -47,7 +47,7 @@ private final AxisAngle4f aaTotal = new AxisAngle4f(); private final Matrix3f matrixStart = new Matrix3f(); private final Matrix3f matrixStartInv = new Matrix3f(); - private final Matrix3f matrixStep = new Matrix3f(); + private Matrix3f matrixStep = new Matrix3f(); private final Matrix3f matrixEnd = new Matrix3f(); private P3 center; @@ -72,27 +72,30 @@ private int iStep; private boolean doEndMove; private float floatSecondsTotal; + private float fStep; - /* - center, matrixEnd, navCenter, - new float[] { - 5 xNav, - 6 yNav, - 7 navDepth, - 8 cameraDepth, - 9 cameraX, - 10 cameraY }, ret }); - - */ @Override - public void setManager(Object manager, Viewer viewer, Object params) { + public int setManager(Object manager, Viewer viewer, Object params) { Object[] options = (Object[]) params; + // { center, matrixEnd, navCenter }, + // { + // 0 floatSecondsTotal + // 1 zoom, + // 2 xTrans, + // 3 yTrans, + // 4 newRotationRadius, + // 5 pixelScale, + // 6 navDepth, + // 7 xNav, + // 8 yNav, + // 9 cameraDepth, + // 10 cameraX, + // 11 cameraY }); setViewer(viewer, "MoveToThread"); transformManager = (TransformManager) manager; center = (P3) options[0]; matrixEnd.setM((Matrix3f) options[1]); float[] f = (float[]) options[3]; - int[] ret = (int[]) options[4]; ptMoveToCenter = (center == null ? transformManager.fixedRotationCenter : center); floatSecondsTotal = f[0]; @@ -102,30 +105,25 @@ rotationRadius = newSlider(transformManager.modelRadius, (center == null || Float.isNaN(f[4]) ? transformManager.modelRadius : f[4] <= 0 ? viewer.calcRotationRadius(center) : f[4])); - pixelScale = newSlider(transformManager.scaleDefaultPixelsPerAngstrom, - (center == null ? transformManager.scaleDefaultPixelsPerAngstrom - : transformManager.defaultScaleToScreen(this.rotationRadius.value))); - if (f[7] != 0) { + pixelScale = newSlider(transformManager.scaleDefaultPixelsPerAngstrom, f[5]); + if (f[6] != 0) { + navCenter = (P3) options[2]; navDepth = newSlider(transformManager.getNavigationDepthPercent(), - f[7]); + f[6]); xNav = newSlider(transformManager.getNavigationOffsetPercent('X'), - f[5]); + f[7]); yNav = newSlider(transformManager.getNavigationOffsetPercent('Y'), - f[6]); - navCenter = (P3) options[2]; + f[8]); } - cameraDepth = newSlider(transformManager.getCameraDepth(), f[8]); - cameraX = newSlider(transformManager.camera.x, f[9]); - cameraY = newSlider(transformManager.camera.y, f[10]); + cameraDepth = newSlider(transformManager.getCameraDepth(), f[9]); + cameraX = newSlider(transformManager.camera.x, f[10]); + cameraY = newSlider(transformManager.camera.y, f[11]); transformManager.getRotation(matrixStart); matrixStartInv.invertM(matrixStart); matrixStep.mul2(matrixEnd, matrixStartInv); aaTotal.setM(matrixStep); - fps = 30; totalSteps = (int) (floatSecondsTotal * fps); - if (totalSteps == 0) - return; frameTimeMillis = 1000 / fps; targetTime = System.currentTimeMillis(); aaStepCenter.setT(ptMoveToCenter); @@ -137,12 +135,11 @@ aaStepNavCenter.sub(transformManager.navigationCenter); aaStepNavCenter.scale(1f / totalSteps); } - ret[0] = totalSteps; - return; + return totalSteps; } private Slider newSlider(float start, float value) { - return (Float.isNaN(value) ? null : new Slider(start, value)); + return (Float.isNaN(value) || value == Float.MAX_VALUE ? null : new Slider(start, value)); } @Override @@ -211,8 +208,7 @@ matrixStep.setAA(aaStep); matrixStep.mul(matrixStart); } - transformManager.setRotation(matrixStep); - float fStep = iStep / (totalSteps - 1f); + fStep = iStep / (totalSteps - 1f); if (center != null) transformManager.fixedRotationCenter.add(aaStepCenter); if (navCenter != null @@ -221,40 +217,25 @@ pt.add(aaStepNavCenter); transformManager.setNavigatePt(pt); } - setValues(fStep); + setValues(matrixStep, null, null); } private void doFinalTransform() { - transformManager.setRotation(matrixEnd); - if (center != null) - transformManager.moveRotationCenter(center, - !transformManager.windowCentered); - if (navCenter != null - && transformManager.mode == TransformManager.MODE_NAVIGATION) - transformManager.navigationCenter.setT(navCenter); - setValues(-1); + fStep = -1; + setValues(matrixEnd, center, navCenter); } - private void setValues(float fStep) { - if (cameraDepth != null) - transformManager.setCameraDepthPercent(cameraDepth.getVal(fStep), false); - if (cameraX != null && cameraY != null) - transformManager.setCamera(cameraX.getVal(fStep), cameraY.getVal(fStep)); - if (zoom != null) - transformManager.zoomToPercent(zoom.getVal(fStep)); - transformManager.modelRadius = rotationRadius.getVal(fStep); - transformManager.scaleDefaultPixelsPerAngstrom = pixelScale.getVal(fStep); - if (xTrans != null && yTrans != null) { - transformManager.translateToPercent('x', xTrans.getVal(fStep)); - transformManager.translateToPercent('y', yTrans.getVal(fStep)); - } - if (xNav != null && yNav != null) - transformManager.navTranslatePercentOrTo(0, xNav.getVal(fStep), yNav - .getVal(fStep)); - if (navDepth != null) - transformManager.setNavigationDepthPercent(navDepth.getVal(fStep)); + private void setValues(Matrix3f m, P3 center, P3 navCenter) { + transformManager.setAll(center, m, navCenter, getVal(zoom), getVal(xTrans), getVal(yTrans), + getVal(rotationRadius), getVal(pixelScale), getVal(navDepth), + getVal(xNav), getVal(yNav), + getVal(cameraDepth), getVal(cameraX), getVal(cameraY) ); } + private float getVal(Slider s) { + return (s == null ? Float.MAX_VALUE : s.getVal(fStep)); + } + @Override public void interrupt() { doEndMove = false; Modified: trunk/Jmol/src/org/jmol/thread/SpinThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/SpinThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/SpinThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -59,7 +59,7 @@ @SuppressWarnings("unchecked") @Override - public void setManager(Object manager, Viewer viewer, Object params) { + public int setManager(Object manager, Viewer viewer, Object params) { transformManager = (TransformManager) manager; setViewer(viewer, "SpinThread"); Object[] options = (Object[]) params; @@ -84,6 +84,7 @@ bsAtoms = (BS) options[3]; isGesture = (options[4] != null); } + return 0; } /** Modified: trunk/Jmol/src/org/jmol/thread/VibrationThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/VibrationThread.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/thread/VibrationThread.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -35,9 +35,10 @@ public VibrationThread() {} @Override - public void setManager(Object manager, Viewer viewer, Object options) { + public int setManager(Object manager, Viewer viewer, Object options) { transformManager = (TransformManager) manager; setViewer(viewer, "VibrationThread"); + return 0; } @Override Modified: trunk/Jmol/src/org/jmol/util/Modulation.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Modulation.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/util/Modulation.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -13,14 +13,13 @@ private static final double TWOPI = 2 * Math.PI; + private int[] qCoefs; + private double a1; private double a2; private double center; private double left, right; - private V3 nq; // wave vector - private double nqlen; - private int fn; // power private char axis; private final int type; @@ -33,30 +32,27 @@ public static final int TYPE_OCC_CRENEL = 3; public static final int TYPE_U_FOURIER = 4; - public V3 getWaveVector() { - return nq; - } - /** * Each atomic modulation involves a fractional coordinate wave vector q, a * Fourier power n, a modulation axis (x, y, or, z), and specified parameters * that depend upon the type of function. * * - * @param nq * @param axis * @param type * @param fn * @param params * @param utens TODO + * @param qCoefs */ - public Modulation(P3 nq, char axis, int type, int fn, P3 params, String utens) { - this.nq = V3.newV(nq); - nqlen = nq.length(); + public Modulation(char axis, int type, int fn, P3 params, String utens, int[] qCoefs) { + if (Logger.debuggingHigh) + Logger.debug("MOD create " + Escape.eAI(qCoefs) + " axis=" + axis + " type=" + type + " fn=" + fn + " params=" + params + " utens=" + utens); this.axis = axis; this.type = type; this.fn = fn; this.utens = utens; + this.qCoefs = qCoefs; switch (type) { case TYPE_DISP_FOURIER: case TYPE_OCC_FOURIER: @@ -86,57 +82,34 @@ /** * - * In general, we have: + * In general, we have, for Fourier: * * u_axis(x) = sum[A1 cos(theta) + B1 sin(theta)] * * where axis is x, y, or z, and theta = 2n pi x * - * However, for symmetry-related atoms, we need to do a 4D transformation, not - * just a 3D one. We need to operate on x first BEFORE applying u(x): - * - * u(x4') = Ru(x4) - * - * where we need to express x4 in terms of a "transformed" x4', because x4' is - * for our rotated point. - * - * x4' = epsilon x4 + delta - * - * where epsilon = +/-1, so - * - * x4 = epsilon (x4' - delta) - * - * More generally, we might have something like: - * - * x4' = x5 + 1/2; x5' = x4 - 1/2 - * - * Will have to work on that later! - * - * + * @param i * @param ms + * @param x4 * */ - void apply(ModulationSet ms) { + void apply(int i, ModulationSet ms, double x4) { - // TODO: must be adapted for d > 1 modulation - double v = 0; //if (type == TYPE_OCC_CRENEL) //delta = 0; - double x4 = ms.epsilon * (nq.dot(ms.r) - fn * ms.delta + nqlen * ms.t); - switch (type) { case TYPE_DISP_FOURIER: case TYPE_OCC_FOURIER: case TYPE_U_FOURIER: - double theta = TWOPI * x4; + double theta = TWOPI * fn * x4; if (a1 != 0) v += a1 * Math.cos(theta); if (a2 != 0) v += a2 * Math.sin(theta); if (Logger.debuggingHigh) - Logger.debug("MOD v=" + v + " a1,a2=" + a1 + " " + a2 + " / theta=" + theta + " id=" + ms.id); + Logger.debug("MOD " + i + ":" + ms.id + " fn=" + fn + " " + " axis=" + axis + " v=" + v + " ccos,csin=" + a1 + "," + a2 + " / theta=" + theta); break; case TYPE_OCC_CRENEL: @@ -147,8 +120,8 @@ // p(x4)=0 if x4 is outside the interval [c-w/2,c+w/2], x4 -= Math.floor(x4); - ms.v = (range(x4) ? 1 : 0); - ms.v0 = Float.NaN; // don't add this in + ms.vocc = (range(x4) ? 1 : 0); + ms.vocc0 = Float.NaN; // don't add this in //System.out.println("MOD " + ms.r + " " + ms.delta + " " + ms.epsilon + " " + ms.id + " " + ms.v + " l=" + left + " x=" + x4 + " r=" + right); return; case TYPE_DISP_SAWTOOTH: @@ -228,6 +201,7 @@ v = a1 * (x4 - center); break; } + switch (axis) { case 'x': ms.x += v; @@ -242,9 +216,9 @@ ms.addUTens(utens, (float) v, fn); break; default: - if (Float.isNaN(ms.v)) - ms.v = 0; - ms.v += (float) v; + if (Float.isNaN(ms.vocc)) + ms.vocc = 0; + ms.vocc += (float) v; } } @@ -260,5 +234,25 @@ || x4 <= right); } + /** just guessing here.... + * + * @param aq + * @param q + * @return pointer to last-used index + */ + int getQ(P3[] aq, P3 q) { + q.set(0, 0, 0); + int eq = 0; + fn = 0; + for (int i = 0; i < aq.length; i++) { + q.scaleAdd2(qCoefs[i], aq[i], q); + if (qCoefs[i] != 0) { + eq = i; + fn+= Math.abs(qCoefs[i]); + } + } + q.scale(1f/fn); + return eq; + } } Modified: trunk/Jmol/src/org/jmol/util/ModulationSet.java =================================================================== --- trunk/Jmol/src/org/jmol/util/ModulationSet.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/util/ModulationSet.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -14,35 +14,133 @@ public class ModulationSet extends Vibration { public JmolList<Modulation> mods; - public float epsilon; - public float delta; + public float[] epsilon; + public float[] delta; + public int[] t = new int[3]; + + public P3[] q123; + public double[] qlen; + private int modDim; public P3 r; public Matrix3f rot; - public float v0; - public float v = Float.NaN; - public int t; + public float vdisp = Float.NaN; + public float vocc = Float.NaN; + public float vocc0 = Float.NaN; public Map<String, Float> htValues; public boolean enabled = false; public String id; - - public ModulationSet(String id, JmolList<Modulation> list) { + + public V3 prevSetting; + + public ModulationSet(String id, JmolList<Modulation> list, int modDim, P3[] q123, double[] qlen) { this.id = id; mods = list; + this.modDim = modDim; + this.q123 = q123; + this.qlen = qlen; } /** * Determine the overall modulation. * + * For symmetry-related atoms, we need to do a 4D transformation, not just a + * 3D one. We need to operate on x first BEFORE applying u(x): + * + * u(x4') = Ru(x4) + * + * where we need to express x4 in terms of a "transformed" x4', because x4' is + * for our rotated point. + * + * x4' = epsilon x4 + delta + * + * where epsilon = +/-1, so + * + * x4 = (x4' - delta) / epsilon = epsilon (x4' - delta) + * + * More generally, we might have something like: + * + * x4' = x5 + 1/2; x5' = x4 - 1/2 + * + * so in those cases, we have to use the proper q. + * + * */ public void calculate() { + // Q: What about x4,x5 exchange? set(0, 0, 0); htValues = null; - v = Float.NaN; - for (int i = mods.size(); --i >= 0;) - mods.get(i).apply(this); + vdisp = vocc = Float.NaN; + P3[] aq = new P3[modDim]; + + for (int iq = 0; iq < modDim; iq++) { + int eps = (int) epsilon[iq]; + if (eps == 0) + continue; + int qpt = (Math.abs(eps) - 1); + aq[iq] = q123[qpt]; + } + P3 q = new P3(); + int jmax = 1; + for (int j = 0;j < modDim; j++) { + // testing hypothesis that either one should work... + // checks out for (0,1) (1,0), but not (1,1) + if (j == jmax)continue; + + for (int i = mods.size(); --i >= 0;) { + + int iq = mods.get(i).getQ(aq, q); + int eps = (int) epsilon[iq]; + eps = (eps > 0 ? 1 : -1); + //int qpt = (Math.abs(eps) - 1); + + + double x4 = eps * (q.dot(r) - delta[iq] + qlen[iq] * t[iq]); + System.out.println("MODSET q=" + q + " r=" + r + + " epsilon=" + eps + " delta=" + delta[iq] + " t=" + t[iq] + + " x4=" + x4); + + // here we are using the original specification for the function. + // F2 = "(0)q1 + (1)q2" + // even though we have switched q1 and q2 + mods.get(i).apply(i, this, x4); + } + } rot.transform(this); } +// http://nanocrystallography.research.pdx.edu/static/mcodcif/4/33/14/4331458.cif + +// _space_group_ssg_name_WJJ P-42_1m(a,a,0)00s(-a,a,0)000 +// loop_ +// _space_group_symop_ssg_id +// _space_group_symop_ssg_operation_algebraic +// 1 x1,x2,x3,x4,x5 +// 2 -x1,-x2,x3,-x4,-x5 +// 3 x2,-x1,-x3,x5,-x4 +// 4 -x2,x1,-x3,-x5,x4 +// 5 -x1+1/2,x2+1/2,-x3,x5+1/2,x4+1/2 +// 6 x1+1/2,-x2+1/2,-x3,-x5+1/2,-x4+1/2 +// 7 -x2+1/2,-x1+1/2,x3,-x4+1/2,x5+1/2 +// 8 x2+1/2,x1+1/2,x3,x4+1/2,-x5+1/2 + +// _cell_wave_vector_seq_id +// _cell_wave_vector_x +// _cell_wave_vector_y +// _cell_wave_vector_z +// 1 0.216050 0.216050 0.000000 +// 2 -0.216050 0.216050 0.000000 + +// loop_ +// _atom_site_Fourier_wave_vector_seq_id +// _jana_atom_site_fourier_wave_vector_q1_coeff +// _jana_atom_site_fourier_wave_vector_q2_coeff +// 1 1 0 +// 2 0 1 +// 3 1 1 +// 4 -1 1 +// 5 2 0 +// 6 0 2 + public void addUTens(String utens, float v, int n) { if (htValues == null) htValues = new Hashtable<String, Float>(); @@ -55,7 +153,6 @@ } - public V3 prevSetting; /** * Set modulation "t" value, which sets which unit cell in sequence we are looking at. @@ -73,12 +170,12 @@ scale(-1); return (enabled ? 2 : 1); } - if (t == this.t) + if (t == this.t[0]) return 4; if (prevSetting == null) prevSetting = new V3(); prevSetting.setT(this); - this.t = t; + this.t[0] = t; calculate(); enabled = false; return 3; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-08-19 04:38:29 UTC (rev 18594) @@ -11,8 +11,10 @@ # The quotes above look odd for a parameter file, but they are # important for the JavaScript version of Jmol. -___JmolVersion="13.3.4_dev_2013.08.17" +___JmolVersion="13.3.4_dev_2013.08.18" +bug fix: translation not read from state + new feature: set platformSpeed [0 to 10] -- basically an expanded "set wireframe OFF" with more options -- only effected during model rotation Modified: trunk/Jmol/src/org/jmol/viewer/StateCreator.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateCreator.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/viewer/StateCreator.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -365,8 +365,8 @@ if ((ivib = viewer.modelGetLastVibrationIndex(i, T.modulation)) >= 0) for (int j = models[i].firstAtomIndex; j <= ivib; j++) { ModulationSet mset = (ModulationSet) viewer.getVibration(j); - if (mset.enabled) - BSUtil.setMapBitSet(temp, j, j, "modulation " + mset.t); + if (mset != null && mset.enabled) + BSUtil.setMapBitSet(temp, j, j, "modulation " + mset.t[0]); } } String s = getCommands(temp, null, "select"); Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -1708,21 +1708,38 @@ matrixEnd.setAA(aaMoveTo); } } - if (!Float.isNaN(cameraX)) + if (Float.isNaN(cameraX) || cameraX == cameraSetting.x) + cameraX = Float.MAX_VALUE; + if (Float.isNaN(cameraY) || cameraY == cameraSetting.y) + cameraY = Float.MAX_VALUE; + if (cameraDepth == this.cameraDepth) + cameraDepth = Float.MAX_VALUE; + if (cameraX != Float.MAX_VALUE) xTrans = cameraX * 50 / newRotationRadius / width * screenPixelCount; - if (!Float.isNaN(cameraY)) + if (cameraY != Float.MAX_VALUE) yTrans = cameraY * 50 / newRotationRadius / height * screenPixelCount; + float pixelScale = (center == null ? scaleDefaultPixelsPerAngstrom + : defaultScaleToScreen(newRotationRadius)); + if (floatSecondsTotal <= 0) { + setAll(center, matrixEnd, navCenter, zoom, xTrans, yTrans, + newRotationRadius, pixelScale, navDepth, xNav, yNav, cameraDepth, + cameraX, cameraY); + viewer.moveUpdate(floatSecondsTotal); + viewer.finalizeTransformParameters(); + return; + } + try { if (motion == null) motion = (JmolThread) Interface .getOptionInterface("thread.MoveToThread"); - int[] ret = new int[1]; - motion.setManager(this, viewer, new Object[] { - center, matrixEnd, navCenter, + int nSteps = motion.setManager(this, viewer, new Object[] { + center, + matrixEnd, + navCenter, new float[] { floatSecondsTotal, zoom, xTrans, yTrans, - newRotationRadius, xNav, yNav, navDepth, cameraDepth, cameraX, - cameraY }, ret }); - int nSteps = ret[0]; + newRotationRadius, pixelScale, navDepth, xNav, yNav, cameraDepth, + cameraX, cameraY } }); if (nSteps <= 0 || viewer.global.waitForMoveTo) { if (nSteps > 0) motion.setEval(eval); @@ -2734,4 +2751,31 @@ scaleFitToScreen(false, zoomLarge, false, true); } + public void setAll(P3 center, Matrix3f m, P3 navCenter, float zoom, + float xTrans, float yTrans, float rotationRadius, + float pixelScale, float navDepth, float xNav, + float yNav, float cameraDepth, float cameraX, float cameraY) { + setRotation(m); + if (center != null) + moveRotationCenter(center, !windowCentered); + if (navCenter != null && mode == MODE_NAVIGATION) + navigationCenter.setT(navCenter); + if (cameraDepth != Float.MAX_VALUE) + setCameraDepthPercent(cameraDepth, false); + if (cameraX != Float.MAX_VALUE && cameraY != Float.MAX_VALUE) + setCamera(cameraX, cameraY); + if (zoom != Float.MAX_VALUE) + zoomToPercent(zoom); + modelRadius = rotationRadius; + scaleDefaultPixelsPerAngstrom = pixelScale; + if (xTrans != Float.MAX_VALUE && yTrans != Float.MAX_VALUE) { + translateToPercent('x', xTrans); + translateToPercent('y', yTrans); + } + if (xNav != Float.MAX_VALUE && yNav != Float.MAX_VALUE) + navTranslatePercentOrTo(0, xNav, yNav); + if (navDepth != Float.MAX_VALUE) + setNavigationDepthPercent(navDepth); + } + } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-08-17 18:41:34 UTC (rev 18593) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-08-19 04:38:29 UTC (rev 18594) @@ -10267,16 +10267,18 @@ return (!getTestFlag(1)); } - public void setModulation(boolean isOn, int t1, int t2, boolean isThread) { + public void setModulation(boolean isOn, int[] t1, int t2, boolean isThread) { + int t = (t1 == null ? Integer.MAX_VALUE : t1[0]); if (t2 == Integer.MAX_VALUE) { if (!isThread) animationManager.setModulationPlay(Integer.MAX_VALUE, 0); - if (t1 != Integer.MAX_VALUE) - global.setI("_modt", t1); - modelSet.setModulation(getSelectionSet(false), isOn, t1); + if (t1 != null) + global.setI("_modt", t1[0]); + modelSet.setModulation(getSelectionSet(false), isOn, t); } else { - animationManager.setModulationPlay(t1, t2); + animationManager.setModulationPlay(t, t2); } + refreshMeasures(true); } public void setModulationFps(float fps) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits