Docs: Graphics Command Library

Introduction

The graphics command library allows a program to install and process a set of standard graphics commands in conjunction with the ERPSS graphics environment and command-processing system. By installing these commands, a graphics program can provide a user with access to a set of basic plotting utilities that are present in a variety of programs. In addition, a standardized set of options is available for controlling graphics parameters such as line width and color, and these options can be conjoined with the native commands of a particular graphics program. By using this library, graphics programs can share both specific commands and general command formats, thus reducing both programming overhead and user effort.

This document assumes that the reader is familiar with the ERPSS plotting environment, the usage of the standard graphics commands, and the ERPSS command interface. These issues are described in the following documents:

Installing the Graphics Commands

The standard graphics commands are implemented in a library named "/usr/erpss/lib/libp.a", and a variety of useful constants and data structures are defined in /usr/erpss/include/plot/grafcom.h. The routines in libp.a must be linked with several other ERPSS libraries: libpf.a, libd.a, libu.a, and libesys.a (in that order). All of the graphics commands can be installed into a program's command list by calling a single routine, gc_install(). This routine is passed a handle to the program's command list and a handle to the plot buffer structure. Once this routine has been called, the program need only process a user's input with the standard do_command() and do_command_line() routines to provide the user with access to all of the standard graphics commands. At the end of the program, the gc_free() routine should be called, which frees the memory associated with the graphics options, followed by the free_commandlist() routine, which will free the memory associated with the command list, including any program-specific commands.

The following is an example of a program, similar to multiplot, that installs the graphics commands and then reads user commands from the standard input and executes them (note that this is a bare-bones version that lacks many desirable features, such as error checking).

Accessing the Graphics Options

In addition to installing the standard graphics commands, most programs will also combine program-specific commands with the standard library options that manipulate line style, text style, translation, etc. These options can be accessed through a small set of global variables and functions, which can be declared as externals in the main program. The names of all of the global variables and functions in the graphics command library begin with "gc_", and to prevent accidental overlap, a program's native variables and functions should not begin with this prefix.

Authors



© 2005 UCSD ERP Lab
Please send comments and suggestions to the ERPSS Webmaster