From: <ha...@us...> - 2007-10-25 05:27:08
|
Revision: 8513 http://jmol.svn.sourceforge.net/jmol/?rev=8513&view=rev Author: hansonr Date: 2007-10-24 22:27:05 -0700 (Wed, 24 Oct 2007) Log Message: ----------- version=11.3.38 VERSION # bug fix -- draw in states # bug fix -- antialiasing with translucent/POV-ray # new feature: set antialiasTranslucent TRUE/FALSE # along with antialiasDisplay and antialiasImages # determines the extent of antialiasing. Requires # antialiasDisplay or antialiasimages TRUE. Modified Paths: -------------- trunk/Jmol/src/org/jmol/export/Export3D.java trunk/Jmol/src/org/jmol/export/_Exporter.java trunk/Jmol/src/org/jmol/export/_PovrayExporter.java trunk/Jmol/src/org/jmol/g3d/Graphics3D.java trunk/Jmol/src/org/jmol/g3d/Platform3D.java trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/export/Export3D.java =================================================================== --- trunk/Jmol/src/org/jmol/export/Export3D.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/export/Export3D.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -618,7 +618,7 @@ * @return the answer */ public boolean isAntialiased() { - return g3d.isAntialiased(); + return false; } public boolean checkTranslucent(boolean isAlphaTranslucent) { Modified: trunk/Jmol/src/org/jmol/export/_Exporter.java =================================================================== --- trunk/Jmol/src/org/jmol/export/_Exporter.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/export/_Exporter.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -181,7 +181,7 @@ commandLineOptions = fileName.substring(pt + 3); fileName = fileName.substring(0, pt); } - viewer.createImage(fileName + ".spt", viewer.getStateInfo(), + viewer.createImage(fileName + ".spt", viewer.getSavedState("_Export"), Integer.MIN_VALUE, 0, 0); try { os = new FileOutputStream(fileName); Modified: trunk/Jmol/src/org/jmol/export/_PovrayExporter.java =================================================================== --- trunk/Jmol/src/org/jmol/export/_PovrayExporter.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/export/_PovrayExporter.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -83,7 +83,7 @@ output("// This script was generated on " + getExportDate() + "\n"); output("// ******************************************************\n"); output("\n/* **** Jmol Embedded Script **** \n"); - output(viewer.getStateInfo()); + output(viewer.getSavedState("_Export")); output("\n*/\n"); output("\n"); output("// ******************************************************\n"); @@ -445,13 +445,6 @@ return tempP3; } - public void renderText(Text t) { - } - - public void drawString(short colix, String str, Font3D font3d, int xBaseline, - int yBaseline, int z, int zSlab) { - } - public void fillCylinder(short colix, byte endcaps, int diameter, Point3f screenA, Point3f screenB) { if (screenA.distance(screenB) == 0) { @@ -504,7 +497,7 @@ private void fillSphereCentered(float diameter, float x, float y, float z, short colix) { - output("a(" + x + "," + y + "," + z + "," + (diameter / 2.0f) + "," + output("a(" + x + "," + y + "," + z + "," + (diameter / 2.0f) + "," + color4(colix) + ")\n"); } @@ -519,19 +512,17 @@ output("// end text " + nText + ": " + text + "\n"); } - // not implemented + // not needed: public void fillHermite(short colix, int tension, int diameterBeg, int diameterMid, int diameterEnd, Point3f s0, Point3f s1, Point3f s2, Point3f s3) { //cartoons, rockets, trace: - //System.out.println("pov fileHermite cartoons rockets trace "+this); } public void drawHermite(short colix, int tension, Point3f s0, Point3f s1, Point3f s2, Point3f s3) { //strands, meshribbon: - //System.out.println("pov drawhermite "+this); } public void drawHermite(short colix, boolean fill, boolean border, @@ -539,7 +530,14 @@ Point3f s3, Point3f s4, Point3f s5, Point3f s6, Point3f s7, int aspectRatio) { //cartoons, meshRibbons: - //System.out.println("pov draw hermite -- cartoons, meshribbons "+this); } + public void renderText(Text t) { + } + + public void drawString(short colix, String str, Font3D font3d, int xBaseline, + int yBaseline, int z, int zSlab) { + } + + } Modified: trunk/Jmol/src/org/jmol/g3d/Graphics3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -62,8 +62,10 @@ Hermite3D hermite3d; Normix3D normix3d; boolean isFullSceneAntialiasingEnabled; - boolean antialiasThisFrame; - + private boolean antialiasThisFrame; + private boolean antialiasTranslucent; + private boolean antialiasEnabled; + /** * is full scene / oversampling antialiasing in effect * @@ -174,22 +176,20 @@ } /** - * Sets the window size. This will be smaller than the + * Sets the window size and clears the buffers. + * This will be smaller than the * rendering size if FullSceneAntialiasing is enabled * * @param windowWidth Window width * @param windowHeight Window height * @param enableFullSceneAntialiasing currently not in production */ - public void setWindowSize(int windowWidth, int windowHeight, + public void setWindowBuffers(int windowWidth, int windowHeight, boolean enableFullSceneAntialiasing) { if (this.windowWidth == windowWidth && this.windowHeight == windowHeight && enableFullSceneAntialiasing == isFullSceneAntialiasingEnabled) return; - this.windowWidth = windowWidth; - this.windowHeight = windowHeight; - isFullSceneAntialiasingEnabled = enableFullSceneAntialiasing; - setWidthHeight(enableFullSceneAntialiasing); + setWindowParameters(windowWidth, windowHeight, enableFullSceneAntialiasing); pbuf = null; zbuf = null; pbufT = null; @@ -197,6 +197,13 @@ platform.releaseBuffers(); } + public void setWindowParameters(int width, int height, boolean antialias) { + windowWidth = width; + windowHeight = height; + antialiasThisFrame = isFullSceneAntialiasingEnabled = antialias; + setWidthHeight(antialiasThisFrame); + } + private void setWidthHeight(boolean isAntialiased) { width = windowWidth; height = windowHeight; @@ -211,7 +218,6 @@ displayMinY = -(height >> 1); displayMaxY = height - displayMinY; bufferSize = width * height; - //System.out.println("set width/height " + isAntialiased + " w="+width + " h=" + height); } public boolean checkTranslucent(boolean isAlphaTranslucent) { @@ -229,7 +235,7 @@ endRendering(); normix3d.setRotationMatrix(rotationMatrix); antialiasThisFrame &= isFullSceneAntialiasingEnabled; - this.antialiasThisFrame = antialiasThisFrame; + antialiasEnabled = this.antialiasThisFrame = antialiasThisFrame; currentlyRendering = true; this.twoPass = twoPass; isPass2 = false; @@ -247,33 +253,39 @@ platform.obtainScreenBuffer(); } - public boolean setPass2() { - //System.out.println("g3d setPass2: haveAlphaTranslucent,currentlyRendering: " + haveAlphaTranslucent + " " + currentlyRendering); + public boolean setPass2(boolean antialiasTranslucent) { if (!haveAlphaTranslucent || !currentlyRendering) return false; - //System.out.println("isPass2"); isPass2 = true; colixCurrent = 0; addAllPixels = true; - if (antialiasThisFrame) - downSampleFullSceneAntialiasing(); - if (pbufT == null) { - platform.allocateTBuffers(); + antialiasTranslucent = antialiasTranslucent && antialiasThisFrame; + if (antialiasThisFrame && !antialiasTranslucent) + downSampleFullSceneAntialiasing(true); + if (pbufT == null || this.antialiasTranslucent != antialiasTranslucent) { + platform.allocateTBuffers(antialiasTranslucent); pbufT = platform.pBufferT; zbufT = platform.zBufferT; } + this.antialiasTranslucent = antialiasTranslucent; platform.clearTBuffer(); return true; } + public void endRendering() { if (!currentlyRendering) return; - if (antialiasThisFrame) - downSampleFullSceneAntialiasing(); - if (isPass2) - mergeOpaqueAndTranslucentBuffers(); + if (pbuf != null) { + if (isPass2 && antialiasTranslucent) + mergeOpaqueAndTranslucentBuffers(); + if (antialiasThisFrame) + downSampleFullSceneAntialiasing(isPass2 && !antialiasTranslucent); + if (isPass2 && !antialiasTranslucent) + mergeOpaqueAndTranslucentBuffers(); + } platform.notifyEndOfRendering(); + setWidthHeight(antialiasEnabled); currentlyRendering = false; } @@ -368,13 +380,16 @@ return depth; } + int backgroundArgb; + /** * sets background color to the specified argb value * * @param argb an argb value with alpha channel */ public void setBackgroundArgb(int argb) { - platform.setBackground(argb); + backgroundArgb = argb & 0x00FFFFFF; //clear alpha channel + platform.setBackground(backgroundArgb); } /** @@ -422,34 +437,49 @@ return (zShade ? (z - slab) * 5 / (depth - slab): 0); } - /** - * used internally when oversampling is enabled - */ - private void downSampleFullSceneAntialiasing() { + private void downSampleFullSceneAntialiasing(boolean downSampleZBuffer) { int width4 = width; int offset1 = 0; int offset4 = 0; - for (int i = windowHeight; --i >= 0; ) { - for (int j = windowWidth; --j >= 0; ) { - int argb; - argb = (pbuf[offset4 ] >> 2) & 0x3F3F3F3F; - argb += (pbuf[offset4 + width4] >> 2) & 0x3F3F3F3F; - int z = zbuf[offset4]; - z = Math.min(z, zbuf[offset4 + width4]); - ++offset4; - argb += (pbuf[offset4 ] >> 2) & 0x3F3F3F3F; - argb += (pbuf[offset4 + width4] >> 2) & 0x3F3F3F3F; + for (int i = windowHeight; --i >= 0; offset4 += width4) + for (int j = windowWidth; --j >= 0; ++offset1) { +/* + int a = pbuf[offset4]; + int b = pbuf[offset4++ + width4]; + int c = pbuf[offset4]; + int d = pbuf[offset4++ + width4]; + int argb = ((((a & 0x0f0f0f) + (b & 0x0f0f0f) + + (c & 0x0f0f0f) + (d & 0x0f0f0f)) >> 2) & 0x0f0f0f) + + ( ((a & 0xF0F0F0) + (b & 0xF0F0F0) + + (c & 0xF0F0F0) + (d & 0xF0F0F0) + ) >> 2); +*/ + + int argb = (pbuf[offset4] >> 2) & 0x3F3F3F3F; + argb += (pbuf[offset4++ + width4] >> 2) & 0x3F3F3F3F; + argb += (pbuf[offset4] >> 2) & 0x3F3F3F3F; + argb += (pbuf[offset4++ + width4] >> 2) & 0x3F3F3F3F; argb += (argb & 0xC0C0C0C0) >> 6; - argb |= 0xFF000000; - pbuf[offset1] = argb; - z = Math.min(z, zbuf[offset4]); - zbuf[offset1] = Math.min(z, zbuf[offset4 + width4]); - ++offset1; - ++offset4; + + pbuf[offset1] = argb & 0x00FFFFFF; } - offset4 += width4; + if (downSampleZBuffer) { + //we will add the alpha mask later + offset1 = offset4 = 0; + for (int i = windowHeight; --i >= 0; offset4 += width4) + for (int j = windowWidth; --j >= 0; ++offset1, ++offset4) { + int z = Math.min(zbuf[offset4], zbuf[offset4 + width4]); + ++offset4; + z = Math.min(z, zbuf[offset4]); + z = Math.min(z, zbuf[offset4 + width4]); + if (z != Integer.MAX_VALUE) + z >>= 1; + zbuf[offset1] = (pbuf[offset1] == backgroundArgb ? Integer.MAX_VALUE + : z); + } + setWidthHeight(antialiasThisFrame = false); } - setWidthHeight(antialiasThisFrame = false); + } void mergeOpaqueAndTranslucentBuffers() { @@ -475,8 +505,6 @@ if (argbA == argbB) return; - //System.out.println("merge " + pt + " " + Integer.toHexString(argbB)+ " " + Integer.toHexString(pbuf[pt])); - int rbA = (argbA & 0x00FF00FF); int gA = (argbA & 0x0000FF00); int rbB = (argbB & 0x00FF00FF); @@ -485,7 +513,6 @@ //just for now: //0 or 1=100% opacity, 2=87.5%, 3=75%, 4=50%, 5=50%, 6 = 25%, 7 = 12.5% opacity. //4 is reserved because it is the default-Jmol 10.2 - //System.out.print(Integer.toHexString(argbB)); switch (logAlpha) { // 0.0 to 1.0 ==> MORE translucent // 1/8 1/4 3/8 1/2 5/8 3/4 7/8 @@ -521,9 +548,7 @@ gA = (((gA << 2) + (gA << 1) + gA + gB) >> 3) & 0x0000FF00; break; } - pbuf[pt] = 0xFF000000 | rbA | gA; - - //System.out.println("mergefinal " + pt + " " + Integer.toHexString(pbuf[pt]) + " " + Integer.toHexString(rb) + " " + Integer.toHexString(g)); + pbuf[pt] = 0xFF000000 | rbA | gA; } public boolean hasContent() { @@ -552,7 +577,6 @@ shadesCurrent = getShades(colix); argbCurrent = argbNoisyUp = argbNoisyDn = getColixArgb(colix); - //System.out.println("setColix:" + Integer.toHexString(colix) + " argb="+Integer.toHexString(argbCurrent)+ " " +isTranslucent + " tMask " + Integer.toHexString(translucencyMask) + " pass2:"+isPass2); return true; } @@ -560,7 +584,6 @@ //if (isPass2) //return; argbCurrent = shadesCurrent[intensity]; - //System.out.println("setColixNoisy:" + " argb="+Integer.toHexString(argbCurrent)); argbNoisyUp = shadesCurrent[intensity < shadeLast ? intensity + 1 : shadeLast]; argbNoisyDn = shadesCurrent[intensity > 0 ? intensity - 1 : 0]; } @@ -585,8 +608,9 @@ if (z < zT) { //new in front -- merge old translucent with opaque //if (zT != Integer.MAX_VALUE) - if (zT - z > zMargin) - mergeBufferPixel(pbuf, pbufT[offset], offset); + int argb = pbufT[offset]; + if (argb != 0 && zT - z > zMargin) + mergeBufferPixel(pbuf, argb, offset); zbufT[offset] = z; pbufT[offset] = p & translucencyMask; } else if (z == zT) { @@ -1098,8 +1122,6 @@ Point3i screenB, short colixB, short normixB, Point3i screenC, short colixC, short normixC) { // mesh, isosurface - //if ( screenA.x < 0 || screenA.y < 0 || screenA.x > 10 || screenA.y > 10)return; - //System.out.println("fillTriangle: "+screenA + screenB + screenC); boolean useGouraud; if (normixA == normixB && normixA == normixC && colixA == colixB && colixA == colixC) { @@ -1884,7 +1906,6 @@ } if (changeableColixMap[id] == 0) changeableColixMap[id] = Colix3D.getColix(argb); - //System.out.println("changeable colix "+Integer.toHexString(id | CHANGEABLE_MASK) + " = "+Integer.toHexString(argb)); return (short)(id | CHANGEABLE_MASK); } Modified: trunk/Jmol/src/org/jmol/g3d/Platform3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Platform3D.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/g3d/Platform3D.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -83,7 +83,8 @@ abstract Image allocateImage(); - void allocateTBuffers() { + void allocateTBuffers(boolean antialiasTranslucent) { + bufferSizeT = (antialiasTranslucent ? bufferSize : windowSize); zBufferT = new int[bufferSizeT]; pBufferT = new int[bufferSizeT]; } @@ -103,8 +104,10 @@ bufferSize = bufferWidth * bufferHeight; zBuffer = new int[bufferSize]; pBuffer = new int[bufferSize]; - //no need for any antialiazing on a translucent buffer - bufferSizeT = windowSize; + // original thought was that there is + // no need for any antialiazing on a translucent buffer + // but that's simply not true. + // bufferSizeT = windowSize; imagePixelBuffer = allocateImage(); /* Logger.debug(" width:" + width + " bufferWidth=" + bufferWidth + Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -654,7 +654,7 @@ for (int i = m.polygonCount; --i >= 0;) { int[] p = m.polygonIndexes[i]; m.axes[i] = new Vector3f(); - if (p.length == 0) { + if (p == null || p.length == 0) { } else if (m.drawVertexCount == 2 || m.drawVertexCount < 0 && m.drawVertexCounts[i] == 2) { m.axes[i].sub(m.vertices[p[0]], Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -7870,7 +7870,7 @@ height = intParameter(pt++); } } else { - type = "image"; + type = "(image)"; } break; } @@ -7892,6 +7892,12 @@ //write script "filename" //write isosurface t.jvxl + if (type.equals("(image)") && Parser.isOneOf(val.toUpperCase(), + "JPG;JPG64;JPEG;JPEG64;PNG;PPM")) { + type = val.toUpperCase(); + pt++; + } + if (pt + 2 == statementLength) { data = parameterAsString(++pt); if (data.charAt(0) != '.') Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2007-10-25 05:27:05 UTC (rev 8513) @@ -1,5 +1,11 @@ version=11.3.38_dev +# bug fix -- antialiasing with translucent/POV-ray +# new feature: set antialiasTranslucent TRUE/FALSE +# along with antialiasDisplay and antialiasImages +# determines the extent of antialiasing. Requires +# antialiasDisplay or antialiasimages TRUE. + # ----------------------------------------------------------------------------- #version=11.3.37 Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -506,6 +506,7 @@ boolean antialiasDisplay = false; boolean antialiasImages = true; + boolean antialiasTranslucent = false; boolean greyscaleRendering = false; boolean zoomLarge = true; //false would be like Chime boolean dotsSelectedOnly = false; @@ -954,6 +955,7 @@ setParameterValue("ambientPercent",ambientPercent); setParameterValue("antialiasImages",antialiasImages); setParameterValue("antialiasDisplay",antialiasDisplay); + setParameterValue("antialiasTranslucent",antialiasTranslucent); setParameterValue("appendNew",appendNew); setParameterValue("applySymmetryToBonds",applySymmetryToBonds); setParameterValue("autoBond",autoBond); Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -92,7 +92,7 @@ private void setViewer(Viewer viewer, int width, int height) { this.viewer = viewer; - setScreenDimension(width, height, true, false, true); + setScreenParameters(width, height, true, false, true, true); } boolean checkedForNavigation = false; @@ -1101,13 +1101,14 @@ private boolean antialias; private boolean useZoomLarge; - void setScreenDimension(int width, int height, boolean useZoomLarge, - boolean antialias, boolean resetSlab) { + void setScreenParameters(int width, int height, boolean useZoomLarge, + boolean antialias, + boolean resetSlab, boolean resetZoom) { this.antialias = antialias; this.width = (antialias ? width * 2 : width); this.height = (antialias ? height * 2 : height); this.useZoomLarge = useZoomLarge; - scaleFitToScreen(false, useZoomLarge, resetSlab); + scaleFitToScreen(false, useZoomLarge, resetSlab, resetZoom); } void setAntialias(boolean TF) { @@ -1121,7 +1122,7 @@ width /= 2; height /= 2; } - scaleFitToScreen(false, useZoomLarge, false); + scaleFitToScreen(false, useZoomLarge, false, false); } private float defaultScaleToScreen(float radius) { @@ -1141,23 +1142,23 @@ } void scaleFitToScreen(boolean andCenter) { - scaleFitToScreen(andCenter, viewer.getZoomLarge(), true); + scaleFitToScreen(andCenter, viewer.getZoomLarge(), true, true); } void scaleFitToScreen(boolean andCenter, boolean zoomLarge, - boolean resetSlab) { + boolean resetSlab, boolean resetZoom) { if (width == 0 || height == 0) return; // translate to the middle of the screen fixedTranslation.set(width * (andCenter ? 0.5f : xTranslationFraction), height * (andCenter ? 0.5f : yTranslationFraction), 0); setTranslationFractions(); - resetNavigationPoint(resetSlab); + if (resetZoom) + resetNavigationPoint(resetSlab); // 2005 02 22 // switch to finding larger screen dimension // find smaller screen dimension screenPixelCount = (zoomLarge == (height > width) ? height : width); - //System.out.println("tman: screenPixelCount:" + screenPixelCount); // ensure that rotations don't leave some atoms off the screen // note that this radius is to the furthest outside edge of an atom @@ -1237,7 +1238,6 @@ if (zoomPercentSetting > MAXIMUM_ZOOM_PERCENTAGE) zoomPercentSetting = MAXIMUM_ZOOM_PERCENTAGE; zoomPercent = (zoomEnabled || isNavigationMode ? zoomPercentSetting : 100); - //System.out.println("calczoom" + zoomPercent); } /** @@ -1275,8 +1275,6 @@ // cale to screen coordinates matrixTemp.setZero(); matrixTemp.set(scalePixelsPerAngstrom); - //System.out.println("tman: antialias " + antialias + " screenPixelCount:" + screenPixelCount + " sppa " + scalePixelsPerAngstrom); - if (!axesOrientationRasmol) { // negate y (for screen) and z (for zbuf) matrixTemp.m11 = matrixTemp.m22 = -scalePixelsPerAngstrom; @@ -1285,8 +1283,6 @@ //z-translate to set rotation center at midplane (Nav) or front plane (V10) matrixTransform.m23 += modelCenterOffset; - //System.out.println("zoom:" + zoomPercent + "\n" + matrixTransform); - // note that the image is still centered at 0, 0 in the xy plane if (false && Logger.isActiveLevel(Logger.LEVEL_DEBUG)) @@ -1910,7 +1906,6 @@ setSpinOn(false); } try { - //System.out.println("sleeping "+sleepTime); Thread.sleep(sleepTime); } catch (InterruptedException e) { break; Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-10-24 13:17:17 UTC (rev 8512) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-10-25 05:27:05 UTC (rev 8513) @@ -434,7 +434,7 @@ stateManager.saveState(saveName); } - String getSavedState(String saveName) { + public String getSavedState(String saveName) { return stateManager.getSavedState(saveName); } @@ -1724,7 +1724,6 @@ + " " + bTotal + " " + bFree + " " + bMax); if (notify) setStatusFileLoaded(0, null, null, null, null, null); - // System.out.println(Token.getSetParameters()); } private void zap(String msg) { @@ -2069,8 +2068,6 @@ } int findNearestAtomIndex(int x, int y) { - //System.out.println("hover x y o :" + x + " " + y - // + " " + (x + y * getScreenWidth())); if (modelSet == null) return -1; if (g3d.isAntialiased()) { @@ -2714,7 +2711,7 @@ // Logger.debug("viewer.setInMotion("+inMotion+")"); if (wasInMotion ^ inMotion) { repaintManager.setInMotion(inMotion); - //resizeImage(dimScreen.width, dimScreen.height, false, false, true); + //resizeImage(0, 0, false, false, true); if (inMotion) { ++motionEventNumber; } else { @@ -2820,22 +2817,32 @@ boolean isImageWrite, boolean isGenerator, boolean isReset) { + if (width > 0) { + dimScreen.width = width; + dimScreen.height = height; + } + boolean antialias = false; if (isReset) antialias = global.antialiasDisplay;//&& !getInMotion(); else if (isImageWrite && !isGenerator) antialias = global.antialiasImages; - dimScreen.width = width; - dimScreen.height = height; - if (!isImageWrite) { + if (width > 0 && !isImageWrite) { global.setParameterValue("_width", width); global.setParameterValue("_height", height); setStatusResized(width, height); } - transformManager.setScreenDimension(width, height, + if (width <= 0) { + width = dimScreen.width; + height = dimScreen.height; + } + transformManager.setScreenParameters(width, height, isImageWrite || isReset? global.zoomLarge : false, - antialias, false); - g3d.setWindowSize(width, height, antialias); + antialias, false, false); + if (isGenerator) + g3d.setWindowParameters(width, height, antialias); + else + g3d.setWindowBuffers(width, height, antialias); } public int getScreenWidth() { @@ -2868,10 +2875,10 @@ */ public String generateOutput(String type, String fileName, int width, int height) { + saveState("_Export"); int saveWidth = dimScreen.width; int saveHeight = dimScreen.height; - if (width > 0 && height > 0) - resizeImage(width, height, true, true, false); + resizeImage(width, height, true, true, false); setModelVisibility(); String data = repaintManager.generateOutput(type, g3d, modelSet, fileName); // mth 2003-01-09 Linux Sun JVM 1.4.2_02 @@ -2882,7 +2889,6 @@ } public void renderScreenImage(Graphics g, Dimension size, Rectangle clip) { - //System.out.println("renderScreen"); if (isTainted || getSlabEnabled()) setModelVisibility(); isTainted = false; @@ -2914,10 +2920,12 @@ g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, matrixRotate, antialias, twoPass); repaintManager.render(g3d, modelSet); //, rectClip - if (twoPass && g3d.setPass2()) { - transformManager.setAntialias(false); + if (twoPass && g3d.setPass2(global.antialiasTranslucent)) { + if (!global.antialiasTranslucent) + transformManager.setAntialias(false); repaintManager.render(g3d, modelSet); //, rectClip - transformManager.setAntialias(antialias); + if (!global.antialiasTranslucent) + transformManager.setAntialias(antialias); } // mth 2003-01-09 Linux Sun JVM 1.4.2_02 // Sun is throwing a NullPointerExceptions inside graphics routines @@ -2931,13 +2939,24 @@ g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, transformManager.getStereoRotationMatrix(true), antialias, twoPass); repaintManager.render(g3d, modelSet);//, rectClip - if (twoPass && g3d.setPass2()) - repaintManager.render(g3d, modelSet);//, rectClip + if (twoPass && g3d.setPass2(global.antialiasTranslucent)) { + if (antialias && !global.antialiasTranslucent) + transformManager.setAntialias(false); + repaintManager.render(g3d, modelSet); //, rectClip + if (antialias && !global.antialiasTranslucent) + transformManager.setAntialias(true); + } g3d.endRendering(); g3d.snapshotAnaglyphChannelBytes(); g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, transformManager.getStereoRotationMatrix(false), antialias, twoPass); - repaintManager.render(g3d, modelSet);//, rectClip + if (twoPass && g3d.setPass2(global.antialiasTranslucent)) { + if (antialias && !global.antialiasTranslucent) + transformManager.setAntialias(false); + repaintManager.render(g3d, modelSet); //, rectClip + if (antialias && !global.antialiasTranslucent) + transformManager.setAntialias(true); + } g3d.endRendering(); switch (stereoMode) { case JmolConstants.STEREO_REDCYAN: @@ -3049,7 +3068,6 @@ } private String evalStringQuiet(String strScript, boolean isQuiet) { - //System.out.println(htmlName + " evalString " + strScript); interruptScript = ""; boolean isInterrupt = (strScript.length() > 0 && strScript.charAt(0) == '!'); if (isInterrupt) @@ -3062,7 +3080,6 @@ interruptScript = strScript; return "!" + strScript; } - //System.out.println(htmlName + " addScript " + strScript); return scriptManager.addScript(strScript, false, isQuiet); } @@ -4261,12 +4278,17 @@ //11.3.36 if (key.equalsIgnoreCase("antialiasDisplay")) { - setAntialias(true, value); + setAntialias(0, value); break; } + if (key.equalsIgnoreCase("antialiasTranslucent")) { + setAntialias(1, value); + break; + } + if (key.equalsIgnoreCase("antialiasImages")) { - setAntialias(false, value); + setAntialias(2, value); break; } @@ -4963,7 +4985,7 @@ private void setZoomLarge(boolean TF) { global.zoomLarge = TF; - transformManager.scaleFitToScreen(false, global.zoomLarge, false); + transformManager.scaleFitToScreen(false, global.zoomLarge, false, true); } boolean getZoomLarge() { @@ -5245,16 +5267,23 @@ return global.zeroBasedXyzRasmol; } - private void setAntialias(boolean isDisplay, boolean TF) { - if (isDisplay) { + private void setAntialias(int mode, boolean TF) { + switch (mode) { + case 0: //display global.setParameterValue("antialiasDisplay", TF); global.antialiasDisplay = TF; - resizeImage(dimScreen.width, dimScreen.height, false, false, true); - refresh(0, "setAntialias()"); + break; + case 1: // translucent + global.setParameterValue("antialiasTranslucent", TF); + global.antialiasTranslucent = TF; + break; + case 2: // images + global.setParameterValue("antialiasImages", TF); + global.antialiasImages = TF; return; } - global.setParameterValue("antialiasImages", TF); - global.antialiasImages = TF; + resizeImage(0, 0, false, false, true); + refresh(0, "setAntialias()"); } // ////////////////////////////////////////////////////////////// @@ -5771,7 +5800,6 @@ * @return nX by nY array of floating values */ public float[][] functionXY(String functionName, int nX, int nY) { - System.out.println("functionXY::: " + functionName); if (functionName.indexOf("file:") < 0) return statusManager.functionXY(functionName, nX, nY); String data = getFileAsString(functionName.substring(5)); @@ -5896,15 +5924,17 @@ int width, int height) { int saveWidth = dimScreen.width; int saveHeight = dimScreen.height; - if (width > 0 && height > 0) + if (quality != Integer.MIN_VALUE) { resizeImage(width, height, true, false, false); - setModelVisibility(); + setModelVisibility(); + } try { statusManager.createImage(file, type_text, quality); } catch (Exception e) { Logger.error("Error creating image: " + e.getMessage()); } - resizeImage(saveWidth, saveHeight, true, false, true); + if (quality != Integer.MIN_VALUE) + resizeImage(saveWidth, saveHeight, true, false, true); } public void syncScript(String script, String applet) { @@ -5931,7 +5961,6 @@ statusManager.setSyncDriver(StatusManager.SYNC_SLAVE); return; } - //System.out.println("syncmode=" + statusManager.getSyncMode()); int syncMode = statusManager.getSyncMode(); if (syncMode == StatusManager.SYNC_OFF) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |