Visualization using observer pattern

Andrew Dalke
Wed, 22 Oct 1997 02:32:55 -0700

> Andrew (still there?), how was that problem solved in VMD?

  Yep, still here.  Which problem?  You mean:
> How could molecules notify the observer upon coordinate change,
> _without_ the user invoking special notify() methods explicitly in
> the interpreter?

I think you mean how does VMD get updated information for MDComm?
In that case, there is an equivalent to notify().

Or are you asking how to update the coordinates in general?  I've
got some ideas for how to make VMD do it, but it does involve passing
around at least the initial PDB file.

The general idea:
  1) create a variation of the 'vmd' startup script that doesn't
spawn an xterm.  You can talk to this via stdin.

  2) save the PDB file, start VMD, and send "mol load pdb whatever.pdb"
to it.  Make a selection of all the atoms "set all [atomselect top all]"

  3) when the coordinates change in MMTK, gather all the coordinates
as a string then send "$all set {x y z} {{list} {of} {coords} ... {here}}"
to VMD.  This will update the coordinates.

If you are adventurous, you could use Tcl's socket commands to set up
a simple server youself.  This would in essense do what flex does.  I
have no idea how to do it, but it shouldn't be be all that complicated.
  You could even open bidirectional pipes (I think we flush stdout
every time) and rig up VMD so when you pick on an atom that information
is sent back to MMTK for additional feedback.

  If you are asking how to do updates when coordinates change, in VMD
I just told Tcl (the 'trace' command makes this easy) that "at least
one coordinate changed", which caused a complete update.  This feature
doesn't exist in Python (could be added as an observer pattern, but
this changes the code, which is something you didn't want to do).

  You mentioned something about overriding __getattr_, but I know at
least one problem is there are two ways to change the atom coordinates
(through Atom and through the matrix containing the complete list of
atom coordinates).

  So the only way I can see to get things working like you want is to
change MMTK to support a more event-based model.  I find that style
of programming very interesting, but harder (you have less control
over how modules interact, so the semantics have to be very well

  Sorry I couldn't be of more help,