From: <ha...@us...> - 2012-09-26 20:38:04
|
Revision: 17583 http://jmol.svn.sourceforge.net/jmol/?rev=17583&view=rev Author: hansonr Date: 2012-09-26 20:37:57 +0000 (Wed, 26 Sep 2012) Log Message: ----------- refactoring for JavaScript Modified Paths: -------------- trunk/Jmol/src/org/jmol/export/Export3D.java trunk/Jmol/src/org/jmol/export/_ObjExporter.java trunk/Jmol/src/org/jmol/export/_TachyonExporter.java trunk/Jmol/src/org/jmol/export/___Exporter.java trunk/Jmol/src/org/jmol/g3d/Graphics3D.java trunk/Jmol/src/org/jmol/render/MeshRenderer.java trunk/Jmol/src/org/jmol/render/RepaintManager.java trunk/Jmol/src/org/jmol/thread/CommandWatcherThread.java trunk/Jmol/src/org/jmol/util/GData.java trunk/Jmol/src/org/jmol/viewer/ShapeManager.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 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/export/Export3D.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -32,7 +32,6 @@ import javax.vecmath.Vector3f; import org.jmol.api.JmolRendererInterface; -import org.jmol.g3d.Graphics3D; import org.jmol.g3d.HermiteRenderer; import org.jmol.modelset.Atom; import org.jmol.util.JmolFont; @@ -52,7 +51,7 @@ private ___Exporter exporter; private double privateKey; - private Graphics3D g3d; + private GData g3d; private short colix; private HermiteRenderer hermite3d; private int width; @@ -87,7 +86,7 @@ } catch (Exception e) { return false; } - g3d = (Graphics3D) gdata; + g3d = gdata; exporter.setRenderer(this); g3d.setNewWindowParametersForExport(); slab = g3d.getSlab(); Modified: trunk/Jmol/src/org/jmol/export/_ObjExporter.java =================================================================== --- trunk/Jmol/src/org/jmol/export/_ObjExporter.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/export/_ObjExporter.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -23,7 +23,6 @@ import javax.vecmath.Vector3f; import org.jmol.export.image.ImageCreator; -import org.jmol.g3d.Graphics3D; import org.jmol.modelset.Atom; import org.jmol.util.Colix; import org.jmol.util.ColorUtil; @@ -435,7 +434,7 @@ * @see org.jmol.export.___Exporter#initializeOutput(org.jmol.viewer.Viewer, org.jmol.g3d.Graphics3D, java.lang.Object) */ @Override - boolean initializeOutput(Viewer viewer, double privateKey, Graphics3D g3d, Object output) { + boolean initializeOutput(Viewer viewer, double privateKey, GData g3d, Object output) { debugPrint("initializeOutput: + output"); // Call the super method boolean retVal = super.initializeOutput(viewer, privateKey, g3d, output); Modified: trunk/Jmol/src/org/jmol/export/_TachyonExporter.java =================================================================== --- trunk/Jmol/src/org/jmol/export/_TachyonExporter.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/export/_TachyonExporter.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -35,7 +35,6 @@ import javax.vecmath.Tuple3f; import javax.vecmath.Vector3f; -import org.jmol.g3d.Graphics3D; import org.jmol.util.GData; import org.jmol.viewer.Viewer; @@ -57,7 +56,7 @@ } @Override - boolean initializeOutput(Viewer viewer, double privateKey, Graphics3D g3d, Object output) { + boolean initializeOutput(Viewer viewer, double privateKey, GData g3d, Object output) { //wasPerspectiveDepth = viewer.getPerspectiveDepth(); //viewer.setPerspectiveDepth(false); getLightingInfo(); Modified: trunk/Jmol/src/org/jmol/export/___Exporter.java =================================================================== --- trunk/Jmol/src/org/jmol/export/___Exporter.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/export/___Exporter.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -50,7 +50,6 @@ import javax.vecmath.Vector3f; import org.jmol.api.JmolRendererInterface; -import org.jmol.g3d.Graphics3D; import org.jmol.modelset.Atom; import org.jmol.script.Token; import org.jmol.util.Colix; @@ -153,7 +152,7 @@ protected String commandLineOptions; protected boolean isToFile; - protected Graphics3D g3d; + protected GData g3d; protected short backgroundColix; protected int screenWidth; @@ -202,7 +201,7 @@ this.jmolRenderer = jmolRenderer; } - boolean initializeOutput(Viewer viewer, double privateKey, Graphics3D g3d, Object output) { + boolean initializeOutput(Viewer viewer, double privateKey, GData g3d, Object output) { this.viewer = viewer; this.g3d = g3d; this.privateKey = privateKey; Modified: trunk/Jmol/src/org/jmol/g3d/Graphics3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -180,12 +180,7 @@ private byte[] anaglyphChannelBytes; private boolean twoPass = false; - protected boolean isPass2; - - public boolean isPass2() { - return isPass2; - } - + private boolean addAllPixels; private boolean haveTranslucentObjects; protected boolean translucentCoverOnly = false; @@ -204,9 +199,7 @@ //int clipWidth; //int clipHeight; - private short colixCurrent; private int[] shadesCurrent; - private int argbCurrent; private int anaglyphLength; private boolean isScreened; private int argbNoisyUp, argbNoisyDn; @@ -572,8 +565,10 @@ private int currentShadeIndex; private int lastRawColor; + @Override public void setColor(int argb) { - argbCurrent = argbNoisyUp = argbNoisyDn = argb; + super.setColor(argb); + argbNoisyUp = argbNoisyDn = argb; } @@ -582,6 +577,7 @@ * @param colix the color index * @return true or false if this is the right pass */ + @Override public boolean setColix(short colix) { boolean isLast = Colix.isColixLastAvailable(colix); if (!isLast && colix == colixCurrent && currentShadeIndex == -1) @@ -947,6 +943,7 @@ plotText(xBaseline, yBaseline, z, argbCurrent, str, currentFont, null); } + @Override public void plotText(int x, int y, int z, int argb, String text, JmolFont font3d, JmolRendererInterface jmolRenderer) { TextRenderer.plot(x, y, z, argb, text, font3d, this, jmolRenderer, @@ -971,14 +968,17 @@ width, height); } + @Override public void setFont(byte fid) { currentFont = JmolFont.getFont3D(fid); } + @Override public void setFont(JmolFont font3d) { currentFont = font3d; } + @Override public JmolFont getFont3DCurrent() { return currentFont; } @@ -1723,6 +1723,7 @@ * @param screenB * @param screenC */ + @Override public void setNoisySurfaceShade(Point3i screenA, Point3i screenB, Point3i screenC) { vectorAB.set(screenB.x - screenA.x, screenB.y - screenA.y, screenB.z - screenA.z); @@ -1758,6 +1759,7 @@ ////////////////////////////////////////////////////////// + @Override public void renderBackground(JmolRendererInterface jmolRenderer) { if (backgroundImage != null) plotImage(Integer.MIN_VALUE, 0, Integer.MIN_VALUE, backgroundImage, @@ -1829,10 +1831,12 @@ private final byte[] shadeIndexes = new byte[normixCount]; private final byte[] shadeIndexes2Sided = new byte[normixCount]; + @Override public Vector3f[] getTransformedVertexVectors() { return transformedVectors; } + @Override public boolean isDirectedTowardsCamera(short normix) { // normix < 0 means a double sided normix, so always visible return (normix < 0) || (transformedVectors[normix].z > 0); Modified: trunk/Jmol/src/org/jmol/render/MeshRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/render/MeshRenderer.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/render/MeshRenderer.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -161,7 +161,10 @@ frontOnly = !viewer.getSlabEnabled() && mesh.frontOnly && !mesh.isTwoSided && !haveBsSlabDisplay; screens = viewer.allocTempScreens(vertexCount); - transformedVectors = g3d.getTransformedVertexVectors(); + if (frontOnly) + transformedVectors = g3d.getTransformedVertexVectors(); + if (transformedVectors == null) + frontOnly = false; } return true; } Modified: trunk/Jmol/src/org/jmol/render/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/render/RepaintManager.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/render/RepaintManager.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -132,7 +132,7 @@ renderers[i] = null; } - private ShapeRenderer getRenderer(int shapeID, Graphics3D g3d) { + private ShapeRenderer getRenderer(int shapeID, JmolRendererInterface g3d) { if (renderers[shapeID] != null) return renderers[shapeID]; String className = JmolConstants.getShapeClassName(shapeID, true) + "Renderer"; @@ -189,7 +189,8 @@ boolean isOK; viewer.finalizeTransformParameters(); try { - shapeManager.transformAtoms(null, null); + shapeManager.finalizeAtoms(null, null); + shapeManager.transformAtoms(); output = (fileName == null ? new StringBuffer() : fileName); Class<?> export3Dclass = Class.forName("org.jmol.export.Export3D"); g3dExport = (JmolRendererInterface) export3Dclass.newInstance(); Modified: trunk/Jmol/src/org/jmol/thread/CommandWatcherThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/CommandWatcherThread.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/thread/CommandWatcherThread.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -25,8 +25,6 @@ package org.jmol.thread; -import java.util.List; - import org.jmol.util.Logger; import org.jmol.viewer.ScriptManager; Modified: trunk/Jmol/src/org/jmol/util/GData.java =================================================================== --- trunk/Jmol/src/org/jmol/util/GData.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/util/GData.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -1,11 +1,16 @@ package org.jmol.util; +import java.awt.Image; + import javax.vecmath.Matrix3f; import javax.vecmath.Point3f; +import javax.vecmath.Point3i; +import javax.vecmath.Vector3f; import org.jmol.api.ApiPlatform; import org.jmol.api.JmolGraphicsInterface; +import org.jmol.api.JmolRendererInterface; import org.jmol.constant.EnumStereoMode; public class GData implements JmolGraphicsInterface { @@ -32,6 +37,8 @@ public int width, height; public int zSlab, zDepth; + protected short colixCurrent; + protected int argbCurrent; public int bufferSize; @@ -553,4 +560,98 @@ public void clearFontCache() { } + /** + * @param x + * @param y + * @param z + * @param image + * @param jmolRenderer + * @param bgcolix + * @param width + * @param height + * + */ + public void plotImage(int x, int y, int z, Image image, + JmolRendererInterface jmolRenderer, short bgcolix, + int width, int height) { + } + + /** + * @param x + * @param y + * @param z + * @param colorArgbOrGray + * @param text + * @param font3d + * @param jmolRenderer + * + */ + public void plotText(int x, int y, int z, int colorArgbOrGray, String text, + JmolFont font3d, JmolRendererInterface jmolRenderer) { + } + + /** + * @param jmolRenderer + */ + public void renderBackground(JmolRendererInterface jmolRenderer) { + } + + public JmolFont getFont3DCurrent() { + return null; + } + + /** + * @param font3d + */ + public void setFont(JmolFont font3d) { + } + + /** + * @param fid + */ + public void setFont(byte fid) { + } + + /** + * @param color + */ + public void setColor(int color) { + argbCurrent = color; + } + + public boolean isPass2; + + public boolean isPass2() { + return isPass2; + } + + /** + * @param colix + * @return TRUE if correct pass (translucent or opaque) + */ + public boolean setColix(short colix) { + return true; + } + + /** + * @param normix + * @return true if front + */ + public boolean isDirectedTowardsCamera(short normix) { + return true; + } + + public Vector3f[] getTransformedVertexVectors() { + return null; + } + + /** + * @param pointA + * @param pointB + * @param pointC + */ + public void setNoisySurfaceShade(Point3i pointA, Point3i pointB, + Point3i pointC) { + } + } Modified: trunk/Jmol/src/org/jmol/viewer/ShapeManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -402,7 +402,7 @@ private final int[] navigationCrossHairMinMax = new int[4]; - public int[] transformAtoms(BitSet bsAtoms, Point3f ptOffset) { + public void finalizeAtoms(BitSet bsAtoms, Point3f ptOffset) { if (bsAtoms != null) { // translateSelected operation Point3f ptCenter = viewer.getAtomSetCenter(bsAtoms); @@ -416,25 +416,31 @@ } bsRenderableAtoms.clear(); Atom[] atoms = modelSet.atoms; - Vector3f[] vibrationVectors = modelSet.vibrationVectors; for (int i = modelSet.getAtomCount(); --i >= 0;) { Atom atom = atoms[i]; if ((atom.getShapeVisibilityFlags() & JmolConstants.ATOM_IN_FRAME) == 0) continue; bsRenderableAtoms.set(i); + } + } + + public int[] transformAtoms() { + Vector3f[] vibrationVectors = modelSet.vibrationVectors; + Atom[] atoms = modelSet.atoms; + for (int i = bsRenderableAtoms.nextSetBit(0); i >= 0; i = bsRenderableAtoms.nextSetBit(i + 1)) { // note that this vibration business is not compatible with // PDB objects such as cartoons and traces, which // use Cartesian coordinates, not screen coordinates - Point3i screen = (vibrationVectors != null && atom.hasVibration() - ? viewer.transformPoint(atom, vibrationVectors[i]) - : viewer.transformPoint(atom)); + Atom atom = atoms[i]; + Point3i screen = (vibrationVectors != null && atom.hasVibration() ? viewer + .transformPoint(atom, vibrationVectors[i]) + : viewer.transformPoint(atom)); atom.screenX = screen.x; atom.screenY = screen.y; atom.screenZ = screen.z; atom.screenDiameter = viewer.scaleToScreen(screen.z, Math .abs(atom.madAtom)); } - if (viewer.getSlabEnabled()) { boolean slabByMolecule = viewer.getSlabByMolecule(); boolean slabByAtom = viewer.getSlabByAtom(); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-09-26 16:33:55 UTC (rev 17582) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-09-26 20:37:57 UTC (rev 17583) @@ -4325,8 +4325,8 @@ return; boolean antialias2 = antialiasDisplay && global.antialiasTranslucent; finalizeTransformParameters(); - int[] minMax = shapeManager.transformAtoms(transformManager.bsSelectedAtoms, - transformManager.ptOffset); + shapeManager.finalizeAtoms(transformManager.bsSelectedAtoms, transformManager.ptOffset); + int[] minMax = shapeManager.transformAtoms(); transformManager.bsSelectedAtoms = null; repaintManager.render(gdata, modelSet, true, minMax); if (gdata.setPass2(antialias2)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |