Yes, there is. Mostly undocumented.

package org.openscience.jmol.app.jsonkiosk;

/*
 * See also org.molecularplayground.MPJmolApp.java for how this works.
 * Note that this service does not require MPJmolApp -- it is a package
 * in the standard Jmol app.
 *
 * Listens over a port on the local host for instructions on what to
display.
 * Instructions come in over the port as JSON strings.
 *
 * This class uses the Naga asynchronous socket network I/O package (NIO),
the
 * JSON.org JSON package and Jmol.
 *
 * http://code.google.com/p/naga/
 *
 * Initial versions of this code, including the JSON-base protocol were
created
 * by Adam Williams, U-Mass Amherst see http://MolecularPlayground.org and
 * org.openscience.jmol.molecularplayground.MPJmolApp.java
 *
 * Sent from Jmol (via outSocket):
 *
 * version 1:
 *   {"magic" : "JmolApp", "role" : "out"}  (socket initialization for
messages TO jmol)
 *   {"magic" : "JmolApp", "role" : "in"}   (socket initialization for
messages FROM jmol)
 * version 2:
 *   {"type" : "login", "source" : "Jmol"}  (socket initialization for
messages TO/FROM jmol)
 * both versions:
 *   {"type" : "script", "event" : "done"}  (script completed)
 *
 * Sent to Jmol (via inSocket):
 *
 *   {"type" : "banner", "mode" : "ON" or "OFF" }   (set banner for kiosk)
 *   {"type" : "banner", "text" : bannerText }      (set banner for kiosk)
 *   {"type" : "command", "command" : command, "var": vname, "data":vdata}
 *       (script command request, with optional definition of a Jmol user
variable prior to execution)
 *   {"type" : "content", "id" : id }            (load content request)
 *   {"type" : "move", "style" : (see below) }   (mouse command request)
 *   {"type" : "quit" }                          (shut down request)
 *   {"type" : "sync", "sync" : (see below) }    (sync command request)
 *   {"type" : "touch",                          (a raw touch event)
 *        "eventType" : eventType,
 *        "touchID"   : touchID,
 *        "iData"     : idata,
 *        "time"      : time,
 *        "x" : x, "y" : y, "z" : z }
 *
 *   For details on the "touch" type, see
org.jmol.viewer.ActionManagerMT::processEvent
 *   Content is assumed to be in a location determined by the Jmol variable
 *   nioContentPath, with %ID% being replaced by some sort of ID number of
tag provided by
 *   the other half of the system. That file contains more JSON code:
 *
 *   {"startup_script" : scriptFileName, "banner_text" : text }
 *
 *   An additional option "banner" : "off" turns off the title banner.
 *   The startup script must be in the same directory as the .json file,
typically as a .spt file
 *
 *   Move commands include:
 *
 *   {"type" : "move", "style" : "rotate", "x" : deltaX, "y", deltaY }
 *   {"type" : "move", "style" : "translate", "x" : deltaX, "y", deltaY }
 *   {"type" : "move", "style" : "zoom", "scale" : scale }  (1.0 = 100%)
 *   {"type" : "sync", "sync" : syncText }
 *
 *   Note that all these moves utilize the Jmol sync functionality
originally intended for
 *   applets. So any valid sync command may be used with the "sync" style.
These include
 *   essentially all the actions that a user can make with a mouse,
including the
 *   following, where the notation <....> represents a number of a given
type. These
 *   events interrupt any currently running script, just as with typical
mouse actions.
 *
 *   "centerAt <int:x> <int:y> <float:ptx> <float:pty> <float:ptz>"
 *      -- set {ptx,pty,ptz} at screen (x,y)
 *   "rotateMolecule <float:deltaX> <float:deltaY>"
 *   "rotateXYBy <float:deltaX> <float:deltaY>"
 *   "rotateZBy <int:degrees>"
 *   "rotateZBy <int:degrees> <int:x> <int:y>" (with center reset)
 *   "rotateArcBall <int:x> <int:y> <float:factor>"
 *   "spinXYBy <int:x> <int:y> <float:speed>"
 *      -- a "flick" gesture
 *   "translateXYBy <float:deltaX, float:deltaY>"
 *   "zoomBy <int:pixels>"
 *   "zoomByFactor <float:factor>"
 *   "zoomByFactor <float:factor> <int:x> <int:y>" (with center reset)
 *
 *
 */

public class JsonNioService extends NIOService implements JsonNioServer {


On Fri, Jul 31, 2015 at 6:21 PM, <e...@biochem.uthscsa.edu> wrote:

> Hi Bob,
>
> I was thinking about interacting with JMol bidirectionally with JSON
> from Qt/C++ for a project, but won't have time to look at this for at
> least 1-2 month...  Is there a JSON mapping of script commands? ...
> it would be nice to have JSON both ways.
>
> Cheers,
> -Emre
>
> > Q: Has anyone any experience with Python? I was just thinking that since
> > Jmol can interact via a web socket, receiving script commands and
> replying
> > with JSON, it should be very easy to script Jmol from Python.
> >
> > It would just be a matter of starting Jmol as a socket listener, then
> > working with that socket from Python.
> >
> > Someone should try that; we could develop it more if necessary.
> >
> > Any interest?
> >
> > Bob
> >
> >
> > --
> > 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
> >
> ------------------------------------------------------------------------------
> > _______________________________________________
> > Jmol-users mailing list
> > Jmol-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jmol-users
> >
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> 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
------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to