## Chapter 4. Sample Visual Programs and Sample Macros

The directory `/usr/local/dx/samples/programs` contains a number of sample visual programs. In addition, a set of subdirectories categorize programs by subject (e.g., 2-D Data, Annotation, etc.). To start, you may want to look at the programs in the subdirectory /SIMPLE.

The sample visual programs listed here can be invoked, like any visual program, from the VPE. To access the available sample programs, enter: `/usr/local/dx/samples/programs/*.net` in the `Filter` field (of the `Open...` dialog box) and press `Enter`.

The macro descriptions are in 4.2 , "Sample Macros".

Notes:

1. For the user's convenience, and where appropriate, some programs have been listed in more than one section.
2. Once a program has been opened, relevant descriptive and tutorial information can be accessed with:
   - the `Application Comment` option of the `Help` pull-down menu (in either the Image window or the VPE window)
   - the `Open` dialog box, by clicking on the `Comments` button.

## 4.1 Sample Visual Programs

### Simple Visual Programs

Found in directory `$DXROOT/samples/programs/SIMPLE`

Each example program listed here illustrates a typical use of the Data Explorer module it is named for.

Arrange.net
AutoAxes.net
AutoColor.net
AutoGlyph.net
AutoGrid.net
Band.net
Caption.net
Color.net
ColorBar.net
Compute2.net
Connect.net
Construct.net
Describe.net
FaceNormals.net
GetSet.net
Gradient.net
Grid.net
Histogram.net
Include.net
Isolate.net
Isosurface.net
Light.net
Map.net
MapToPlane.net
MarkUnmark.net
Post.net
QuantizeImage.net
Reduce.net
Refine.net
Regrid.net
Route.net
Rubbersheet.net
ScaleScreen.net
ShowBoundary.net
Slab.net
Sort.net
Streamline.net
Supervise.net
Switch.net
Verify.net
VisualObject.net

### 2-Dimensional Data

Found in directory `$DXROOT/samples/programs/2D_DATA`

`AlternateVisualizations.net` Various ways to visualize 2-dimensional data sets.

`BandedColors.net` How to create an image with a set of constant-color bands

`ConnectingScatteredPoints.net` How to use the Connect and Regrid modules to create connections (interpolation elements) between points.

`FFT.net` Computing fast and discrete Fourier transformations on sample data sets.

`GeneralImport1.net, GeneralImport2.net` Importing data in the general array import format.

`InvalidData.net` How data marked as invalid are handled by various modules.

`Sealevel.net` Visualizing the effect of rising sea levels on eastern U.S. coastlines.

`Sort.net` How to sort a field based on the y-position.

`Topo.net` Some ways of visualizing topographic data (in this example, two data sets sharing the same grid: elevation and a gray-scale image).

`UsingDrape.net` How to "drape" an image or other field onto a height map.

`UsingFilter.net` How to perform filtering operations on images.

`UsingIsosurface.net` How to create isosurfaces and contour lines.

`UsingMorph.net` How to perform morphological operations on images.

`UsingOverlay.net` Using the Overlay module to combine images.

### 3-Dimensional Data

Found in directory `$DXROOT/samples/programs/3D_DATA`

`AnnotationGlyphs.net` How to create your own glyphs for use with AutoGlyph and Glyph.

`AutoColor.net` A simple use of AutoColor to color a 3D field.

`CappedIso.net` How to "close" an isosurface at the boundary of a three-dimensional volume.

`ComputeOnData.net` How to perform a mathematical function on all the data values in a field.

`ContoursAndCaption.net` How to draw contour lines on a plane. The position of the plane is controlled by the Sequencer, and a caption shows the current position of the plane.

`Distributed.net` Demonstrating the module-level distributed processing capabilities of Data Explorer. The network is decomposed into three mutually disjoint subsets, each of which can be executed on a different host in a distributed network.

`FlyThrough.net`, `FlyThrough2.net` Two ways to create a "fly through" of data.

`Imide_Potential.net` Visualizing a molecule in a potential field. This program also demonstrates the use of a data-driven sequencer.

`Isolate.net` How to isolate connections of an object.

`MappedIso.net` How to map a variable onto an isosurface of another variable.

`MovingCamera.net` Using the Sequencer to control the position of the viewing point.

`MovingSheet.net` Using the Sequencer to control the position of a slice through a data set.

`MRI_2.net` One way to visualize a set of 2-dimensional MRI slices as a 3-dimensional volume.

`PickStreamline.net` Using the Pick tool to select points (on an isosurface) as the origin of streamlines in the data.

`PlotLine.net, PlotLine2.net, PlotTwoLines.net` Using the Plot module to display 2-dimensional plots of data values.

`ProbeText.net` One way to place text in an image to show data values at probe points.

