From: <ha...@us...> - 2006-09-14 21:06:19
|
Revision: 5550 http://svn.sourceforge.net/jmol/?rev=5550&view=rev Author: hansonr Date: 2006-09-14 14:06:04 -0700 (Thu, 14 Sep 2006) Log Message: ----------- halos added -- Halos.java, HalosRenderer.java reorganization of Viewer to bring all the global settings together. Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Atom.java trunk/Jmol/src/org/jmol/viewer/Balls.java trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Frame.java trunk/Jmol/src/org/jmol/viewer/JmolConstants.java trunk/Jmol/src/org/jmol/viewer/ModelManager.java trunk/Jmol/src/org/jmol/viewer/Token.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/viewer/Halos.java trunk/Jmol/src/org/jmol/viewer/HalosRenderer.java Modified: trunk/Jmol/src/org/jmol/viewer/Atom.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Atom.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/Atom.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -294,6 +294,8 @@ } short convertEncodedMad(int size) { + if (size == 0) + return 0; if (size == -1000) { // temperature int diameter = getBfactor100() * 10 * 2; if (diameter > 4000) Modified: trunk/Jmol/src/org/jmol/viewer/Balls.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Balls.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/Balls.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -66,14 +66,33 @@ void setModelClickability() { Atom[] atoms = frame.atoms; - int haloVisibilityFlag = Viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_HALO); for (int i = frame.atomCount; --i >= 0; ) { Atom atom = atoms[i]; atom.clickabilityFlags = 0; if((atom.shapeVisibilityFlags & myVisibilityFlag) != 0) atom.clickabilityFlags |= myVisibilityFlag; - if((atom.shapeVisibilityFlags & haloVisibilityFlag) != 0) - atom.clickabilityFlags |= haloVisibilityFlag; } } + + void setVisibilityFlags(BitSet bs) { + Atom[] atoms = frame.atoms; + int displayModelIndex = viewer.getDisplayModelIndex(); + boolean isOneFrame = (displayModelIndex >= 0); + boolean showHydrogens = viewer.getShowHydrogens(); + for (int i = frame.atomCount; --i >= 0; ) { + Atom atom = atoms[i]; + atom.shapeVisibilityFlags &= ( + ~JmolConstants.ATOM_IN_MODEL + & ~myVisibilityFlag); + if (atom.madAtom == JmolConstants.MAR_DELETED + || ! showHydrogens && atom.elementNumber == 1) + continue; + if (! isOneFrame && bs.get(atom.modelIndex) + || atom.modelIndex == displayModelIndex) { + atom.shapeVisibilityFlags |= JmolConstants.ATOM_IN_MODEL; + if (atom.madAtom != 0) + atom.shapeVisibilityFlags |= myVisibilityFlag; + } + } + } } Modified: trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/BallsRenderer.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -28,13 +28,10 @@ class BallsRenderer extends ShapeRenderer { int minX, maxX, minY, maxY, minZ, maxZ; - short colixSelection; int ballVisibilityFlag; - int haloVisibilityFlag; void initRenderer() { ballVisibilityFlag = Viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_BALLS); - haloVisibilityFlag = Viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_HALO); } boolean labelsGroup; @@ -49,7 +46,6 @@ maxZ = g3d.getDepth(); } labelsGroup = viewer.getLabelsGroupFlag() && !viewer.getLabelsFrontFlag(); - colixSelection = viewer.getColixSelection(); Atom[] atoms = frame.atoms; if (labelsGroup) for (int i = frame.groupCount; --i >= 0;) @@ -77,8 +73,6 @@ } if ((atom.shapeVisibilityFlags & ballVisibilityFlag) != 0) renderBall(atom); - if ((atom.shapeVisibilityFlags & haloVisibilityFlag) != 0) - renderHalo(atom); } } @@ -87,18 +81,4 @@ atom.screenX, atom.screenY, atom.screenZ); } - void renderHalo(Atom atom) { - int diameter = atom.screenDiameter; - if (diameter == 0) - diameter = viewer.scaleToScreen(atom.screenZ, 500); - int halowidth = (diameter / 4); - if (halowidth < 4) - halowidth = 4; - if (halowidth > 10) - halowidth = 10; - int haloDiameter = diameter + 2 * halowidth; - if (haloDiameter > 0) - g3d.fillScreenedCircleCentered(colixSelection, haloDiameter, - atom.screenX, atom.screenY, atom.screenZ); - } } Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -490,6 +490,9 @@ case Token.star: star(); break; + case Token.halo: + halo(); + break; case Token.cpk: spacefill(); break; @@ -1858,7 +1861,8 @@ argb); return; } - if (str.equalsIgnoreCase("selectionHalo")) { + if (str.equalsIgnoreCase("selectionHalo") + || str.equalsIgnoreCase("selectionHalos")) { viewer.setSelectionArgb(argb); return; } @@ -2656,7 +2660,7 @@ } void star() throws ScriptException { - short mad = 0; + short mad = 0; // means back to selection business int tok = Token.on; if (statementLength > 1) { tok = statement[1].tok; @@ -2704,6 +2708,57 @@ viewer.setShapeSize(JmolConstants.SHAPE_STARS, mad); } + void halo() throws ScriptException { + short mad = 0; + int tok = Token.on; + if (statementLength > 1) { + tok = statement[1].tok; + if (!((statementLength == 2) || (statementLength == 3 + && tok == Token.integer && statement[2].tok == Token.percent))) { + badArgumentCount(); + } + } + switch (tok) { + case Token.on: + mad = -20; // on goes to 25% + break; + case Token.vanderwaals: + mad = -100; // cpk with no args goes to 100% + break; + case Token.off: + break; + case Token.integer: + int radiusRasMol = statement[1].intValue; + if (statementLength == 2) { + if (radiusRasMol >= 750 || radiusRasMol < -100) + numberOutOfRange(-100, 749); + mad = (short) radiusRasMol; + if (radiusRasMol > 0) + mad *= 4 * 2; + } else { + if (radiusRasMol < 0 || radiusRasMol > 100) + numberOutOfRange(0, 100); + mad = (short) -radiusRasMol; // use a negative number to specify %vdw + } + break; + case Token.decimal: + float angstroms = floatParameter(1); + if (angstroms < 0 || angstroms > 3) + numberOutOfRange(0f, 3f); + mad = (short) (angstroms * 1000 * 2); + break; + case Token.temperature: + mad = -1000; + break; + case Token.ionic: + mad = -1001; + break; + default: + booleanOrNumberExpected(); + } + viewer.setShapeSize(JmolConstants.SHAPE_HALOS, mad); + } + /// aka cpk void spacefill() throws ScriptException { short mad = 0; Modified: trunk/Jmol/src/org/jmol/viewer/Frame.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/Frame.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -1010,7 +1010,7 @@ } void increaseRotationRadius(float increaseInAngstroms) { - if (viewer.isWindowCentered()) + if (isWindowCentered()) rotationRadius += increaseInAngstroms; } @@ -1023,7 +1023,7 @@ boolean andRadius) { if (newCenterOfRotation != null) { rotationCenter = newCenterOfRotation; - if (andRadius && viewer.isWindowCentered()) + if (andRadius && isWindowCentered()) rotationRadius = calcRotationRadius(rotationCenter); } else { rotationCenter = rotationCenterDefault; @@ -1032,6 +1032,16 @@ return rotationCenter; } + boolean windowCenteredFlag = true; + + boolean isWindowCentered() { + return windowCenteredFlag; + } + + void setWindowCentered(boolean TF) { + windowCenteredFlag = TF; + } + Point3f setRotationCenterAndRadiusXYZ(String relativeTo, Point3f pt) { Point3f pointT = new Point3f(pt); if (relativeTo == "average") @@ -2862,4 +2872,17 @@ } return hAtoms; } + + boolean selectionHaloEnabled = false; + + public void setSelectionHaloEnabled(boolean selectionHaloEnabled) { + if (this.selectionHaloEnabled != selectionHaloEnabled) { + this.selectionHaloEnabled = selectionHaloEnabled; + } + } + + boolean getSelectionHaloEnabled() { + return selectionHaloEnabled; + } + } Added: trunk/Jmol/src/org/jmol/viewer/Halos.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Halos.java (rev 0) +++ trunk/Jmol/src/org/jmol/viewer/Halos.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -0,0 +1,89 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2006-08-22 03:13:40 -0500 (Tue, 22 Aug 2006) $ + * $Revision: 5412 $ + + * + * Copyright (C) 2002-2005 The Jmol Development Team + * + * Contact: jmo...@li... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jmol.viewer; + +import java.util.BitSet; + +import org.jmol.g3d.Graphics3D; + +class Halos extends Shape { + + short[] mads; + short[] colixes; + + void setSize(int size, BitSet bsSelected) { + Atom[] atoms = frame.atoms; + for (int i = frame.atomCount; --i >= 0;) + if (bsSelected.get(i)) { + if (mads == null) + mads = new short[frame.atomCount]; + Atom atom = atoms[i]; + mads[i] = atom.convertEncodedMad(size); + } + } + + void setProperty(String propertyName, Object value, BitSet bs) { + int atomCount = frame.atomCount; + Atom[] atoms = frame.atoms; + if ("color" == propertyName) { + short colix = Graphics3D.getColix(value); + for (int i = atomCount; --i >= 0;) + if (bs.get(i)) { + if (colixes == null) + colixes = new short[atomCount]; + colixes[i] = ((colix != Graphics3D.UNRECOGNIZED) ? colix : viewer + .getColixAtomPalette(atoms[i], (String) value)); + } + return; + } + if ("translucency" == propertyName) { + return; + } + } + + void setVisibilityFlags() { + BitSet bsSelected = (viewer.getSelectionHaloEnabled() ? viewer + .getSelectionSet() : null); + for (int i = frame.atomCount; --i >= 0;) { + Atom atom = frame.atoms[i]; + if ((atom.shapeVisibilityFlags & JmolConstants.ATOM_IN_MODEL) == 0) + continue; + boolean isVisible = bsSelected != null && bsSelected.get(i) + || (mads != null && mads[i] != 0); + atom.setShapeVisibility(myVisibilityFlag, isVisible); + } + } + + void setModelClickability() { + if (mads == null) + return; + for (int i = frame.atomCount; --i >= 0;) { + Atom atom = frame.atoms[i]; + if ((atom.shapeVisibilityFlags & myVisibilityFlag) != 0) + atom.clickabilityFlags |= myVisibilityFlag; + } + } +} Added: trunk/Jmol/src/org/jmol/viewer/HalosRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/HalosRenderer.java (rev 0) +++ trunk/Jmol/src/org/jmol/viewer/HalosRenderer.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -0,0 +1,80 @@ +/* $RCSfile$ + * $Author: migueljmol $ + * $Date: 2006-03-25 09:27:43 -0600 (Sat, 25 Mar 2006) $ + * $Revision: 4696 $ + + * + * Copyright (C) 2003-2005 The Jmol Development Team + * + * Contact: jmo...@li... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jmol.viewer; + +import org.jmol.g3d.Graphics3D; +import java.util.BitSet; + +class HalosRenderer extends ShapeRenderer { + + void render() { + Halos halos = (Halos) shape; + boolean selectDisplayTrue = viewer.getSelectionHaloEnabled(); + if (halos.mads == null && !selectDisplayTrue) + return; + Atom[] atoms = frame.atoms; + BitSet bsSelected = (selectDisplayTrue ? viewer.getSelectionSet() : null); + for (int i = frame.atomCount; --i >= 0;) { + Atom atom = atoms[i]; + if ((atom.shapeVisibilityFlags & JmolConstants.ATOM_IN_MODEL) == 0) + continue; + short mad = (halos.mads == null ? 0 : halos.mads[i]); + short colix = (halos.colixes == null ? 0 : halos.colixes[i]); + if (selectDisplayTrue && bsSelected.get(i)) { + if (mad == 0) + mad = -1; // unsized + if (colix == 0) + colix = viewer.getColixSelection(); + } + if (mad == 0) + continue; + render1(atom, mad, colix); + } + } + + void render1(Atom atom, short mad, short colix) { + int z = atom.screenZ; + int diameter = mad; + if (diameter < 0) { //unsized selection + diameter = atom.screenDiameter; + if (diameter == 0) + diameter = viewer.scaleToScreen(z, 500); + } else { + diameter = viewer.scaleToScreen(z, mad); + } + int halowidth = (diameter / 4); + if (halowidth < 4) + halowidth = 4; + if (halowidth > 10) + halowidth = 10; + int haloDiameter = diameter + 2 * halowidth; + if (haloDiameter <= 0) + return; + colix = Graphics3D.inheritColix(colix, atom.colixAtom); + g3d.fillScreenedCircleCentered(colix, haloDiameter, atom.screenX, + atom.screenY, atom.screenZ); + } +} Modified: trunk/Jmol/src/org/jmol/viewer/JmolConstants.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -2200,26 +2200,26 @@ public final static int SHAPE_RIBBONS = 13; public final static int SHAPE_ROCKETS = 14; public final static int SHAPE_STARS = 15; + public final static int SHAPE_HALOS = 16; - public final static int SHAPE_MIN_SELECTION_INDEPENDENT = 16; - public final static int SHAPE_AXES = 16; - public final static int SHAPE_BBCAGE = 17; - public final static int SHAPE_UCCAGE = 18; - public final static int SHAPE_FRANK = 19; - public final static int SHAPE_ECHO = 20; - public final static int SHAPE_HOVER = 21; - public final static int SHAPE_POLYHEDRA = 22; - public final static int SHAPE_MIN_NAMED_OBJECT = 23; - public final static int SHAPE_DIPOLES = 23; - public final static int SHAPE_MIN_MESH_COLLECTION = 24; - public final static int SHAPE_PMESH = 24; - public final static int SHAPE_MO = 25; - public final static int SHAPE_ISOSURFACE = 26; - public final static int SHAPE_LCAOCARTOON = 27; - public final static int SHAPE_DRAW = 28; + public final static int SHAPE_MIN_SELECTION_INDEPENDENT = 17; + public final static int SHAPE_AXES = 17; + public final static int SHAPE_BBCAGE = 18; + public final static int SHAPE_UCCAGE = 19; + public final static int SHAPE_FRANK = 20; + public final static int SHAPE_ECHO = 21; + public final static int SHAPE_HOVER = 22; + public final static int SHAPE_POLYHEDRA = 23; + public final static int SHAPE_MIN_NAMED_OBJECT = 24; + public final static int SHAPE_DIPOLES = 24; + public final static int SHAPE_MIN_MESH_COLLECTION = 25; + public final static int SHAPE_PMESH = 25; + public final static int SHAPE_MO = 26; + public final static int SHAPE_ISOSURFACE = 27; + public final static int SHAPE_LCAOCARTOON = 28; + public final static int SHAPE_DRAW = 29; public final static int SHAPE_MAX = SHAPE_DRAW + 1; //handled in Balls.java: (It's ok that this is SHAPE_MAX) - public final static int SHAPE_HALO = SHAPE_MAX; //see Jmol 10.2 for programming information --- pruned from 11.0 //Bob Hanson 7/17/06 @@ -2233,7 +2233,7 @@ "Balls", "Sticks", "Hsticks", "Sssticks", "Labels", "Vectors", "Measures", "Dots", "Backbone", "Trace", "Cartoon", "Strands", - "MeshRibbon", "Ribbons", "Rockets", "Stars", + "MeshRibbon", "Ribbons", "Rockets", "Stars", "Halos", "Axes", "Bbcage", "Uccage", "Frank", "Echo", "Hover", "Polyhedra", "Dipoles", @@ -2252,7 +2252,7 @@ Token.atom, Token.bonds, Token.hbond, Token.ssbond, Token.label, Token.vector, Token.monitor, Token.dots, Token.backbone, Token.trace, Token.cartoon, Token.strands, - Token.meshRibbon, Token.ribbon, Token.rocket, Token.star, + Token.meshRibbon, Token.ribbon, Token.rocket, Token.star, Token.halo, Token.axes, Token.boundbox, Token.unitcell, Token.frank, Token.echo, Token.hover, Token.polyhedra, Token.dipole, Modified: trunk/Jmol/src/org/jmol/viewer/ModelManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ModelManager.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/ModelManager.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -365,7 +365,9 @@ void setNewRotationCenter(Point3f center, boolean doScale) { // once we have the center, we need to optionally move it to // the proper XY position and possibly scale - if (viewer.isWindowCentered()) { + if (frame == null) + return; + if (frame.isWindowCentered()) { viewer.translateToXPercent(0); viewer.translateToYPercent(0);///CenterTo(0, 0); frame.setRotationCenterAndRadiusXYZ(center, true); @@ -376,6 +378,18 @@ } } + boolean isWindowCentered() { + if (frame == null) + return false; + return frame.isWindowCentered(); + } + + void setWindowCentered(boolean TF) { + if (frame == null) + return; + frame.setWindowCentered(TF); + } + Point3f setRotationCenterAndRadiusXYZ(Point3f center, boolean andRadius) { if (frame == null) return null; @@ -1373,12 +1387,6 @@ void setModelVisibility() { if (frame == null) return; - Atom[] atoms = frame.atoms; - int displayModelIndex = viewer.getDisplayModelIndex(); - boolean isOneFrame = (displayModelIndex >= 0); - boolean showHydrogens = viewer.getShowHydrogens(); - int ballVisibilityFlag = Viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_BALLS); - int haloVisibilityFlag = Viewer.getShapeVisibilityFlag(JmolConstants.SHAPE_HALO); //named objects must be set individually //in the future, we might include here a BITSET of models rather than just a modelIndex @@ -1390,25 +1398,9 @@ Polyhedra p = (Polyhedra) frame.shapes[JmolConstants.SHAPE_POLYHEDRA]; if (p != null) p.setVisibilityFlags(bs); - - for (int i = frame.atomCount; --i >= 0; ) { - Atom atom = atoms[i]; - atom.shapeVisibilityFlags &= ( - ~JmolConstants.ATOM_IN_MODEL - & ~ballVisibilityFlag - & ~haloVisibilityFlag); - if (atom.madAtom == JmolConstants.MAR_DELETED - || ! showHydrogens && atom.elementNumber == 1) - continue; - if (! isOneFrame && bs.get(atom.modelIndex) - || atom.modelIndex == displayModelIndex) { - atom.shapeVisibilityFlags |= JmolConstants.ATOM_IN_MODEL; - if (atom.madAtom != 0) - atom.shapeVisibilityFlags |= ballVisibilityFlag; - if(viewer.hasSelectionHalo(atom.atomIndex)) - atom.shapeVisibilityFlags |= haloVisibilityFlag; - } - } + if (frame.shapes[JmolConstants.SHAPE_HALOS] != null) + frame.shapes[JmolConstants.SHAPE_HALOS].setVisibilityFlags(bs); + frame.shapes[JmolConstants.SHAPE_BALLS].setVisibilityFlags(bs); } void setModelClickability() { @@ -1460,13 +1452,6 @@ info.put(shapeType, shapeinfo); } } - if (viewer.selectionHaloEnabled) { - Hashtable shapeinfo = new Hashtable(); - shapeinfo.put("index", new Integer(JmolConstants.SHAPE_HALO)); - shapeinfo.put("myVisibilityFlag", new Integer(Viewer - .getShapeVisibilityFlag(JmolConstants.SHAPE_HALO))); - info.put("halo", shapeinfo); - } return info; } @@ -1627,4 +1612,16 @@ public int getSpaceGroupIndexFromName(String spaceGroup) { return SpaceGroup.determineSpaceGroupIndex(spaceGroup); } + + public void setSelectionHaloEnabled(boolean selectionHaloEnabled) { + if (frame == null) + return; + frame.setSelectionHaloEnabled(selectionHaloEnabled); + } + + boolean getSelectionHaloEnabled() { + if (frame == null) + return false; + return frame.getSelectionHaloEnabled(); + } } Modified: trunk/Jmol/src/org/jmol/viewer/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Token.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/Token.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -173,7 +173,7 @@ final static int vibration = command | 82; final static int vector = command | 83 | negnums; final static int meshRibbon = command | 84; - //final static int prueba = command | 85; //free + final static int halo = command | 85; final static int rocket = command | 86; final static int geosurface = command | 87; final static int moveto = command | 88 | negnums; @@ -543,7 +543,8 @@ "vectors", null, "meshribbon", new Token(meshRibbon,onDefault1, "meshribbon"), "meshribbons", null, - //"prueba", new Token(prueba, onDefault1, "prueba"), + "halo", new Token(halo, varArgCount, "halo"), + "halos", null, "rocket", new Token(rocket, onDefault1, "rocket"), "rockets", null, "moveto", new Token(moveto, varArgCount, "moveto"), Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-09-14 20:19:35 UTC (rev 5549) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-09-14 21:06:04 UTC (rev 5550) @@ -74,6 +74,7 @@ public class Viewer extends JmolViewer { + GlobalSettings global = new GlobalSettings(); Component awtComponent; ColorManager colorManager; PropertyManager propertyManager; @@ -529,8 +530,6 @@ final Rectangle rectClip = new Rectangle(); - boolean enableFullSceneAntialiasing = false; - public void setScreenDimension(Dimension dim) { // There is a bug in Netscape 4.7*+MacOS 9 when comparing dimension objects // so don't try dim1.equals(dim2) @@ -544,7 +543,7 @@ dimScreen.height = height; transformManager.setScreenDimension(width, height); transformManager.scaleFitToScreen(); - g3d.setWindowSize(width, height, enableFullSceneAntialiasing); + g3d.setWindowSize(width, height, global.enableFullSceneAntialiasing); } public int getScreenWidth() { @@ -824,15 +823,11 @@ } void reportSelection(String msg) { - if (selectionHaloEnabled) + if (modelManager.getSelectionHaloEnabled()) setTainted(true); scriptStatus(msg); } - boolean hasSelectionHalo(int atomIndex) { - return selectionHaloEnabled && selectionManager.isSelected(atomIndex); - } - public void selectAll() { selectionManager.selectAll(); refresh(0, "Viewer:selectAll()"); @@ -1002,18 +997,16 @@ return fileManager.inlineData; } - char inlineNewlineChar = '|'; - public void setInlineChar(char newLine) { - inlineNewlineChar = newLine; + global.inlineNewlineChar = newLine; } public char getInlineChar() { - return inlineNewlineChar; + return global.inlineNewlineChar; } public void loadInline(String strModel) { - loadInline(strModel, inlineNewlineChar); + loadInline(strModel, global.inlineNewlineChar); } public void loadInline(String strModel, char newLine) { @@ -1029,10 +1022,7 @@ strModel = strModel.substring(i + 1); strModel = strModel.replace(newLine, '\n'); } - int[] A = new int[4]; - A[1] = (int) ptDefaultLattice.x; - A[2] = (int) ptDefaultLattice.y; - A[3] = (int) ptDefaultLattice.z; + int[] A = global.getDefaultLattice(); openStringInline(strModel, A); } @@ -1144,7 +1134,6 @@ modelManager.setClientFile(null, null, null); selectionManager.clearSelection(); clearMeasurements(); - setWindowCentered(true); transformManager.setFixedRotationCenter(new Point3f(0, 0, 0)); setStatusFileLoaded(0, null, null, null, null, null); refresh(0, "Viewer:clear()"); @@ -1808,14 +1797,13 @@ return repaintManager.frameRenderer; } + boolean wasInMotion = false; int motionEventNumber; public int getMotionEventNumber() { return motionEventNumber; } - boolean wasInMotion = false; - void setInMotion(boolean inMotion) { // Logger.debug("viewer.setInMotion("+inMotion+")"); if (wasInMotion ^ inMotion) { @@ -2086,14 +2074,12 @@ eval.haltExecution(); } - String defaultLoadScript = ""; - void setDefaultLoadScript(String script) { - defaultLoadScript = script; + global.defaultLoadScript = script; } String getDefaultLoadScript() { - return defaultLoadScript; + return global.defaultLoadScript; } String getStandardLabelFormat() { @@ -2241,34 +2227,28 @@ return Graphics3D.getColix(object); } - boolean rasmolHydrogenSetting = true; - void setRasmolHydrogenSetting(boolean b) { - rasmolHydrogenSetting = b; + global.rasmolHydrogenSetting = b; } boolean getRasmolHydrogenSetting() { - return rasmolHydrogenSetting; + return global.rasmolHydrogenSetting; } - boolean rasmolHeteroSetting = true; - void setRasmolHeteroSetting(boolean b) { - rasmolHeteroSetting = b; + global.rasmolHeteroSetting = b; } boolean getRasmolHeteroSetting() { - return rasmolHeteroSetting; + return global.rasmolHeteroSetting; } - boolean debugScript = false; - boolean getDebugScript() { - return debugScript; + return global.debugScript; } public void setDebugScript(boolean debugScript) { - this.debugScript = debugScript; + global.debugScript = debugScript; Logger.setActiveLevel(Logger.LEVEL_DEBUG, debugScript); } @@ -2344,7 +2324,7 @@ } void popupMenu(int x, int y) { - if (disablePopupMenu) + if (global.disablePopupMenu) return; statusManager.popupMenu(x, y); } @@ -2605,132 +2585,108 @@ //////// flags and settings //////// - boolean dotSurfaceFlag = true; - boolean getDotSurfaceFlag() { - return dotSurfaceFlag; + return global.dotSurfaceFlag; } void setDotSurfaceFlag(boolean TF) { - dotSurfaceFlag = TF; + global.dotSurfaceFlag = TF; } - boolean dotsSelectedOnlyFlag = false; - boolean getDotsSelectedOnlyFlag() { - return dotsSelectedOnlyFlag; + return global.dotsSelectedOnlyFlag; } void setDotsSelectedOnlyFlag(boolean TF) { - dotsSelectedOnlyFlag = TF; + global.dotsSelectedOnlyFlag = TF; } - boolean rangeSelected = false; - boolean isRangeSelected() { - return rangeSelected; + return global.rangeSelected; } void setRangeSelected(boolean TF) { - rangeSelected = TF; + global.rangeSelected = TF; } - boolean windowCenteredFlag = true; - boolean isWindowCentered() { - return windowCenteredFlag; + return modelManager.isWindowCentered(); } void setWindowCentered(boolean TF) { - windowCenteredFlag = TF; + modelManager.setWindowCentered(TF); } - boolean adjustCameraFlag = true; - boolean isCameraAdjustable() { - return adjustCameraFlag; + return global.adjustCameraFlag; } void setAdjustCamera(boolean TF) { - adjustCameraFlag = TF; + global.adjustCameraFlag = TF; } - boolean allowCameraMoveFlag = true; - boolean allowCameraMove() { - return allowCameraMoveFlag; + return global.allowCameraMoveFlag; } void setAllowCameraMove(boolean TF) { - allowCameraMoveFlag = TF; + global.allowCameraMoveFlag = TF; } - float solventProbeRadius = 1.2f; - void setSolventProbeRadius(float radius) { - solventProbeRadius = radius; + global.solventProbeRadius = radius; } float getSolventProbeRadius() { - return solventProbeRadius; + return global.solventProbeRadius; } float getCurrentSolventProbeRadius() { - return solventOn ? solventProbeRadius : 0; + return global.solventOn ? global.solventProbeRadius : 0; } - boolean solventOn = false; - void setSolventOn(boolean isOn) { - solventOn = isOn; + global.solventOn = isOn; } boolean getSolventOn() { - return solventOn; + return global.solventOn; } void setAllowStatusReporting(boolean TF) { statusManager.setAllowStatusReporting(TF); } - boolean testFlag1; - - boolean testFlag2; - - boolean testFlag3; - - boolean testFlag4; - void setTestFlag1(boolean value) { - testFlag1 = value; + global.testFlag1 = value; } boolean getTestFlag1() { - return testFlag1; + return global.testFlag1; } void setTestFlag2(boolean value) { - testFlag2 = value; + global.testFlag2 = value; } boolean getTestFlag2() { - return testFlag2; + return global.testFlag2; } void setTestFlag3(boolean value) { - testFlag3 = value; + global.testFlag3 = value; } boolean getTestFlag3() { - return testFlag3; + return global.testFlag3; } void setTestFlag4(boolean value) { - testFlag4 = value; + global.testFlag4 = value; } boolean getTestFlag4() { - return testFlag4; + return global.testFlag4; } public void setPerspectiveDepth(boolean perspectiveDepth) { @@ -2747,32 +2703,28 @@ return transformManager.axesOrientationRasmol; } - private int axesMode = JmolConstants.AXES_MODE_BOUNDBOX; - void setAxesModeMolecular(boolean TF) { - axesMode = (TF ? JmolConstants.AXES_MODE_MOLECULAR + global.axesMode = (TF ? JmolConstants.AXES_MODE_MOLECULAR : JmolConstants.AXES_MODE_BOUNDBOX); axesAreTainted = true; } void setAxesModeUnitCell(boolean TF) { - axesMode = (TF ? JmolConstants.AXES_MODE_UNITCELL + global.axesMode = (TF ? JmolConstants.AXES_MODE_UNITCELL : JmolConstants.AXES_MODE_BOUNDBOX); axesAreTainted = true; } int getAxesMode() { - return axesMode; + return global.axesMode; } - private boolean displayCellParameters = true; - void setDisplayCellParameters(boolean displayCellParameters) { - this.displayCellParameters = displayCellParameters; + global.displayCellParameters = displayCellParameters; } boolean getDisplayCellParameters() { - return displayCellParameters; + return global.displayCellParameters; } public boolean getPerspectiveDepth() { @@ -2787,68 +2739,53 @@ return transformManager.getCameraDepth(); } - boolean selectionHaloEnabled = false; - public void setSelectionHaloEnabled(boolean selectionHaloEnabled) { - if (this.selectionHaloEnabled != selectionHaloEnabled) { - this.selectionHaloEnabled = selectionHaloEnabled; - refresh(0, "Viewer:setSelectionHaloEnabled()"); - } + modelManager.setSelectionHaloEnabled(selectionHaloEnabled); } boolean getSelectionHaloEnabled() { - return selectionHaloEnabled; + return modelManager.getSelectionHaloEnabled(); } - private boolean bondSelectionModeOr; - void setBondSelectionModeOr(boolean bondSelectionModeOr) { - this.bondSelectionModeOr = bondSelectionModeOr; + global.bondSelectionModeOr = bondSelectionModeOr; refresh(0, "Viewer:setBondSelectionModeOr()"); } boolean getBondSelectionModeOr() { - return bondSelectionModeOr; + return global.bondSelectionModeOr; } - boolean chainCaseSensitive = false; - boolean getChainCaseSensitive() { - return chainCaseSensitive; + return global.chainCaseSensitive; } void setChainCaseSensitive(boolean chainCaseSensitive) { - this.chainCaseSensitive = chainCaseSensitive; + global.chainCaseSensitive = chainCaseSensitive; } - boolean ribbonBorder = false; - boolean getRibbonBorder() { - return ribbonBorder; + return global.ribbonBorder; } void setRibbonBorder(boolean borderOn) { - this.ribbonBorder = borderOn; + global.ribbonBorder = borderOn; } - boolean cartoonRocketFlag = false; - boolean getCartoonRocketFlag() { - return cartoonRocketFlag; + return global.cartoonRocketFlag; } void setCartoonRocketFlag(boolean TF) { - this.cartoonRocketFlag = TF; + global.cartoonRocketFlag = TF; } - boolean hideNameInPopup = false; - boolean getHideNameInPopup() { - return hideNameInPopup; + return global.hideNameInPopup; } void setHideNameInPopup(boolean hideNameInPopup) { - this.hideNameInPopup = hideNameInPopup; + global.hideNameInPopup = hideNameInPopup; } void setSsbondsBackbone(boolean ssbondsBackbone) { @@ -2868,46 +2805,38 @@ // Graphics3D // ////////////////////////////////////////////////////////////// - boolean greyscaleRendering; - void setGreyscaleRendering(boolean greyscaleRendering) { - this.greyscaleRendering = greyscaleRendering; + global.greyscaleRendering = greyscaleRendering; g3d.setGreyscaleMode(greyscaleRendering); refresh(0, "Viewer:setGreyscaleRendering()"); } boolean getGreyscaleRendering() { - return greyscaleRendering; + return global.greyscaleRendering; } - boolean labelsFrontFlag; - void setLabelsFrontFlag(boolean labelsFrontFlag) { - this.labelsFrontFlag = labelsFrontFlag; + global.labelsFrontFlag = labelsFrontFlag; } boolean getLabelsFrontFlag() { - return labelsFrontFlag; + return global.labelsFrontFlag; } - boolean labelsGroupFlag; - void setLabelsGroupFlag(boolean labelsGroupFlag) { - this.labelsGroupFlag = labelsGroupFlag; + global.labelsGroupFlag = labelsGroupFlag; } boolean getLabelsGroupFlag() { - return labelsGroupFlag; + return global.labelsGroupFlag; } - boolean disablePopupMenu; - void setDisablePopupMenu(boolean disablePopupMenu) { - this.disablePopupMenu = disablePopupMenu; + global.disablePopupMenu = disablePopupMenu; } boolean getDisablePopupMenu() { - return disablePopupMenu; + return global.disablePopupMenu; } // /////////////////////////////////////////////////////////////// @@ -3033,14 +2962,12 @@ refresh(0, "setShowMeasurements()"); } - boolean measureAllModels = false; - public void setMeasureAllModels(boolean TF) { - measureAllModels = TF; + global.measureAllModels = TF; } public boolean getMeasureAllModelsFlag() { - return measureAllModels; + return global.measureAllModels; } public boolean getShowMeasurements() { @@ -3245,7 +3172,6 @@ void setStereoMode(int[] twoColors) { transformManager.setStereoMode(twoColors); } - int getStereoMode() { return transformManager.stereoMode; @@ -3392,12 +3318,10 @@ endDegrees, false, isSpin); } - int pickingSpinRate = 10; - void setPickingSpinRate(int rate) { if (rate < 1) rate = 1; - pickingSpinRate = rate; + global.pickingSpinRate = rate; } void startSpinningAxis(int atomIndex1, int atomIndex2, boolean isClockwise) { @@ -3413,8 +3337,8 @@ setSpinOn(false); return; } - transformManager.rotateAboutPointsInternal(pt1, pt2, pickingSpinRate, - Float.MAX_VALUE, isClockwise, true); + transformManager.rotateAboutPointsInternal(pt1, pt2, + global.pickingSpinRate, Float.MAX_VALUE, isClockwise, true); } Point3f getDrawObjectCenter(String axisID) { @@ -3444,14 +3368,12 @@ modelManager.getAtomIdentityInfo(atomIndex, info); } - Point3f ptDefaultLattice = new Point3f(); - void setDefaultLattice(Point3f ptLattice) { - ptDefaultLattice.set(ptLattice); + global.setDefaultLattice(ptLattice); } Point3f getDefaultLattice() { - return ptDefaultLattice; + return global.ptDefaultLattice; } public void setAtomCoord(int atomIndex, float x, float y, float z) { @@ -3474,15 +3396,98 @@ return modelManager.getAdditionalHydrogens(atomSet); } - String helpPath; void setHelpPath(String url) { - helpPath = url; + global.helpPath = url; } void getHelp(String what) { - if (helpPath == null) - helpPath = styleManager.getDefaultHelpPath(); - showUrl(helpPath + what); + if (global.helpPath == null) + global.helpPath = styleManager.getDefaultHelpPath(); + showUrl(global.helpPath + what); } + private class GlobalSettings { + + /* + * Mostly these are just saved and restored directly from Viewer. + * They are collected here for reference and to ensure that no + * methods are written that bypass viewer's get/set methods. + * + * Because these are not Frame variables, they should persist past + * a new file loading. There is some question in my mind whether all + * should be in this category. + * + */ + //file loading + + char inlineNewlineChar = '|'; + String defaultLoadScript = ""; + Point3f ptDefaultLattice = new Point3f(); + + void setDefaultLattice(Point3f ptLattice) { + ptDefaultLattice.set(ptLattice); + } + int[] getDefaultLattice() { + int[] A = new int[4]; + A[1] = (int) ptDefaultLattice.x; + A[2] = (int) ptDefaultLattice.y; + A[3] = (int) ptDefaultLattice.z; + return A; + } + + //centering and perspective + + boolean allowCameraMoveFlag = true; + boolean adjustCameraFlag = true; + + //solvent + + boolean solventOn; + float solventProbeRadius = 1.2f; + + //measurements + + boolean measureAllModels; + + //rendering + + boolean enableFullSceneAntialiasing; + boolean greyscaleRendering; + boolean labelsGroupFlag; + boolean labelsFrontFlag; + boolean dotsSelectedOnlyFlag; + boolean dotSurfaceFlag = true; + boolean displayCellParameters = true; + int axesMode = JmolConstants.AXES_MODE_BOUNDBOX; + + //atoms and bonds + + boolean bondSelectionModeOr; + + //secondary structure + Rasmol + + boolean rasmolHydrogenSetting = true; + boolean rasmolHeteroSetting = true; + boolean cartoonRocketFlag; + boolean ribbonBorder; + boolean chainCaseSensitive; + boolean rangeSelected; + + //misc + + int pickingSpinRate = 10; + boolean hideNameInPopup; + boolean disablePopupMenu; + String helpPath; + + //testing + + boolean debugScript; + boolean testFlag1; + boolean testFlag2; + boolean testFlag3; + boolean testFlag4; + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |