Revision: 20870 http://sourceforge.net/p/jmol/code/20870 Author: hansonr Date: 2015-11-29 22:18:42 +0000 (Sun, 29 Nov 2015) Log Message: ----------- Jmol.___JmolVersion="14.5.0_2015.11.29"
new feature: drawing of spheres in 2D window -- as percent position or absolute, as for ECHO -- diameter is % if position is %; otherwise is pixels -- examples draw d1 diameter 5 [90 90 %] color blue // 5% diameter draw d2 diameter 15 [90 90] color blue // pixel diameter draw dO diameter 2 [90 90 %] color @{ {_O}.color } set echo eO [95 90 %]; echo "O" -- can be used in the context of an element key: function createElementKey() { var y = 90 for (var e in {*}.element.pivot){ var c = {element=@e}.color draw ID @{"d_"+ e} diameter 2 [90 @y %] color @c set echo ID @{"e_" + e} [91 @{y-1} %] echo @e font echo 24 bold sansserif color echo black y -= 5 } } load $caffeine createElementKey new feature: additional predefined sets for periodic table: "@nonmetal _H,_He,_C,_N,_O,_F,_Ne,_S,_P,_Cl,_Ar,_Se,_Br,_Kr,_I,_Xe,_At,_Rn", "@noblegas _He,_Ne,_Ar,_Kr,_Xe,_Rn", "@metal !nonmetal", "@alkaliMetal _Li,_Na,_K,_Rb,_Cs,_Fr", "@alkalineEarth _Be,_Mg,_Ca,_Sr,_Ba,_Ra", "@semimetal _B,_Si,_Ge,_As,_Sb,_Te,_Po", "@transitionMetal elemno>=21&elemno<=30|elemno>=39&elemno<=48|elemno>=72&elemno<=80|elemno>=104&elemno<=112", "@lanthanide elemno>=57&elemno<=71", "@actinide elemno>=89&elemno<=103", new feature: load =am/<mineralName> loads last (earliest?) entry in American Mineralogist Crystal Database -- for example, load =am/corundum -- reads mineral page such as http://rruff.geo.arizona.edu/AMS/minerals/Corundum and extracts from that the last database ID. -- adding /1, /2, ..., /0 will return only the first, second, ..., last structure on that page -- requires a preliminary search followed by the actual file load. -- only the final ID-based file load is saved in the state. -- a hack; uses an evaluation of the string: 'http://rruff.geo.arizona.edu/AMS/CIF_text_files/'+load('http://rruff.geo.arizona.edu/AMS/minerals/%FILE').split(\"viewJmol('\")[%n].split(\"'\")[1]+'_cif.txt' -- for example, see http://rruff.geo.arizona.edu/AMS/viewJmol.php?id=19280 bug fix: files with names containing "[]" cannot be loaded. bug fix: print {cell=555}.find("cellFormula") can fail because of 2% slop involved in defining cell=555 Modified Paths: -------------- branches/v14_4/Jmol/src/org/jmol/popup/JmolGenericPopup.java branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java branches/v14_4/Jmol/src/org/jmol/shapespecial/Draw.java branches/v14_4/Jmol/src/org/jmol/symmetry/Symmetry.java branches/v14_4/Jmol/src/org/jmol/util/SimpleUnitCell.java branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties branches/v14_4/Jmol/src/org/jmol/viewer/OutputManager.java branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java branches/v14_4/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java trunk/Jmol/src/org/jmol/popup/JmolGenericPopup.java trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java trunk/Jmol/src/org/jmol/script/ScriptEval.java trunk/Jmol/src/org/jmol/script/ScriptParam.java trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/symmetry/Symmetry.java trunk/Jmol/src/org/jmol/symmetry/UnitCellIterator.java trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java trunk/Jmol/src/org/jmol/viewer/GlobalSettings.java trunk/Jmol/src/org/jmol/viewer/JC.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/OutputManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java Modified: branches/v14_4/Jmol/src/org/jmol/popup/JmolGenericPopup.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/popup/JmolGenericPopup.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/popup/JmolGenericPopup.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -362,8 +362,7 @@ int i = modelSetFileName.lastIndexOf("."); isZapped = (JC.ZAP_TITLE.equals(modelSetName)); if (isZapped || "string".equals(modelSetFileName) - || "files".equals(modelSetFileName) - || "string[]".equals(modelSetFileName)) + || "String[]".equals(modelSetFileName)) modelSetFileName = ""; modelSetRoot = modelSetFileName.substring(0, i < 0 ? modelSetFileName.length() : i); Modified: branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/script/ScriptEval.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -4408,7 +4408,7 @@ if (isSmiles) { filename = "$" + filename; } else { - if (filename.indexOf("[]") >= 0) + if (filename.equals("String[]")) return; if (filename.indexOf("[") == 0) { filenames = Escape.unescapeStringArray(filename); @@ -4440,7 +4440,7 @@ i++; // for whatever reason, we don't allow a filename with [] in it. - if (filename.indexOf("[]") >= 0) + if (filename.equals("String[]")) return; // MANIFEST "..." if ((tok = tokAt(i)) == T.manifest) { @@ -4581,7 +4581,7 @@ } else if (!isData) { if (localName != null) localName = vwr.fm.getFilePath(localName, false, false); - if (!filename.equals("string") && !filename.equals("string[]")) + if (!filename.equals("string") && !filename.equals("String[]")) loadScript.append("/*file*/").append( (localName != null ? PT.esc(localName) : "$FILENAME$")); } Modified: branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -2766,15 +2766,14 @@ case T.split: if (x.tok == T.bitset) { BS bsSelected = SV.bsSelectVar(x); - sArg = "\n"; int modelCount = vwr.ms.mc; - s = ""; + Lst<SV> lst = new Lst<SV>(); for (int i = 0; i < modelCount; i++) { - s += (i == 0 ? "" : "\n"); BS bs = vwr.getModelUndeletedAtomsBitSet(i); bs.and(bsSelected); - s += Escape.eBS(bs); + lst.addLast(SV.getVariable(bs)); } + return mp.addXList(lst); } return mp.addXAS(PT.split(s, sArg)); case T.join: Modified: branches/v14_4/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/shapespecial/Draw.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/shapespecial/Draw.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -358,13 +358,6 @@ return; } - if ("coords" == propertyName) { - Lst<SV> pts = (Lst<SV>) value; - for (int i = 0, n = pts.size(); i < n; i++) - vData.addLast(new Object[] { Integer.valueOf(PT_COORD), SV.ptValue(pts.get(i)) }); - return; - } - if ("offset" == propertyName) { offset = V3.newV((P3) value); if (thisMesh != null) @@ -383,9 +376,13 @@ return; } + if ("coords" == propertyName) { + addPoints(PT_COORD, value, false); + return; + } + if ("modelBasedPoints" == propertyName) { - vData.addLast(new Object[] { Integer.valueOf(PT_MODEL_BASED_POINTS), - value }); + addPoints(PT_MODEL_BASED_POINTS, value, true); return; } @@ -419,6 +416,26 @@ setPropertySuper(propertyName, value, bs); } + private void addPoints(int type, Object value, boolean allowNull) { + @SuppressWarnings("unchecked") + Lst<SV> pts = (Lst<SV>) value; + Integer key = Integer.valueOf(type); + for (int i = 0, n = pts.size(); i < n; i++) { + SV v = pts.get(i); + P3 pt; + switch (v.tok) { + case T.bitset: + if (!allowNull && ((BS) v.value).isEmpty()) + continue; + pt = vwr.ms.getAtomSetCenter((BS) v.value); + break; + default: + pt = SV.ptValue(v); + } + vData.addLast(new Object[] { key, pt }); + } + } + private void deleteModels(int modelIndex) { //int firstAtomDeleted = ((int[])((Object[])value)[2])[1]; //int nAtomsDeleted = ((int[])((Object[])value)[2])[2]; Modified: branches/v14_4/Jmol/src/org/jmol/symmetry/Symmetry.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/symmetry/Symmetry.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/symmetry/Symmetry.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -378,7 +378,6 @@ public boolean checkUnitCell(SymmetryInterface uc, P3 cell, P3 ptTemp, boolean isAbsolute) { uc.toFractional(ptTemp, isAbsolute); - float slop = 0.02f; // {1 1 1} here is the original cell return (ptTemp.x >= cell.x - 1f - slop && ptTemp.x <= cell.x + slop && ptTemp.y >= cell.y - 1f - slop && ptTemp.y <= cell.y + slop Modified: branches/v14_4/Jmol/src/org/jmol/util/SimpleUnitCell.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/util/SimpleUnitCell.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/util/SimpleUnitCell.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -373,18 +373,22 @@ cell.z = (nnn % f) + offset; } + public final static float SLOP = 0.02f; + private final static float SLOP1 = 1 - SLOP; + /** * calculate weighting of 1 (interior), 0.5 (face), 0.25 (edge), or 0.125 (vertex) * @param pt + * @param tolerance fractional allowance to consider this on an edge * @return weighting */ public static float getCellWeight(P3 pt) { float f = 1; - if (pt.x == 0) + if (pt.x <= SLOP || pt.x >= SLOP1) f /= 2; - if (pt.y == 0) + if (pt.y <= SLOP || pt.y >= SLOP1) f /= 2; - if (pt.z == 0) + if (pt.z <= SLOP || pt.z >= SLOP1) f /= 2; return f; } Modified: branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties 2015-11-29 22:18:42 UTC (rev 20870) @@ -8,8 +8,17 @@ # see also http://chemapps.stolaf.edu/jmol/zip for daily updates -Jmol.___JmolVersion="14.4.0_2015.11.26" +Jmol.___JmolVersion="14.4.0_2015.11.29" +bug fix: files with names containing "[]" cannot be loaded. +bug fix: print {cell=555}.find("cellFormula") can fail because of 2% slop involved in defining cell=555 + +JmolVersion="14.4.0_2015.11.27" + +bug fix: {atomset}.split() [split atomset by model] returns array of strings, not array of atoms + +JmolVersion="14.4.0_2015.11.26" + bug fix: getproperty SHAPEINFO fails if CGO is present bug fix: CGO from state deletes DRAW objects bug fix: CGO not properly isolated to current model; "fixed" not implemented Modified: branches/v14_4/Jmol/src/org/jmol/viewer/OutputManager.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/viewer/OutputManager.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/viewer/OutputManager.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -565,7 +565,7 @@ fileName = fullPath[0]; String pathName = (type.equals("FILE") ? vwr.fm.getFullPathName(false) : null); boolean getCurrentFile = (pathName != null && (pathName.equals("string") - || pathName.indexOf("[]") >= 0 || pathName.equals("JSNode"))); + || pathName.equals("String[]") || pathName.equals("JSNode"))); boolean asBytes = (pathName != null && !getCurrentFile); if (asBytes) { pathName = vwr.getModelSetPathName(); Modified: branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -1851,7 +1851,7 @@ Map<String, Object> htParams, SB loadScript) { if (fileName == null) return null; - if (fileName.indexOf("[]") >= 0) { + if (fileName.equals("String[]")) { // no reloading of string[] or file[] data -- just too complicated return null; } @@ -2287,7 +2287,7 @@ String filename = fm.getFullPathName(false); if (filename.equals("string") || filename.equals(JC.MODELKIT_ZAP_TITLE)) return ms.getInlineData(am.cmi); - if (filename.indexOf("[]") >= 0) + if (filename.equals("String[]")) return filename; if (filename == "JSNode") return "<DOM NODE>"; Modified: branches/v14_4/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java =================================================================== --- branches/v14_4/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java 2015-11-27 11:57:16 UTC (rev 20869) +++ branches/v14_4/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -1576,7 +1576,7 @@ static final String chemFileProperty = "chemFile"; void notifyFileOpen(String fullPathName, String title) { - if (fullPathName == null || !fullPathName.equals("file[]")) { + if (fullPathName == null || !fullPathName.equals("String[]")) { int pt = (fullPathName == null ? -1 : fullPathName.lastIndexOf("|")); if (pt > 0) fullPathName = fullPathName.substring(0, pt); Modified: trunk/Jmol/src/org/jmol/popup/JmolGenericPopup.java =================================================================== --- trunk/Jmol/src/org/jmol/popup/JmolGenericPopup.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/popup/JmolGenericPopup.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -362,8 +362,7 @@ int i = modelSetFileName.lastIndexOf("."); isZapped = (JC.ZAP_TITLE.equals(modelSetName)); if (isZapped || "string".equals(modelSetFileName) - || "files".equals(modelSetFileName) - || "string[]".equals(modelSetFileName)) + || "String[]".equals(modelSetFileName)) modelSetFileName = ""; modelSetRoot = modelSetFileName.substring(0, i < 0 ? modelSetFileName.length() : i); Modified: trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -133,20 +133,24 @@ if (diameter == 0) diameter = 1; } - if ((dmesh.isVector) && dmesh.haveXyPoints) { - int ptXY = 0; - // [x y] or [x,y] refers to an xy point on the screen - // just a Point3f with z = Float.MAX_VALUE - // [x y %] or [x,y %] refers to an xy point on the screen - // as a percent - // just a Point3f with z = -Float.MAX_VALUE - for (int i = 0; i < 2; i++) - if (vertices[i].z == Float.MAX_VALUE - || vertices[i].z == -Float.MAX_VALUE) - ptXY += i + 1; - if (--ptXY < 2) { - renderXyArrow(ptXY); - return; + if (dmesh.haveXyPoints) { + if (dmesh.isVector) { + int ptXY = 0; + // [x y] or [x,y] refers to an xy point on the screen + // just a Point3f with z = Float.MAX_VALUE + // [x y %] or [x,y %] refers to an xy point on the screen + // as a percent + // just a Point3f with z = -Float.MAX_VALUE + for (int i = 0; i < 2; i++) + if (vertices[i].z == Float.MAX_VALUE + || vertices[i].z == -Float.MAX_VALUE) + ptXY += i + 1; + if (--ptXY < 2) { + renderXyArrow(ptXY); + return; + } + } else if (drawType == Draw.EnumDrawType.POINT){ + renderXyPoint(); } } int tension = 5; @@ -353,7 +357,26 @@ } } + private void renderXyPoint() { + // new in Jmol 14.5 + pt0.setT(vertices[0]); + if (diameter == 0) + diameter = (int) width; + if (pt0.z == -Float.MAX_VALUE) { + pt0.x *= vwr.tm.width / 100f; + pt0.y *= vwr.tm.height / 100f; + diameter = (int) (diameter * vwr.getScreenDim() / 100f); + } + if (g3d.isAntialiased()) + diameter *= 2; + pt0.y = vwr.tm.height - pt0.y; + pt0.z = vwr.tm.cameraDistance; + pt1i.set((int) pt0.x, (int) pt0.y, (int) pt0.z); + g3d.fillSphereI(diameter, pt1i); + } + private void renderXyArrow(int ptXY) { + // only 0 or 1 here; so ptXYZ is 1 or 0 int ptXYZ = 1 - ptXY; P3[] arrowPt = new P3[2]; arrowPt[ptXYZ] = pt1; Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -4407,7 +4407,7 @@ if (isSmiles) { filename = "$" + filename; } else { - if (filename.indexOf("[]") >= 0) + if (filename.equals("String[]")) return; if (filename.indexOf("[") == 0) { filenames = Escape.unescapeStringArray(filename); @@ -4439,7 +4439,7 @@ i++; // for whatever reason, we don't allow a filename with [] in it. - if (filename.indexOf("[]") >= 0) + if (filename.equals("String[]")) return; // MANIFEST "..." if ((tok = tokAt(i)) == T.manifest) { @@ -4580,7 +4580,7 @@ } else if (!isData) { if (localName != null) localName = vwr.fm.getFilePath(localName, false, false); - if (!filename.equals("string") && !filename.equals("string[]")) + if (!filename.equals("string") && !filename.equals("String[]")) loadScript.append("/*file*/").append( (localName != null ? PT.esc(localName) : "$FILENAME$")); } Modified: trunk/Jmol/src/org/jmol/script/ScriptParam.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptParam.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/script/ScriptParam.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -553,6 +553,40 @@ return pt; } + public P4 xyzpParameter(int index) throws ScriptException { + // [x y z] or [x,y,z] refers to an xy point on the screen + // return a P4 with w = Float.MAX_VALUE + // [x y z%] or [x,y,z %] refers to an xyz point on the screen + // as a percent + // return a P4 with w = -Float.MAX_VALUE + + int tok = tokAt(index); + if (tok == T.spacebeforesquare) + tok = tokAt(++index); + if (tok != T.leftsquare || !isFloatParameter(++index)) + return null; + P4 pt = new P4(); + pt.x = floatParameter(index); + if (tokAt(++index) == T.comma) + index++; + if (!isFloatParameter(index)) + return null; + pt.y = floatParameter(index); + if (tokAt(++index) == T.comma) + index++; + if (!isFloatParameter(index)) + return null; + pt.z = floatParameter(index); + boolean isPercent = (tokAt(++index) == T.percent); + if (isPercent) + ++index; + if (tokAt(index) != T.rightsquare) + return null; + iToken = index; + pt.w = (isPercent ? -1 : 1) * Float.MAX_VALUE; + return pt; + } + public String optParameterAsString(int i) throws ScriptException { if (i >= slen) return ""; Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -880,7 +880,8 @@ if (nVertices == 3 && isPlane) isPlane = false; length = Float.MAX_VALUE; - thisMesh.diameter = 0; + if (isVector) + thisMesh.diameter = 0; } else if (nVertices == 2 && isVector) { ptList[1].add(ptList[0]); } Modified: trunk/Jmol/src/org/jmol/symmetry/Symmetry.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/Symmetry.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/symmetry/Symmetry.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -378,11 +378,10 @@ public boolean checkUnitCell(SymmetryInterface uc, P3 cell, P3 ptTemp, boolean isAbsolute) { uc.toFractional(ptTemp, isAbsolute); - float slop = 0.02f; // {1 1 1} here is the original cell - return (ptTemp.x >= cell.x - 1f - slop && ptTemp.x <= cell.x + slop - && ptTemp.y >= cell.y - 1f - slop && ptTemp.y <= cell.y + slop - && ptTemp.z >= cell.z - 1f - slop && ptTemp.z <= cell.z + slop); + return (ptTemp.x >= cell.x - 1f - SimpleUnitCell.SLOP && ptTemp.x <= cell.x + SimpleUnitCell.SLOP + && ptTemp.y >= cell.y - 1f - SimpleUnitCell.SLOP && ptTemp.y <= cell.y + SimpleUnitCell.SLOP + && ptTemp.z >= cell.z - 1f - SimpleUnitCell.SLOP && ptTemp.z <= cell.z + SimpleUnitCell.SLOP); } @Override Modified: trunk/Jmol/src/org/jmol/symmetry/UnitCellIterator.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/UnitCellIterator.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/symmetry/UnitCellIterator.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -44,10 +44,13 @@ * @param atom * @param atoms * @param bsAtoms - * @param distance <= 0 indicates that distance will be set later, probably from a point + * @param distance + * <= 0 indicates that distance will be set later, probably from a + * point * @return */ - public UnitCellIterator set(SymmetryInterface unitCell, Atom atom, Atom[] atoms, BS bsAtoms, float distance) { + public UnitCellIterator set(SymmetryInterface unitCell, Atom atom, + Atom[] atoms, BS bsAtoms, float distance) { this.unitCell = unitCell; this.atoms = atoms; addAtoms(bsAtoms); @@ -95,13 +98,15 @@ if (max.z < p.z) max.z = p.z; } - minXYZ = P3i.new3((int)Math.floor(min.x), (int)Math.floor(min.y), (int)Math.floor(min.z)); - maxXYZ = P3i.new3((int)Math.ceil(max.x), (int)Math.ceil(max.y), (int)Math.ceil(max.z)); + minXYZ = P3i.new3((int) Math.floor(min.x), (int) Math.floor(min.y), + (int) Math.floor(min.z)); + maxXYZ = P3i.new3((int) Math.ceil(max.x), (int) Math.ceil(max.y), + (int) Math.ceil(max.z)); if (Logger.debugging) Logger.info("UnitCellIterator minxyz/maxxyz " + minXYZ + " " + maxXYZ); t = P3i.new3(minXYZ.x - 1, minXYZ.y, minXYZ.z); nextCell(); - } + } @Override public void addAtoms(BS bsAtoms) { @@ -109,7 +114,7 @@ if (done) return; unitList = new Lst<P3[]>(); - String cat = ""; + String cat = ""; M4[] ops = unitCell.getSymmetryOperations(); int nOps = ops.length; for (int i = bsAtoms.nextSetBit(0); i >= 0; i = bsAtoms.nextSetBit(i + 1)) { @@ -123,7 +128,7 @@ unitCell.unitize(pt); unitCell.toCartesian(pt, false); } else { - unitCell.toUnitCell(pt, null); + unitCell.toUnitCell(pt, null); } String key = "_" + (int) (pt.x * 100) + "_" + (int) (pt.y * 100) + "_" + (int) (pt.z * 100) + "_"; @@ -151,9 +156,9 @@ } return false; } - + private boolean nextCell() { - if (done) + if (done) return false; if (++t.x >= maxXYZ.x) { t.x = minXYZ.x; @@ -176,7 +181,7 @@ public int next() { return (done || ipt < 0 ? -1 : getAtom().i); } - + private Atom getAtom() { return ((Atom) unitList.get(listPt)[0]); } @@ -190,7 +195,7 @@ public P3 getPosition() { Atom a = getAtom(); if (Logger.debugging) - Logger.info("draw ID p_" + nFound + " " + p + " //" + a + " " + t); + Logger.info("draw ID p_" + nFound + " " + p + " //" + a + " " + t); if (this.p.distanceSquared(a) < 0.0001f) return a; Point3fi p = new Point3fi(); Modified: trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java =================================================================== --- trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -373,18 +373,22 @@ cell.z = (nnn % f) + offset; } + public final static float SLOP = 0.02f; + private final static float SLOP1 = 1 - SLOP; + /** * calculate weighting of 1 (interior), 0.5 (face), 0.25 (edge), or 0.125 (vertex) * @param pt + * @param tolerance fractional allowance to consider this on an edge * @return weighting */ public static float getCellWeight(P3 pt) { float f = 1; - if (pt.x == 0) + if (pt.x <= SLOP || pt.x >= SLOP1) f /= 2; - if (pt.y == 0) + if (pt.y <= SLOP || pt.y >= SLOP1) f /= 2; - if (pt.z == 0) + if (pt.z <= SLOP || pt.z >= SLOP1) f /= 2; return f; } Modified: trunk/Jmol/src/org/jmol/viewer/GlobalSettings.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/GlobalSettings.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/viewer/GlobalSettings.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -889,32 +889,42 @@ return structureList; } - String resolveDataBase(String database, String id, String format) { - if (format == null) { - if ((format = databases.get(database.toLowerCase())) == null) - return null; - if (id.indexOf("/") < 0) { - if (database.equals("pubchem")) - id = "name/" + id; - else if (database.equals("nci")) - id += "/file?format=sdf&get3d=True"; - } - } else if (id.indexOf(".") >= 0 && format.indexOf("%FILE.") >= 0) { - // replace RCSB format extension when a file extension is made explicit - format = format.substring(0, format.indexOf("%FILE")); + String resolveDataBase(String database, String id, String format) { + if (format == null) { + if ((format = databases.get(database.toLowerCase())) == null) + return null; + int pt = id.indexOf("/"); + if (pt < 0) { + if (database.equals("pubchem")) + id = "name/" + id; + else if (database.equals("nci")) + id += "/file?format=sdf&get3d=True"; } - try { - while (format.indexOf("%c") >= 0) - for (int i = 1; i < 10; i++) { - format = PT.rep(format, "%c" + i, id.substring(i - 1, i)); - } - } catch (Exception e) { - // too bad. + if (format.startsWith("'")) { + // needs evaluation + int n = (pt > 0 ? PT.parseInt(id.substring(pt + 1)) : 0); + if (n > 0) + n++; + if (pt > 0) + id = id.substring(0, pt); + format = PT.rep(format, "%n", "" + n); } - return (format.indexOf("%FILE") >= 0 ? PT.formatStringS(format, "FILE", id) - : format.indexOf("%file") >= 0 ? PT.formatStringS(format, "file", - id.toLowerCase()) : format + id); + } else if (id.indexOf(".") >= 0 && format.indexOf("%FILE.") >= 0) { + // replace RCSB format extension when a file extension is made explicit + format = format.substring(0, format.indexOf("%FILE")); } + try { + while (format.indexOf("%c") >= 0) + for (int i = 1; i < 10; i++) { + format = PT.rep(format, "%c" + i, id.substring(i - 1, i)); + } + } catch (Exception e) { + // too bad. + } + return (format.indexOf("%FILE") >= 0 ? PT.formatStringS(format, "FILE", id) + : format.indexOf("%file") >= 0 ? PT.formatStringS(format, "file", + id.toLowerCase()) : format + id); + } static boolean doReportProperty(String name) { return (name.charAt(0) != '_' && unreportedProperties.indexOf(";" + name Modified: trunk/Jmol/src/org/jmol/viewer/JC.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/JC.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/viewer/JC.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -67,7 +67,8 @@ "pubchem", "http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/%FILE/SDF?record_type=3d", "map", "http://www.ebi.ac.uk/pdbe/api/%TYPE/%FILE?pretty=false&metadata=true", "rna3d", "http://rna.bgsu.edu/rna3dhub/%TYPE/download/%FILE", - "aflow", "http://aflowlib.mems.duke.edu/users/jmolers/binary_new/%FILE.aflow_binary" + "aflow", "http://aflowlib.mems.duke.edu/users/jmolers/binary_new/%FILE.aflow_binary", + "am", "'http://rruff.geo.arizona.edu/AMS/CIF_text_files/'+load('http://rruff.geo.arizona.edu/AMS/minerals/%FILE').split(\"viewJmol('\")[%n].split(\"'\")[1]+'_cif.txt'" }; public static String[] macros = { @@ -561,6 +562,7 @@ "@ssSegments within(dssr,'ssSegments')", "@stacks within(dssr,'stacks')", "@stems within(dssr,'stems')", + }; // these are only updated once per file load or file append @@ -627,8 +629,19 @@ "@spine protein&_a>=1&_a<4|nucleic&(_a>=6&_a<11|_a=13)", "@sidechain (protein,nucleic) & !backbone", "@base nucleic & !backbone", - "@dynamic_flatring search('[a]')" + "@dynamic_flatring search('[a]')", + //periodic table + "@nonmetal _H,_He,_C,_N,_O,_F,_Ne,_S,_P,_Cl,_Ar,_Se,_Br,_Kr,_I,_Xe,_At,_Rn", + "@noblegas _He,_Ne,_Ar,_Kr,_Xe,_Rn", + "@metal !nonmetal", + "@alkaliMetal _Li,_Na,_K,_Rb,_Cs,_Fr", + "@alkalineEarth _Be,_Mg,_Ca,_Sr,_Ba,_Ra", + "@semimetal _B,_Si,_Ge,_As,_Sb,_Te,_Po", + "@transitionMetal elemno>=21&elemno<=30|elemno>=39&elemno<=48|elemno>=72&elemno<=80|elemno>=104&elemno<=112", + "@lanthanide elemno>=57&elemno<=71", + "@actinide elemno>=89&elemno<=103", + // "@hetero", handled specially }; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-11-29 22:18:42 UTC (rev 20870) @@ -62,8 +62,59 @@ TODO: consider if models with no atoms will cause issues in relation to model.firstAtomIndex -Jmol.___JmolVersion="14.5.0_2015.11.27" +Jmol.___JmolVersion="14.5.0_2015.11.29" +new feature: drawing of spheres in 2D window + -- as percent position or absolute, as for ECHO + -- diameter is % if position is %; otherwise is pixels + -- examples + draw d1 diameter 5 [90 90 %] color blue // 5% diameter + draw d2 diameter 15 [90 90] color blue // pixel diameter + draw dO diameter 2 [90 90 %] color @{ {_O}.color } + set echo eO [95 90 %]; echo "O" + -- can be used in the context of an element key: + function createElementKey() { + var y = 90 + for (var e in {*}.element.pivot){ + var c = {element=@e}.color + draw ID @{"d_"+ e} diameter 2 [90 @y %] color @c + set echo ID @{"e_" + e} [91 @{y-1} %] + echo @e + font echo 24 bold sansserif + color echo black + y -= 5 + } + } + load $caffeine + createElementKey + +new feature: additional predefined sets for periodic table: + "@nonmetal _H,_He,_C,_N,_O,_F,_Ne,_S,_P,_Cl,_Ar,_Se,_Br,_Kr,_I,_Xe,_At,_Rn", + "@noblegas _He,_Ne,_Ar,_Kr,_Xe,_Rn", + "@metal !nonmetal", + "@alkaliMetal _Li,_Na,_K,_Rb,_Cs,_Fr", + "@alkalineEarth _Be,_Mg,_Ca,_Sr,_Ba,_Ra", + "@semimetal _B,_Si,_Ge,_As,_Sb,_Te,_Po", + "@transitionMetal elemno>=21&elemno<=30|elemno>=39&elemno<=48|elemno>=72&elemno<=80|elemno>=104&elemno<=112", + "@lanthanide elemno>=57&elemno<=71", + "@actinide elemno>=89&elemno<=103", + +new feature: load =am/<mineralName> loads last (earliest?) entry in American Mineralogist Crystal Database + -- for example, load =am/corundum + -- reads mineral page such as http://rruff.geo.arizona.edu/AMS/minerals/Corundum + and extracts from that the last database ID. + -- adding /1, /2, ..., /0 will return only the first, second, ..., last structure on that page + -- requires a preliminary search followed by the actual file load. + -- only the final ID-based file load is saved in the state. + -- a hack; uses an evaluation of the string: + 'http://rruff.geo.arizona.edu/AMS/CIF_text_files/'+load('http://rruff.geo.arizona.edu/AMS/minerals/%FILE').split(\"viewJmol('\")[%n].split(\"'\")[1]+'_cif.txt' + -- for example, see http://rruff.geo.arizona.edu/AMS/viewJmol.php?id=19280 + +bug fix: files with names containing "[]" cannot be loaded. +bug fix: print {cell=555}.find("cellFormula") can fail because of 2% slop involved in defining cell=555 + +JmolVersion="14.5.0_2015.11.27" + bug fix: {atomset}.split() [split atomset by model] returns array of strings, not array of atoms code: BSUtil.cardinalityOf cleanup. Modified: trunk/Jmol/src/org/jmol/viewer/OutputManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/OutputManager.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/viewer/OutputManager.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -565,7 +565,7 @@ fileName = fullPath[0]; String pathName = (type.equals("FILE") ? vwr.fm.getFullPathName(false) : null); boolean getCurrentFile = (pathName != null && (pathName.equals("string") - || pathName.indexOf("[]") >= 0 || pathName.equals("JSNode"))); + || pathName.equals("String[]") || pathName.equals("JSNode"))); boolean asBytes = (pathName != null && !getCurrentFile); if (asBytes) { pathName = vwr.getModelSetPathName(); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -139,8 +139,9 @@ * * The JmolViewer runs on Java 1.5+ virtual machines. The 3d graphics rendering * package is a software implementation of a z-buffer. It does not use Java3D - * and does not use Graphics2D from Java 1.2. + * and does not use Graphics2D from Java 1.2. " * + * * public here is a test for applet-applet and JS-applet communication the idea * being that applet.getProperty("jmolViewer") returns this Viewer object, * allowing direct inter-process access to public methods. @@ -1851,7 +1852,7 @@ Map<String, Object> htParams, SB loadScript) { if (fileName == null) return null; - if (fileName.indexOf("[]") >= 0) { + if (fileName.equals("String[]")) { // no reloading of string[] or file[] data -- just too complicated return null; } @@ -1863,7 +1864,7 @@ boolean haveFileData = (htParams.containsKey("fileData")); if (fileName.indexOf('$') == 0) htParams.put("smilesString", fileName.substring(1)); - boolean isString = (fileName.equalsIgnoreCase("string") || fileName + boolean isString = (fileName.equals("string") || fileName .equals(JC.MODELKIT_ZAP_TITLE)); String strModel = null; if (haveFileData) { @@ -2287,7 +2288,7 @@ String filename = fm.getFullPathName(false); if (filename.equals("string") || filename.equals(JC.MODELKIT_ZAP_TITLE)) return ms.getInlineData(am.cmi); - if (filename.indexOf("[]") >= 0) + if (filename.equals("String[]")) return filename; if (filename == "JSNode") return "<DOM NODE>"; @@ -3906,7 +3907,9 @@ int pt = f.indexOf("/"); String database = f.substring(0, pt); f = g.resolveDataBase(database, f.substring(pt + 1), null); - return (f == null ? name : f); + if (f != null && f.startsWith("'")) + f = evaluateExpression(f).toString(); + return (f == null || f.length() == 0 ? name : f); } catch (Exception e) { return name; } Modified: trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java 2015-11-27 11:57:16 UTC (rev 20869) +++ trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java 2015-11-29 22:18:42 UTC (rev 20870) @@ -1576,7 +1576,7 @@ static final String chemFileProperty = "chemFile"; void notifyFileOpen(String fullPathName, String title) { - if (fullPathName == null || !fullPathName.equals("file[]")) { + if (fullPathName == null || !fullPathName.equals("String[]")) { int pt = (fullPathName == null ? -1 : fullPathName.lastIndexOf("|")); if (pt > 0) fullPathName = fullPathName.substring(0, pt); 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