From: <ha...@us...> - 2007-04-23 13:58:29
|
Revision: 7468 http://svn.sourceforge.net/jmol/?rev=7468&view=rev Author: hansonr Date: 2007-04-23 06:58:27 -0700 (Mon, 23 Apr 2007) Log Message: ----------- version=11.1.29 # adds applySymmetryToBonds (default: FALSE) # applySymmetryToBonds # # When set TRUE, this flag instructs Jmol when applying symmetry # to atoms, as in "load xxx.cif {1 1 1}", to also apply symmetry # to the bonds indicated in the file. The flag is useful when # normal Jmol autobonding would not properly connect atoms, but # the model is "molecular" -- the base atom coordinates are correct # for whole molecules. The flag should NOT be used in cases where # the application of symmetry operations creates new bonds that # were not present in the original set, as for quartz.cif, where # there is only one bond initially, and after applying symmetry # new bonds are created that are between atoms that were created # using two different symmetry operations. The JmolAdapter api is changed to pass a Hashtable to a reader rather than an int[]. Modified Paths: -------------- trunk/Jmol/src/org/jmol/Jmol.properties 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/CifReader.java trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java trunk/Jmol/src/org/jmol/api/JmolAdapter.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/FileManager.java trunk/Jmol/src/org/jmol/viewer/Frame.java trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/Jmol.properties 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/Jmol.properties 2007-04-23 13:58:27 UTC (rev 7468) @@ -1,5 +1,22 @@ version=11.1.29 +# adds applySymmetryToBonds (default: FALSE) + +# applySymmetryToBonds +# +# When set TRUE, this flag instructs Jmol when applying symmetry +# to atoms, as in "load xxx.cif {1 1 1}", to also apply symmetry +# to the bonds indicated in the file. The flag is useful when +# normal Jmol autobonding would not properly connect atoms, but +# the model is "molecular" -- the base atom coordinates are correct +# for whole molecules. The flag should NOT be used in cases where +# the application of symmetry operations creates new bonds that +# were not present in the original set, as for quartz.cif, where +# there is only one bond initially, and after applying symmetry +# new bonds are created that are between atoms that were created +# using two different symmetry operations. + + # adds isosurface HOMO/LUMO [+/- n] # better isosurface plane rendering, especially in regard to meshes Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -312,7 +312,7 @@ } */ atom.atomSetIndex = currentAtomSetIndex; - atom.atomSite = ++atomSetAtomCounts[currentAtomSetIndex]; + atom.atomSite = atomSetAtomCounts[currentAtomSetIndex]++; } void addAtomWithMappedName(Atom atom) { @@ -392,7 +392,7 @@ setGlobalBoolean(GLOBAL_FRACTCOORD); } - void setLatticeCells(int[] latticeCells) { + void setLatticeCells(int[] latticeCells, boolean applySymmetryToBonds) { //set when unit cell is determined // x <= 555 and y >= 555 indicate a range of cells to load // AROUND the central cell 555 and that @@ -400,6 +400,7 @@ this.latticeCells = latticeCells; isLatticeRange = (latticeCells[2] == 0 || latticeCells[2] == 1) && (latticeCells[0] <= 555 && latticeCells[1] >= 555); doNormalize = (!isLatticeRange || latticeCells[2] == 1); + setApplySymmetryToBonds(applySymmetryToBonds); } boolean setNotionalUnitCell(float[] info) { @@ -453,6 +454,8 @@ int count = getLastAtomSetAtomCount(); int atomIndex = getLastAtomSetAtomIndex(); + bondCount0 = bondCount; + SymmetryOperation[] finalOperations = spaceGroup.getFinalOperations(atoms, atomIndex, count, doNormalize); for (int i = 0; i < count; i++) @@ -508,67 +511,85 @@ } Point3f[] cartesians; + int bondCount0; + int bondIndex0; + boolean applySymmetryToBonds = false; - private int symmetryAddAtoms(SymmetryOperation[] finalOperations, int atomIndex, - int count, int transX, int transY, int transZ, int pt) throws Exception { + void setApplySymmetryToBonds(boolean TF) { + applySymmetryToBonds = TF; + } + + private int symmetryAddAtoms(SymmetryOperation[] finalOperations, + int atomIndex, int count, int transX, + int transY, int transZ, int pt) throws Exception { boolean isBaseCell = (transX == 0 && transY == 0 && transZ == 0); int nOperations = finalOperations.length; if (isBaseCell) pt = 0; - for (; pt < count; pt++) { - Atom atom = atoms[atomIndex + pt]; - cartesians[pt] = new Point3f(atom); - finalOperations[0].transform(cartesians[pt]); - unitCell.toCartesian(cartesians[pt]); - atom.bsSymmetry.set(0); - } + for (; pt < count; pt++) { + Atom atom = atoms[atomIndex + pt]; + cartesians[pt] = new Point3f(atom); + finalOperations[0].transform(cartesians[pt]); + unitCell.toCartesian(cartesians[pt]); + atom.bsSymmetry.set(0); + } + int[] atomMap = new int[count]; for (int iSym = 0; iSym < nOperations; iSym++) { + if (isBaseCell && finalOperations[iSym].getXyz().equals("x,y,z")) + continue; int pt0 = pt; - if (!isBaseCell || !finalOperations[iSym].getXyz().equals("x,y,z")) { - int i1 = atomIndex; - int i2 = i1 + count; - for (int i = i1; i < i2; i++) { - Atom atom = new Atom(); - finalOperations[iSym] - .newPoint(atoms[i], atom, transX, transY, transZ); - Point3f cartesian = new Point3f(atom); - unitCell.toCartesian(cartesian); + int i1 = atomIndex; + int i2 = i1 + count; + for (int i = i1; i < i2; i++) { + Atom atom = new Atom(); + finalOperations[iSym].newPoint(atoms[i], atom, transX, transY, transZ); + Point3f cartesian = new Point3f(atom); + unitCell.toCartesian(cartesian); - - //System.out.println((Point3f) atoms[i] + " " + (Point3f) atom + " " - // + transX + " " + transY + " " + transZ + " " + cartesian - // + finalOperations[iSym].getXyz()); - - - Atom special = null; - for (int j = pt0; --j >= 0;) { -// System.out.println(j + ": " + cartesians[j] + " ?cart? " + cartesian + " d=" + cartesian.distance(cartesians[j])); + //System.out.println((Point3f) atoms[i] + " " + (Point3f) atom + " " + // + transX + " " + transY + " " + transZ + " " + cartesian + // + finalOperations[iSym].getXyz()); - if (cartesian.distance(cartesians[j]) < 0.01) { - special = atoms[atomIndex + j]; - break; - } + Atom special = null; + for (int j = pt0; --j >= 0;) { + // System.out.println(j + ": " + cartesians[j] + " ?cart? " + cartesian + " d=" + cartesian.distance(cartesians[j])); + + if (cartesian.distance(cartesians[j]) < 0.01) { + special = atoms[atomIndex + j]; + break; } - if (special == null) { - Atom atom1 = newCloneAtom(atoms[i]); - atom1.x = atom.x; - atom1.y = atom.y; - atom1.z = atom.z; - // System.out.println(cartesian + " " + (Point3f)atom + "X" + finalOperations[iSym].getXyz() + " " + transX+" "+transY+" "+transZ); - atom1.atomSite = atoms[i].atomSite; - atom1.bsSymmetry = new BitSet(); - atom1.bsSymmetry.set(iSym); - cartesians[pt++] = cartesian; - } else { - special.bsSymmetry.set(iSym); - - // System.out.println(iSym + " " + finalOperations[iSym].getXyz() - // + " special set: " + i + " " + " " + special.bsSymmetry); - - // System.out.println(cartesian+"Y" + "X" + finalOperations[iSym].getXyz() + " " + transX+" "+transY+" "+transZ); - } } + if (special != null) { + atomMap[atoms[i].atomSite] = special.atomIndex; + special.bsSymmetry.set(iSym); + + // System.out.println(iSym + " " + finalOperations[iSym].getXyz() + // + " special set: " + i + " " + " " + special.bsSymmetry); + + // System.out.println(cartesian+"Y" + "X" + finalOperations[iSym].getXyz() + " " + transX+" "+transY+" "+transZ); + } else { + atomMap[atoms[i].atomSite] = atomCount; + Atom atom1 = newCloneAtom(atoms[i]); + atom1.x = atom.x; + atom1.y = atom.y; + atom1.z = atom.z; + // System.out.println(cartesian + " " + (Point3f)atom + "X" + finalOperations[iSym].getXyz() + " " + transX+" "+transY+" "+transZ); + atom1.atomSite = atoms[i].atomSite; + atom1.bsSymmetry = new BitSet(); + atom1.bsSymmetry.set(iSym); + cartesians[pt++] = cartesian; + } } + if (bondCount0 > bondIndex0 && applySymmetryToBonds) { + // Clone bonds + for (int bondNum = bondIndex0; bondNum < bondCount0; bondNum++) { + Bond bond = bonds[bondNum]; + int iAtom1 = atomMap[atoms[bond.atomIndex1].atomSite]; + int iAtom2 = atomMap[atoms[bond.atomIndex2].atomSite]; + if (iAtom1 >= i2 || iAtom2 >= i2) + addNewBond(iAtom1, iAtom2, bond.order); + } + } } return pt; } @@ -696,6 +717,7 @@ } void newAtomSet() { + bondIndex0 = bondCount; if (isTrajectory) { if (trajectory == null && atomCount > 0) trajectory = new Point3f[0]; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -32,6 +32,7 @@ import java.io.BufferedReader; +import java.util.Hashtable; /* * Notes 9/2006 Bob Hanson @@ -182,6 +183,7 @@ boolean ignoreFileSymmetryOperators; boolean ignoreFileSpaceGroupName; boolean isTrajectory; + boolean applySymmetryToBonds; // state variables @@ -225,6 +227,7 @@ ignoreFileSymmetryOperators = false; doConvertToFractional = false; doApplySymmetry = false; + applySymmetryToBonds = false; fileCoordinatesAreFractional = false; @@ -236,10 +239,15 @@ initializeSymmetry(); } - void initialize(int[] params) { + void initialize(Hashtable htParams) { initialize(); - if (params == null) - return; + int[] params = null; + if (htParams != null) { + params = (int[]) htParams.get("params"); + if (params == null) + return; + applySymmetryToBonds = htParams.containsKey("applySymmetryToBonds"); + } // params is of variable length: 4, 5, or 11 // [desiredModelNumber, i, j, k, @@ -318,7 +326,7 @@ void setSymmetryOperator(String jonesFaithful) { if (ignoreFileSymmetryOperators) return; - atomSetCollection.setLatticeCells(latticeCells); + atomSetCollection.setLatticeCells(latticeCells, applySymmetryToBonds); if (!atomSetCollection.addSymmetry(jonesFaithful)) Logger.warn("Skipping symmetry operation " + jonesFaithful); iHaveSymmetryOperators = true; @@ -406,7 +414,7 @@ atomSetCollection.setNotionalUnitCell(notionalUnitCell); atomSetCollection.setAtomSetSpaceGroupName(spaceGroup); if (doConvertToFractional || fileCoordinatesAreFractional) { - atomSetCollection.setLatticeCells(latticeCells); + atomSetCollection.setLatticeCells(latticeCells, applySymmetryToBonds); if (ignoreFileSpaceGroupName || !iHaveSymmetryOperators) { SpaceGroup sg = SpaceGroup.createSpaceGroup(desiredSpaceGroupIndex, (spaceGroup.indexOf("*")>=0 ? "P1" : spaceGroup), notionalUnitCell); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/CifReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/CifReader.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/adapter/smarter/CifReader.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -335,7 +335,7 @@ return; } if (str.startsWith("_geom_bond")) { - if (doApplySymmetry) //not reading bonds when symmetry is enabled yet + if (doApplySymmetry && !applySymmetryToBonds) skipLoop(); else processGeomBondLoopBlock(); @@ -647,7 +647,7 @@ final static String[] geomBondFields = { "_geom_bond_atom_site_label_1", "_geom_bond_atom_site_label_2", - "_geom_bond_site_symmetry_2", +// "_geom_bond_site_symmetry_2", }; /** @@ -693,7 +693,7 @@ break; } } - if (symmetry != null || atomIndex1 < 0 || atomIndex2 < 0) + if (/*symmetry != null || */ atomIndex1 < 0 || atomIndex2 < 0) continue; Bond bond = new Bond(); bond.atomIndex1 = atomIndex1; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -27,6 +27,7 @@ import java.io.BufferedReader; import java.util.StringTokenizer; import org.jmol.util.Logger; +import java.util.Hashtable; class Resolver { @@ -42,7 +43,7 @@ return resolve(name, bufferedReader, null); } - static Object resolve(String name, BufferedReader bufferedReader, int[] params) + static Object resolve(String name, BufferedReader bufferedReader, Hashtable htParams) throws Exception { AtomSetCollectionReader atomSetCollectionReader; String atomSetCollectionReaderName = determineAtomSetCollectionReader( @@ -62,7 +63,7 @@ Logger.error(err, e); return err; } - atomSetCollectionReader.initialize(params); + atomSetCollectionReader.initialize(htParams); AtomSetCollection atomSetCollection = atomSetCollectionReader .readAtomSetCollection(bufferedReader); bufferedReader.close(); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -53,14 +53,14 @@ public Object openBufferedReader(String name, BufferedReader bufferedReader) { - return openBufferedReader(name, bufferedReader, (int[]) null); + return openBufferedReader(name, bufferedReader, (Hashtable) null); } public Object openBufferedReader(String name, - BufferedReader bufferedReader, int[] params) { + BufferedReader bufferedReader, Hashtable htParams) { try { Object atomSetCollectionOrErrorMessage = - Resolver.resolve(name, bufferedReader, params); + Resolver.resolve(name, bufferedReader, htParams); if (atomSetCollectionOrErrorMessage instanceof String) return atomSetCollectionOrErrorMessage; if (atomSetCollectionOrErrorMessage instanceof AtomSetCollection) { @@ -247,7 +247,7 @@ } public int getAtomSetIndex() { return atom.atomSetIndex; } public BitSet getAtomSymmetry() { return atom.bsSymmetry; } - public int getAtomSite() { return atom.atomSite; } + public int getAtomSite() { return atom.atomSite + 1; } public Object getUniqueID() { return new Integer(atom.atomIndex); } public String getElementSymbol() { if (atom.elementSymbol != null) Modified: trunk/Jmol/src/org/jmol/api/JmolAdapter.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolAdapter.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/api/JmolAdapter.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -105,12 +105,12 @@ /** * @param name File name, String or URL acting as the source of the reader * @param bufferedReader The BufferedReader - * @param params Optional integer parameters + * @param htParams Optional hashtable containing symmetry/cell information * @return The clientFile or String with an error message * @see #openBufferedReader(String, BufferedReader) */ public Object openBufferedReader(String name, - BufferedReader bufferedReader, int[] params) { + BufferedReader bufferedReader, Hashtable htParams) { return null; } Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -3511,6 +3511,10 @@ StringBuffer loadScript = new StringBuffer("load"); int[] params = new int[4]; Point3f unitCells = viewer.getDefaultLattice(); + Hashtable htParams = new Hashtable(); + if (viewer.getApplySymmetryToBonds()) + htParams.put("applySymmetryToBonds", Boolean.TRUE); + htParams.put("params", params); //params[0] will be a designated model number or -1 for a trajectory params[1] = (int) unitCells.x; params[2] = (int) unitCells.y; @@ -3547,7 +3551,7 @@ filename = fixFileName(filename); loadScript.append(" ").append(StateManager.escape(filename)).append(";"); if (!isSyntaxCheck || isScriptCheck && fileOpenCheck) - viewer.openFile(filename, params, loadScript.toString(), isMerge); + viewer.openFile(filename, htParams, loadScript.toString(), isMerge); } else if (getToken(i + 1).tok == Token.leftbrace || theTok == Token.integer) { if ((filename = parameterAsString(i++)).length() == 0) @@ -3589,6 +3593,7 @@ p[j] = params[j]; p[4] = iGroup; params = p; + htParams.put("params", params); } if (tokAt(i) == Token.unitcell) { ++i; @@ -3605,11 +3610,12 @@ } loadScript.append("}"); params = p; + htParams.put("params", params); } } loadScript.append(";"); if (!isSyntaxCheck || isScriptCheck && fileOpenCheck) - viewer.openFile(filename, params, loadScript.toString(), isMerge); + viewer.openFile(filename, htParams, loadScript.toString(), isMerge); } else { String modelName; if (i == 2) { Modified: trunk/Jmol/src/org/jmol/viewer/FileManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/FileManager.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/viewer/FileManager.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -24,6 +24,7 @@ package org.jmol.viewer; import org.jmol.util.CompoundDocument; + import org.jmol.util.Logger; import org.jmol.api.JmolAdapter; @@ -43,6 +44,8 @@ import java.io.StringReader; import java.io.Reader; import java.util.zip.GZIPInputStream; +import java.util.Hashtable; + /**************************************************************** * will not work with applet import java.net.URI; @@ -111,12 +114,12 @@ loadScript += "\n"+viewer.getLoadState() + script + "\n"; } - void openFile(String name, int[] params, String loadScript, boolean isMerge) { + void openFile(String name, Hashtable htParams, String loadScript, boolean isMerge) { setLoadScript(loadScript, isMerge); String sp = ""; - if (params != null) - for (int i = 0; i < params.length; i++) - sp+="," + params[i]; + //if (params != null) + //for (int i = 0; i < params.length; i++) + //sp+="," + params[i]; Logger.info("\nFileManager.openFile(" + name + sp + ")"); nameAsGiven = name; openErrorMessage = fullPathName = fileName = null; @@ -125,7 +128,7 @@ Logger.error("file ERROR: " + openErrorMessage); return; } - fileOpenThread = new FileOpenThread(fullPathName, name, params); + fileOpenThread = new FileOpenThread(fullPathName, name, htParams); fileOpenThread.run(); } @@ -155,30 +158,30 @@ openStringInline(strModel, null, isMerge); } - void openStringInline(String strModel, int[] params, boolean isMerge) { + void openStringInline(String strModel, Hashtable htParams, boolean isMerge) { String tag = (isMerge ? "append" : "model"); String script = "data \""+tag+" inline\"" + strModel + "end \""+tag+" inline\";"; setLoadScript(script, isMerge); String sp = ""; - if (params != null) - for (int i = 0; i < params.length; i++) - sp += "," + params[i]; +// if (htParams != null) + // for (int i = 0; i < params.length; i++) + // sp += "," + params[i]; Logger.info("FileManager.openStringInline(" + sp + ")"); openErrorMessage = null; fullPathName = fileName = "string"; inlineData = strModel; //isInline = true; //isDOM = false; - if (params == null) + if (htParams == null) fileOpenThread = new FileOpenThread(fullPathName, new BufferedReader(new StringReader( strModel))); else fileOpenThread = new FileOpenThread(fullPathName, new BufferedReader(new StringReader( - strModel)), params); + strModel)), htParams); fileOpenThread.run(); } - void openStringInline(String[] arrayModels, int[] params, boolean isMerge) { + void openStringInline(String[] arrayModels, Hashtable htParams, boolean isMerge) { loadScript = "dataSeparator = \"~~~next file~~~\";\ndata \"model inline\""; for (int i = 0; i < arrayModels.length; i++) { if (i > 0) @@ -189,9 +192,9 @@ setLoadScript(loadScript, isMerge); String sp = ""; - if (params != null) - for (int i = 0; i < params.length; i++) - sp += "," + params[i]; + //if (params != null) + //for (int i = 0; i < params.length; i++) + //sp += "," + params[i]; Logger.info("FileManager.openStringInline(string[]" + sp + ")"); openErrorMessage = null; fullPathName = fileName = "string[]"; @@ -480,24 +483,24 @@ String nameAsGivenInThread; Object clientFile; BufferedReader reader; - int[] params; + Hashtable htParams; FileOpenThread(String fullPathName, String nameAsGiven) { this.fullPathNameInThread = fullPathName; this.nameAsGivenInThread = nameAsGiven; - this.params = null; + this.htParams = null; } - FileOpenThread(String fullPathName, String nameAsGiven, int[] params) { + FileOpenThread(String fullPathName, String nameAsGiven, Hashtable htParams) { this.fullPathNameInThread = fullPathName; this.nameAsGivenInThread = nameAsGiven; - this.params = params; + this.htParams = htParams; } - FileOpenThread(String name, BufferedReader reader, int[] params) { + FileOpenThread(String name, BufferedReader reader, Hashtable htParams) { nameAsGivenInThread = fullPathNameInThread = name; this.reader = reader; - this.params = params; + this.htParams = htParams; } FileOpenThread(String name, BufferedReader reader) { @@ -524,7 +527,7 @@ private void openBufferedReader(BufferedReader reader) { Object clientFile = modelAdapter.openBufferedReader(fullPathNameInThread, - reader, params); + reader, htParams); if (clientFile instanceof String) errorMessage = (String) clientFile; else Modified: trunk/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Frame.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/viewer/Frame.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -339,9 +339,10 @@ if (adapter != null) { doUnitcellStuff(); // perform bonding if necessary - boolean doBond = (bondCount == baseBondIndex || isMultiFile || isPDB - && (bondCount - baseBondIndex) < (atomCount - baseAtomIndex) / 2 || someModelsHaveSymmetry - && maxSymOp < 2); + boolean doBond = (bondCount == baseBondIndex + || isMultiFile + || isPDB && (bondCount - baseBondIndex) < (atomCount - baseAtomIndex) / 2 + || someModelsHaveSymmetry && !viewer.getApplySymmetryToBonds()); if (viewer.getForceAutoBond() || doBond && viewer.getAutoBond() && getModelSetProperty("noautobond") == null) { BitSet bs = null; @@ -350,7 +351,10 @@ for (int i = baseAtomIndex; i < atomCount; i++) bs.set(i); } + Logger.info("Frame: autobonding; use autobond=false to not generate bonds automatically"); autoBond(bs, bs, null); + } else { + Logger.info("Frame: not autobonding; use forceAutobond=true to force automatic bond creation"); } } finalizeGroupBuild(); // set group offsets and build monomers Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -371,6 +371,7 @@ char inlineNewlineChar = '|'; //pseudo static boolean appendNew = true; + boolean applySymmetryToBonds = false; //new 11.1.29 boolean zeroBasedXyzRasmol = false; boolean forceAutoBond = false; boolean autoBond = true; @@ -401,6 +402,7 @@ setParameterValue("allowEmbeddedScripts", true); appendCmd(str, "autoBond = " + autoBond); appendCmd(str, "appendNew = " + appendNew); + appendCmd(str, "applySymmetryToBonds = " + applySymmetryToBonds); if (viewer.getAxesOrientationRasmol()) appendCmd(str, "axesOrientationRasmol = true"); appendCmd(str, "bondRadiusMilliAngstroms = " + bondRadiusMilliAngstroms); @@ -622,7 +624,7 @@ //settings won't be reflected in the load state, which is determined //earlier, when the file loads. ";refreshing;defaults;backgroundmodel;stereo;" - + ";appendnew;backgroundcolor;axescolor;axis1color;axis2color;axis3color;boundboxcolor;unitcellcolor;" + + ";appendnew;bondsymmetryatoms;backgroundcolor;axescolor;axis1color;axis2color;axis3color;boundboxcolor;unitcellcolor;" + ";ambientpercent;diffusepercent;specular;specularexponent;specularpower;specularpercent;" + ";debugscript;showfrank;showaxes;showaxis1;showaxis2;showaxis3;showunitcell;showboundbox;" + ";slabEnabled;zoomEnabled;axeswindow;axesunitcell;axesmolecular;windowcentered;" @@ -829,6 +831,7 @@ setParameterValue("ambientPercent",ambientPercent); // setParameterValue("argbBackground",argbBackground); setParameterValue("appendNew",appendNew); + setParameterValue("applySymmetryToBonds",applySymmetryToBonds); setParameterValue("autoBond",autoBond); setParameterValue("autoFps",autoFps); setParameterValue("axesMode",axesMode); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-04-23 05:06:21 UTC (rev 7467) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-04-23 13:58:27 UTC (rev 7468) @@ -1306,28 +1306,28 @@ + StateManager.escape(TextFormat.simpleReplace(name, "\\", "/"))); } - void openFile(String name, int[] params, String loadScript, boolean isMerge) { + void openFile(String name, Hashtable htParams, String loadScript, boolean isMerge) { //Eval if (name == null) return; if (name.equalsIgnoreCase("string")) { - openStringInline(fileManager.inlineData, params, isMerge); + openStringInline(fileManager.inlineData, htParams, isMerge); return; } if (name.equalsIgnoreCase("string[]")) { - openStringInline(fileManager.inlineDataArray, params, isMerge); + openStringInline(fileManager.inlineDataArray, htParams, isMerge); return; } if (!isMerge) zap(false); long timeBegin = System.currentTimeMillis(); - fileManager.openFile(name, params, loadScript, isMerge); + fileManager.openFile(name, htParams, loadScript, isMerge); long ms = System.currentTimeMillis() - timeBegin; setStatusFileLoaded(1, name, "", getModelSetName(), null, null); String sp = ""; - if (params != null) - for (int i = 0; i < params.length; i++) - sp += "," + params[i]; + //if (params != null) + //for (int i = 0; i < params.length; i++) + //sp += "," + params[i]; Logger.info("openFile(" + name + sp + ")" + ms + " ms"); } @@ -1355,21 +1355,21 @@ openStringInline(strModel, null, false); } - private void openStringInline(String strModel, int[] params, boolean isMerge) { + private void openStringInline(String strModel, Hashtable htParams, boolean isMerge) { //loadInline, openFile, openStringInline if (!isMerge) clear(); - fileManager.openStringInline(strModel, params, isMerge); + fileManager.openStringInline(strModel, htParams, isMerge); String errorMsg = getOpenFileError(isMerge); if (errorMsg == null) setStatusFileLoaded(1, "string", "", getModelSetName(), null, null); } - private void openStringInline(String[] arrayModels, int[] params, boolean isMerge) { + private void openStringInline(String[] arrayModels, Hashtable htParams, boolean isMerge) { //loadInline, openFile, openStringInline if (!isMerge) clear(); - fileManager.openStringInline(arrayModels, params, isMerge); + fileManager.openStringInline(arrayModels, htParams, isMerge); String errorMsg = getOpenFileError(isMerge); if (errorMsg == null) setStatusFileLoaded(1, "string[]", "", getModelSetName(), null, null); @@ -1392,7 +1392,12 @@ if (strModel == null) return; int i; - int[] A = global.getDefaultLatticeArray(); + int[] params = global.getDefaultLatticeArray(); + Hashtable A = new Hashtable(); + A.put("params", params); + if (global.applySymmetryToBonds) + A.put("applySymmetryToBonds", Boolean.TRUE); + Logger.debug(strModel); if (newLine != 0 && newLine != '\n') { int len = strModel.length(); @@ -1431,10 +1436,22 @@ //loadInline if (arrayModels == null || arrayModels.length == 0) return; - int[] A = global.getDefaultLatticeArray(); + int[] params = global.getDefaultLatticeArray(); + Hashtable A = new Hashtable(); + A.put("params", params); + if (global.applySymmetryToBonds) + A.put("applySymmetryToBonds", Boolean.TRUE); openStringInline(arrayModels, A, isMerge); } + boolean getApplySymmetryToBonds() { + return global.applySymmetryToBonds; + } + + void setApplySymmetryToBonds(boolean TF) { + global.applySymmetryToBonds = TF; + } + void loadCoordinates(String coordinateData) { modelManager.loadCoordinates(coordinateData); } @@ -3991,6 +4008,14 @@ boolean setBooleanProperty(String key, boolean value, boolean defineNew) { boolean notFound = false; while (true) { + + //11.1.29 + + if (key.equalsIgnoreCase("applySymmetryToBonds")) { + setApplySymmetryToBonds(value); + break; + } + //11.1.22 @@ -4237,7 +4262,8 @@ } if (setAxesMode(key, value)) break; - + + //these next are deprecated because they don't //give much indication what they really do: if (key.equalsIgnoreCase("frank")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |