Revision: 20552 http://sourceforge.net/p/jmol/code/20552 Author: hansonr Date: 2015-06-05 23:16:38 +0000 (Fri, 05 Jun 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.14_2015.06.05"
new feature: load "...." FILL BOUNDBOX new feature: load "...." FILL UNITCELL new feature: load "...." FILL [o va vb vc] new feature: load "...." FILL [o vabc] new feature: load "...." FILL -- loads a crystal structure such that a given volume is packed -- volume can be the current boundbox or the current unitcell -- can specify origin and a,b,c vectors or origin and diagonal vector -- no parameters --> {0 0 0} {10 10 10} -- when not a crystal, just loads this model with the specified boundbox -- simplification of initial idea (6/4/2015) Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/aflow/AFLOWReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java trunk/Jmol/src/org/jmol/scriptext/CmdExt.java trunk/Jmol/src/org/jmol/viewer/AnimationManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/Viewer.java trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/StatusListener.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/aflow/AFLOWReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/aflow/AFLOWReader.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/adapter/readers/aflow/AFLOWReader.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -11,6 +11,7 @@ import org.jmol.adapter.readers.xtal.VaspPoscarReader; import org.jmol.java.BS; +import org.jmol.util.Logger; /** * A reader for various AFLOW file types. @@ -42,6 +43,7 @@ private boolean getComposition; private String listKey, listKeyCase; private int fileModelNumber; + private boolean havePRE; @@ -137,11 +139,15 @@ compositions = new Hashtable<String, float[]>(); quiet = true; asc.bsAtoms = new BS(); + addJmolScript("unitcell off;axes off;"); + havePRE = (line.indexOf("Structure PRE") >= 0); } @Override protected boolean checkLine() throws Exception { - discardLinesUntilContains("Structure PRE"); + if (!havePRE) + discardLinesUntilContains("Structure PRE"); + havePRE = false; if (line == null) return false; continuing &= readPrePost(); @@ -153,6 +159,7 @@ String titleMsg = "" + (modelNumber+1) + (getComposition ? "," + fileModelNumber + ", Cb=" + fracB : ""); elementLabel = null; + int n0 = asc.bsAtoms.cardinality(); if (readPRE) { readStructure(titleMsg); } else { @@ -167,11 +174,70 @@ // offset.scale(-0.5f); //asc.setModelInfoForSet("unitCellOffset", offset, asc.iSet); } else { - asc.removeCurrentAtomSet(); + asc.bsAtoms.clearBits(asc.getLastAtomSetAtomIndex(), asc.ac); + doCheckUnitCell = false; } + finalizeModel(); + if (n0 != asc.bsAtoms.cardinality()) + Logger.info("AFLOW: file#, saved#, atoms: " + fileModelNumber + " " + modelNumber + " " + (asc.bsAtoms.cardinality() - n0)); return !haveModel || modelNumber != desiredModelNumber; } + private void finalizeModel() throws Exception { + int n = asc.ac; + int nremoved = 0; + int i0 = asc.getLastAtomSetAtomIndex(); + int nnow = 0; + for (int i = i0; i < n; i++) { + if (!asc.bsAtoms.get(i)) { + nremoved++; + asc.ac--; + asc.atoms[i] = null; + continue; + } + if (nremoved > 0) { + asc.atoms[asc.atoms[i].index = i - nremoved] = asc.atoms[i]; + asc.atoms[i] = null; + } + nnow++; + } + asc.atomSetAtomCounts[asc.iSet] = nnow; + if (nnow == 0) { + asc.iSet--; + asc.atomSetCount--; + } else { + asc.bsAtoms.setBits(i0, i0 + nnow); + } + } + + /** + * scan the AFLOWReader PRE structure for elements in coord section + * @throws Exception + */ + private void readElementLabelsOnly() throws Exception { + readLines(5); + rdline(); + int n = getTokens().length; + elementLabel = new String[n]; + rdline(); // DIRECT + line = ""; + String s = null, last = null; + for (int i = 0; i < n; i++) { + while (s == null || s.equals(last)) { + rdline(); + String[] tokens = getTokens(); + if (tokens.length != 4 + || (s = elementLabel[i] = getElement(tokens[3])) == null) { + i = n + 1; + break; + } + } + last = s; + } + if (s == null) + elementLabel = defaultLabels; + } + private boolean getData() throws Exception { discardLinesUntilContains("- DATA -"); Map<String, Object> htAFLOW = new Hashtable<String, Object>(); @@ -181,6 +247,8 @@ SB sb = new SB(); float listVal = Float.MAX_VALUE; String strcb = "?"; + String listValStr = null; + float cb = 0; while (rdline() != null && (pt = line.indexOf(" # ")) >= 0) { String key = line.substring(pt + 3).trim(); String val = line.substring(0, pt).trim(); @@ -188,7 +256,7 @@ if (key.toUpperCase().startsWith(listKey)) { listKey = key.toUpperCase(); listKeyCase = key; - asc.setAtomSetName(aabb + " " + (getComposition ? fracB + " " : " ") + key + "=" + val); + listValStr = val; listVal = parseFloatStr(val); } if (key.equals("Ca")) { @@ -197,11 +265,12 @@ return false; } else if (key.equals("Cb")) { - float cb = parseFloatStr(strcb = val); + cb = parseFloatStr(strcb = val); if (getComposition && Math.abs(cb - fracB) > 0.01f) return false; } } + asc.setAtomSetName(aabb + " " + cb + " " + listKey + "=" + listValStr); float[] count_min = compositions.get(strcb); if (count_min == null) compositions.put(strcb, count_min = new float[] {0, Float.MAX_VALUE } ); Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -11,11 +11,16 @@ import javajs.util.SB; /** + * + * adjusted for AFLOW options - adding element names, environment radius on atom line + * * http://cms.mpi.univie.ac.at/vasp/ * * @author Pieremanuele Canepa, Wake Forest University, Department of Physics * Winston Salem, NC 27106, cane...@wfu.edu (pcan...@mit.edu) * + * @author Bob Hanson + * * @version 1.0 */ @@ -44,34 +49,6 @@ asc.setAtomSetName(title + (titleMsg == null ? "" : "[" + titleMsg + "]")); } - /** - * scan the AFLOWReader PRE structure for elements in coord section - * @throws Exception - */ - protected void readElementLabelsOnly() throws Exception { - readLines(5); - rdline(); - int n = getTokens().length; - elementLabel = new String[n]; - rdline(); // DIRECT - line = ""; - String s = null, last = null; - for (int i = 0; i < n; i++) { - while (s == null || s.equals(last)) { - rdline(); - String[] tokens = getTokens(); - if (tokens.length != 4 - || (s = elementLabel[i] = getElement(tokens[3])) == null) { - i = n + 1; - break; - } - } - last = s; - } - if (s == null) - elementLabel = defaultLabels; - } - @Override protected void finalizeSubclassReader() throws Exception { if (!haveAtomLabels && !atomsLabeledInline) @@ -148,6 +125,9 @@ asc.setAtomSetName(s); } + int radiusPt = Integer.MIN_VALUE; + int elementPt = Integer.MIN_VALUE; + protected void readCoordinates() throws Exception { // If Selective is there, then skip a line boolean isSelective = discardLinesUntilNonBlank().toLowerCase().contains("selective"); @@ -159,12 +139,18 @@ for (int i = 0; i < ac; i++) { float radius = Float.NaN; String[] tokens = PT.getTokens(rdline()); - if (tokens.length == 4 && tokens[3].indexOf(".") >= 0) - radius = parseFloatStr(tokens[3]); - if (!isSelective && i == 0 && !atomsLabeledInline && tokens.length > 3 - && (tokens[3] = getElement(tokens[3])) != null) - atomsLabeledInline = true; - String label = (atomsLabeledInline ? tokens[3] : atomLabels.get(i)); + if (radiusPt == Integer.MIN_VALUE) { + for (int j = tokens.length - 1; --j > 2;) + if (tokens[j].equals("radius")) { + radiusPt = j + 1; + } else if (getElement(tokens[j]) != null) { + elementPt = j; + atomsLabeledInline = true; + } + } + if (radiusPt >= 0) + radius = parseFloatStr(tokens[radiusPt]); + String label = (atomsLabeledInline ? tokens[elementPt] : atomLabels.get(i)); if (isCartesian) for (int j = 0; j < 3; j++) tokens[j] = "" + parseFloatStr(tokens[j]) * scaleFac; @@ -183,7 +169,7 @@ * @param token * @return element symbol */ - private String getElement(String token) { + protected String getElement(String token) { String s = null; switch (token.length()) { default: Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -457,6 +457,7 @@ atomSetAtomCounts[iSet] = 0; iSet--; atomSetCount--; + reader.doCheckUnitCell = false; } public int getHydrogenAtomCount() { Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -214,10 +214,6 @@ private Lst<String> moreUnitCellInfo; -// public void finalize() { -// System.out.println(this + " finalized"); -// } - protected String filePath; protected String fileName; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -54,7 +54,7 @@ "pymol.", ";PyMOL;", "simple.", ";Alchemy;Ampac;Cube;FoldingXyz;GhemicalMM;HyperChem;Jme;JSON;Mopac;MopacArchive;Tinker;Input;", "xtal.", ";Abinit;Aims;Bilbao;Castep;Cgd;Crystal;Dmol;Espresso;Gulp;Jana;Magres;Shelx;Siesta;VaspOutcar;" + - "VaspPoscar;VaspChgcar;Wien2k;Xcrysden;", + "VaspPoscar;Wien2k;Xcrysden;", "xml.", ";XmlArgus;XmlCml;XmlChem3d;XmlMolpro;XmlOdyssey;XmlXsd;XmlVasp;XmlQE;", }; @@ -664,7 +664,7 @@ String type = recordTags[0]; if (!type.equals("Xml")) return type; - if (header.indexOf("/AFLOWDATA/") >= 0) + if (header.indexOf("/AFLOWDATA/") >= 0 || header.indexOf("-- Structure PRE --") >= 0) return "AFLOW"; // for XML check for an error message from a server -- certainly not XML // but new CML format includes xmlns:xhtml="http://www.w3.org/1999/xhtml" in <cml> tag. @@ -822,12 +822,9 @@ return "Gromacs"; if (checkCrystal(lines)) return "Crystal"; - if (checkCastep(lines)) - return "Castep"; - if (checkVasp(lines, true)) - return "VaspPoscar"; - if (checkVasp(lines, false)) - return "VaspChgcar"; + String s = checkCastepVasp(lines); + if (s != null) + return s; return null; } @@ -862,27 +859,21 @@ return true; } - private static boolean checkCastep(String[] lines) { + private static String checkCastepVasp(String[] lines) { for ( int i = 0; i<lines.length; i++ ) { - if (lines[i].indexOf("Frequencies in cm-1") == 1 - || lines[i].contains("CASTEP") - || lines[i].toUpperCase().startsWith("%BLOCK LATTICE_ABC") - || lines[i].toUpperCase().startsWith("%BLOCK LATTICE_CART") - || lines[i].toUpperCase().startsWith("%BLOCK POSITIONS_FRAC") - || lines[i].toUpperCase().startsWith("%BLOCK POSITIONS_ABS") - || lines[i].contains("<-- E")) return true; + String line = lines[i].toUpperCase(); + if (line.indexOf("FREQUENCIES IN CM-1") == 1 + || line.contains("CASTEP") + || line.startsWith("%BLOCK LATTICE_ABC") + || line.startsWith("%BLOCK LATTICE_CART") + || line.startsWith("%BLOCK POSITIONS_FRAC") + || line.startsWith("%BLOCK POSITIONS_ABS") + || line.contains("<-- E")) return "Castep"; + if (i > 6 && i < 10 && (line.startsWith("DIRECT") || line.startsWith("CARTESIAN"))) + return "VaspPoscar"; } - return false; + return null; } - private static boolean checkVasp(String[] lines, boolean isPoscar) { - int i = (isPoscar ? (lines[5].length() < 2 ? 8 : 7) : 6); - String line = lines[i].toLowerCase(); - if (isPoscar && line.contains("selective")) - line = lines[++i].toLowerCase(); - return (line.contains("direct") || line.contains("cartesian")); - } - - } Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -474,28 +474,63 @@ */ private int checkPacked(int i, Map<String, Object> htParams, SB sOptions) throws ScriptException { - if (tokAt(i) == T.fill) { + switch (tokAt(i)) { + case T.fill: + T3[] pts = null; int tok = tokAt(++i); - e.iToken = i; - SymmetryInterface unitCell = null; - boolean isArray = e.isArrayParameter(i + 1); - T3[] pts = (isArray ? e.getPointArray(++i, 4, false) : null); - if (!e.chk) { - if (!isArray && tok == T.unitcell) { - unitCell = vwr.getCurrentUnitCell(); - if (unitCell != null) - pts = BoxInfo.getUnitCellPoints( - unitCell.getUnitCellVerticesNoOffset(), - unitCell.getCartesianOffset()); + switch (tok) { + case T.unitcell: + case T.boundbox: + break; + default: + if (e.isArrayParameter(i)) { + pts = e.getPointArray(i, -1, false); + i = e.iToken; + } else { + pts = new P3[0]; + --i; } - if (pts == null) - pts = BoxInfo.getUnitCellPoints(vwr.ms.getBBoxVertices(), null); - System.out.println("CmdExt load center at " + pts[0]); - htParams.put("fillRange", pts); } - i = ++e.iToken; - } - if (tokAt(i) == T.packed) { + i++; + if (e.chk) + return i; + switch (tok) { + case T.unitcell: + SymmetryInterface unitCell = vwr.getCurrentUnitCell(); + if (unitCell != null) { + pts = BoxInfo.getUnitCellPoints( + unitCell.getUnitCellVerticesNoOffset(), + unitCell.getCartesianOffset()); + break; + } + //$FALL-THROUGH$ + case T.boundbox: + pts = BoxInfo.getUnitCellPoints(vwr.ms.getBBoxVertices(), null); + break; + } + switch (pts.length) { + case 2: + // origin and diagonal vector + T3 a = pts[1]; + pts = new T3[] { pts[0], P3.newP(pts[0]), new P3(), new P3(), new P3() }; + pts[1].x = a.x; + pts[2].y = a.y; + pts[3].z = a.z; + break; + case 3: + // implicit origin {0 0 0} with three vectors + pts = new T3[] { new P3(), pts[0], pts[1], pts[2] }; + break; + case 4: + break; + default: + // {0 0 0} with 10x10x10 cell + pts = new T3[] { new P3(), P3.new3(10, 0, 0), P3.new3(0, 10, 0), P3.new3(0, 0, 10) }; + } + htParams.put("fillRange", pts); + sOptions.append(" FILL [" + pts[0] + pts[1] + pts[2] + pts[3] + "]"); + break; + case T.packed: float f = Float.NaN; if (isFloatParameter(++i)) f = floatParameter(i++); @@ -507,6 +542,7 @@ sOptions.append(" " + f); } } + break; } return i; } Modified: trunk/Jmol/src/org/jmol/viewer/AnimationManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/AnimationManager.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/viewer/AnimationManager.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -78,7 +78,7 @@ vwr.refresh(3, "Viewer:setAnimationOff"); animation(false); //stopModulationThread(); - vwr.setStatusFrameChanged(false, true); + vwr.setStatusFrameChanged(false, false); } @@ -432,7 +432,7 @@ setBackgroundModelIndex(-1); vwr.setTainted(true); setFrameRangeVisible(); - vwr.setStatusFrameChanged(false, true); + vwr.setStatusFrameChanged(false, false); if (vwr.ms != null && !vwr.g.selectAllModels) vwr.slm.setSelectionSubset(vwr.getModelUndeletedAtomsBitSet(cmi)); } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-06-05 23:16:38 UTC (rev 20552) @@ -14,8 +14,23 @@ TODO: remove HTML5 dependency on synchronous file loading (check SCRIPT command for problems) -Jmol.___JmolVersion="14.3.14_2015.06.04" +Jmol.___JmolVersion="14.3.14_2015.06.05" +new feature: load "...." FILL BOUNDBOX +new feature: load "...." FILL UNITCELL +new feature: load "...." FILL [o va vb vc] +new feature: load "...." FILL [o vabc] +new feature: load "...." FILL + + -- loads a crystal structure such that a given volume is packed + -- volume can be the current boundbox or the current unitcell + -- can specify origin and a,b,c vectors or origin and diagonal vector + -- no parameters --> {0 0 0} {10 10 10} + -- when not a crystal, just loads this model with the specified boundbox + -- simplification of initial idea (6/4/2015) + +JmolVersion="14.3.14_2015.06.04" + new feature: _argCount, _arguments for functions and scripts new feature: _caller for functions @@ -72,15 +87,6 @@ _arguments = [ 5,6,{ "x": "scriptlevel","caller": { },"_arguments": [ "testing","here" ] },7,8,9 ] -new feature: load "...." FILL BOUNDBOX -new feature: load "...." FILL UNITCELL -new feature: load "...." FILL UNITCELL [o a b c] -new feature: load "...." FILL BOUNDBOX [o a b c] - - -- loads a crystal structure such that a given volume is packed - -- volume can be the current boundbox or the current unitcell or a specified origin and a,b,c vectors - -- if BOUNDBOX, sets the current boundbox after loading to be current boundbox - JmolVersion="14.3.14_2015.06.03" new feature: AFLOW binary alloy file reader centers unit cells in all frames at the same point Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -2257,7 +2257,7 @@ runScript(script); break; case T.vibration: - setStatusFrameChanged(true, true); + setStatusFrameChanged(true, false); break; case T.vanderwaals: shm.deleteVdwDependentShapes(null); @@ -4313,8 +4313,7 @@ /** * @param isVib - * @param doNotify - * ignored; not implemented + * @param doNotify -- force even if same frame (file loading) */ void setStatusFrameChanged(boolean isVib, boolean doNotify) { if (isVib) { @@ -4369,7 +4368,7 @@ g.setO("_modelType", (modelIndex < 0 ? "" : ms.getModelFileType(modelIndex))); - if (currentFrame == prevFrame && currentMorphModel == prevMorphModel) + if (!doNotify && currentFrame == prevFrame && currentMorphModel == prevMorphModel) return; prevFrame = currentFrame; prevMorphModel = currentMorphModel; @@ -4555,6 +4554,7 @@ sm.setFileLoadStatus(fullPathName, fileName, modelName, strError, ptLoad.getCode(), doCallback, isAsync); if (doCallback) { +// setStatusFrameChanged(false, true); // ensures proper title in JmolFrame but then we miss the file name if (doHaveJDX()) getJSV().setModel(am.cmi); if (isJS) Modified: trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -1734,11 +1734,15 @@ addMouseListener(this); } + private long lastPressTime; + @Override public void mousePressed(MouseEvent e) { vwr.evalStringQuiet(script); - if (jmolApp.autoAnimationDelay > 0) - vwr.evalStringQuiet("animation_running = true; delay " + jmolApp.autoAnimationDelay + "; if(animation_running){timeout '__animBtn' -200 \"" + script + "\"}"); + long t = System.currentTimeMillis(); + if (t - lastPressTime > jmolApp.autoAnimationDelay * 2000 && jmolApp.autoAnimationDelay > 0) // 0.2 s + vwr.evalStringQuiet("timeout '__animBtn' OFF;animation_running = true; delay " + jmolApp.autoAnimationDelay + "; if(animation_running){timeout '__animBtn' -200 \"" + script + "\"}"); + lastPressTime = t; } @Override Modified: trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/StatusListener.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/StatusListener.java 2015-06-05 05:18:22 UTC (rev 20551) +++ trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/StatusListener.java 2015-06-05 23:16:38 UTC (rev 20552) @@ -139,6 +139,8 @@ //int model = iData[2]; if (display.haveDisplay) { String menuName = (String) data[2]; + if (menuName.equals("0.0: ")) + menuName = ""; display.status.setStatus(1, menuName); if (jmol.frame != null) jmol.frame.setTitle(menuName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits