Visualization using observer pattern
Konrad Hinsen
hinsen@ibs.ibs.fr
Tue, 28 Oct 1997 19:01:32 +0100
> I just discovered a lightweight visualization package called Flex
> (http://www.sdsc.edu/CCMS/Packages/flex.html), which can act as a
> visualization server via TCP/IP sockets. I hust hacked a little MMTK
I also discovered it a while ago, but wasn't impressed by its graphical
representation, so I dropped it. The TCP/IP stuff is neat though...
> Now my question: How could molecules notify the observer upon coordinate
> change, _without_ the user invoking special notify() methods explicitly in
> the interpreter? As I don't want to mess with the existing class structure
> for ChemicalObjects, but still want to make my standard collections
> viewable, I decided to override the __getattr__ and __setattr__ methods at
> the Atom or ChemicalObjects class or at the Atom instance level. None
> worked though.
You'd have to override the setPosition() method for atoms, have it
call the old version, and send the notification you need.
However, there are a couple of problems:
1) You wouldn't catch coordinate changes made by C modules (i.e. MD).
2) You would get a notification per atom, which could be much more than
you want.
3) Doing it is a bit messy, because the only solution I can think of
is to assign a new function to Atom.setPosition.
I think the "right" solution is to build a notification framework
into MMTK. But before doing that, the important question is what
exactly it should do. I suppose implementation is a much smaller
problem.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------