25th July, 2002 Developers' Meeting - Molecular Graphics Overview
The molecular graphics program comprises two windows visible to the user,
the GUI and the OpenGL window, connected by several modules.
The "main" program is a Python script which starts up both the GUI and
OpenGL windows, each in a separate thread. The main program then listens
for input from the two user windows and despatched instructions back to them.
The main program also takes care of opening files, calling the right modules
to deal with commands, etc.
Some of the program is written in Tcl, some in Python and some in C/C++.
The program uses MMDB extensively and Clipper, though not yet very heavily.
Communication between Python and C/C++ is achieved through various SWIG
General Flow Control
Once the program is up and running, the user opens a coordinate or a mtz file
with a GUI directory browser window. The main program then loads the file into
MMDB or Clipper. Next some default actions are taken. For a coordinate file, all
atoms are selected for viewing and the default colouring scheme is applied. For
an mtz map, the user must specified the required columns, but the possible options
The selected atoms, colouring scheme, display parameters, etc are contained in a
single object which is then passed to a module which creates a set of graphical
primitives (points, lines, polygons, etc.) from this data.
The object containing primitives is then passed to the OpenGL module which then
draw the picture.
User Input and Feedback
The GUI, OpenGL window, and potentially other modules/processes all generate
events triggered by the user. These are all placed onto a single job queue handled
by the main program. The first part of the message contains a flag which specifies
what should happen to this message. Some messages are commands which need execution
of a function, generation of object, etc. by the main thread. Some are messages
back to the GUI to update on completion of a command. Some deal only with graphical
objects and are thus sent to an interface module between the main program and OpenGL.
Main program classes
- CDataManager: The overall "top" class which contains the objects pertaining
to each model, etc.
- MolData: class containing data for whole molecule, reads PDB file, etc.
- Colour: contains methods for colouring atoms by atom type, residue, type, etc.
- Selection: defines various default selection methods, and provides a method
for user input of arbitrary selection criteria. Then creates actual selection.
- Style: provides interface to define various drawing parameters.
- MolDisp: interface between main program and graphics subsystem.
- Various others for communicating with GUI.
- GLUTThread: the class which opens OpenGL window and does all the drawing and
receiving of OpenGL events.
- Quat: defines a quaternion representation of rotation.
- Displayobject: a class which contains the graphical primitives which are drawn
along with an orientation and position.
- Primitive: base abstract class for all other primitives. Each primitive class
contains its own method for generating its vertices and for drawing itself.
- Plane: defines a plane in 3D space, useful for clipping, selection.
- Volume: a set of planes.
- Lighting, Light: lights and object material properties.
- Texture, Bumpmap: for visual effects.
- Connectivity: a means of converting various MMDB connection criteria: distance,
monomer library bonds, etc. into a single set of connectivity lists.
- Tree: singly connected, directed graph representation of bonding.
- Various others utilities.
- Draw line, ball and stick, space filling representations of molecular structure.
- Draw hydrogen bonds, only secondary structure related ones though.
- Draw ribbons for secondary structure.
- Draw chicken-wire or solid surface grid data.
- Move, rotate any object.
- Select/label any atom(s) (soon with arbitrary info).
- Rotate about/stretch bonds. Though method for specifying which bond doesn't
yet exist, though easy.
- Save/restore state, probably.
- Very flexible selection and colouring criteria.
- Many extra GUI features.
- Rewrite of large chunks of displayobject/primitive code in C++. Was all previously
in Python. Results in 10-50 fold increase in performance in the most intensive parts
of the program.
- Tree representation of internal coordinates.
- Generalized bonding scheme. Program can now use molecular bonds as defined in
monomer library rather than simple distance based criteria. Ability to merge two
selected sets of atoms with the connectivity defined in possibly different ways.
- Much prettier text, on Unix/Linux, using arbitrary system fonts, including symbols.
Something similar, simpler, and most likely better, will appear for Windows also.
Further, HTML-esque syntax for bold, underline, italic, subscript, superscript and
Greek characters. Tex-esque behaviour for sub-/superscript combinations.
- Many bugs fixed.
- Probably much more that I have forgotten.
Last modified: Tue Jul 23 12:18:28 GMT 2002