Advanced Visualization for Chemistry Part 11 Tools customization Mario Valle March 7 8, 2006 Why we need customization Read new file formats Compute and fuse together new derived quantities Add (computed) new graphical elements in the view Integrate visualization with some computational code Visualization is almost ok, but What the tools offer Save status Scripting language interface TCL Python V (for AVS/Express) C++ API Data model 1
STM3 customization 1. Save application network 2. Modify or create V macros 3. Create modules AVS/Express architecture Object Manager AVS/Express project structure prj Sources avsenv v/ bin/ lib/ include/ bld/ express.* xexpress.* user.* xuser.* templ.v pc/ module1/ express.exe XP_PATH Save Project - Workspace content 2
Create a user interface Add Module Wizard (1 of 3) Add Module Wizard (2 of 3) 3
Add Module Wizard (3 of 3) Interface between V and code Generated by the wizard AVS/Express Code Module definition Interface Code Parameters Behavior Extensibility MolecularDataType group MolecularDataType { int num_atoms; // total number of atoms int atom_z[.num_atoms]; // atomic numbers list string atom_name[.num_atoms]; // atom names as read from the file string residue_name[.num_atoms]; // residue names int residue_id[.num_atoms]; // residue number float xyz_lst[.num_atoms][3]; // atom coordinates float charge_lst[.num_atoms]; // atom charge or generic parameter int num_bonds; // numeber of bonds int connect_lst[2*.num_bonds]; // connection list int bond_type_lst[.num_bonds]; // type of bond; the values are defined in mol_type.h float offset_lst[.num_atoms][3]; // atom offsets provided by some formats group unit_cell { // info on unit cell placement float side_vectors[3][3]; // vectors defining the three unit cell sides float angles[3]; // angles between unit cell sides float origin[3]; // the origin of the unit cell }; group symmetry { // info on atom symmetries string space_group; // the space group symmetry group label }; }; 4
VMD customization Source a TCL script Package a script as an extension Add your code as a loadable TCL command Adding a new format reader TCL To execute Tcl commands, you will be using a convenient text console called Tk Console. Select the Extensions Tk Console menu item. VMD TCL commands animate atomselect axes color colorinfo display exit, quit help imd label light logfile material measure menu molecule or mol molinfo mouse play render rock rotate scale stage tool translate user vmdinfo wait sleep Play/Pause/Rewind a molecular trajectory. Create atom selection objects for analysis. Position a set of XYZ axes on the screen. Change the color assigned to molecules, or edit the colormap. (Tcl) Obtain color properties for various objects Change various aspects of the graphical display window. Quit VMD. Display an on-line help file with an HTML viewer. Control the connection to a remote simulation. Turn on/off labels for atoms, bonds, angles, dihedral angles, or springs. Control the light sources used to illuminate graphical objects. Turn on/off logging a VMD session to a file or the console. Create new material definitions and modify their settings. Measure properties of moleculear structures. Control or query the on-screen GUI menu forms. Load, modify, or delete a molecule. Get information about a molecule or loaded file. Change the current state (mode) of the mouse. Start executing text commands from a specified file. Output the currently displayed image (scene) to a file. Rotate the current scene continually at a specified rate. Rotate the current scene around a given axis by a certain angle. Scale the current scene up or down. Position a checkerboard stage on the screen. Initialize and control external spatial tracking devices. Translate the objects in the current scene. Add new keyboard commands. (Tcl) Get information about this version of VMD Wait a number of seconds before reading another command. Animation continues. Sleep a number of seconds before reading another command. Animation is frozen. 5
The Draw command point {x y z} line {x1 y1 z1} {x2 y2 z2} [width w] [style solid dashed] cylinder {x1 y1 z1} {x2 y2 z2} [radius r] [resolution n] [filled yes no] cone {basex basey basez} {tipz tipy tipz} [radius r] [resolution n] triangle {x1 y1 z1} {x2 y2 z2} {x3 y3 z3} trinorm {x1 y1 z1} {x2 y2 z2} {x3 y3 z3} {nx1 ny1 nz1} {nx2 ny2 nz2} {nx3 ny3 nz3} sphere {x y z} [radius r] [resolution n] text {x y z} text string [size s] Example: MultiMSMS plugin Problem: if you have a trajectory and want to use the MSMS representation, the surface is recomputed for each timestep. Why do not compute them once and simply redisplay them when needed? So I developed the MultiMSMS plugin using pure TCL/Tk <http://www.cscs.ch/~mvalle/chemviz/multimsms.html> Add computational code SWIG wraps C and C++ code as a scripting language loadable extension 6
Something to take home 1. Some tools could be extended 2. The What is more important than the How 3. Ask! We are eager to extend our tools Next steps OK, visualization is not only presentation, but communication is really important for a scientist Advanced Visualization for Chemistry Thanks for your attention! Mario Valle http://www.cscs.ch/~mvalle/ mvalle@cscs.ch 7