Otis, that's very interesting. Nice job on that. I think you are
forgetting, though, that JSME is fully integrated into JSmol already. You
do not need to add any functions of your own.
If you look at the code for chemapps.stolaf.edu/jmol/jsmol/jsmetest2.htm,
you will see that JSME integrates into JSmol very smoothly. It's as simple
as this:
<script type="text/javascript" language="javascript"
src="jsme/jsme/jsme.nocache.js"></script>
<script type="text/javascript" src="JSmol.min.js"></script>
<script type="text/javascript" src="js/JSmolJME.js"></script>
var JMEInfo = {
use: "HTML5",
visible: true
,"options" : "nocanonize"//"query,hydrogens"
}
...
jmol = Jmol.getApplet("jmol", JmolInfo)
jme = Jmol.getJMEApplet("jme", JMEInfo, *jmol*);
That last parameter tells JSmol that you want jme to be associated with the
jmol instance of JSmol.
You don't need anything more on the page.
Now you have a 2D and 3D applet linked together with a tab interface.
Automatic updating.
If you want two separate applets, like you have there, then you just add a
div to that JMEinfo:
var JMEInfo = {
use: "HTML5"
,visible: true
* ,divId: "jmediv"* ,options : "autoez;nocanonize"
}
See jsmetest2.htm for something like what you are doing. The two buttons on
that page are driving:
Jmol.show2d(jmol, false) // to 3D
Jmol.show2d(jmol, true) // to 2D
Note that when JSME is in an environment where JSmol and JSpecView are both
there -- http://chemapps.stolaf.edu/jmol/jsmol/jsv_predict2.htm -- then it
doesn't use this callback and instead uses an even more interesting one:
app._applet.setAfterStructureModifiedCallback(f);
This sends a detailed message every time you change the structure or click
on an "atom" in the 2D drawing. JSmol is using this to synchronize the
spectrum and JSmol window when the JSME applet is clicked or the structure
is modified. Works like a charm!
That page is actually extraordinarily simple. JSmol automatically senses
the presence of JSME, Jmol, and JSpecView on the page using a sort of "bus"
communication system. Robert Lancashire and I worked this out a couple of
years ago. It's complicated in JSmolCore.js, but it's super simple in terms
of the page. As the atoms or spectral regions are clicked, registered
applets are automatically queried for their state, and the signal is passed
around until all are two or three applets on the page are in sync.
The synchronization is activated by a a call to Jmol.updateView(isJmol ?
jmol : jme);
"Simple" as that! :)
Bob
On Thu, Apr 28, 2016 at 6:15 PM, Otis Rothenberger <osrot...@icloud.com>
wrote:
> Maybe someone pointed this out before, but it’s new to me...
>
> The page below is an ongoing test page that I use, so there are some
> button and screen message issues (conflicts). Nevertheless one new JSME
> point is so much fun that I thought I’d point it out:
>
> http://chemagic.org/molecules/mini2.html
>
> JSME now has a callback function:
> jsmeApplet.setCallBack("AfterStructureModified", sendToJmol);
>
> On the above page, I’ve set the callback sendToJmol to:
>
> function sendToJmol(jsmeEvent) {
> var jsme = jsmeEvent.src;
> var jmefile = jsme.jmeFile();
> window.parent.jms('var molf2 = "' + jmefile + '"; load "@molf2";
> hover off; delete hydrogen;calculate hydrogen;boundbox {*}; centerat
> boundbox; zoom 100;’);
> }
>
> (jms is a run Jmol script function)
>
> On the page, ignore the Jmol window messages and standard Jmol/JSME
> transfer arrow buttons. Just start drawing in the JSME window. Great fun…
>
> There are some loaded Jmol model issues via this route. I’ll try to figure
> them out and then ask Bob!
>
> Otis
>
> --
> Otis Rothenberger
> o...@chemagic.org
> http://chemagic.org
>
>
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications
> Manager
> Applications Manager provides deep performance insights into multiple
> tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
If nature does not answer first what we want,
it is better to take what answer we get.
-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users