`RubberTube.net` How to make a tube diameter vary with the data value.

`SharedCamera.net` How to create two images that share the same camera. One of the images is used for rotating, zooming, and resizing; the other tracks the changes.

`SimplifySurface.net` How to simplify a surface consisting of triangles so that fewer triangles are used.

`Streamline.net` Using parameters of the Streamline module to visualize a vector field.

`ThunderGlyphSheet.net` Visualization of simulation data from a model of a thunder storm. (A slicing surface of variable position and shape is used to intersect an isosurface of the data; the area of the isosurface is calculated and displayed.)

`ThunderStreamlines.net` Using the Streamline module to visualize a wind field.

`Thunder_cellcentered.net` Differences between position-dependent and connection-dependent (cell-centered) data.

`UsingClipPlane.net` Using probes to control the orientation of the clipping plane.

`UsingGlyphs.net` Using the AutoGlyph module to create glyphs for data values.

`UsingIsosurface` How to create isosurfaces and contour lines.

`UsingMap.net` Three ways to use the Map module. Two fields differing only in the content of their data components are used as the data-set and mapping operands of the Map module. The results are displayed in three separate windows.

`UsingStreakline.net` Using the Streakline module to visualize a vector-field series.

`VolumeClip.net` How to clip a surface in a three-dimensional volume by a plane and then close the surface by the plane.

`VolumeRenderingSimple.net, VolumeRendering.net` How to create a volume rendering of a 3-dimensional data set. The first example is the simplest possible visual program; the second is more complex, with a color bar to annotate the image.

`WindVorticity.net` Using the DivCurl module to display the vorticity of a vector field. The program also uses a shared camera and data-driven interactors.

### Annotation

Found in directory `$DXROOT/samples/programs/ANNOTATION`

`AnnotationGlyphs.net` How to create your own glyphs for use with AutoGlyph and Glyph.

`AutoAxesSpecifyTicks.net` How to explicitly specify tick locations and labels for the ticks.

`BandedColors.net` How to create an image with a set of constant color bands.

`Categorical.net` How to display categorical (non-spatial) data

`ContoursAndCaption.net` How to draw contour lines on a plane. The position of the plane is controlled by the Sequencer, and a caption shows the current position of the plane.

`Distributed.net` Demonstrating the module-level distributed processing capabilities of Data Explorer. The network is decomposed into three mutually disjoint subsets, each of which can be executed on a different host in a distributed network.

`ExpandedFonts.net` How to use the expanded font sets of the area and roman_ext fonts.

`FontPreview.net` Displaying ASCII text in a Data Explorer font.

`GroceryList.net` Plots information from a grocery list in a number of different ways; by category, by item name, etc.

`Imide_Potential.net` Visualizing a molecule in a potential field. This program also demonstrates the use of a data-driven sequencer.

`Legend.net` Shows how to use the Legend module to associate colors with strings.

`PickPlot.net` Demonstrates how to use picking in a plot to extract x,y positions.

`PlotGroupOfLines.net` How to plot a multiple-line graph

`PlotLine.net, PlotLine2.net, PlotTwoLines.net` Using the Plot module to display 2-dimensional plots of data values.

`PlotSpecifyTicks.net` How to explicitly specify tick locations and labels.

`ProbeText.net` One way to place text in an image to show data values at probe points.

`SalesOnStates.net` Shows how to display sales or other data on a per-state basis.

`Sort.net` How to sort a field based on the y-position.

`SpecialCharacters.net` Displaying all of the characters in the "pitman" or "area" fonts supplied with Data Explorer. How to specify non-ASCII characters.

`ThunderGlyphSheet.net` Visualization of simulation data from a model of a thunder storm. (A slicing surface of variable position and shape is used to intersect an isosurface of the data; the area of the isosurface is calculated and displayed.)

`UsingGlyphs.net` Using the AutoGlyph module to create glyphs for data values.

`UsingTextAndTextGlyphs.net` How to display text data at specified locations in the space occupied by an object.

### Categorical

Found in directory `$DXROOT/samples/programs/CATEGORICAL`

`Categorical.net` How to display categorical (non-spatial) data

`Duplicates.net` How to detect duplicate values in a data set using CategoryStatistics

`GroceryList.net` Plots information from a grocery list in a number of different ways; by category, by item name, etc.

`Legend.net` How to create a legend, which associates a set of colors with a set of strings

`SalesOnStates.net` How to display sales data by state

`ZipCodes.net` How to import some data associated with zipcodes using ImportSpreadsheet, then display those data on a state map. This program also illustrates the use of CategoryStatistics to compute the mean data value for each category (in this case, zipcode).

### Colormap Editor

Found in directory `$DXROOT/samples/programs/COLORMAP_EDITOR`

`DataDrivenInteractors.net` Some uses of data-driven interactors.

