http://www.mail-archive.com/jmol-...@lists.sourceforge.net/msg13044.html
For reference, my initial posting is below.
Thanks,
Jason
I've been using jmol quite a bit lately in Sage for drawing 3d
mathematical surfaces. One thing I really miss is the ability to have
nice meshes (including arbitrary meshes) on a surface. Currently Jmol
allows a mesh option to pmesh surfaces, but that only draws a specific
grid that is hard to see (it is the same color as the surface, but
lighter or something).
Probably the easiest change would be to make the mesh default to black
lines (like the black lines for contour plots on cut planes). That
would make the mesh lines much easier to see. Seeing the mesh lines
often really helps us mathematicians (especially those of us teaching).
A very nice functionality to add would be the ability to draw arbitrary
meshes on surfaces, similar to what is implemented here (but as black
lines on the surface, rather than the crude approximation constructed
here):
http://trac.sagemath.org/sage_trac/attachment/ticket/5511/mesh_function.jpeg.
I think Mathematica has a nice interface to these sorts
of things: http://reference.wolfram.com/mathematica/ref/MeshFunctions.html
We (Sage) can take care of the interface to draw meshes. What we'd need
from jmol is the ability to draw a line *on* a surface and have it look
like the contour lines look like on a plane. Maybe for each triangle in
the surface, we could give a list of lines to draw on that triangle by
specifying (for each line) the two edges the line crosses and the
fraction of the distance along the edge to make the intersection between
the line and the edge of the triangle.
What do you think?
Thanks,
Jason
--
Jason Grout
In fact, Bob Hanson suggests creating a new mathematics plot type that
has things like arbitrary meshes, annotations, and whatever else we want:
What you suggest might be possible -- even now -- but I suggest
we start talking about a new object type. Maybe a "plot3d" that
is an extended isosurface. We already have that for molecular
orbitals, LCAO cartoons, and pmesh. The way it works is that the
extended object has more capabilities -- in this case, to map
more than just contours onto an isosurface. Like you say, a
totally variable mesh, which would just be a set of lines of
variable width, color, and translucency. Possibly annotations. In
addition, possibly, automatic scaling. Right now you have to do
some transforms that are oblivious to Jmol. I'd like the
oblivious part to be in the use interface and let Jmol take care
of anisotropic scaling.
So, now is the time to dream about the perfect jmol primitive for our
graphics. Any ideas? People that have worked on the 3d graphics in
Sage are especially encouraged to reply.
Here's what I found by poking around for a bit. Everything has changed
since the new notebook, so someone that knows, *please* correct me if
I'm wrong.
In Sage 4.2, it looks like the jmol-invoking javascript code is in:
local/lib/python2.6/site-packages/sagenb/data/sage/js/jmol_lib.js
That appears to be the code that actually sets up a jmol applet and
makes the "Get Image" link.
That file is loaded in
local/lib/python2.6/site-packages/sagenb/data/sage/js/notebook_lib.js
Jmol is initialized at the bottom of the template file:
local/lib/python2.6/site-packages/sagenb/data/sage/html/notebook/head.tmpl
The actual jmol application is in:
local/lib/python2.6/site-packages/sagenb/data/jmol
The jmol code gets invoked when a ".jmol" file is created by a 3d plot.
The notebook then comes by, sees the .jmol file, and creates the jmol
applet. The code that does this is in
local/lib/python2.6/site-packages/sagenb/notebook/cell.py (search for
jmol).
The code in Sage that generates the .jmol files is (I believe) in
devel/sage/sage/plot/plot3d/base.pyx (see the show method, starting with
the following code. EMBEDDED_MODE is True when you are inside the
notebook, and False if you are not executing inside the notebook.)
if DOCTEST_MODE or viewer=='jmol':
# Temporary hack: encode the desired applet size in the end
of the filename:
# (This will be removed once we have dynamic resizing of
applets in the browser.)
base, ext = os.path.splitext(filename)
fg = figsize[0]
#if fg >= 2:
# fg = 2
filename = '%s-size%s%s'%(base, fg*100, ext)
ext = "jmol"
archive_name = "%s.%s.zip" % (filename, ext)
if EMBEDDED_MODE:
# jmol doesn't seem to correctly parse the ?params part
of a URL
archive_name = "%s-%s.%s.zip" % (filename, randint(0, 1
<< 30), ext)
T = self._prepare_for_jmol(frame, axes, frame_aspect_ratio,
aspect_ratio, zoom)
T.export_jmol(archive_name, force_reload=EMBEDDED_MODE,
zoom=zoom*100, **kwds)
viewer_app = "sage-native-execute " +
os.path.join(sage.misc.misc.SAGE_LOCAL, "bin/jmol")
# We need a script to load the file
f = open(filename + '.jmol', 'w')
f.write('set defaultdirectory "%s"\n' % archive_name)
f.write('script SCRIPT\n')
f.close()
I hope this helps.