Advanced Visualization
Advanced Visualization
for Chemistry
for Chemistry
Part 11
Part 11
–
–
Tools customization
Tools customization
Mario Valle
Mario Valle
March 7
March 7
–
–
8, 2006
8, 2006
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Why we need customization
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…
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
What the tools offer
What the tools offer
Save “status”
Scripting language interface
TCL
Python
V (for AVS/Express)
C++ API
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
STM3 customization
STM3 customization
1. Save application network
2. Modify or create V macros
3. Create modules
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
AVS/Express architecture
AVS/Express architecture
Object Manager
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
AVS/Express project structure
AVS/Express project structure
avsenv
templ.v
v/
express.exe
pc/
bin/
lib/
include/
module1/
bld/
express.*
xexpress.*
user.*
xuser.*
prj
Save Project - Workspace content
XP_PATH
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Create a user interface
Create a user interface
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Add Module Wizard (1 of 3)
Add Module Wizard (1 of 3)
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Add Module Wizard (2 of 3)
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Add Module Wizard (3 of 3)
Add Module Wizard (3 of 3)
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Interface between V and code
Interface between V and code
AVS/Express
Code
Module
definition
Interface
Code
Parameters
Behavior
Generated by the wizard
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Extensibility
Extensibility
–
–
MolecularDataType
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
};
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
VMD customization
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
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
TCL
TCL
To execute Tcl commands, you will be using a
convenient text console called Tk Console.
Select the Extensions
Tk Console menu item.
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
VMD TCL commands
VMD TCL commands
Sleep a number of seconds before reading another command. Animation is frozen. sleep
Wait a number of seconds before reading another command. Animation continues. wait
(Tcl) Get information about this version of VMD vmdinfo
Add new keyboard commands. user
Translate the objects in the current scene. translate
Initialize and control external spatial tracking devices. tool
Position a checkerboard stage on the screen. stage
Scale the current scene up or down. scale
Rotate the current scene around a given axis by a certain angle. rotate
Rotate the current scene continually at a specified rate. rock
Output the currently displayed image (scene) to a file. render
Start executing text commands from a specified file. play
Change the current state (mode) of the mouse. mouse
Get information about a molecule or loaded file. molinfo
Load, modify, or delete a molecule. molecule or mol
Control or query the on-screen GUI menu forms. menu
Measure properties of moleculear structures. measure
Create new material definitions and modify their settings. material
Turn on/off logging a VMD session to a file or the console. logfile
Control the light sources used to illuminate graphical objects. light
Turn on/off labels for atoms, bonds, angles, dihedral angles, or springs. label
Control the connection to a remote simulation. imd
Display an on-line help file with an HTML viewer. help
Quit VMD. exit, quit
Change various aspects of the graphical display window. display
(Tcl) Obtain color properties for various objects colorinfo
Change the color assigned to molecules, or edit the colormap. color
Position a set of XYZ axes on the screen. axes
Create atom selection objects for analysis. atomselect
Play/Pause/Rewind a molecular trajectory. animate
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
The Draw command
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]
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Example: MultiMSMS plugin
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>
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Add computational code
Add computational code
SWIG wraps C and C++ code
as a scripting language
loadable extension
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Something to take home
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
Advanced Visualization for Chemistry – Mario Valle – CSCS – March 7-8, 2006
Next steps
Next steps
OK, visualization is not only presentation, but
communication is really important for a scientist
Advanced Visualization
Advanced Visualization
for Chemistry
for Chemistry
Thanks for your attention!
Thanks for your attention!
Mario Valle
Mario Valle
http://www.cscs.ch/~mvalle/
http://www.cscs.ch/~mvalle/