`Imide_Potential.net` Visualizing a molecule in a potential field. This program also demonstrates the use of a data-driven Sequencer.

`StandardColormaps` Demonstrates a number of useful colormaps, depending on the type of data being viewed.

`UsingColorMaps.net` Using color maps to control the visualization of data.

`VolumeRendering.net` How to create a volume rendering of a 3-dimensional data set.

### Compute

Found in directory `$DXROOT/samples/programs/COMPUTE`

(Compute is a general purpose module for performing mathematical operations on data.)

`Bounce.net` The path of a bouncing ball.

`Compute2.net` A simple visual program which demonstrates how to use the Compute2 module.

`ComputeMultiLine.net` How to pass a multiline arithmetic expression to Compute2.

`ComputeOnData.net` How to perform a mathematical function on all the data values in a field.

`WarpingPositions.net` How to use the Compute module to "warp" the positions component of a field (e.g., warping a 2-dimensional field into the shape of a cylinder or sphere).

### Data-driven Interactors

Found in directory `$DXROOT/samples/programs/DATA_DRIVEN_INTERACTORS`

`DataDrivenInteractors.net` Some uses of data-driven interactors.

`DataDrivenSelector.net` How to use a data-driven selector interactor.

`Imide_Potential.net` Visualizing a molecule in a potential field. This program also demonstrates the use of a data-driven Sequencer.

### Debugging

Found in directory `$DXROOT/samples/programs/DEBUGGING`

`Verify.net` How to check the internal consistency of a data object.

`VisualObject.net` Display the hierarchy of a data field.

### Distributed Processing

Found in directory `$DXROOT/samples/programs/DISTRIBUTED_PROCESSING`

`Distributed.net` Demonstrating the module-level distributed processing capabilities of Data Explorer. The network is decomposed into three mutually disjoint subsets, each of which can be executed on a different host in a distributed network.

### Image Processing

Found in directory `$DXROOT/samples/programs/IMAGE_PROCESSING`

`FFT.net` Computing fast and discrete Fourier transformations on sample data sets.

`MRI_1.net` One way to visualize 2-dimensional MRI slices.

`UsingEqualize.net` How to use the Equalize module to emphasize features in an image.

`UsingFilter.net` How to perform filtering operations on images.

`UsingMorph.net` How to perform morphological operations on images.

`UsingOverlay.net` Using the Overlay module to combine images.

### Importing Data

Found in directory `$DXROOT/samples/programs/IMPORTING`

`Categorical.net` How to import some data associated with state abbreviations using ImportSpreadsheet, then plot the average data for each state.

`Duplicates.net` checks a simple table of data and checks for duplicate state names.

`GeneralImport1.net, GeneralImport2.net` Importing data in the general array import format.

`ImportExternalFilter.net` How to use the external-filter option of the Import module to import data in file formats other than Data Explorer.

`ZipCodes.net` How to import some data associated with zipcodes using ImportSpreadsheet, then display those data on a state map. This program also illustrates the use of CategoryStatistics to compute the mean data value for each category (in this case, zipcode).

### Interface Control

Found in directory `$DXROOT/samples/programs/INTERFACE_CONTROL`

`DialogStyle.net` Using dialog-style control panels. This program is intended to run with Data Explorer in image mode (i.e., started with `dx -image`).

`InterfaceControl1.net` Using ManageControlPanel and ManageColormapEditor to open and close control panels and the Colormap editor according to the setting of the Selector interactor (alternating between two realization techniques).

`InterfaceControl2.net` Using ManageImageWindow to close a plot image window when a toggle interactor requires it.

`InterfaceControl3.net` Using ManageControlPanel to open and close different multiple panels.

### Looping

Found in directory `$DXROOT/samples/programs/LOOPING`

`Accumulate.net` How to use Get and Set to accumulate objects (in this case, slabs selected from a 3-dimensional volume).

`Bounce.net` The path of a bouncing ball.

`SimpleGetSetLoop.net` How to create a program loop with GetLocal/SetLocal, GetGlobal/SetGlobal, and Done.

### Miscellaneous

Found in directory `$DXROOT/samples/programs/MISC`

`CensusData.net` How to visualize census data on a map of the United States.

`ExampleSMP.net` How Partition should be incorporated in a visual program so that Data Explorer SMP can run it in parallel on SMP (symmetric multiprocessor) machines.

`Factorial.net` How to compute N factorial using looping.

`HomeOwn.net` Illustrates the use of the MapOnStates macro to plot home ownership in the United States over time.

`ImageTool.net` Using interactors to control different aspects of the Image tool (e.g., AutoAxes and background color).

`Image_wo_UI.net` Demonstrates the Image2Macro, which implements much of the functionality of the Image tool with SuperviseWindow, SuperviseState, and Display. Thus this macro shows how you could build your own custom direct interactors independent of the Data Explorer user interface.

`IndependentlyArrange.net` Illustrates how to independently arrange a number of interactive windows within a single larger window using the SuperviseWindow and SuperviseState modules.

`InsetImage.net` Illustrates how to inset an independently interactive window within a larger window.

`Interop.net` One way of making Data Explorer modules work together. Data can be mapped onto objects at different points in the visualization to achieve desired results.

`InvalidData.net` How data marked as invalid are handled by various modules.

`Majority.net` The difference between row and column majority when using the general array format.

`ManipulateGroups.net` How to use ChangeGroupType and ChangeGroupMember to restructure groups.

`MRI_1.net` One way to visualize 2-dimensional MRI slices.

`MRI_2.net` One way to visualize a set of 2-dimensional MRI slices as a 3-dimensional volume.

`MultipleDataSets.net` Using the Inquire module and data-driven interactors to make visual programs more flexible. A relatively "generic" program that can be used with a variety of different input data sets.

`PickStreamline.net` Using the Pick tool to select points (on an isosurface) as the origin of streamlines in the data.

`ScatterData.net` Some ways to visualize scattered data

`Supervise.net` Demonstrates how to use SuperviseWindow, SuperviseState, and Display together in a simple visual program.

`Topo.net` Some ways of visualizing topographic data (in this example, two data sets sharing the same grid: elevation and a gray-scale image).

`UsingAttributes.net` Using attributes in a Data Explorer format file. (In this example, attributes added to the file to indicate date and source are used to caption the image.)

`UsingDrape.net` How to "drape" an image or other field onto a height map.

`UsingEqualize.net` How to use the Equalize module to emphasize features in an image.

`UsingMessage.net` Using the Message module to present information to the user of a visual program.

`UsingMultiGrids.net` Some of the differences between multigrid groups and generic groups.

`UsingParse.net` Using the Parse module to extract information from a string.

`UsingSwitchAndRoute.net` Using the Switch and Route modules to control the execution of a visual program.

### Probes

Found in directory `$DXROOT/samples/programs/PROBES`

`PlotLine2.net` Using the Plot module to display 2-dimensional plots of data values.

`ProbeText.net` One way to place text in an image to show data values at probe points.

`UsingProbes.net` Using probes to control the position of a cutting plane through a 3-dimensional data set.

`UsingStreakline.net` Using the Streakline module to visualize a vector-field series.

### Rendering

Found in directory `$DXROOT/samples/programs/RENDERING`

`FatLines.net` How to antialias lines and create multiple pixel width lines in hardware rendering.

`Isolate.net` Demonstrates an alternative to volume rendering using the Isolate module.

`SharedCamera.net` How to create two images that share the same camera. One of the images is used for rotating, zooming, and resizing; the other tracks the changes.

`TextureMapOpenGL.net` Using texture mapping (available only with a hardware adapter that supports OpenGL) to map an image onto a surface.

`UsingClipPlane.net` Using probes to control the orientation of the clipping plane.

`UsingLights.net` How to use lights to illuminate the object in an image.

`UsingShade.net` Controlling the shading properties of an object.

`VolumeRenderingSimple.net, VolumeRendering.net` How to create a volume rendering of a 3-dimensional data set. The first example is the simplest possible visual program; the second is more complex, with a color bar to annotate the image.

### Scattered Data

Found in directory `$DXROOT/samples/programs/SCATTERED`

`AnnotationGlyphs.net` How to create your own glyphs for use with AutoGlyph and Glyph.

`ConnectingScatteredPoints.net` How to use the Connect and Regrid modules to create connections (interpolation elements) between points.

`ScatterData.net` Some ways to visualize scattered data

### Sequencer

Found in directory `$DXROOT/samples/programs/SEQUENCER`

`ContoursAndCaption.net` How to draw contour lines on a plane. The position of the plane is controlled by the Sequencer, and a caption shows the current position of the plane.

`FlyThrough.net`, `FlyThrough2.net` Two ways to create a "fly through" of data.

`Imide_Potential.net` Visualizing a molecule in a potential field. This program also demonstrates the use of a data-driven Sequencer.

`MRI_1.net` One way to visualize 2-dimensional MRI slices.

`MovingCamera.net` Using the Sequencer to control the position of the viewing point.

`MovingSheet.net` Using the Sequencer to control the position of a slice through a data set.

`Sort.net` How to sort a field based on the y-position.

`SpecialCharacters.net` Displaying all of the characters in the "pitman" or "area" fonts supplied with Data Explorer. How to specify non-ASCII characters.

`Streamline.net` Using parameters of the Streamline module to visualize a vector field.

[ OpenDX Home at IBM | OpenDX.org ]