From: <ha...@us...> - 2012-06-12 23:32:05
|
Revision: 17290 http://jmol.svn.sourceforge.net/jmol/?rev=17290&view=rev Author: hansonr Date: 2012-06-12 23:31:58 +0000 (Tue, 12 Jun 2012) Log Message: ----------- JmolCore upgrade; includes JmolGLmol.js Modified Paths: -------------- trunk/Jmol/appletweb/JmolApi.js trunk/Jmol/appletweb/JmolApplet.jar trunk/Jmol/appletweb/JmolAppletSigned.jar trunk/Jmol/appletweb/JmolCD.js trunk/Jmol/appletweb/JmolCore.js Added Paths: ----------- trunk/Jmol/appletweb/JmolGLmol.js Modified: trunk/Jmol/appletweb/JmolApi.js =================================================================== --- trunk/Jmol/appletweb/JmolApi.js 2012-06-12 18:54:58 UTC (rev 17289) +++ trunk/Jmol/appletweb/JmolApi.js 2012-06-12 23:31:58 UTC (rev 17290) @@ -11,16 +11,16 @@ addSelectionOptions: false, serverURL: "http://chemapps.stolaf.edu/jmol/jmolcd.php", defaultModel: "", + script: null, + src: null, + readyFunction: null, useNoApplet: false, useJmolOnly: true, useWebGlIfAvailable: true, useImageOnly: false, - isSigned: false, jarPath: ".", jarFile: "JmolApplet0.jar", - readyFunction: null, - script: null, - src: null, + isSigned: false, debug: false }; Modified: trunk/Jmol/appletweb/JmolApplet.jar =================================================================== (Binary files differ) Modified: trunk/Jmol/appletweb/JmolAppletSigned.jar =================================================================== (Binary files differ) Modified: trunk/Jmol/appletweb/JmolCD.js =================================================================== --- trunk/Jmol/appletweb/JmolCD.js 2012-06-12 18:54:58 UTC (rev 17289) +++ trunk/Jmol/appletweb/JmolCD.js 2012-06-12 23:31:58 UTC (rev 17290) @@ -24,7 +24,7 @@ // overrides the function in JmolCore.js // ChemDoodle: first try with WebGL unless that doesn't work or we have indicated NOWEBGL var canvas = null; - if (Info.useWebGlIfAvailable && ChemDoodle.featureDetection.supports_webgl()) + if (Info.useWebGlIfAvailable && Jmol.featureDetection.supportsWebGL()) canvas = new Jmol._Canvas3D(id, Info, null, checkOnly); if (canvas == null) canvas = new Jmol._Canvas(id, Info, null, checkOnly); @@ -35,7 +35,7 @@ Jmol._Canvas3D = function(id, Info, caption, checkOnly){ this._is2D = false; - this._jmolType = "Jmol._Canvas3D"; + this._jmolType = "Jmol._Canvas3D (ChemDoodle)"; if (checkOnly) return this; this._dataMultiplier=1; @@ -45,7 +45,7 @@ Jmol._Canvas = function(id, Info, caption, checkOnly){ this._is2D = true; - this._jmolType = "Jmol._Canvas"; + this._jmolType = "Jmol._Canvas (ChemDoodle)"; if (checkOnly) return this; this._dataMultiplier=20; @@ -69,10 +69,6 @@ Jmol._documentWrite(t); this.create(id, Info.width, Info.height); this._setDefaults(); - if (this.defaultModel) - this._search(this._defaultModel); - if (this._readyScript) - this._script(this._readyScript); t = ""; } else { t += '<script type="text/javascript">' @@ -133,15 +129,8 @@ } proto._searchDatabase = function(query, database, script){ - this._showInfo(false); - if (query.indexOf("?") >= 0) { - Jmol._getInfoFromDatabase(this, database, query.split("?")[0]); + if (Jmol._searchDatabase(this, query, database, script)) return; - } - if (Jmol.db._DirectDatabaseCalls[database]) { - this._loadFile(database + query); - return; - } this.emptyMessage="Searching..."; this.molecule=null; this.repaint(); @@ -163,7 +152,7 @@ this.emptyMessage="Retrieving data..."; this.molecule=null; this.repaint(); - this._jmolFileType = Jmol._cdGetFileType(fileName); + this._jmolFileType = Jmol._getFileType(fileName); var cdcanvas = this; Jmol._loadFileData(this, fileName, function(data){Jmol._cdProcessFileData(cdcanvas, data)}); } @@ -190,20 +179,9 @@ this.specs.bonds_clearOverlaps_2D = true; } - Jmol._cdGetFileType = function(name) { - var database = name.substring(0, 1); - if (database == "$" || database == ":") - return "MOL"; - if (database == "=") - return (name.substring(1,2) == "=" ? "LCIF" : "PDB"); - // just the extension, which must be PDB, XYZ..., CIF, or MOL - name = name.split('.').pop().toUpperCase(); - return name.substring(0, Math.min(name.length, 3)); - } - Jmol._cdProcessFileData = function(cdcanvas, data) { var factor = cdcanvas._dataMultiplier; - data = Jmol._cdCleanFileData(data); + data = Jmol._cleanFileData(data); var molecule; switch(cdcanvas._jmolFileType) { case "PDB": @@ -232,16 +210,6 @@ cdcanvas.loadMolecule(Jmol._cdScaleMolecule(molecule, factor)); } - Jmol._cdCleanFileData = function(data) { - if (data.indexOf("\r") >= 0 && data.indexOf("\n") >= 0) { - return data.replace(/\r\n/g,"\n"); - } - if (data.indexOf("\r") >= 0) { - return data.replace(/\r/g,"\n"); - } - return data; - } - Jmol._cdScaleMolecule = function(molecule, multiplier) { if (multiplier != 0 && multiplier != 1) { var atoms = molecule.atoms; Modified: trunk/Jmol/appletweb/JmolCore.js =================================================================== --- trunk/Jmol/appletweb/JmolCore.js 2012-06-12 18:54:58 UTC (rev 17289) +++ trunk/Jmol/appletweb/JmolCore.js 2012-06-12 23:31:58 UTC (rev 17290) @@ -358,6 +358,19 @@ features.supportsXhr2 = function() {return jQuery && jQuery.support.cors} + features._webGLtest = 0; + + features.supportsWebGL = function() { + if (!Jmol.featureDetection._webGLtest) { + var canvas; + Jmol.featureDetection._webGLtest = ( + window.WebGLRenderingContext + && ((canvas = document.createElement("canvas")).getContext("webgl") + || canvas.getContext("experimental-webgl")) ? 1 : -1); + } + return (Jmol.featureDetection._webGLtest > 0); + }; + features.compliantBrowser = function() { var a = !!document.getElementById; var os = features.os() @@ -578,4 +591,37 @@ obj._src = Info.src; } + Jmol._cleanFileData = function(data) { + if (data.indexOf("\r") >= 0 && data.indexOf("\n") >= 0) { + return data.replace(/\r\n/g,"\n"); + } + if (data.indexOf("\r") >= 0) { + return data.replace(/\r/g,"\n"); + } + return data; + }; + + Jmol._getFileType = function(name) { + var database = name.substring(0, 1); + if (database == "$" || database == ":") + return "MOL"; + if (database == "=") + return (name.substring(1,2) == "=" ? "LCIF" : "PDB"); + // just the extension, which must be PDB, XYZ..., CIF, or MOL + name = name.split('.').pop().toUpperCase(); + return name.substring(0, Math.min(name.length, 3)); + }; + + Jmol._searchDatabase = function(applet, query, database, script) { + applet._showInfo(false); + if (query.indexOf("?") >= 0) { + Jmol._getInfoFromDatabase(applet, database, query.split("?")[0]); + return true; + } + if (Jmol.db._DirectDatabaseCalls[database]) { + applet._loadFile(database + query, script); + return true; + } + return false; + } })(Jmol); \ No newline at end of file Added: trunk/Jmol/appletweb/JmolGLmol.js =================================================================== --- trunk/Jmol/appletweb/JmolGLmol.js (rev 0) +++ trunk/Jmol/appletweb/JmolGLmol.js 2012-06-12 23:31:58 UTC (rev 17290) @@ -0,0 +1,230 @@ +// JmolGLmol.js -- Jmol GLmol extension author: Bob Hanson, ha...@st... 4/16/2012 +// biochem_fan 6/12/2012 + +// This library requires +// +// json2.js +// JmolCore.js +// jQuery.min.js +// Three49cusom.js +// GLmol.js +// +// prior to JmolGlmol.js + +if(typeof(GLmol)=="undefined") GLmol = null; + +(function (Jmol) { + + if (!GLmol) + return; + + Jmol._getCanvas = function(id, Info, checkOnly) { + // overrides the function in JmolCore.js + var canvas = null; + if (Info.useWebGlIfAvailable && Jmol.featureDetection.supportsWebGL()) + canvas = new Jmol._Canvas3D(id, Info, null, checkOnly); + else + return null; + if (Jmol._document) + canvas._readyCallback(id, id, true, null); + return canvas; + } + + Jmol._Canvas3D = function(id, Info, caption, checkOnly){ + this._is2D = false; + this._jmolType = "Jmol._Canvas3D (GLmol)"; + if (checkOnly) + return this; + this._dataMultiplier=1; + this._create(id, Info, caption); + return this; + }; + + var _glSetPrototype = function(proto) { + Jmol._setCommonMethods(proto); + + proto._create = function(id, Info, caption) { + Jmol._setObject(this, id, Info); + var t = Jmol._getWrapper(this, true); + //console.log(this); + if (Jmol._document) { + Jmol._documentWrite(t); + this.glmol = new GLmol(id + "_appletdiv", true); + this.glmol.defineRepresentation = Jmol._glmol_DefineRep; + this.glmol.wrapper = this; + this._setDefaults(); + t = ""; + } else { + t += '<script type="text/javascript">' + + id + '.create("'+id+'",'+Info.width+','+Info.height+');' + + id + '._setDefaults();' + if (Info.defaultModel) + t += id + "._search(" + id + "._defaultModel);"; + if (this._readyScript) + t += id + '._script(' + id + '._readyScript);' + t += '</script>'; + } + t += Jmol._getWrapper(this, false); + if (Info.addSelectionOptions) + t += Jmol._getGrabberOptions(this, caption); + if (Jmol._debugAlert && !Jmol._document) + alert(t); + this._code = Jmol._documentWrite(t); + }; + + proto._canScript = function(script) {return (script.indexOf("#alt") >= 0);}; + + proto._script = function(script) { + if (!this._canScript(script)) + return; + var Cmd = jQuery.trim(script.split("#alt:")[1]); + var pt = Cmd.indexOf(" "); + var what = jQuery.trim(Cmd.substring(pt + 1)); + switch (Cmd.substring(0, pt)) { + case "SETTING": + switch (what) { + case "Ball and Stick": this.hetatmMode = 'ballAndStick2'; break; + case "Line": this.hetatmMode = 'line'; break; + case "van der Waals Spheres": this.hetatmMode = 'sphere'; break; + } + this.glmol.rebuildScene(); + this.glmol.show(); + return; + case "LOAD": + if (what.indexOf("??") >= 0) { + var db = what.split("??")[0]; + what = prompt(what.split("??")[1], ""); + if (!what) + return; + if (!Jmol.db._DirectDatabaseCalls[what.substring(0,1)]) + what = db + what; + } + Jmol.loadFile(this, what); + return; + } + }; + + proto._searchDatabase = function(query, database, script){ + if (Jmol._searchDatabase(this, query, database, script)) + return; + this.emptyMessage="Searching..."; + var glcanvas = this; + Jmol._getRawDataFromServer( + database, + query, + function(data){Jmol._glProcessFileData(glcanvas, data, script)} + ); + }; + + proto._show = function(tf) { + document.getElementById(this._id + "_appletdiv").style.display = (tf ? "block" : "none"); + }; + + proto._loadFile = function(fileName, script){ + this._showInfo(false); + this._thisJmolModel = "" + Math.random(); + this.emptyMessage="Retrieving data..."; + this._jmolFileType = Jmol._getFileType(fileName); + var glcanvas = this; + Jmol._loadFileData(glcanvas, fileName, function(data){Jmol._glProcessFileData(glcanvas, data, script)}); + }; + + return proto; + }; + + Jmol._Canvas3D.prototype = _glSetPrototype({}); + + Jmol._Canvas3D.prototype._setDefaults = function() { + this.backgroundColor = 0x000000; + this.hetatmMode = 'ballAndStick2'; + this.mainchainMode = 'thickRibbon'; + this.colorMode = 'chainbow'; + }; + + Jmol._glProcessFileData = function(glcanvas, data, script) { + glcanvas.glmol.loadMoleculeStr(false, Jmol._cleanFileData(data)); + script && Jmol.script(glcanvas, script); + }; + + Jmol._glmol_DefineRep = function() { + // "this" is glcanvas.glmol + var all = this.getAllAtoms(); + var allHet = this.getHetatms(all); + var hetatm = this.removeSolvents(allHet); + this.colorByAtom(all, {}); + switch (this.wrapper.colorMode) { + case 'ss': this.colorByStructure(all, 0xcc00cc, 0x00cccc); break; + case 'chain': this.colorByChain(all); break; + case 'chainbow': this.colorChainbow(all); break; + case 'b': this.colorByBFactor(all); break; + case 'polarity': this.colorByPolarity(all, 0xcc0000, 0xcccccc); break; + } + + var asu = new THREE.Object3D(); + switch (this.wrapper.mainchainMode) { + case 'ribbon': + this.drawCartoon(asu, all, this.wraper.doNotSmoothen); + this.drawCartoonNucleicAcid(asu, all); + break; + case 'thickRibbon': + this.drawCartoon(asu, all, this.wrapper.doNotSmoothen, this.thickness); + this.drawCartoonNucleicAcid(asu, all, null, this.thickness); + break; + case 'strand': + this.drawStrand(asu, all, null, null, null, null, null, doNotSmoothen); + this.drawStrandNucleicAcid(asu, all); + break; + case 'chain': + this.drawMainchainCurve(asu, all, this.curveWidth, 'CA', 1); + this.drawMainchainCurve(asu, all, this.curveWidth, 'O3\'', 1); + break; + case 'tube': + this.drawMainchainTube(asu, all, 'CA'); + this.drawMainchainTube(asu, all, 'O3\''); + break; + case 'bonds': + this.drawBondsAsLine(asu, all, this.lineWidth); + break; + } + + if (this.wrapper.drawSidechains) + this.drawBondsAsLine(this.modelGroup, this.getSidechains(all), this.lineWidth); + + switch (this.wrapper.baseMode) { + case 'nuclStick': this.drawNucleicAcidStick(this.modelGroup, all); break; + case 'nuclLine': this.drawNucleicAcidLine(this.modelGroup, all); break; + case 'nuclPolygon': this.drawNucleicAcidLadder(this.modelGroup, all); break; + } + + var target = this.wrapper.symopAtoms ? asu : this.modelGroup; + if (this.wrapper.showNonbonded) { + var nonBonded = this.getNonbonded(allHet); + if (this.wrapper.nbMode == 'nb_sphere') { + this.drawAtomsAsIcosahedron(target, nonBonded, 0.3, true); + } else if (this.wrapper.nbMode == 'nb_cross') { + this.drawAsCross(target, nonBonded, 0.3, true); + } + } + + switch (this.wrapper.hetatmMode) { + case 'stick': this.drawBondsAsStick(target, hetatm, this.cylinderRadius, this.cylinderRadius, true); break; + case 'sphere': this.drawAtomsAsSphere(target, hetatm, this.sphereRadius); break; + case 'line': this.drawBondsAsLine(target, hetatm, this.curveWidth); break; + case 'ballAndStick': this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, false, 0.3); break; + case 'ballAndStick2': this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, true, 0.3); break; + } + + this.setBackground(this.wrapper.backgroundColor); + + if (this.wrapper.showCell) + this.drawUnitcell(this.modelGroup); + + if (this.wrapper.drawBiomt) + this.drawSymmetryMates2(this.modelGroup, asu, this.protein.biomtMatrices); + + if (this.wrapper.drawPacking) + this.drawSymmetryMatesWithTranslation2(this.modelGroup, asu, this.protein.symMat); + this.modelGroup.add(asu); + }; + +})(Jmol); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |