Vis5D Scripting

Last updated: May 13, 1996

Contents

  1. Introduction
  2. Setting up full Tcl support
  3. The built-in interpreter
  4. Accessing the Tcl interface in Vis5D
  5. Examples of basic Vis5D Tcl commands
  6. Basic Tcl syntax
  7. Vis5D Tcl command structure
  8. Command reference
  9. Example scripts


1. Introduction

Vis5D 4.2 features a Tcl interface for automation of Vis5D with scripts.
Tcl (Tool command language, pronounced "tickle") is a free, popular, interpreted scripting language designed by John Ousterhout. Example uses of scripts include automatically setting colors, computing graphics, and making off-line animations.

While Tcl experience is recommended for writing Vis5D scripts, some short but useful scripts can be written without any real Tcl knowledge.

Note that the Tcl package does not have to be installed on your computer in order to use Vis5D's script interface. If it is not installed, Vis5D uses a small, built-in interpreter which can execute very simple Tcl scripts. However, if you want to take full advantage of Vis5D's Tcl interface you should install Tcl on your computer.




2. Setting up full Tcl support

If you do not have Tcl installed on your computer and only plan to use simple Vis5D Tcl scripts you may skip this section.

To obtain and install Tcl see the instructions on the Tcl page .

After Tcl has been installed you can enable the full Tcl support in Vis5D by following these instructions:

If all goes well vis5d will compile and link with Tcl support. If there are errors be sure that you've correctly specified the location of the include and library files described above.




3. The built-in interpreter

When Tcl is not installed Vis5D uses a simple built-in interpreter. It only understands the Tcl set and source commands, the Vis5D-specific commands, variable substitution and comments.

The set command assigns a value to a variable. Its syntax is:

   set var value
Where var is a variable name and value is a number or a character string. Examples:

   set temperature 280.0
   set month February
   set message "Press any key"
Note that multi-word strings must be surrounded by double-quotation marks.

The value of a variable is obtained by preceding the name with a $ sign. Example:

   set time 4
   vis5d_set_timestep $ctx $time
The source command reads Tcl commands from another file. Its syntax is:
   source file
Where file is the name of another Tcl file.

Lines which start with the # symbol are considered to be comments and ignored.

The built-in interpeter cannot evaluate mathematical expressions or execute control structures like loops, conditionals or subroutines. The Tcl package must be installed to execute scripts with those constructs.




4. Accessing the Tcl interface in Vis5D

On Vis5D's control panel there are two buttons labeld SCRIPT.. and INTERP... The first button is used to execute a Tcl script from a file and the second button is used to interactively type in Tcl commands.

Script files

When you click on the SCRIPT.. button a file selector window will appear. Select the Tcl script you want to execute and click on OK. If an error occurs while executing the script a pop-up window will tell you so. Also, look in your shell window for error messages.

You may also execute a script file when you start vis5d with the -script command line option. For example

   vis5d LAMPS.v5d -script foo.tcl
executes foo.tcl automatically upon startup.

Interactive Tcl commands

When you click on the INTERP.. button Vis5D will halt. In your shell window the vis5d> prompt will appear. You can now type in Tcl commands. Type exit when finished.

If it exists, the startup file vis5d.tcl is automatically executed before you get the vis5d> prompt. One use of this file is to load macros or functions that you always use.




5. Examples of basic Vis5D Tcl commands

We begin with some simple examples which could be executed either from a script file or typed in by hand.

Example 1

Suppose we have an isosurface of temperature (variable name "T") displayed in vis5d and we want to color it red. The following Tcl command will do that:

   vis5d_set_color $ctx VIS5D_ISOSURF "T" 1.0 0.0 0.0 1.0

The command name is vis5d_set_color. The arguments are:

Example 2

Suppose we simply want to set the currently displayed timestep to be the fourth in the dataset.

   vis5d_set_timestep $ctx 3
This command should be self explanatory except for the fact that we specified 3 instead of perhaps 4. The reason is Vis5D begins counting timesteps starting at zero, not one. Therefore timestep number 3 is actually the fourth timestep.

Example 3

Suppose we want to compute and display a horizontal colored slice of wind speed (variable name "SPD") at vertical grid level 2. The following commands will do that.

   vis5d_set_chslice $ctx "SPD" 2.0
   vis5d_make_chslice $ctx VIS5D_ALL_TIMES "SPD"
   vis5d_enable_graphics $ctx VIS5D_CHSLICE "SPD" VIS5D_ON
The first command sets the position of the colored slice to grid level 2.0

The second command tells vis5d to actually compute the horizontal colored slice graphic of "SPD" for all time steps.

The third command tells vis5d to actually display the colored slice.




6. Basic Tcl syntax

This section gives examples of basic Tcl language constructs by comparing them to C and Fortran syntax. See a Tcl language reference for more information.

Comments

C:
  /* this is a comment */  
Fortran:
  C this is a comment  
Tcl:
  # this is a comment  

Assigments

C:
  x = 1.0; 
Fortran:
  x = 1.0 
Tcl:
  set x 1.0 

Expressions and assignments

C:
  average = (a+b)/2.0; 
Fortran:
  average = (a+b)/2.0  
Tcl:
  set average [ expr ($a+$b)/2.0 ] 

For Loops

C:
    for (i=1;i<=10;i++) {
        body of loop
    }
Fortran:
    do i=1,10
        body of loop
    enddo
Tcl:
    for {set i 1} {$i <= 10} { set i [expr $i+1] } {
        body of loop
    }

Conditionals

C:
    if (x<0.0) {
        y = 0.0;
    }
    else if (x>100.0) {
        y = 100.0;
    }
    else {
        y = x;
    }
Fortran:
    if x .lt. 0 then
        y = 0.0
    else if x .gt. 100 then
        y = 100.0
    else
        y = x
    end if
Tcl:
    if {$x<0.0} {
        set y 0.0
    }
    elseif {$x>100.0} {
        set y 100.0
    }
    else {
        set y $x
    }



7. Vis5D Tcl command structure

All of the Vis5D Tcl commands start with the prefix vis5d_ and all of the Vis5D Tcl constants start with the prefix VIS5D_. This makes it easy to spot Vis5D-specific commands in a script and prevents confusion with other Tcl identifiers.

Vis5D Tcl commands are of the form:

vis5d_command $ctx arguments

That is, a command name followed by the context variable, followed by zero or more arguments.

A note on $ctx and Vis5D contexts

Vis5D's internal core supports multiple contexts. A context can be thought of as a Vis5D file read into memory plus all the associated graphics. At Vis5D's user level, however, only one context is ever used at a time. To reference this context we use the default $ctx variable in each command. Future applications based on Vis5D's core may use more than one context. In that case, complex scripts controlling multiple contexts will use other identifiers in place of $ctx.

For the time being, you should always use $ctx to specify the context of your commands for future compatability.

A note on variable and timestep numbers

Many of the Vis5D Tcl commands take timestep and/or physical variable parameters. Be aware that timesteps are numbered starting at 0. Similarly, variables are numbered starting with 0. Also, wherever a physical variable argument is expected you may either supply a number a name.




8. Command reference

In this section we document each of the Vis5D Tcl commands. Programmers should note that the Vis5D Tcl commands are a subset of the Vis5D API functions described in the Vis5D API document. More of the API functions may be made available as Tcl commands in the future.

Timestep Commands

vis5d_get_numtimes context
Returns the number of timesteps in the given context.
vis5d_get_time_stamp context timestep
Returns the date and time associated with the given timestep as a list of two elements: {YYDDD HHMMSS}. Timestep 0 is the first timestep.
vis5d_set_time_stamp context timestep data time
Sets the date (YYDDD) and time (HHMMSS) associated with a timestep.
vis5d_set_timestep context timestep
Sets the current timestep. The first timestep is number zero.
vis5d_get_timestep context
Returns the number of the current timestep, starting at zero.

Physical Variable Commands

vis5d_get_numvars context
Returns the number of physical variables in the given context.
vis5d_get_var_name context varnum
Returns the name of a physical variable. varnum is an integer where zero is the first variable.
vis5d_get_var_units context varnum
Returns the physical units of a variable. For example, the units typically associated with "U" is "m/s" (meters per second).
vis5d_get_var_type context var
Returns the type of the given variable. var may be a variable name or number. Possible types are VIS5D_REGULAR, VIS5D_CLONE, VIS5D_EXT_FUNC, and VIS5D_EXPRESSION.
vis5d_get_var_range context var
Returns the min and max values for the specified variable. var may be a name or number. The min and max values are returned as a list of two numbers.

Grid Commands

vis5d_get_grid_rows context
Returns the number of rows in each 3-D data grid.
vis5d_get_grid_columns context
Returns the number of columns in each 3-D data grid.
vis5d_get_grid_levels context var
Returns the number of levels in each 3-D data grid for a particular physical variable. The number of levels in a 3-D grid can vary from variable to variable.

Cloning, External Functions and Expression Commands

vis5d_make_clone_variable context clonename var
Make a clone of an existing variable. clonename is the new for the clone and var is the number or name of the variable to copy.
vis5d_compute_ext_func context name
Invoke an external Fortran function named name to make a new variable of the same name.
vis5d_make_expr_var context expression
Evaluate a simple expression, resulting in a new variable. Expressions are of the form: "var = expression"

Rendering Commands

vis5d_draw_frame context
Redraw the window image for the current timestep.
vis5d_graphics_mode context graphic mode
Enable/disable drawing of a Vis5D graphic.
  • graphic - one of
    • VIS5D_BOX = the 3-D box
    • VIS5D_CLOCK = the clock
    • VIS5D_MAP = the map lines
    • VIS5D_TOPO = the topography
    • VIS5D_PERSPECTIVE = perspective rendering
    • VIS5D_CONTOUR_NUMBER = display of contour numbers in slices
    • VIS5D_GRID_COORDS = display grid coords instead of geographic coords
    • VIS5D_PRETTY = pretty rendering mode
    • VIS5D_INFO = information display
    • VIS5D_PROBE = the probe values
    • VIS5D_CURSOR = the 3-D cursor
    • VIS5D_ANIMRECORD = stored frame animation
    • VIS5D_TEXTURE = texture mapping on topography
    • VIS5D_DEPTHCUE = depth cuing of 3-D box
  • mode - one of
    • VIS5D_ON = turn on the graphic
    • VIS5D_OFF = turn off the graphic
    • VIS5D_TOGGLE = toggle the graphics display state
    • VIS5D_GET = just return current setting
Returns 1 if graphic is displayed, 0 if graphic is not displayed or an error message if any parameters are invalid.
vis5d_enable_graphics context graphic number mode
Enable/disable drawing of a Vis5D graphic.
  • graphic - one of
    • VIS5D_ISOSURF = isosurface
    • VIS5D_HSLICE = horizontal contour line slice
    • VIS5D_VSLICE = vertical contour line slice
    • VIS5D_CHSLICE = horizontal colored slice
    • VIS5D_CVSLICE = vertical colored slice
    • VIS5D_VOLUME = volume rendering
    • VIS5D_TRAJ = wind trajectory set
    • VIS5D_HWIND = horizontal wind slice
    • VIS5D_VWIND = vertical wind slice
    • VIS5D_STREAM = horizontal streamline slice
  • number - depends on value of graphic:
    • variable number, if graphic = VIS5D_ISOSURF, VIS5D_HSLICE, VIS5D_VSLICE, VIS5D_CHSLICE, VIS5D_CVSLICE or VIS5D_VOLUME
    • trajectory set if graphic = VIS5D_TRAJ
    • slice number if graphic = VIS5D_HWIND, VIS5D_VWIND or VIS5D_STREAM
    • ignored otherwise
  • mode - one of
    • VIS5D_ON = turn on the graphic
    • VIS5D_OFF = turn off the graphic
    • VIS5D_TOGGLE = toggle the graphics display state
    • VIS5D_GET = just return current setting
Returns 1 if graphic is displayed, 0 if graphic is not displayed or an error message if any parameters are invalid.
vis5d_get_volume context
Returns the variable number of the currently displayed volume or -1 if none is currently displayed.
vis5d_set_volume context var
Set the currently displayed volume. var is a variable number or name indicating the variable to display. If var is -1, disable volume display.
vis5d_set_color context graphic number red green blue alpha
Set the color of a Vis5D graphic such as an isosurface, slice or trajectory.
  • graphic - one of
    • VIS5D_ISOSURF = isosurface
    • VIS5D_HSLICE = horizontal contour line slice
    • VIS5D_VSLICE = vertical contour line slice
    • VIS5D_CHSLICE = horizontal colored slice
    • VIS5D_CVSLICE = vertical colored slice
    • VIS5D_VOLUME = volume rendering
    • VIS5D_TRAJ = wind trajectory set
    • VIS5D_HWIND = horizontal wind slice
    • VIS5D_VWIND = vertical wind slice
    • VIS5D_STREAM = horizontal streamline slice
    • VIS5D_BOX = the 3-D box
    • VIS5D_BACKGROUND = window background color
    • VIS5D_LABEL = color of text labels
    • VIS5D_MAP = color of map lines
  • number - meaning depends on value of graphic argument
    • variable number, if graphic = VIS5D_ISOSURF, VIS5D_HSLICE, VIS5D_VSLICE, VIS5D_CHSLICE or VIS5D_CVSLICE
    • trajectory set if graphic = VIS5D_TRAJ
    • slice number if graphic = VIS5D_HWIND, VIS5D_VWIND or VIS5D_STREAM
    • ignored otherwise
  • red, green, blue - the color components as floating point numbers in the interval [0,1]
  • alpha - the transparency where 0 is completely transparent and 1 is completely opaque
vis5d_set_color_table_entry context graphic var entry r g b a
Set one entry in a color lookup table. To setup a whole color table will typically require 256 calls to this function. One call per color table entry.
  • graphic - one of
    • VIS5D_ISOSURF = an isosurface's color table
    • VIS5D_CHSLICE = a horizontal colored slice's color table
    • VIS5D_CVSLICE = a vertical colored slice's color table
    • VIS5D_TRAJ = a trajectory set's color table
    • VIS5D_VOLUME = a volume's color table
  • var - which variable
  • entry - which color table entry, must be between 0 and 255.
  • r, g, b, a - the red, green, blue, and alpha values in [0,1]
Note that changes to the topography color table will not be put into effect until vis5d_recolor_topo is called.
vis5d_alpha_mode context mode
Sets the alpha (transparency) mode for a context. If mode is zero then "screen-door" transparency is used. If mode is one then alpha blending is used to render transparent surfaces.
vis5d_font context fontname [size]
Specifies the font used for drawing text labels and the clock. fontname is the name of a GL or X font. If using GL fonts, size is the height of the font to use where 72 equals one inch.
vis5d_linewidth context width
Specifies the width of line segments in pixels. Default is 1.0.

Map and Topography Commands

vis5d_recolor_topo context reset
Recolors the topography according to the topography color table. If reset is non-zero, then the colortable will be reset to its initial, default values.

3-D View Commands

vis5d_set_matrix context matrix
Sets the 3-D viewing matrix. matrix is a list of sixteen values representing the transformation matrix in row-major order. This is an advanced function not intended for most users.
vis5d_set_view context xrot yrot zrot scale xtrans ytrans ztrans
Sets the 3-D viewing matrix by means of separate rotation, scale and translation values. The order of transformations is Z-axis rotate, X-axis rotate, Y-axis rotate, scale then translate. Arguments:
  • xrot, yrot, zrot - rotation about each axis in degrees
  • scale - scaling factor
  • xtrans, ytrans, ztrans - translation along each axis
vis5d_set_camera context perspective frontclip zoom
Sets the parameters of the imaginary 3-D camera. Arguments:
  • perspective - 0=orthographic, 1=perspective
  • frontclip - position of front clipping plane, a value in [0,1] where 0=no clipping and 1=all clipped
  • zoom - zoom (scale) factor, 1.0 is normal

Isosurface, Slice, and Trajectory Commands

vis5d_set_isosurface context var isolevel
Sets the isolevel for the isosurface specified by var. Note that the isosurface is not computed by this function.
vis5d_get_isosurface context var
Returns the current isolevel for a particular variable.
vis5d_set_isosurface_color_var context isovar colorvar
Specifies which variable to use to color an isosurface. isovar is the isosurface to color. colorvar is the variable to color the surface or -1 which means don't color the surface.
vis5d_make_isosurface context time var urgent
Compute a(n) isosurface(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. var indicates which variable to compute the isosurface for. If urgent is non-zero then computing this isosurface will be given priority over any other pending computation.
vis5d_set_hslice context var interval low high level
Sets the attributes for a horizontal contour line slice.
  • var - which variable, a name or number
  • interval - the interval between contour lines
  • low - the low limit for contouring
  • high - the high limit for contouring
  • level - position of the slice as a grid level
Note that this function does not actually compute the slice.
vis5d_make_hslice context time var urgent
Compute (a) horizontal contour slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. var indicates which variable to compute the slice for. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_set_vslice context var interval low high r0 c0 r1 c1
Sets the attributes for a vertical contour line slice.
  • var - which variable, a name or number
  • interval - the interval between contour lines
  • low - the low limit for contouring
  • high - the high limit for contouring
  • r0, c0 - position of left edge of slice in grid rows and columns
  • r1, c1 - position of right edge of slice in grid rows and columns
Note that this function does not actually compute the slice.
vis5d_make_vslice context time var urgent
Compute (a) vertical contour slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. var indicates which variable to compute the slice for. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_set_chslice context var level
Sets the attributes for a horizontal color slice.
  • var - which variable, a name or number
  • level - position of the slice as a grid level
Note that this function does not actually compute the slice.
vis5d_make_chslice context time var urgent
Compute (a) horizontal color slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. var indicates which variable to compute the slice for. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_set_cvslice context var r0 c0 r1 c1
Sets the attributes for a vertical color slice.
  • var - which variable, a name or number
  • r0, c0 - position of left edge of slice in grid rows and columns
  • r1, c1 - position of right edge of slice in grid rows and columns
Note that this function does not actually compute the slice.
vis5d_make_cvslice context time var urgent
Compute (a) vertical color slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. var indicates which variable to compute the slice for. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_set_hwindslice context slicenum density scale level
Sets the attributes for a horizontal wind vector slice.
  • slicenum - which slice, currently 0 or 1
  • density - density of wind vectors 0.25, 0.5 or 1.0 for example
  • scale - scale factor for vectors. 1.0 is normal
  • level - position of the slice as a grid level
Note that this function does not actually compute the slice.
vis5d_make_hwindslice context time slice urgent
Compute (a) horizontal wind vector slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. slice indicates which slice to compute. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_set_vwindslice context slicenum density scale r0 c0 r1 c1
Sets the attributes for a vertical wind vector slice.
  • slicenum - which slice, currently 0 or 1
  • density - density of wind vectors 0.25, 0.5 or 1.0 for example
  • scale - scale factor for vectors. 1.0 is normal
  • r0, c0 - position of left edge of slice in grid rows and columns
  • r1, c1 - position of right edge of slice in grid rows and columns
Note that this function does not actually compute the slice.
vis5d_make_vwindslice context time slice urgent
Compute (a) vertical wind vector slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. slice indicates which slice to compute. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_set_streamslice context slicenum density level
Sets the attributes for a horizontal wind stream slice.
  • slicenum - which slice, currently 0 or 1
  • density - density of stream lines, 1.0 is default
  • level - position of the slice as a grid level
Note that this function does not actually compute the slice.
vis5d_make_streamslice context time slice urgent
Compute (a) horizontal wind stream slice(s). Time indicates which timestep to compute. The value VIS5D_ALL_TIMES can be used to specify all timesteps. slice indicates which slice to compute. If urgent is non-zero then computing this slice will be given priority over any other pending computation.
vis5d_make_traj context row column level time trajset
Compute a window trajectory.
  • row, column, level - starting coordinate of trajectory in grid coordinates
  • time - timestep at which to start trajectory trace
  • trajset - which trajectory set
vis5d_set_traj context step length ribbonflag
Set trajectory attributes.
  • step - trajectory step size. 1.0 is default
  • length - trajectory length scaling. 1.0 is default
  • ribbonflag - if non-zero draw a ribbon trajectory, else draw as line segments.
vis5d_delete_last_traj context
Delete the last trajectory made.
vis5d_delete_traj_set context set
Delete a whole set of trajectories.
vis5d_set_trajectory_color_var context set var
Color all trajectories in the specified set according to the physical variable var. var may be a variable name or number.

Text Label Commands

vis5d_make_label context x y text
Make a text label at coordinate (x,y). x and y are in window coordinates with (0,0) being the upper-left corner. text is a string.

Cursor Commands

vis5d_get_cursor context
Returns the current 3-D cursor position as a list of three numbers which are in graphics coordinates.
vis5d_set_cursor context x y z
Sets the current 3-D cursor position given an (X,Y,Z) position in graphics space.

3-D Window Commands

vis5d_get_image_formats context
Return's a list of image file formats supported by this implementation of Vis5D. The list may include:
  • VIS5D_RGB - SGI's RGB image file format
  • VIS5D_GIF - GIF image file format
  • VIS5D_XWD - X window dump file format
  • VIS5D_PS - Black and white PostScript
  • VIS5D_COLOR_PS - Color PostScript
vis5d_save_window context filename format
Save the window image to the named file. format is one of the file format identifiers returned by vis5d_get_image_formats.

Coordinate Conversion Commands

vis5d_xyz_to_grid context time var {x y z}
Convert a graphics (x,y,z) coordinate to a grid coordinate. The resulting grid coordinate is returned as a list of three values: {row column level}.
vis5d_grid_to_xyz context time var {row col lev}
Convert a grid (row,column,level) coordinate to a graphics coordinate. The resulting graphics coordinate is returned as a list of three values: {x y z}.
vis5d_xyz_to_geo context time var {x y z}
Convert a graphics (x,y,z) coordinate to a geographic coordinate. The resulting geographic coordinate is returned as a list of three values: {latitude longitude height}.
vis5d_geo_to_xyz context time var {lat lon hgt}
Convert a geographic coordinate (lat,lon,hgt) to a graphics coordinate. The resulting graphics coordinate is returned as a list of three values: {x y z}.

Miscellaneous Commands

vis5d_free_graphics context
Deletes all graphics from memory. It may be useful to flush Vis5D's graphics memory if it has become severely fragmented.
vis5d_sleep time
Pause execution of the script for time milliseconds.



9. Example scripts

This section contains a number of example scripts. The Tcl package must be installed to execute them.


Example 1: Save a time series of GIF images

This script will generate a GIF image file for each timestep in your dataset. Near the top is the basename variable which is used to name the GIF files. You may want to change it.

# movie.tcl

# Base file name for all images:
set basename "frame"

# File format and file extension
set format VIS5D_GIF
set extension ".gif"


# Determine how many timesteps there are
set numtimes [ vis5d_get_numtimes $ctx ]

# Loop over the timesteps
for {set time 0} {$time<$numtimes} {set time [expr $time+1]} {
	# Set current timestep
	vis5d_set_timestep $ctx $time
	# Draw the frame
	vis5d_draw_frame $ctx
	# Setup the filename
	set name $basename$time$extension
	# Write window image to file
	vis5d_save_window $ctx $name $format
}

Example 2: Generate a column of wind trajectories

This script generates a column of trajectories, one for each grid level, at the cursor's current latitude/longitude.

# trajcol.tcl

# Generate a column of trajectories at the cursor's lat/lon
# for the current timestep.


# Which trajectory set should the trajectories be put in:
set trajset 0


# This is a bit tricky:  we need to know how many grid levels are
# present for trajectory tracing.  We query the variables used for
# trajectory tracing and then call vis5d_get_grid_levels to find out
# how many grid levels are present for the U rajectory component.
# Note: element 6 of the wind_vars list is the traj U variable.
set wind_vars [ vis5d_get_wind_vars $ctx ]
set traj_uvar [ lindex $wind_vars 6 ]
set traj_levs [ vis5d_get_grid_levels $ctx $traj_uvar ]


# Get current timestep
set curtime [ vis5d_get_timestep $ctx ]


# Get the current cursor position as (row,col).
set cursor_xyz [ vis5d_get_cursor $ctx ]
set cursor_rcl [ vis5d_xyz_to_grid $ctx $curtime $traj_uvar $cursor_xyz ]
set row [ lindex $cursor_rcl 0 ]
set col [ lindex $cursor_rcl 1 ]


# Loop over grid levels making a trajectory for each level.
for {set lev 0} {$lev < $traj_levs} {set lev [expr $lev+1]} {
	vis5d_make_traj $ctx $row $col $lev $curtime $trajset   
}

Example 3: Display a horizontal contour slice of W

# wslice.tcl

# Display a horizontal contour line slice of W (vertical wind) at the
# middle altitude using dashed lines for negative values.  Draw the
# slice in yellow.


# You can change these:
set wvar "W"
set interval -0.05

# The color specified in RGBA:
set red 1.0
set green 1.0
set blue 0.0
set alpha 1.0


# Get min and max W values
set minmax [ vis5d_get_var_range $ctx $wvar ]
set low_val  [ lindex $minmax 0 ]
set high_val [ lindex $minmax 1 ]

# Compute location of middle grid level
set num_levels [ vis5d_get_grid_levels $ctx $wvar ]
set level [ expr $num_levels / 2.0 ]


# set the color
vis5d_set_color $ctx VIS5D_HSLICE $wvar $red $green $blue $alpha

# setup slice parameters
vis5d_set_hslice $ctx $wvar $interval $low_val $high_val $level

# compute the slice
vis5d_make_hslice $ctx VIS5D_ALL_TIMES $wvar 0

# display it!
vis5d_enable_graphics $ctx VIS5D_HSLICE $wvar VIS5D_ON

Example 4: Spin and zoom the 3-D box

# spin.tcl

# Spin and zoom the 3-D box


# spin
for {set angle 0} {$angle <= 360} {set angle [expr $angle + 10]} {
	vis5d_set_view $ctx -60.0 0.0 $angle  1.0  0.0 0.0 0.0
	vis5d_draw_frame $ctx
	vis5d_sleep 100
}

# zoom in
for {set scale 1.0} {$scale <= 1.8} {set scale [expr $scale + 0.1]} {
	vis5d_set_view $ctx -60.0 0.0 0.0  $scale  0.0 0.0 0.0
	vis5d_draw_frame $ctx
	vis5d_sleep 100
}

# zoom out
for {set scale 1.8} {$scale >= 1.0} {set scale [expr $scale - 0.1]} {
	vis5d_set_view $ctx -60.0 0.0 0.0  $scale  0.0 0.0 0.0
	vis5d_draw_frame $ctx
	vis5d_sleep 100
}


Other links:
Vis5D, API document, Scripting document, Bill Hibbard, Brian Paul.