From: <ha...@us...> - 2007-03-12 21:50:26
|
Revision: 7081 http://svn.sourceforge.net/jmol/?rev=7081&view=rev Author: hansonr Date: 2007-03-12 14:50:22 -0700 (Mon, 12 Mar 2007) Log Message: ----------- 11.1.21 support for translucent 0-3, with translucent 1 being the default (settable using set defaultTranslucent [0-3]) and translucent 0 being the same as Jmol 10. Modified Paths: -------------- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/g3d/Graphics3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-03-12 21:00:48 UTC (rev 7080) +++ trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-03-12 21:50:22 UTC (rev 7081) @@ -149,10 +149,10 @@ platform.releaseBuffers(); } - public boolean checkTranslucent(boolean isScreened) { - if (isScreened) + public boolean checkTranslucent(boolean isTranslucent) { + if (isTranslucent) haveTranslucent = true; - return (!twoPass || twoPass && (isPass2 == isScreened)); + return (!twoPass || twoPass && (isPass2 == isTranslucent)); } public boolean haveTranslucentObjects() { @@ -335,7 +335,7 @@ */ public boolean setColix(short colix) { isTranslucent = (colix & TRANSLUCENT_FLAG) != 0; - if (!checkTranslucent(isTranslucent)) + if (!checkTranslucent(isTranslucent && (colix & TRANSLUCENT_LEVEL_MASK) != 0)) return false; addAllPixels = isPass2 || !isTranslucent; if (isPass2) Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-03-12 21:00:48 UTC (rev 7080) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-03-12 21:50:22 UTC (rev 7081) @@ -2855,9 +2855,8 @@ boolean isDelete = false; boolean haveType = false; boolean haveOperation = false; - boolean isTranslucentOrOpaque = false; String translucency = null; - int translucentLevel = 0; + int translucentLevel = -1; boolean isColorOrRadius = false; int nAtomSets = 0; int nDistances = 0; @@ -2921,11 +2920,11 @@ break; case Token.translucent: case Token.opaque: - if (isTranslucentOrOpaque) + if (translucency != null) invalidArgument(); - isColorOrRadius = isTranslucentOrOpaque = true; + isColorOrRadius = true; translucency = parameterAsString(i); - if (tokAt(i+1) == Token.integer) + if (theTok == Token.translucent && tokAt(i + 1) == Token.integer) translucentLevel = intParameter(++i); break; case Token.radius: @@ -2959,7 +2958,7 @@ distances[1] = distances[0]; distances[0] = JmolConstants.DEFAULT_MIN_CONNECT_DISTANCE; } - if (isTranslucentOrOpaque || !Float.isNaN(radius) + if (translucency != null || !Float.isNaN(radius) || color != Integer.MIN_VALUE) { if (!haveType) bondOrder = JmolConstants.BOND_ORDER_ANY; @@ -2981,7 +2980,9 @@ if (color != Integer.MIN_VALUE) viewer.setShapeProperty(JmolConstants.SHAPE_STICKS, "color", new Integer(color), bsBonds); - if (isTranslucentOrOpaque) { + if (translucency != null) { + if (translucentLevel < 0) + translucentLevel = viewer.getDefaultTranslucent(); viewer.setShapeProperty(JmolConstants.SHAPE_STICKS, "translucentLevel", new Integer(translucentLevel)); viewer.setShapeProperty(JmolConstants.SHAPE_STICKS, "translucency", @@ -3175,11 +3176,11 @@ } void colorShape(int shapeType, int index) throws ScriptException { - String translucentOrOpaque = null; + String translucency = null; Object colorvalue = null; String colorOrBgcolor = "color"; BitSet bs = null; - int translucentLevel = 0; + int translucentLevel = -1; if (index < 0) { bs = expression(-index); index = iToken + 1; @@ -3196,10 +3197,11 @@ colorOrBgcolor = "bgcolor"; getToken(++index); } - if (theTok == Token.translucent || theTok == Token.opaque) - translucentOrOpaque = parameterAsString(index++); + if (theTok == Token.translucent || theTok == Token.opaque) { + translucency = parameterAsString(++index); if (theTok == Token.translucent && tokAt(index) == Token.integer) translucentLevel = intParameter(index++); + } String modifier = ""; if (shapeType < 0) { //geosurface @@ -3213,9 +3215,8 @@ colorvalue = (argb == 0 ? null : new Integer(argb)); if (tokAt(index = iToken + 1) != Token.nada) { getToken(index); - if (translucentOrOpaque == null - && (theTok == Token.translucent || theTok == Token.opaque)) { - translucentOrOpaque = parameterAsString(index); + if (translucency == null && (theTok == Token.translucent || theTok == Token.opaque)) { + translucency = parameterAsString(index); if (theTok == Token.translucent && tokAt(index + 1) == Token.integer) translucentLevel = intParameter(++index); } @@ -3294,16 +3295,15 @@ else setShapeProperty(shapeType, colorOrBgcolor + modifier, colorvalue); } - if (translucentOrOpaque != null) { - setShapeProperty(shapeType, "translucentLevel", new Integer(translucentLevel)); - setShapeProperty(shapeType, "translucency" + modifier, - translucentOrOpaque); - } + if (translucency != null) + setShapeTranslucency(shapeType, modifier, translucency, translucentLevel); } - void setShapeTranslucency (int shapeType, String translucentOrOpaque, int translucentLevel) { + void setShapeTranslucency (int shapeType, String modifier, String translucency, int translucentLevel) { + if (translucentLevel < 0) + translucentLevel = viewer.getDefaultTranslucent(); setShapeProperty(shapeType, "translucentLevel", new Integer(translucentLevel)); - setShapeProperty(shapeType, "translucency", translucentOrOpaque); + setShapeProperty(shapeType, "translucency" + modifier, translucency); } Hashtable variables = new Hashtable(); @@ -7213,7 +7213,7 @@ boolean idSeen = false; boolean isInitialized = false; boolean isTranslucent = false; - int translucentLevel = 0; + int translucentLevel = -1; int colorArgb = Integer.MIN_VALUE; int intScale = 0; for (int i = 1; i < statementLength; ++i) { @@ -7355,11 +7355,6 @@ i = iToken; havePoints = true; break; - case Token.translucent: - isTranslucent = true; - if (tokAt(i + 1) == Token.integer) - translucentLevel = intParameter(++i); - break; default: if (!setMeshDisplayProperty(JmolConstants.SHAPE_DRAW, theTok)) invalidArgument(); @@ -7382,7 +7377,7 @@ setShapeProperty(JmolConstants.SHAPE_DRAW, "colorRGB", new Integer( colorArgb)); if (isTranslucent) - setShapeTranslucency(JmolConstants.SHAPE_DRAW, "translucent", translucentLevel); + setShapeTranslucency(JmolConstants.SHAPE_DRAW, "", "translucent", translucentLevel); if (intScale != 0) { setShapeProperty(JmolConstants.SHAPE_DRAW, "scale", new Integer(intScale)); } @@ -7431,8 +7426,8 @@ setShapeProperty(JmolConstants.SHAPE_POLYHEDRA, "init", null); String setPropertyName = "centers"; String decimalPropertyName = "radius_"; - String translucency = ""; - int translucentLevel = 0; + String translucency = null; + int translucentLevel = -1; int color = Integer.MIN_VALUE; for (int i = 1; i < statementLength; ++i) { String propertyName = null; @@ -7451,10 +7446,8 @@ decimalPropertyName = "radius"; continue; case Token.translucent: - translucency = "translucent"; - continue; case Token.opaque: - translucency = "opaque"; + translucency = parameterAsString(i); continue; case Token.colorRGB: case Token.leftsquare: @@ -7569,8 +7562,8 @@ if (color != Integer.MIN_VALUE) setShapeProperty(JmolConstants.SHAPE_POLYHEDRA, "colorThis", new Integer( color)); - if (translucency.length() > 0) - setShapeTranslucency(JmolConstants.SHAPE_POLYHEDRA, translucency, translucentLevel); + if (translucency != null) + setShapeTranslucency(JmolConstants.SHAPE_POLYHEDRA, "", translucency, translucentLevel); } void lcaoCartoon() throws ScriptException { @@ -8272,8 +8265,8 @@ propertyName = "fill"; break; case Token.translucent: - int iLevel = (tokAt(iToken + 1) == Token.integer ? intParameter(++iToken) : 0); - setShapeTranslucency(shape, "translucent", iLevel); + setShapeTranslucency(shape, "", "translucent", + tokAt(iToken + 1) == Token.integer ? intParameter(++iToken) : -1); return true; case Token.opaque: propertyName = "translucency"; Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-03-12 21:00:48 UTC (rev 7080) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-03-12 21:50:22 UTC (rev 7081) @@ -518,6 +518,7 @@ boolean showNavigationPointAlways = false; String propertyColorScheme = "roygb"; boolean useNumberLocalization = true; + int defaultTranslucent = 1; // window @@ -828,6 +829,7 @@ setParameterValue("defaultAngleLabel",defaultAngleLabel); setParameterValue("defaultDirectory",defaultDirectory); setParameterValue("defaultDistanceLabel",defaultDistanceLabel); + setParameterValue("defaultTranslucent",defaultTranslucent); setParameterValue("helpPath",defaultHelpPath); setParameterValue("defaultLoadScript",defaultLoadScript); setParameterValue("defaultTorsionLabel",defaultTorsionLabel); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-03-12 21:00:48 UTC (rev 7080) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-03-12 21:50:22 UTC (rev 7081) @@ -858,6 +858,14 @@ colorManager.setDefaultColors(colorScheme); } + private void setDefaultTranslucent(int value) { + global.defaultTranslucent = value; + } + + int getDefaultTranslucent() { + return global.defaultTranslucent; + } + int getColixArgb(short colix) { return g3d.getColixArgb(colix); } @@ -3676,6 +3684,12 @@ while (true) { ///11.1/// + + if (key.equalsIgnoreCase("defaultTranslucent")) { + setDefaultTranslucent(value); + break; + } + if (key.equalsIgnoreCase("strandCount")) { setShapeProperty(JmolConstants.SHAPE_STRANDS, "strandCount", new Integer(value >= 0 && value <= 20 ? value : 5)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |