PGS is an application program interface (API) that is independent of the underlying host graphics system. All of the graphics portability headaches are confined to PGS and applications which use PGS are completely portable. PGS currently sits on top of X Windows on UNIX platforms, Quickdraw on Macintoshes, and Microsofts graphics library on DOS platforms.
PGS takes a least common denominator approach regarding what graphics functionality it supports. The goal is to run on the widest variety of machines. This lets out high level graphics capabilities such as real time 3D rotations which depend on specific hardware. On the other hand, any rendering capability that can be implemented with reasonable efficiency in software is fair game for PGS. This model will almost certainly change in time as both graphics hardware and software evolve and become ubiquitous across platforms.
PGS also structures display surfaces with a viewport defined in normalized coordinates, an enclosing boundary where axes are drawn which is defined as a set of offsets from the viewport window, and a world coordinate system attached to the viewport. The enclosing boundary is useful for obtaining a standoff between rendered data such as line plots and the axes used to measure the rendering.
PGS supports both line and text drawing primitives, line and text attributes, and bit maps for handling images and other cell array data. Most functionality in PGS is either primitive operations such as moves and draws or at a very high level such as axis drawing and the rendering algorithms that it supports. These rendering algorithms have two interfaces: one for raw data; and one for PML type mappings. This gives a great deal of flexibility to the application developer.
PGS has the following rendering algorithms currently: 1D line plots; 2D contour plots; 2D vector plots; 2D image plots; 3D wire frame mesh plots (for 2D data sets); and Grotrian diagram plots.
2.0
Overview of PGS
PGS has two main goals: to provide a portable interface to various host graphics systems; and to provide high level functionality to applications which most host graphics systems do not provide. To meet these goals it was necessary to develop a model of the kinds of devices which the various host graphics systems support so that the functional interface could be defined and implemented.
It was also necessary to identify which graphics primitives to support. Some host graphics systems have a very rich supply of graphics primitives. In fact, some go way beyond supplying primitive graphics functionality and provide high level rendering capabilities. Other host graphics systems have a relatively small set of primitive graphics operations. The decision was made to design PGS so as to depend on as small a subset of graphics primitives as possible. This makes PGS extremely portable. It also forces PGS to either implement or forego higher level graphics functionality. Hopefully, a useful balance has been struck on this issue.
As the above discussion implies, PGS has two obvious layers. The first layer is a low level one that communicates directly with the host graphics system. The other layer is oriented more toward the application and includes the high level rendering and axis drawing functions. This layer actually breaks down into several layers. The details of this breakdown will be discussed as appropriate.
The remainder of this section discusses the PGS device model and the PGS drawing model.
2.1 The
PGS Device Model
To provide the maximum degree of portability in what is an inherently platform dependent field, the attempt has been made to isolate all of the platform dependencies behind abstraction barriers. The functional interface provides one set of abstraction barriers. This however does not help with the problem of the notion of graphics state. Graphics state consists of information such as the current default line attributes, default text attributes, coordinate systems, and so on. Furthermore, in a general purpose setting, an application may wish to manage multiple independent devices each with its own separate graphics state.
First, PGS defines a graphics device as an abstract entity containing a logical two dimensional drawing surface and a set of parameters which describe how and where all drawing functions are to be performed on the drawing surface.
Nearly all host graphics systems have their own abstraction barrier wrapped around their drawing surface(s). However, they almost all provide a pointer or index to applications to specify which drawing surface is intended for a particular operation. This latter point is most relevant to windows on display screens, although a file indicator is the correct analog for PostScript or CGM type devices. In any case, PGS handles the interface to the host graphics system and hides it from applications. In the place of the host graphics device indicator, PGS supplies a structure called a PG_device. Applications open and manipulate PG_devices only. This way all PGS based applications have a single portable interface to all devices supported by PGS.
The PG_device not only contains the host graphics device indicators, it also contains the graphics state for each device. In this way each PG_device is independent of every other PG_device. This gives applications the ability to draw the same picture on every device by simply changing the PG_device passed to the drawing functions. No device conditional logic is required of applications.
The host graphics systems supported by PGS currently are:
X Windows
PostScript
CGM (Computer Graphics Metafile)
Quickdraw (Apple Macintosh)
Microsoft Graphics Library
2.2 The
PGS Drawing Model
Almost all host graphics systems employ a drawing model. This specifies information such as coordinate systems and their origins, how clipping is done, and so on. PGS has a somewhat more difficult time coming up with a drawing model since it must present a drawing model that is compatible with all host graphics systems even when the various host graphics systems are in conflict with one another. PGS accomplishes this task by using the least common denominator of the host systems, defining as much of the drawing model as possible, and mapping host graphics systems models into the PGS model.
A PG_device can be thought of as a window on the display area of the host graphics system. In that view, a PGS window can be defined as the region of the host graphics system display surface controlled by PGS during drawing operations. PGS windows then map naturally onto the kinds of windows associated with such host graphics systems as X Windows and Quickdraw. This idea also has application to a PostScript or CGM device.
2.2.1
PGS Window Placement
In placing a PGS window which contains the drawing surface on a display screen or a PostScript page, the position of the upper left corner of the PGS window is given in normalized coordinates relative to a coordinate origin in the upper left corner of the host graphics system device.
2.2.2
Frames, Viewports, and View Boundaries
Any part of the interior of a PGS window may be drawn on by PGS routines. Windows do have some additional structure to help applications conveniently handle high level plotting constructs.
A window may be partitioned into frames with a view to drawing more than one plot at a time. Within each frame there is a preferred drawing area called the viewport. The viewport is defined relative to its enclosing frame and by default each window has a single frame which is the same size as the window. PGS supports clipping which can render it impossible to draw to any part of the window but the current viewport.
In addition to the viewport there is a bounding region of the viewport which is used to offset axes from the viewport so that there is a nice, application controllable separation between the axes and whatever is drawn in the viewport. This bounding region is called the view boundary.
The application can move the frame or viewport around in the PGS window at any time as well as altering its size.
2.2.3
Coordinate Systems
Inside a PGS window there are three coordinate systems: world coordinates, normalized coordinates, and pixel coordinates. World coordinates are application defined and have whatever meaning the application requires. The lower left corner of the viewport corresponds to the minium x and y values of the world coordinate domain. Normalized coordinates represent the fraction of the PGS window width and height that a point is from the origin which is in the lower left corner of the PGS window. Pixel coordinates represent the integer number of pixels that a point is from the origin which is in the lower left corner of the PGS window.
PGS supplies a set of macros to convert between all of the coordinate systems which a PGS window may have.
3.0
The PGS User Interface Model
The subject of user interfaces can be a rather complicated one. For many applications the most natural interface is a graphical one. However, some systems make the mistake of insisting that a graphical interface is the only interface which an application may have. PGS supports a model of user interfaces that permits the application developer to seek the natural interface for his or her application. This means that PGS supports development of textual interfaces, graphical interfaces, and hybrids. In the following sections, we will discuss the concepts underlying user interfaces from PGSs point of view (PGS emphasizes portability and flexibility especially).
3.1
A Textual Interface
Consider the following program fragment which is typical of an application with a textual interface: char s[MAXLINE], *t;
char *dispatch(char *s);
printf(-> );
while (fgets(s, MAXLINE, stdin) != NULL)
{t = dispatch(s);
printf(%s\n-> , t);};
This code prints a prompt, gets some input (fgets), processes it (dispatch), and prints the result. It does this in a loop until something ends the program.
For a program so simple and ordinary, it is astonishing how difficult some systems make it to run this code. One of the peg points of PGS is that it must be easy to run such an application whether the system wants to make it easy or hard. Some of the graphical user interface models can be ported with some careful abstraction barriers (and PGS does this too), but this example is something of a lowest common denominator. So we will start with this and build up a model that supports this simple text driven style and the most elaborate graphical application.
3.2
Adding Abstraction Barriers
By adding two macros and two function pointers we can make an enormous shift in the portability of this program: #define
GETLN (*getln)
#define
PRINT (*putln)
char *(*
getln)(char *s, int n, FILE *fp)
int (*
putln)(FILE *fp, char *fmt, ...)
These items are defined in score.h which is #included by pgs.h
With these elements we can modify the original example as follows:
char s[MAXLINE], *t;
char *dispatch(char *s);
getln = fgets;
putln = fprintf;
PRINT(stdout, -> );
while (GETLN(s, MAXLINE, stdin) != NULL)
{t = dispatch(s);
PRINT(stdout, %s\n-> , t);};
This doesnt look like much at all, but the impact of this change is enormous! Now we can insert other functions which are call compatible with the standard C library functions, fgets and fprintf. PGS supplies two such functions: PG_wind_fgets and PG_fprintf. In fact, when a call to PG_open_device or PG_open_console is made these functions are connected to getln and putln for you!
PG_wind_fgets, in addition to looking for input from the terminal as fgets does, also looks for events from the windowing system under which the application is running. PG_fprintf prints your formatted text to a terminal or to a screen window depending on what is appropriate to the system on which the application is running.
This example can be filled out to a complete program (modulo the definition of the dispatch function) which is completely portable:
#include <pgs.h>
main(int c, char **v)
{char s[MAXLINE], *t;
char *dispatch(char *s);
PG_open_console(test, COLOR, TRUE, 0.1, 0.7, 0.5, 0.3);
PRINT(stdout, -> );
while (GETLN(s, MAXLINE, stdin) != NULL)
{t = dispatch(s);
PRINT(stdout, %s\n-> , t);};
return(0);}
There is an important issue remaining here and that is the subject of the next section.3.3
Multiplexed I/O and Interrupt Driven I/O
In the program we have been discussing, input is gathered from either the terminal or the windowing system. This is an example of multiplexed I/O. Many applications use multiplexed I/O. It is common in networking programs for example. With multiplexed I/O a variety of input sources are polled to see whether there is any input ready. Depending on the device that has input, the application takes the appropriate action as it becomes available. In the more efficient applications the operating system is usually involved since it is better able to control machine resources than any application.
Our sample program doesnt necessarily need to do multiplexed I/O (on the other hand we havent said what the dispatch function does!). If it were a graphical application however the chances are that it would have to handle input from both the terminal and from the windowing system. GETLN, more specifically PG_wind_fgets, does just that. If the specified FILE pointer is stdin, it obtains input from either source, and copies terminal input into the buffer passed in as an argument or dispatches input from the windowing system (also referred to as events) to functions which are registered with PGS to handle specific kinds of events. If the specified FILE pointer is in fact something beside stdin it simple performs an fgets on that file. PG_wind_fgets only returns when a newline or an end of file condition is encountered. For terminal input this means typing a carriage return.
It appears that input can only be handled when GETLN is called. However, it is often desirable to have input handled whenever it comes in. Some operating systems support this through the use of assignable interrupts. Input handled this way is said to be interrupt driven. In PGS, when a screen window is opened all of the machinery is put into place to allow interrupt driven I/O. The application switches interrupt handling on and off through the macro PG_IO_INTERRUPTS which take a value of TRUE to turn it on and FALSE to turn it off. When I/O interrupts are on input from the terminal is saved in a buffer to be copied into the buffer of the next GETLN call, and input from the windowing system is dispatched to the appropriate event handler. After the input is processed the interrupt handler returns and execution resumes from the point where the interrupt occurred.
With interrupt driven I/O activated, our simple program has all the capabilities of a vastly more complicated application written for certain specific operating environments which enforce a graphical interface only mode of programming. The fact that PGS runs on such systems as wells as those that support text only or hybrid interfaces should give some idea of the idea of portability and flexibility which PGS aims to provide.
3.4
Event Handling
Now that we have seen how input is handled in the broadest terms and how PGS presents a portable application interface for input handling, lets turn to an closer examination of the way in which input from a windowing system is dealt with. Generically, window input is said to consist of sequences of events. Events can be such things as key presses when the mouse or locator is in a window, mouse button presses and releases, or the locator entering or leaving a window.
Different windowing system define varying sets of events. PGS supports the following set of events everywhere:
KEY_DOWN_EVENT a key on the keyboard is pressed
KEY_UP_EVENT a key on the keyboard is released
MOUSE_DOWN_EVENT a mouse button is pressed
MOUSE_UP_EVENT a mouse button is released
UPDATE_EVENT the window system says that the window has changed
in some way
EXPOSE_EVENT the window has become fully visible (is no longer
obscured by another window
MOTION_EVENT the mouse has moved in the window
It should be understood that all events have a context. They all happen in or relate to a particular screen window. So when PGS get notified by the windowing system that there is an event present, it determines which window is effected. It then passes both the pointer to the effected window and the event on to the function which is going to handle the event.
Does a blocking read of the next event from the windowing system and fills in the specified PG_event structure, ev.
Return the state of the keyboard for the specified window, d. The x and y coordinates of the mouse or locator, which key is pressed, and which modifiers are present are returned in x, y, c, and mod respectively. In the F77 binding this is associated only with one specific keyboard event. It should be called only a single time from a
Return the state of the mouse
The modifiers are:
F77 Binding:
Return a pointer to the PG_device (screen window) in which the event, ev, occurred or to which it relates.
Return the ASCII code of the next character entered from the keyboard into the specified PG_device, d.
Region a polygonal region in the window defining the context of the object
Visible flag specifies whether the object is to be drawn or not
Selectable flag specifies whether the object can be selected or not
Active flag specifies whether the object is currently active or not
Draw method how to draw the object if it is visible
Select method how to select the object if it is selectable
Action method what action to take when the object is active or activated
Parent interface object of which this is a child
Children array of child interface objects
Each PG_device has a tree of interface objects associated with it. Interface objects are created by calls to PG_make_interface_object. These objects individually and by virtue of their relationship in a hierarchy allow one to define the conventional graphical interface tools such as buttons, slider bars, and text boxes. The mechanism is very open ended and extensible. By defining the draw, select, and action methods and building trees of interface objects, application developers can generate virtually any kind of graphical interface functionality they wish.
Valid operators are:
BND boundary specifier
CLR specifies fore and background colors (by index)
DRW names function that draws object when visible
FLG state flags
NAME object name
SEL names function that identifies object as selected when selectable
Valid BND parameters are:
RECT 2 NDC points specifying the lower left and upper right limits of a boundary
rectangle follow
Valid FLG parameters are:
IsSel object is selectable
IsAct object is active
Valid CLR parameters are (using the standard color table):
1 logical WHITE
2 LGHT_WHITE
3 GRAY
4 BLUE
5 GREEN
6 CYAN
7 RED
8 MAGENTA
9 BROWN
10 LGHT_BLUE
11 LGHT_GREEN
12 LGHT_CYAN
13 LGHT_RED
14 YELLOW
15 LGHT_MAGENTA
The default for FLG parameters is IsVis and IsSel. You only need use the FLG operator if you wish to change this setting. Each parameter specified turns on its corresponding flag. To turn all flags off use FLG( ) (one space between the parentheses).
draw-variable draw a variable object (default for VARIABLE objects)
draw-container draw a container object (default for CONTAINER objects)
draw-button draw a button object (default for BUTTON objects)
draw-slider draw a slider button
select-logical select based on logical containment
toggle action function to toggle visibility and selectability of objects
With these building blocks in hand we will look at some common widgets found in many graphical user interface kits. It is very important to note that much of the behavior of these objects derives from their relative positions in the hierarchy of interface objects. This position relationship contributes as much as the atomic properties of the individual objects to the functioning of these combinations. This is a key feature in the flexibility of the PGS design.
3.4.1 Event Handling Functions
Given the above list of recognized events, PGS defines a function pointer (hook) associated with each type of event so that applications may control what is done with specific events. The following functions let applications assign their function to these hooks.
SX Binding:
F77 Binding: integer pgseku(integer d, fnc)
SX Binding:
F77 Binding: integer pgsemd(integer d, fnc)
SX Binding:
F77 Binding: integer pgsemu(integer d, fnc)
SX Binding:
F77 Binding: integer pgseup(integer d, fnc)
SX Binding:
F77 Binding: integer pgseex(integer d, fnc)
SX Binding:
F77 Binding: integer pgsedf(integer d, fnc)
SX Binding:
These assign the specified function fnc to be the event handler for the device, d. The function fnc is a pointer to a function returning nothing which takes a PG_device pointer and a PG_event pointer as arguments.The C routines all return the old value of the hook and the following typedef applies: typedef void (*
PFByte)();
To explicitly call these functions in a generic way (i.e. regardless of the specific function attached to the hook) use the following macros:
void PG_handle_key_down_event(PG_device *d, PG_event *ev)
void PG_handle_key_up_event(PG_device *d, PG_event *ev)
void PG_handle_mouse_down_event(PG_device *d, PG_event *ev)
void PG_handle_mouse_up_event(PG_device *d, PG_event *ev)
void PG_handle_update_event(PG_device *d, PG_event *ev)
void PG_handle_expose_event(PG_device *d, PG_event *ev)
void PG_handle_default_event(PG_device *d, PG_event *ev)
These simply call the specified event handler with the PG_device and PG_event. The default event handler is an additional way to handle events. The application can have a single handler for all events. For example, when PGS gets a mouse down event it first checks to see whether there is a mouse down handler. If so it is called. If not it then checks to see whether there is a default handler and if so calls it.3.4.2 Event Related Macros
In addition to the above which have to do with routing events off to handlers, there are some other macros which the event handlers or user call-back functions can use to access event information.
SX Binding:
SX Binding:
SX Binding:
SX Binding:
SX Binding:
3.5
Interface Objects
3.5.1
Event Handling and Interface Objects
Checks to see whether a mouse down or key down event occurred inside any selectable
interface object.
If inside an interface object that has an action, then that action is called.
Otherwise if there is a handler for the event type, it is called.
3.5.2
Portable User Interface Description
3.5.2.1
Syntax for Interface Description
3.6 PGS Interface Objects
The specific objects which PGS supplies are: CONTAINER, BUTTON, TEXT, and VARIABLE. With these objects and some defined relationships between them it is possible to build most of the common widgets found in the sets supplied with various systems.3.6.1
Buttons
Button CLR(3,2) DRW(draw-button) ACT(End) BND(RECT) (0.1,0.9) (0.2,0.95)
{Text NAME(End) CLR(10,-1) FLG(IsVis) DRW(draw-text) BND(RECT) (0.05,0.3) (0.95,0.7)}
The action method of the button is the function associated with the string End in the callback table. The text End appears in the button and is visible but not selectable.3.6.2
Enumerable Variables
Container CLR(0,0) BND(RECT) (0.1,0.82) (0.25,0.87)
{Variable NAME(Output) CLR(10,0) BND(RECT) (0.0,0.49) (1.0,1.0)
{Button CLR(3,2) ACT(1) BND(RECT) (0.0,-1.0) (0.5,0.0)
{Text NAME(On) CLR(10,-1) FLG(IsVis) BND(RECT) (0.05,0.05) (0.95,0.95)}
Button CLR(3,2) ACT(0) BND(RECT) (0.5,-1.0) (1.0,0.0)
{Text NAME(Off) CLR(10,-1) FLG(IsVis) BND(RECT) (0.05,0.05) (0.95,0.95)}}}
The children of the variable registered using PG_register_variable under the name Output are buttons which when selected set the value of the variable to the value taken from the action of the button (1 for the On button and 0 for the Off button). A second more elaborate example shows this same principle:Container CLR(0,0) BND(RECT) (0.85,0.88) (1.0,1.0)
{Variable NAME(Direction) CLR(10,0) BND(RECT) (0.2,0.0) (0.8,0.2)
{Button CLR(3,2) ACT(n)
BND(5) (0.51,3.12) (0.64,3.53) (0.51,3.88) (0.36,3.53) (0.51,3.12)
{Text NAME(N) CLR(10,0) FLG(IsVis) BND(RECT) (0.0,1.0) (1.0,2.0)}
Button CLR(3,2) ACT(e)
BND(5) (0.55,3.0) (0.7,2.59) (0.9,3.0) (0.7,3.41) (0.55,3.0)
{Text NAME(E) CLR(10,0) FLG(IsVis) BND(RECT) (1.0,0.0) (2.0,1.0)}
Button CLR(3,2) ACT(s)
BND(5) (0.51,2.88) (0.36,2.53) (0.51,2.12) (0.64,2.53) (0.51,2.88)
{Text NAME(S) CLR(10,0) FLG(IsVis) BND(RECT) (0.0,-1.0) (1.0,0.0)}
Button CLR(3,2) ACT(w)
BND(5) (0.45,3.0) (0.3,3.41) (0.1,3.0) (0.3,2.59) (0.45,3.0)
{Text NAME(W) CLR(10,0) FLG(IsVis) BND(RECT) (-1.0,0.0) (0.0,1.0)}}}
Here a variable registered under the name Direction has four buttons (which are not rectangles), N, E, S, and W which take values that are strings and the text of the buttons is outside of the buttons at the points.3.6.3
Nonenumerable Variables
Container CLR(0,0) BND(RECT) (0.26,0.82) (0.39,0.87)
{Variable NAME(Theta) CLR(10,0) BND(RECT) (0.0,0.49) (1.0,1.0)
{Text NAME(30) CLR(10,-1) BND(RECT) (0.05,-0.95) (0.95,-0.05)}}
The text 30 might be the initial value for the variable registered using PG_register_variable under the name Theta. PGS uses the actual current value of the variable in the code for all display purposes. To change the value, you place the cursor in the region of the text, edit it to show the correct value, and hit a carriage return. The value of the variable is then set to that show in the text box. Note that the VARIABLE object must be selectable in order for the text box which actually controls the value to be selectable.3.6.4
Sliders
Container CLR(0,0) BND(RECT) (0.41,0.82) (0.54,0.88)
{Variable NAME(Phi) CLR(10,0) BND(RECT) (0.0,0.67) (1.0,1.0)
{Text NAME(-60) CLR(10,-1) BND(RECT) (0.05,-0.93) (0.95,-0.067)}
Container CLR(2,2) BND(RECT) (0.0,0.0) (1.0,0.3)
{Button CLR(0,0) DRW(draw-slider) ACT(slider) BND(RECT) (0.28,0.0) (0.43,1.0)}}
What makes this a one dimensional slider is that the BUTTON with the slider action takes up the entire span in the y direction of the parent CONTAINER. The text is not strictly necessary here. It is nice to see the value, however, and you can also change the value by entering it in the text box. Either mode of setting the values causes both indicators to show the same value.Container CLR(0,0) BND(RECT) (0.65,0.82) (0.8,0.97)
{Variable NAME(Theta) CLR(10,0) BND(RECT) (0.05,0.88) (0.45,0.99)
{Text NAME(45) CLR(10,-1) BND(RECT) (0.05,-0.95) (0.95,-0.05)}
Variable NAME(Phi) CLR(10,0) BND(RECT) (0.55,0.88) (0.95,0.99)
{Text NAME(0) CLR(10,-1) BND(RECT) (0.05,-0.95) (0.95,-0.05)}
Container CLR(2,2) BND(RECT) (0.0,0.0) (1.0,0.72)
{Button CLR(0,0) DRW(draw-slider) ACT(slider) BND(RECT) (0.0,0.0) (0.1,0.1)}}
This is a two dimensional slider because the BUTTON with the slider action does not span either the entire x or y direction of the CONTAINER parent. The first VARIABLE, Theta, associates with the x direction and the second VARIABLE, Phi, with the y direction. The text boxes work the same way as for the one dimensional slider.3.6.5
Transients
Container NAME(Menu) CLR(0,0) FLG( ) BND(RECT) (0.349,0.021) (0.551,0.121)
{Text NAME(A) CLR(10,-1) FLG(IsVis) BND(RECT) (0.052,0.014) (0.948,0.333)
Text NAME(B) CLR(10,-1) FLG(IsVis) BND(RECT) (0.052,0.333) (0.948,0.667)
Text NAME(C) CLR(10,-1) FLG(IsVis) BND(RECT) (0.052,0.667) (0.948,0.986)}
Button CLR(3,2) DRW(draw-button) ACT(toggle,Menu) BND(RECT) (0.101,0.05) (0.200,0.10)
{Text NAME(Menu) CLR(10,-1) FLG(IsVis) DRW(draw-text)
BND(RECT) (0.053,0.286) (0.947,0.714)}
The container Menu forms the subtree which is to be summoned and dismissed by actuating the button. Notice how the connection works. The action specifies both the toggle method and an interface object whose visibility and selectability are to be toggled. Compare this with the next example below.Container NAME(Rendering) CLR(0,0) FLG( ) BND(RECT) (0.399,0.051) (0.601,0.151)
{Text NAME(Rend) CLR(10,-1) FLG(IsVis) BND(RECT) (0.052,0.014) (0.948,0.333)}
Container NAME(Axis) CLR(0,0) FLG( ) BND(RECT) (0.449,0.101) (0.651,0.201)
{Text NAME(Ax) CLR(10,-1) FLG(IsVis) BND(RECT) (0.052,0.014) (0.948,0.333)}
Container CLR(0,0) BND(RECT) (0.101,0.100) (0.200,0.18)
{Variable NAME(Which-Panel) CLR(0,0) ACT(toggle) BND(RECT) (0.0,0.0) (1.0,1.0)
{Button CLR(3,2) DRW(draw-button) ACT(Rendering) BND(RECT) (0.0,0.5) (1.0,1.0)
{Text NAME(Render) CLR(10,-1) FLG(IsVis) DRW(draw-text)
BND(RECT) (0.05,0.3) (0.95,0.95)}
Button CLR(3,2) DRW(draw-button) ACT(Axis) BND(RECT) (0.0,0.0) (1.0,0.5)
{Text NAME(Axis) CLR(10,-1) FLG(IsVis) DRW(draw-text)
BND(RECT) (0.05,0.3) (0.95,0.95)}}}
In this case a variable is defined with the toggle method. The value of the variable is a string which is the name of the container to be toggled. That is, if the Render button is pressed, the Rendering container becomes visible and selectable. If the Axis button is now pressed, the Rendering container becomes invisible and unselectable while the Axis container becomes visible and selectable. A key feature here is that the variable Which-Panel does not and should not be registered by the application. PGS implicitly defines and registers undefined variables like this as strings and uses them as described above.4.0 Rendering Model
This section describes the model used in PGS to do various high level renderings of data for the purposes of scientific visualization. High level renderings refer to the notion of carrying out a large number of graphical operations to generate a plot or rendering of a set of data. To make this as easy as possible, PGS supplies a set of routines which will give one picture for one call. These routines have the flexibility to produce plots which fit the needs of the user who can set rendering attributes to control the output in detail. The attributes all have a reasonable default value so that it is possible to make reasonable plots with a single call.
4.1 Data Structures
The data structures employed in PGS for the purposes of visualization come from PGS itself and PML, the math library for PACT. The interested user should consult the PML Users Manual for more complete information as well as descriptions of routines which manipulate these structures.4.2
Rendering Modes
POLAR Polar plot with r vs theta.
INSEL Inselberg plot with parallel axes and (x, y) points represented as lines connecting the values on the axes.
HISTOGRAM Cartesian histogram plot with the steps starting with the LEFT value, the RIGHT value, or the averaged or CENTER value.
SCATTER Scatter plot where points are a plotted with a marker character but not connected by line segments (Cartesian)
LOGICAL Plot y values versus their array index. The x values are ignored.
ERROR_BAR Like a scatter plot but instead of marker characters being used error bars are drawn. Requires 2 arrays for x error and y error or 4 arrays for positive and negative going x error and positive or negative going y error.
PLOT_CONTOUR A traditional iso contour plot. Can be done with either logical or arbitrary connectivity.
PLOT_IMAGE A rasterized image plot. Can only be done with logical connectivity.
PLOT_WIRE_MESH The domain values are x and y and the range values are z in a 3 dimensional space. Line segments connect neighboring points. The data can be examined from any specified view angle. The algorithm is a z buffered scan line technique. Can be done with either logical or arbitrary connectivity.
PLOT_SURFACE The domain values are x and y and the range values are z in a 3 dimensional space. In addition to showing the connecting line segments, the faces bounded by the segments are shaded. Two dimensional ranges are handled by taking the first component to be the z value and the second component as the color value. The data can be examined from any specified view angle. The algorithm is a z buffered scan line technique. Can be done with either logical or arbitrary connectivity.
PLOT_FILL_POLY The facets bounded by segments connecting neighbors are filled with a single color determined by the range value. Can be done with either logical or arbitrary connectivity.
4.3
Rendering Attributes
By default PGS assumes a look and feel for the various renderings that it can do. This look can be reduced to a list of characteristic or attribute values. Realizing that applications need to control their own look and feel, they are given a mechanism to change these attributes.
void *SC_assoc(pcons *alist, char *s)
Return the attribute value if present
pcons *SC_add_alist(pcons *alist, char *name, char *type, void *val)
Add an attribute value to a list
pcons *SC_rem_alist(pcons *alist, char *name)
Remove an attribute value from a list
pcons *SC_change_alist(pcons *alist, char *name, char *type, void *val)
Change an attribute value and add it if it is not there
void SC_free_alist(pcons *alist, int level)
Release an association list. Use level 2.
4.3.1 Attributes
This is the list of attributes currently understood by PGS. In use these all appear as quoted strings.
Flag specifying an axis type of
CARTESIAN, POLAR, or INSEL (int). The
default is CARTESIAN.
CHI
Value specifying the chi component of the three
Euler angles (double). The
default is 0.0.
CORNER
Value indicating the node of a logical rectangle which is associated with the
zone center (int). 1 associates lower right, 2 upper right, 3 upper left,
and 4 lower left. This applies to logical rectangular mappings only. The
default is 2.
DRAW-AXIS
If TRUE a high level rendering routine will draw a set of axes.
DRAW-LABEL
If TRUE a high level rendering routine will draw the graph label.
DRAW-LEGEND
If TRUE the contour plotting routine will draw the legend of contour values.
DX-MINUS
For
PLOT_ERROR_BAR type renderings this is the array of negative going
errors on the x values (double *). This must have the same number of
entries as the x values.
DX-PLUS
For
PLOT_ERROR_BAR type renderings this is the array of positive going
errors on the x values (double *). This must have the same number of
entries as the x values.
DY-MINUS
For
PLOT_ERROR_BAR type renderings this is the array of negative going
errors on the y values (double *). This must have the same number of
entries as the y values.
DY-PLUS
For
PLOT_ERROR_BAR type renderings this is the array of positive going
errors on the y values (double *). This must have the same number of
entries as the y values.
EXISTENCE
An existence map array specifiying missing zones in a logical rectangular
mesh (char *). This prevents plotting of information which would be
associated with non-existent zones in a domain mesh.
HIST-START
Flag specifying whether a PLOT_HISTOGRAM rendering starts with the
value on the LEFT, CENTER, or RIGHT side of the bar (int).
LEVELS
The array of contour levels which must be N-LEVELS long (double *). This is
only used when an application wants more control over contour levels
than the contour plotting routines in PGS already provide.
LIMITS
Array of minimum and maximum values (one pair per dimension) specifying
the plotting limits of a domain or range set (double *). The length must
be twice the number of dimensions of the set.
LINE-COLOR
The line color index (int). The default is
BLUE.
LINE-STYLE
The line style index
SOLID, DOTTED, DASHED, DOTDASHED (int). The
default is SOLID.
LINE-WIDTH
The line width (double). The default is 0.0.
MARKER-INDEX
The index into the marker array (int). This depends on how many markers have
been defined with
PG_def_marker. The default is 0.
MARKER-SCALE
The scale factor applied to a marker when drawn (double). The default is 0.01.
N-LEVELS
The number of isocontour levels used in a contour plot (int). The default is 10.
NORMAL-DIRECTION
A flag specifying the normal direction of surface elements in hidden surface
plot (int). The default is 1.
PALETTE
The name of the
palette to use in those plots which need color palettes (char *).
The default is the current palette of the device.
PHI
Value specifying the phi component of the
Euler angles defining the viewing
angle (double). The default is 0.0.
PHI-LIGHT
Value specifiying the phi angle of a light source illuminating a surface plot
(double). The default is 45.0 degrees.
PLOT-TYPE
Flag specifying the plot type
CARTESIAN, POLAR, or INSEL (int). The
default is CARTESIAN.
RATIO
Isocontour spacing ratio (double). The default is 1.0.
SCATTER
Flag specifying that a rendering be done as a scatter plot if TRUE (int). The
default is FALSE.
THETA
Value specifying the theta component of the
Euler angles defining the viewing
angle (double). The default is 0.0.
THETA-LIGHT
Value specifiying the theta angle of a light source illuminating a surface plot
(double). The default is 45.0 degrees.
VIEW-PORT
An array of values in
normalized coordinates (xmin, xmax, ymin, and ymax)
specifying a viewport to be for a plot (double *). The default is defined
by each rendering routine to maximize the area of the plot.
4.3.2 Plots and associated attributes
This section tells which rendering attributes are meaningful to which renderings.4.3.2.1 Contour Plot Attributes
DRAW-AXIS
4.3.2.2 Domain Plot Attributes
CHI
4.3.2.3 Line Plot Attributes
AXIS-TYPE
4.3.2.4 Hidden Surface Attributes
NORMAL-DIRECTION
4.3.2.5 Image Plot Attributes
CORNER
4.3.2.6 Fill Poly Plot Attributes
CORNER
4.3.2.7 Surface Plot Attributes
CHI
4.3.2.8 Vector Plot Attributes
CORNER
5.0 The
PGS API
The application program interface (API) for PGS is presented in this section. There are three language bindings for most functions in PGS: C; Fortran; and SX. SX is a part of PACT as is PGS. It is an extended dialect of the Scheme programming language. What you get using SX is like what you get using C and loading with the PGS library. Keep in mind however that SX is an interpreted language and lends itself to certain applications which are not suitable for C or Fortran. For more on SX see the SX Users Manual.
Each language has its own particular features and consequently there are differences in how the PGS functions are used. We have tried to keep consistency between the bindings in order to help users who are familiar with one or more of the languages involved to be able to use any of them. Some discussion of the language differences is given below and the reader is STRONGLY urged to READ this material before proceeding.
OFF and FALSE mean 0 in all languages
Since there is no accepted standard for how C and Fortran communicate, it is necessary for PGS (and all of PACT) to observe one rule regarding string arguments: two variables are passed. The first is the number of meaningful characters in the string and the second is the string itself.
Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.
5.1
Compiling and Loading
To compile your C programs you must use the following #include <pgs.h>
in the source files which deal with PGS graphics.5.2
PGS 5.2.1
Global State Setting Routines
These routines set state that is global in scope as opposed to device or graph level control.
SX Binding: (pg-define-marker x1 y1 x2 y2 ...)
This routine defines a new marker in terms of a set of line segments. The arguments are the number of segments, n_seg, and arrays specifying the x and y values of the endpoints of each segment. Each array must be n_seg elements long. The values in the arrays must be between -1.0 and 1.0. The marker can be scaled to any size and rotated by using the macros PG_set_marker_scale and PG_set_marker_orientation. The index of the new marker is returned and should be used as values for the MARKER-INDEX attribute where called for.
Set a global mode which the high level rendering routines use to interpret what it means to clear the current picture. There are three interpretations which PGS supports: 1) is to clear the entire PGS window (
SX Binding:
SX Binding: (pg-set-view-angle! theta phi chi)
Set a global default viewing angle for 3D plots. From the observers point of view: phi is a clockwise rotation about the positive z axis; theta is a clockwise rotation about the positive x axis; and chi is a counter-clockwise rotation about the line of sight which is the same as the z axis after the theta and phi rotations have been applied. The theta rotation is done so that a view looking down the z axis (x, y) is turned into a view looking down the y axis (x, z) in the most economical manner - that is with theta equal to 90 degrees.
Get the current value of the global mode which the high level rendering routines use to interpret what it means to clear the current picture. See 5.2.2
Global State Query Routines
SX Binding:
5.2.3
Memory Management Routines
These routines allocate and initialize or release instances of PGS data structures.
SX Binding: (pg-make-device name type title)
Allocate and initialize a new PG_device structure. Name specifies the kind of device wanted (WINDOW, PS, CGM, RASTER). Type specifies whether the device is COLOR or MONOCHROME. Title is either the text of a title bar or the name of an output file as in the case of PS or CGM devices. In the case of PS or CGM devices the title is used as the base of the file name and .ps or .cgm is added as the suffix appropriately. In addition, with PS devices the EPS conformance level can be specified as follows:
base_name [PS-level [EPS-level]]
where PS-level and EPS-level specify the level of conformance. PGS writes very highly conforming files but some applications which would import them cannot recognize standards which are higher or lower than the ones for which they are programmed. This method lets PGS based applications target their applications. Values of 2.0 or 3.0 are most common.
Setup and return a PG_graph using a PM_mapping, f, and rendering information in the alist info. The id is a character which will be used as a starting data-id on a contour plot or as the data-id of a line plot. To chain graphs together so that they may be plotted together next is used to point to the next graph in a chain.
Setup a new instance of a PG_graph and return it. The arguments are: the domain and range sets of the mapping part of the graph; the relative of the centering of the range and domain data; and rendering information in the form of an alist, info, or line color, width and style and an existence map, emap, for the mesh. The label is a string used to label the entire plot and may be plotted in some circumstances. The id is a character which will be used as a starting data-id on a contour plot or as the data-id of a line plot. To chain graphs together so that they may be plotted together next is used to point to the next graph in a chain.
Setup and return a specific kind of graph containing a 2d rectangular domain from arrays x and y and a matching 1d range from array r. The size of the arrays is kmax by lmax. If cp is TRUE the x, y, and r arrays will be copied for the domain and range sets. It is sometimes necessary for the sets to have dynamically allocated spaces or to have spaces which they can safely free when they are released. The id is a character which will be used as a starting data-id on a contour plot. The dname and rname are strings used a labels for the domain and range sets respectively. They are never printed on a plot but would be written out to a data file. The label is a string used to label the entire plot and may be plotted in some circumstances.
Setup and return a specific kind of graph containing a 1d domain from array x and a matching 1d range from array y. The size of the arrays is n. If cp is TRUE the x, y, and r arrays will be copied for the domain and range sets. The reason for this is that it is sometimes necessary for the sets to have dynamically allocated spaces or to have spaces which they can safely free when they are released. The id is a character which will be used as a data-id on a plot. The xname and yname are strings used a labels for the domain and range sets respectively. They are never printed on a plot but would be written out to a data file. The label is a string used to label the entire plot and may be plotted in some circumstances.
This function releases an instance of a PG_graph. If rld is TRUE the data arrays in the domain set will be freed and if rlr is TRUE the data arrays in the range set will be freed.
The arguments to this function are:
type the data type used in the image
(xmn, xmx) the minimum and maximum extent in the x direction
(ymn, ymx) the minimum and maximum extent in the y direction
(zmn, zmx) the minimum and maximum extent in the image data
(k, l) the number of pixels in the x and y direction respectively
bits_pix the number of image bits per pixel (1 for MONOCHROME and typically 8 for COLOR)
palette the palette to be used in rendering the image
F77 Binding:
These two functions create and release PG_image instances. The images are k by l pixels. They have world coordinate extents from xmin to xmax and ymin to ymax. The data ranges from zmin to zmax and is of type type. A palette may be supplied along with a label for a plot.
Clear the page for a text window such as the console. Leave the current line at line i in the PGS window.
Clear the rectangular region, specified in normalized coordinates, of the given device. The limits of the rectangle are xmn, xmx, ymn, and ymx. The pad is a number of pixels to inset the cleared region. This facilitates clearing a region without removing a border line around the region.
Clear the entire PGS window on the specified device.
Clear the current viewport region only on the specified device.
Close the specified device, dev.
Finish the picture on the specified device. Once a picture is finished, nothing more can be drawn to the device until a call to PG_clear_window is done without serious consequences. This is especially necessary for devices such as PS and CGM devices.
Get the x-axis or y-axis log scale flags in the specified device. The argument xls contains the value of the x-axis log flag and yls contains the value of the y-axis log flag on return,
Make the specified device the current device for drawing.
Open a console device at the specified point (xf, yf) with the specified width, dxf, and height, dyf (these are all in normalized coordinates). The console window will have title in the title bar, type, type, and the indicated background color. Type, the window type is one of COLOR or MONOCHROME. Bckgr should be TRUE for white background and FALSE for black background.
Open the specified device at the specified point (xf, yf) with the specified width, dxf, and height, dyf. These values are all normalized to the physical device dimensions. NOTE: to make it easy to create a square window, the actual pixel height of the PGS window is computed as dyf*display_pixel_width!
Release the specified device as the current drawing device. (A few host graphics systems need this functionality).
Set the collection of attributes from the PG_dev_attributes structure attr in the specified device.
Set the x-axis or y-axis log scale flags in the specified device. The argument xls causes the x-axis to be plotted with a log scale if TRUE and yls causes the y-axis to be plotted with a log scale if TRUE.
Set the width of the
Turn on clipping to the current viewport if flag is TRUE and turn off clipping to the current viewport if flag is FALSE on the specified device. NOTE: moving the viewport after turning on the clipping does NOT move the clipping rectangle. To do this turn clipping off and back on again.
Set the fill color for the device to color. The color index is mapped through the current palette.
Set the state of the flag that tells the high level rendering routines whether or not to assume a plot is finished and issue a call to PG_finish_plot. This is crucial when doing multiple plots or adding to a plot after the high level renderer returns.
Set the orientation angle to be applied when drawing markers. Markers can be drawn at any angle. The angle, theta, is a uniform rotation from the positive x axis in the counter-clockwise direction of all the segments comprising the
Set the scale factor to be applied when drawing
To better match the characteristics of varying output devices (especially conventional video) this function scales the overall intensity as well as the intensity of the RGB values down from their maximum of unity. The overall, red, green, and blue values are controlled by osc, rsc, gsc, and bsc respectively.
Set the current palette to be the named one. The built-in palettes are named: standard,
SX Binding:
SX Binding: (pg-make-graph domain range [centering color width style emap name])
SX Binding:
SX Binding:
SX Binding: automatically garbage collected
SX Binding: (pg-build-image dev data k l [name xmn xmx ymn ymx zmn zmx])
SX Binding: automatically garbage collected
5.2.4
Device Control Routines
SX Binding:
SX Binding: (pg-clear-region dev xmn xmx ymn ymx pad)
SX Binding: (pg-clear-window dev)
SX Binding: (pg-clear-viewport dev)
SX Binding:
pgclos(integer dev)
SX Binding: (pg-close-device dev)
SX Binding: (pg-finish-plot dev)
SX Binding:
SX Binding: (pg-make-device-current dev)
SX Binding:
SX Binding: (pg-open-device dev xf yf dxf dyf)
SX Binding: (pg-release-current-device dev)
SX Binding:
SX Binding:
SX Binding: (pg-set-border-width dev t)
SX Binding: (pg-set-clipping! dev flag)
SX Binding: (pg-set-fill-color dev color)
SX Binding: (pg-set-finish-state! dev fin)
SX Binding: (pg-set-marker-orientation! dev theta)
SX Binding: (pg-set-marker-scale! dev v)
SX Binding: (pg-set-maximum-intensity! dev osc rsc gsc bsc)
SX Binding: (pg-set-palette! dev name)
SX Binding: (pg-set-resolution-scale-factor! dev sf)
Set the value of the hardcopy resolution scale factor. Hardcopy devices can be very high resolution devices which can lead to enormous image files. This control lets the application scale down the resolution of the device to keep image files a reasonable size. The default value is 8, that is by default the resolution is a factor of 8 less than could be obtained for the device. This means a factor of 64 in size for raster images.
Set the position of the viewport in the window. The specifications are normalized.
Set the shape of the viewport in the window. The specifications are normalized. The aspect ratio is used iff the height is given as 0.0.
SX Binding:
SX Binding:
SX Binding: (pg-set-autodomain! dev n)
Determine the domain interval from the data iff n or dm is ON.
SX Binding: (pg-set-autoplot! dev n)
Set flag to applications to automatically replot iff n is ON. This is simply a global variable provided by PGS which applications may use to control plotting.
SX Binding: (pg-set-autorange! dev n)
Determine the range interval from the data iff n or rn is ON.
SX Binding: (pg-set-data-id-flag! dev n)
Draw data identifiers on plots iff n is ON.
SX Binding: (pg-set-grid-flag! dev n)
Turn the full axis grid ON or OFF.
SX Binding: (pg-set-scatter-flag! dev n)
Draw 1D data sets as scatter plots iff n is ON.
SX Binding: (pg-update-view-surface dev)
Update the view surface of the specified device. This flushes any buffered graphics to the output medium of the device.
SX Binding: (pg-set-white-background! dev n)
If n is TRUE use a white background otherwise use a black background.
TRUE iff dev is a color PostScript device.
Return the name, type, and title of the device as given in the PG_make_device call which created the device.
Collect and return the selection of attributes from the specified device in a newly allocated PG_dev_attributes structure.
Get the current clipping state for the specified device in flag.
5.2.5 Device Query Routines
SX Binding:
SX Binding: (pg-device-properties dev)
SX Binding:
SX Binding: (pg-clipping? dev)
SX Binding: (pg-finish-state dev)
Return the state of the flag that tells the high level rendering routines whether or not to assume a plot is finished and issue a call to PG_finish_plot.
SX Binding: (pg-marker-orientation dev)
Get the current marker orientation angle of the device. Markers can be drawn at any angle. The angle returned in v is a uniform rotation from the positive x axis in the counter-clockwise direction of all the segments comprising the marker.
SX Binding: (pg-marker-scale dev)
Get the current marker scale factor of the device. Markers can be drawn to any size since they are defined in normalized units (see PG_def_marker). The scale factor returned in s controls the actual size.
SX Binding: (pg-maximum-intensity dev)
Return the maximum intensity aggregate value and the individual values for red, green, and blue colors in the specified device. The values are normalized (0.0 to 1.0).
SX Binding: (pg-palette->list dev name)
Returns a pointer to the palette specified by name.
SX Binding: (pg-palettes dev)
Return a list of palettes available for the specified device.
TRUE iff dev is a PostScript device.
Query the device for size in pixels and color planes. The number of colors which a device supports is 2nplanes.
Query the shape of the window on the device.
Temporarily spawn a window to display the available marker characters on the specified device.
SX Binding:
SX Binding: (pg-query-device dev)
SX Binding: (pg-query-window dev)
SX Binding: (pg-show-markers)
5.2.6 Coordinate Transformation Routines
These routines transform points from one coordinate system to another. The three coordinate systems are: pixel coordinates referring to the integer coordinates of pixels in a device; normalized coordinates whose values range from 0.0 to 1.0 and are device independent; and world coordinates which are user defined coordinates (see PG_set_window) tailored to the particular application at hand.
SX Binding: (pg-pixel->normalized dev ix iy)
Converts (ix, iy) from pixel coordinates to NDC/Screen coordinates (x, y).
SX Binding: (pg-normalized->pixel dev x y)
Converts (x, y) from NDC/Screen coordinates to pixel coordinates (ix, iy).
SX Binding: (pg-normalized->world dev x y)
Converts (x, y) from screen coordinates to world coordinates.
SX Binding: (pg-world->normalized dev x y)
Converts (x, y) from world coordinates to screen coordinates.
5.2.7
Coordinate System and Viewport Control Routines
These routines provide access to the coordinate system and viewport of a PGS window.
SX Binding: (pg-frame dev)
Get the frame of the specified device. The x and y intervals are specified in NDC by (x1, x2) and (y1, y2) respectively.
SX Binding: (pg-viewport dev)
Get the viewport of the specified device. The x and y intervals are specified in NDC by (x1, x2) and (y1, y2) respectively.
SX Binding: (pg-world-coordinate-system dev)
Get the world coordinate system defined relative to the viewport for the specified device. The x and y intervals are specified in WC by (x1, x2) and (y1, y2) respectively.
Restore the current viewport, coordinate transformations, and related graphical state. A previously saved state (see pgsvpa) is referenced by the index n.
Save the current viewport, coordinate transformations, and related graphical state. If n < 0, a new space is internally allocated. Otherwise n is interpreted as an existing state whose space will be reused. Returns an index in n which is to be used with a corresponding call to pgrvpa.
Set the frame of the specified device. The x and y intervals are specified in NDC by (x1, x2) and (y1, y2) respectively.
Set the world coordinate system (defined relative to the viewport) for the specified device finding the limits of the n points in the supplied data arrays. The x and y arrays are specified in WC. Type is the plot type (INSEL, HISTOGRAM, POLAR, CARTESIAN).
Set the viewport of the specified device. The x and y intervals are specified in NDC by (x1, x2) and (y1, y2) respectively.
Set the world coordinate system defined relative to the viewport for the specified device. The x and y intervals are specified in WC by (x1, x2) and (y1, y2) respectively.
SX Binding:
SX Binding:
SX Binding: (pg-set-frame! dev x1 x2 y1 y2)
SX Binding:
SX Binding: (pg-set-viewport! dev x1 x2 y1 y2)
SX Binding: (pg-set-world-coordinate-system! dev x1 x2 y1 y2)
5.2.8
Line
SX Binding: (pg-line-color dev)
SX Binding: (pg-line-style dev)
SX Binding: (pg-line-width dev)
SX Binding: (pg-set-line-color! dev lc)
SX Binding: (pg-set-line-style! dev ls)
SX Binding: (pg-set-line-width! dev lw)
5.2.9
Text Attribute Control Routines
The following provide control over text properties. A good deal of this is either unsupported by many host graphics systems or is superceded by the font based approach common in more modern host graphics systems. Users should preferentially use routines addressing themselves to font and type faces.
SX Binding: (pg-set-char-path! dev x y)
This routine sets the direction along which text will be written.
Set the current character size in normalized coordinates.
This routine sets the spacing between characters in world coordinates.
This routine sets the direction along which characters will be oriented. This is usually orthogonal to the direction along which characters are written.
This routine sets the font in the specified device. Face refers generically to the type face. PGS always supports helvetica, courier, and times. Style refers to the type style and the options are: medium, bold, italic, and bold-italic. Size refers to type size in points.
Set the text color for the specified device.
This routine returns the direction along which text will be written.
Return the current character size in normalized coordinates.
Get the current character size in world coordinates.
This routine returns the spacing between characters in world coordinates.
This routine returns the direction along which characters will be oriented. This is usually orthogonal to the direction along which characters are written.
This routine queries the font in the specified device. Face refers generically to the type face. PGS always supports helvetica, courier, and times. Style refers to the type style and the options are: medium, bold, italic, and bold-italic. Size refers to type size in points. The FORTRAN binding has some extra behavior. The string lengths here are both input and output variables. On input they contain the lengths of the string buffers, face and style. On output they contain the number of actual characters in their respective strings. If the buffers are not long enough pggtxf returns FALSE and does nothing but return the lengths of the strings. The application can then make a second call with larger buffers.
Query the text color for the specified device.
This routine returns the world coordinate extent of the character string s as a width in px and height in py.
This routine returns the normalized coordinate extent of the character string s as a width in px and height in py.
This routine prints a text string, label, on the specified device and centered horizontally with a normalized vertical position specified by sy.
This function is call compatible with the standard C library fgets call. It gets input from the console device, PG_console_device, window if stream is stdin and from a file otherwise. In the FORTRAN binding using 0 for stream results in the use of stdin.
This function is call compatible with the standard C library fprintf call. It prints to the console device, PG_console_device, window if fp is stdout and to a file otherwise.
This routine does an sprintf style print to the specified device, dev, and at the world coordinate point specified by (x, y).
These move the line drawing point (gr) or the text drawing point (tx) to an absolute world coordinate point or relative to the current world coordinate point.
This routine draws a line between two world coordinate points specified by (x1, y1) and (x2, y2).
These draw a line segment on the specified device to the absolute world coordinate point specified or relative to the current world coordinate point. These both reset the current drawing point to the destination endpoint.
This routine draws a connected line on the device, dev, starting with the first point and ending with the last point. The n points are specified in world coordinates and are contained in the x and y arrays. Clp causes the polyline to be clipped to the current viewport if TRUE.
This routine draws n unconnected line segments whose 2n endpoints are specified in the x and y arrays (NOTE: x and y are 2n long!). If flag is TRUE and the device has either range or domain autoranging on, the limits of the points in x and y will be used to reset the world coordinate system. If coord is TRUE the points are taken to be in world coordinates and otherwise in normalized coordinates.
This routine draws a polygon specified by the n world coordinate points in the x and y arrays and fills it with the current fill color (see PG_set_fill_color).
SX Binding:
SX Binding:
SX Binding: (pg-set-char-up! dev x y)
SX Binding: (pg-set-text-font! dev face style size)
SX Binding: (pg-set-text-color! dev tc)
SX Binding: (pg-character-path dev)
SX Binding: (pg-character-size-ndc dev)
SX Binding:
SX Binding:
SX Binding: (pg-character-up dev)
SX Binding: (pg-text-font dev)
SX Binding: (pg-text-color dev)
SX Binding: (pg-text-extent dev s)
SX Binding:
5.2.10
Graphical
SX Binding: (pg-center-label dev sy label)
SX Binding:
SX Binding:
SX Binding: (pg-draw-text-abs dev x y txt)
5.2.11
Point Move Routines
PGS maintains two points, a text point and a drawing point, at which the next text and line drawing operations will start.
SX Binding:
SX Binding:
SX Binding:
5.2.12
Primitive
SX Binding: (pg-draw-line dev x1 y1 x2 y2)
SX Binding:
SX Binding:
SX Binding: (pg-draw-polyline-2d dev clp x1 y1 x2 y2 ...)
SX Binding: (pg-draw-disjoint-polyline-2d dev flag coord x1 y1 x2 y2 x3 y3 x4 y4 ...)
SX Binding: (pg-fill-polygon dev c x1 y1 x2 y2 ...)
5.2.13
Basic
SX Binding: (pg-draw-arc dev r a1 a2 x y unit)
This routine draws an arc with radius, r, in world coordinates from angles a1 to a2 centered about the point (x, y) in world coordinates. Unit controls whether the angle is specified in degrees or radians. See the description for PG_draw_rad below for additional details.
SX Binding: (pg-draw-box dev xmin xmax ymin ymax)
This routine draws a rectangle from xmin to xmax and from ymin to ymax which are specified in world coordinates.
SX Binding: (pg-draw-disjoint-polyline-3d dev theta phi chi flag norm x1 y1 z1 x2 y2
z2 x3 y3 z3 x4 y4 z4 ...)
This routine draws disjoint three dimensional line segments specified in world coordinates. The number of segments, n, is half the number of points. The arrays x, y, and z define the endpoint vectors X. X[2*i] is one endpoint of the ith segment, and X[2*i+1] is the other endpoint. The viewing angle is specified by theta, phi, and chi. The flag norm determines whether the segment will be converted to normalized coordinates, and flag specifies whether the line segments are clipped to the viewport limits.
F77 Binding: integer pgdrmk(integer dev, integer n, real x, real y, integer marker)
SX Binding: (pg-draw-markers dev marker x y)
This routine draws the marker character specified by marker at each of the n world coordinate points defined by the x and y arrays on the specified device.
SX Binding: (pg-draw-radius dev rmin rmax a x y unit)
This routine draws a radial line from the central point (x, y) from rmin to rmax along the direction specified by the angle a (with respect to positive x axis increasing counter-clockwise). If unit has the value DEGREE then the angle a is in degrees and otherwise it is in radians (there is a RADIAN constant for symmetry).
5.2.14
Axis Drawing Routines
These routines handle various aspects of drawing axes. The most basic routine here draws a single axis with very general and controllable characteristics.
SX Binding: (pg-axis device type)
This routine draws a set of axes which are tied to the viewport and world coordinate system. The valid values for axis_type are: CARTESIAN, POLAR, and INSEL. The axes are drawn on the view boundary. See the drawing model section above for the definition of the view boundary.
This routine draws a simple set of 3D axes oriented at the specified angle. The extent of the axes is determined by the n_pts points in (px, py, pz). The view angle for the axes is specified by theta, phi, and chi. The unrotated limits of the data are specified by xmn, xmx, ymn, ymx, zmn, and zmx. If the axes should be drawn to normalized coordinates the norm flag should be TRUE.
SX Binding:
SX Binding: (pg-draw-axis dev xl yl xr yr t1 t2 v1 v2 sc format tick_type label_type
tickdef)
This routine will draw a single axis and produce labels and/or ticks depending on the arguments. The arguments are:
(xr, yr) coordinate of terminating end
(t1, t2) fractional position of v1 and v2
(v1, v2) first and last tick or label value
sc an additional scale factor which is used, for example, when doing an
Inselberg axis in which the range may correspond to one appropriate for the
perpendicular dimension (set to 1.0 in most cases)
format specifies the label format in the standard C way
tick_type types of ticks
An axis is a directed line segment (from Xl to Xr) with ticks. The label values as defined by v1, v2, t1, and t2; the ticks associate with the line segment as follows:
This routine sets the parameters which control the look of the axes being drawn. An arbitrary number of specifications can be made in key/value pairs. The list is terminated with a zero key. In the F77 binding the key/value pairs are placed as floating point numbers in the array attr. The value n is the number of pairs. If the attribute is a character string, the value is put in the character array attrs, and the number of characters is put in attr as the attribute value following the attribute key. The character strings are packed together with no space between the attribute values. This also means that the order of the attributes in the array attr must match those in attrs since only the number of characters is used to associate the attribute with its position in the string attrs.
AXIS_LINESTYLE integer 1 style of the lines
AXIS_LINETHICK real 2 thickness of the lines
AXIS_LINECOLOR integer 3 color of the lines
AXIS_LABELCOLOR integer 4 color of the labels
AXIS_LABELFONT char * 6 label font type face
AXIS_LABELPREC integer 7 character precision
AXIS_X_FORMAT char * 8 format of the x labels
AXIS_Y_FORMAT char * 9 format of the y labels
AXIS_TICKSIZE real 10 tick size in fraction of axis length
AXIS_GRID_ON integer 11 turn on grid iff TRUE
AXIS_SIGNIF_DIGIT integer 12 number of digits in labels
AXIS_CHAR_ANGLE real 13 orientation angle for label
characters (not supported on
all devices)
F77 Binding: integer pggaxd(real d)
This routine returns the current maximum number of decades that log axes will span in the argument d. This facility is primarily aimed at making the use of logarithmic axes more flexible by defining a user controlled limit to the number of decades plotted. In this way, potentially ill-defined logarithmic values (such as very small positive numbers) dont interfere with the display of otherwise fine values.
This routine sets the current maximum number of decades that log axes will span to the value of the argument d. This facility is primarily aimed at making the use of logarithmic axes more flexible by defining a user controlled limit to the number of decades plotted. In this way, potentially ill-defined logarithmic values (such as very small positive numbers) dont interfere with the display of otherwise fine values.
Display the colormap for the current
This routine pops up a temporary new window to display the palettes available for the specified device. The user may browse through the palettes and select one to be the new current palette. When the selection is made the palette window goes away. The type argument specifies the type of device to be spawned (WINDOW, PS, or CGM), this is useful for making hardcopies of the palette set. The wbck argument is TRUE if a white background is wanted and FALSE for a black one.
This function reads a palette file and makes the resulting palette the current palette of the specified device. The format of a palette file is simple. It is an ASCII file whose first line contains the name of the palette and the number of colors, nc. The next nc lines contain normalized red, green, and blue values.
This function writes a specified palette, pal, to a palette file. The format of a palette file is simple. It is an ASCII file whose first line contains the name of the palette and the number of colors, nc. The next nc lines contain normalized red, green, and blue values.
This routine draws the graph specified by data on the device specified by dev. The PG_graph structure contains both data and rendering specifications.
This routine draws the domain set specified by dom on the device specified by dev. The PM_set structure contains the data. This is the generalization of a mesh plot. A range set, ran, may optionally be provided if labels or other information associated with the mesh points are desired. The FORTRAN and SX bindings do not allow a range to be given at this time. The SX binding does allow for plotting limits to be set on the domain. They are specified by n (min, max) pairs where n is the dimensionality of the domain. The plot type may also be directly specified as PLOT_SURFACE, PLOT_MESH, or PLOT_WIRE_MESH instead of in the attribute list of the PM_set. The default is PLOT_WIRE_MESH
Return the identifier character, id, of the specified graph. In the C binding this is a macro.
Return the attribute list, alst, of the specified graph. In the C binding this is a macro.
Restrict the domain of the mapping contained in the graph to the values in the array v. There are 2n values in (min, max) pairs where n is the dimensionality of the domain.
Set the identifier character, id, of the specified graph. In the C binding this is a macro.
Set the attribute list, alst, of the specified graph. In the C binding this is a macro.
Set a single rendering attribute in the specified graph. The name of the attribute is in name, its type in type and its value in val. See the section on attributes for more information on attributes and their values.
Set the plot type, plt, and axis type, axs, for the specified association list, inf. This list is usually the info part of a PG_graph.
Restrict the range of the mapping contained in the graph to the values in the array v. There are 2n values in (min, max) pairs where n is the dimensionality of the range.
A PG_graph may have its own viewport limits which supercede the device viewport limits. This function takes an array, v, containing the limits and attaches them to the info list of the specified graph, grid. The limits are arranged as xmin, xmax, ymin, ymax.
This routine is a moderately high level routine in that it will call the other routines depending on the values in the association list info and plot the n points in the x and y arrays. In the FORTRAN binding the following attributes may be passed directly:
axt axis type (CARTESIAN, POLAR, INSEL)
col line color
wid line width
sty line style
sca scatter plot flag
mrk marker index
sta histogram starting point ( l if FALSE the world coordinates are recomputed from the data and the axes are
drawn
F77 Binding: use pgplot
These routines plot the n points in the x and y arrays as a: rectangular cartesian plot; histogram plot; Inselberg plot; or polar plot. The qualifying arguments are:
lnwid line width
lnsty line style
scatter TRUE for scatter plot
marker index of marker character for scatter plots
start LEFT, l if TRUE the world coordinate system is redefined by x and y data
This routine renders the specified graph as a contour plot. PG_draw_graph dispatches to this routine when the rendering specified in data is a contour plot.
Make a contour plot of the given
z data array
lev contour level value array
(k, l) array dimensions
nlev number of contour levels
labl starting label character if non-zero
alst an integer attribute list identifier (use 0 if none)
Compute an array of nlev iso contour levels between fmn and fmx using the spacing ratio. Put them in the space provided, lev. The arguments are:
nlev the number of contour levels
(fmn, fmx ) the minimum and maximum values for contour levels
ratio the spacing ratio between contour levels
This routine renders the specified graph as a filled polygon plot. PG_draw_graph dispatches to this routine when the rendering specified in data is a a filled polygon plot.
This routine renders the specified graph as a raster image plot. PG_draw_graph dispatches to this routine when the rendering specified in data is an image plot.
This routine makes an image plot from a PG_image structure. A pointer to the image is in im and a label for the plot is in label.
This routine makes an image plot from raw data. The arguments are:
type the type of the data (char, short, int, long, float, double)
z the array of pixel values (will be scaled to the current palette of the
device)
(k, l) the dimensions of the image
(xmn, xmx) the minimum and maximum x values (for axis labels)
(ymn, ymx) the minimum and maximum y values (for axis labels)
(zmn, zmx) the nminimum and maximum data values (for palette labels)
alst an integer attribute list identifier (use 0 if none)
F77 Binding: integer pgdrpa(integer devid, REAL xmn, REAL ymn, REAL xmx,
REAL ymx, REAL zmn, REAL zmx, REAL wid)
This routine draws the specified device palette as a raster image. The palette is drawn next to the viewport in a rectangle along an axis specified by the points (xmn, ymn) and (xmx, ymx). The axis is labeled by values ranging from zmn to zmx. The width of the palette in the rectangle is specified in normalized form by wid.
This routine renders the specified graph as a surface plot. PG_draw_graph dispatches to this routine when the rendering specified in data is a surface plot.
This routine is a medium level routine which can be called directly from applications. The data can be rendered as a wire frame mesh or as a true shaded surface. Both forms do hidden line and hidden surface removal. The algorithm uses a raster scan line approach with a single Z buffer line. This choice minimizes the memory requirements of the routine at some expense of speed.
a1, a2 the arrays specifying height of the surface and color shading. If
the color array is NULL the a1 array will do both height and color in a shaded
plot
aext the minimum and maximum values for a1 and a2
x, y the x and y components of the positions of the nodes
nn the number of points
xmn, xmx the minimum and maximum values for x
ymn, ymx the minimum and maximum values for y
theta, phi, chi the Euler view angles
width the line width to use
color the line color to use
style the line style to use
type PLOT_SURFACE or name a label for the plot
mesh_type Logical-Rectangular (LR) or cnnct connectivity specifications: array of dimensions for LR meshes
or a pointer to a PM_mesh_topology struct for AC meshes
alist association list of plotting attributes
This routine renders the specified graph as a vector plot. PG_draw_graph dispatches to this routine when the rendering specified in data is a vector plot.
Make a vector plot of the given
(px, py) farrays containing the x and y positions
(pu, pv) farrays containing the u and v vector components
n an integer number of vectors
alst an integer attribute list identifier (use 0 if none)
This routine sets the properties of the vectors for the next vector plot. The parameters are paired, optional, and can be in any order. For each pair, the first value describes the option, the second, the value. The options are ints. The values can be ints, REALs, or chars. What type the values are is determined by the option. Most values are normalized to unity with the angle being the exception. The list must be ended with a zero. The attributes are:
This routine renders the specified graph as a level diagram plot. PG_draw_graph dispatches to this routine when the rendering specified in data is a level diagram plot. These graphs have an unusual data layout and would not produce a very meaningful plot rendered any other way.
This routine draws the entire graphical interface of the specified device.
This routine reads the entire graphical interface from the named file into the specified device.
This routine registers a function with PGS so that it may be called by an
This routine registers a variable with PGS so that its value may be changed by an
This routine writes the entire graphical interface of the specified device to the named file.
RIGHT_OF_AXIS ticks on right
LEFT_OF_AXIS ticks on left
STRADDLE_AXIS ticks straddle (both)
label_type types of labels
RIGHT_OF_AXIS labels on right
LEFT_OF_AXIS labels on left
NOTHING_ON_AXIS no labels
ENDS labels at ends of axis
tickdef specifies the labels and ticks - one or more may be given and the list is
terminated with a value of 0.
MAJOR major ticks
MINOR minor ticks
LABEL labels
flag if TRUE return a pointer to a PG_axis def structure (this is mainly for
internal use) otherwise return NULL.
SX Binding:
SX Binding:
SX Binding:
5.2.15
Colormap Related Routines
SX Binding:
SX Binding: (pg-show-palettes dev wbck)
SX Binding: (pg-make-palette dev name nc wbck)
SX Binding: (pg-read-palette dev fname)
SX Binding: (pg-write-palette dev pal fname)
5.2.16
Graph Control Routines
SX Binding: (pg-draw-graph dev [data]* rendering)
SX Binding: (pg-draw-domain dev [dom]* [type extrema])
SX Binding:
SX Binding:
SX Binding: (pg-set-domain-limits! gr v1mn v1mx ...)
SX Binding:
SX Binding:
SX Binding: (pg-set-graph-attribute! gr name type val)
SX Binding:
SX Binding: (pg-set-range-limits! gr v1mn v1mx ...)
SX Binding:
5.2.17
Line
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
5.2.18
Contour
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
SX Binding: set LEVEL attribute
5.2.19
Filled Polygon Plot Routines
SX Binding: use pg-draw-graph
5.2.20
Image
SX Binding: use pg-draw-graph
SX Binding: (pg-draw-image dev im)
SX Binding:
SX Binding: (pg-draw-palette dev xmn ymn xmx ymx zmn zmx wid)
5.2.21
Surface
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
5.2.22
Vector
SX Binding: use pg-draw-graph
SX Binding: use pg-draw-graph
SX Binding: (pg-set-vector-attributes! dev ...)
C Id FORTRAN Id Description Default
VEC_SCALE 1
VEC_ANGLE 2
VEC_HEADSIZE 3
VEC_FIXSIZE 4 a
VEC_MAXSIZE 5 a
VEC_LINESTYLE 6
VEC_LINETHICK 7
VEC_COLOR 8
VEC_FIXHEAD 9 a 5.2.23
Level Diagram
SX Binding: use pg-draw-graph
5.2.24 Graphical Interface Routines
These routines supply a capability for applications to develop portable, user and runtime configurable graphical user interfaces.
SX Binding:
SX Binding:
MOUSE_CENTER,
SX Binding:
SX Binding:
SX Binding:
SX Binding:
5.3
Structures
PG_graph
The PG_graph structure contains information specifying how data is to be rendered. That includes specification of the typedef PG_graph *(*
PFPPG_graph)();
The last type is a Pointer to a Function returning a Pointer to a PG_GRAPH. This convention is used throughout PACT. See the related documentation for further information.
PG_palette
The PG_palette structure contains the specification of a
PG_device
The PG_device structure contains the information which the host graphics system requires applications to provide and maintain and it keeps a set of
PG_image
The PG_image structure contains the specification for cell array or image plots. It contains data, the data type, the array dimensions, bounding values for use in defining scales, palette information, and other appropriate data.
PG_dev_attributes
The PG_dev_attributes structure contains a large number of the commonly queried and set attributes found in the PG_device. The intent of this structure is to allow applications to access and change many device attributes quickly and efficiently. The attributes include line, text, and fill colors, line style and width, palette, and clipping state. It is convenient to save these all at once in a PG_dev_attributes, change the device state, perform drawing operation, and restore the original device state from the PG_dev_attributes.
5.4
PGS Constants
PGS defines and uses several #defined constants. These can be used by applications and are listed here by category.
General Purpose Constants
PG_IMAGE_VERSION 0
Device Characterization Constants
TEXT_WINDOW_DEVICE 128
Rendering Clear Mode Constants
CLEAR_SCREEN -5
Axis Description Constants
AXIS_LINESTYLE 1
Grid Description Constants
GRID_LINESTYLE 1
Vector Description Constants
VEC_SCALE 1
Rendering Mode Constants
PLOT_CURVE 10
6.0
Glossary
Here is a list of terms which are used in this manual.
console A special device which mimics a UNIX shell window on platforms which lack that functionality (e.g. Macintosh)
NDC Normalized device coordinates or screen coordinates. Values range between 0.0 and 1.0.
image An array of pixel values also called a raster image or cell array
graph Generically the collection of information needed to visualize a collection of data. More specifically a PG_graph structure.
set Generically a collection of related data. More specifically a PM_set structure.
mapping Generically a rule of association between elements of two sets. More specifically a PM_mapping structure.
palette An application oriented representation of a color scheme to be associated with data in a plot.
colormap A host oriented representation of a color scheme to be associated with colors in hardware.
marker A user definable character. A collection of line segments which can be rotated and scaled collectively.
connectivity The collection of neighbor relationships between points of a computational mesh.
7.0
PGS By Example
Perhaps the best way to learn to use PGS is by example. Certainly it is the easiest way to explain certain aspects of it. In this section there are examples of some of the low level graphics primitives and the high level rendering functions. The actual tests are:
Text Placement and Drawing
Line Drawing
Making Line Plots
Making Contour Plots
Making Image Plots
Making Wire Frame Mesh Plots
Making Vector Plots
Before showing the examples we discuss some sequences of PGS calls that are common to most PGS applications. The hope is that this will make clear why some of PGS functions exist and how they relate to one another.7.1
Common Call Sequences
The PGS functions are generally not very meaningful taken one at a time. What is important is the way they are used together to accomplish various graphical objectives. We are not focusing on the details of the calls here so many details are omitted. Concentrate on which calls are being made and when they are performed.7.1.1
Initializing a Device
The first basic job in a graphics application is to setup the devices to be used. Most common is setting up screen windows. Also important is initializing hardcopy devices such as a PostScript device. The sequence is all the same, some of the parameters differ. dev =
PG_make_device(...);
PG_set_viewport_pos(dev, ...);
PG_set_viewport_shape(dev, ...);
PG_white_background(dev, ...);
PG_open_device(dev, ...)
The PG_make_device call only allocates a PG_device structure and sets default values for the state it contains. The PG_open_device call actually consults the state of the PG_device and opens the device. The calls in between change the state of the PG_device from the defaults.
7.1.2
Making a Picture
The next basic idea is to put together a picture. This may be done with low level drawing operations or high level rendering calls or both. What is common to all is that the picture must be set up, drawn, and finished.
PG_clear_window(dev);
...
draw
...
PG_update_vs(dev);
...
PG_finish_plot(dev);
The call to PG_clear_window must be done for hardcopy devices! It is a pretty good idea for screen window devices too. Sometimes in the process of drawing a picture you want to see the results so far with the idea that more will be drawn later. PG_update_vs makes sure that everything the has been requested is visible. When the picture is complete and there is nothing more to be drawn to it, PG_finish_plot is called. This is crucial for hardcopy devices! It is also crucial that PG_clear_window and PG_finish_plot be called once per picture.
7.1.3
Setting Attributes
To gain control of the appearance of high level plots, applications must set rendering attributes. See the discussion of rendering attributes before going any further here. The sequence is to use PG_get_render_info to obtain the attribute list from the graph, use SC_change_alist to change or add values to the list, and use PG_set_render_info to update the graphs attribute list.
Here are C and FORTRAN examples of setting some attributes in a graph. In this example some attributes are set for contour plotting.
PG_graph *g;
pcons *alst;
double *clev;
int *nlev;
nlev = MAKE(int);
*nlev = 6;
clev = MAKE_N(double, *nlev);
PG_get_render_info(g, alst);
alst = SC_change_alist(alst, LEVELS, double *, clev);
alst = SC_change_alist(alst, N-LEVELS, int *, nlev);
PG_set_render_info(g, alst);
integer gid, ial, nlev
real clev(10)
call
pgginf (gid, ial)
call scchal (ial, 6, LEVELS, 6, double, nlev, clev)
call scchal (ial, 8, N-LEVELS, 7, integer, 1, nlev)
call
pgsinf (gid, ial)
7.2
Text Placement and Drawing
The following program demonstrates some of the PGS functionality for placement and drawing of text.
#include
pgs.h
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
void main(argc, argv)
int argc;
char *argv[];
{char s[MAXLINE], *token;
PG_device *SCR_dev, *PS_dev, *CGM_dev;
REAL x1, y1, x2, y2, dx, dy;
char *face, *style;
int size;
/* connect the I/O functions */
PG_open_console(PGS Test, COLOR, TRUE, 0.1, 0.7, 0.5, 0.3);
SCR_dev = PG_make_device(WINDOW, COLOR, PGS Test);
PG_open_device(SCR_dev, 0.1, 0.1, 0.5, 0.6);
PG_set_viewport(SCR_dev, 0.1, 0.9, 0.2, 0.8);
PG_set_window(SCR_dev, 0.0, 1.0, 0.0, 1.0);
PG_draw_box(SCR_dev, -0.02, 1.02, -0.02, 1.02);
CGM_dev = PG_make_device(CGM, MONOCHROME, gstxts);
PG_open_device(CGM_dev, 0.1, 0.1, 0.8, 0.8);
PS_dev = PG_make_device(PS, MONOCHROME, gstxts);
PG_open_device(PS_dev, 0.1, 0.1, 0.8, 1.1);
PG_expose_device(PG_console_device);
PG_clear_window(SCR_dev);
PG_clear_window(CGM_dev);
PG_clear_window(PS_dev);
test_dev(SCR_dev);
test_dev(CGM_dev);
test_dev(PS_dev);
PG_finish_plot(SCR_dev);
PG_finish_plot(CGM_dev);
PG_finish_plot(PS_dev);
SC_pause();
PG_close_device(SCR_dev);
PG_close_device(CGM_dev);
PG_close_device(PS_dev);
exit(0);}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* SF_DT - set the font and draw the text */
static void sf_dt(dev, x1, y1, face, style, size)
PG_device *dev;
double x1, y1;
char *face, *style;
int size;
{double x2, y2, dx, dy;
PG_set_font(dev, face, style, size);
PG_get_text_ext(dev, foo, &dx, &dy);
/* write some text and draw a box around it */
PG_write_abs(dev, x1, y1, %s, foo);
x2 = x1 + dx;
y2 = y1 + dy;
PG_draw_box(dev, x1, x2, y1, y2);
return;}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* TEST_DEV - test the entire device */
static void test_dev(dev)
PG_device *dev;
{PG_set_line_color(dev, dev->BLACK);
PG_set_text_color(dev, dev->BLACK);
sf_dt(dev, .1, .9, helvetica, medium, 12);
sf_dt(dev, .1, .8, helvetica, italic, 12);
sf_dt(dev, .1, .7, helvetica, bold, 12);
sf_dt(dev, .1, .6, helvetica, bold-italic, 12);
sf_dt(dev, .1, .50, helvetica, medium, 10);
sf_dt(dev, .1, .45, helvetica, italic, 10);
sf_dt(dev, .1, .40, helvetica, bold, 10);
sf_dt(dev, .1, .35, helvetica, bold-italic, 10);
sf_dt(dev, .1, .30, helvetica, medium, 8);
sf_dt(dev, .1, .25, helvetica, italic, 8);
sf_dt(dev, .1, .20, helvetica, bold, 8);
sf_dt(dev, .1, .15, helvetica, bold-italic, 8);
sf_dt(dev, .3, .9, times, medium, 12);
sf_dt(dev, .3, .8, times, italic, 12);
sf_dt(dev, .3, .7, times, bold, 12);
sf_dt(dev, .3, .6, times, bold-italic, 12);
sf_dt(dev, .3, .50, times, medium, 10);
sf_dt(dev, .3, .45, times, italic, 10);
sf_dt(dev, .3, .40, times, bold, 10);
sf_dt(dev, .3, .35, times, bold-italic, 10);
sf_dt(dev, .3, .30, times, medium, 8);
sf_dt(dev, .3, .25, times, italic, 8);
sf_dt(dev, .3, .20, times, bold, 8);
sf_dt(dev, .3, .15, times, bold-italic, 8);
sf_dt(dev, .5, .9, courier, medium, 12);
sf_dt(dev, .5, .8, courier, italic, 12);
sf_dt(dev, .5, .7, courier, bold, 12);
sf_dt(dev, .5, .6, courier, bold-italic, 12);
sf_dt(dev, .5, .50, courier, medium, 10);
sf_dt(dev, .5, .45, courier, italic, 10);
sf_dt(dev, .5, .40, courier, bold, 10);
sf_dt(dev, .5, .35, courier, bold-italic, 10);
sf_dt(dev, .5, .30, courier, medium, 8);
sf_dt(dev, .5, .25, courier, italic, 8);
sf_dt(dev, .5, .20, courier, bold, 8);
sf_dt(dev, .5, .15, courier, bold-italic, 8);
PG_update_vs(dev);
return;}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
7.3
Line Drawing
This program illustrates some of the PGS calls for handling drawing attributes and for drawing lines.
#include
pgs.h
char
*color[] = {BLACK,
WHITE,
LGHT_WHITE
GRAY,
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LGHT_BLUE,
LGHT_GREEN,
LGHT_CYAN,
LGHT_RED,
YELLOW,
LGHT_MAGENTA};
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
main(argc, argv)
int argc;
char *argv[];
{PG_device *SCR_dev;
PG_device *SCR_dew;
REAL y, dy;
int i, n;
SCR_dev =
PG_make_device(WINDOW, COLOR, PGS Test A);
SCR_dew =
PG_make_device(WINDOW, COLOR, PGS Test B);
PG_set_viewport_pos(SCR_dev, 0.0001, 0.0001);
PG_set_viewport_shape(SCR_dev, 0.9999, 0.0, 1.0);
PG_set_viewport_pos(SCR_dew, 0.0001, 0.0001);
PG_set_viewport_shape(SCR_dew, 0.9999, 0.0, 1.0);
PG_white_background(SCR_dev, TRUE);
PG_white_background(SCR_dew, FALSE);
PG_open_device(SCR_dev, 0.1, 0.1, 0.4, 0.4);
PG_open_device(SCR_dew, 0.5, 0.1, 0.4, 0.4);
/* connect the I/O functions */
PG_open_console(PGS Test, MONOCHROME, 0.1, 0.7, 0.5, 0.3);
PG_set_viewport(SCR_dev, 0.0, 1.0, 0.0, 1.0);
PG_set_window(SCR_dev, 0.0, 1.0, 0.0, 1.0);
PG_set_viewport(SCR_dew, 0.0, 1.0, 0.0, 1.0);
PG_set_window(SCR_dew, 0.0, 1.0, 0.0, 1.0);
n = 16;
dy = 1.0/(n + 1.0);
y = 0.5*dy;
for (i = 0; i < n; i++)
{PG_set_line_color(SCR_dev, i);
PG_draw_line(SCR_dev, 0.0, y, 0.5, y);
PG_set_text_color(SCR_dev, i);
PG_write_abs(SCR_dev, 0.6, y, %d %s, i, color[i]);
PG_set_line_color(SCR_dew, i);
PG_draw_line(SCR_dew, 0.0, y, 0.5, y);
PG_set_text_color(SCR_dew, i);
PG_write_abs(SCR_dew, 0.6, y, %d %s, i, color[i]);
y += dy;};
PG_update_vs(SCR_dew);
PG_update_vs(SCR_dev);
SC_pause();
PG_close_device(SCR_dew);
PG_close_device(SCR_dev);
exit(0);}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
7.4
Line Plots
This program demonstrates some of the line plot capabilities of PGS.
#include
pgs.h
#define N 50
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
main(argc, argv)
int argc;
char **argv;
{int i;
REAL *x, *y;
char *s;
PG_graph *data;
PG_device *SCR_dev, *SCR_dew, *PS_dev;
s = SC_strsave(WINDOW);
for (i = 1; i < argc; i++)
if (argv[i][0] == -)
{switch (argv[i][1])
{case h : i++;
s = argv[i];
break;};};
x = MAKE_N(REAL, N);
y = MAKE_N(REAL, N);
for (i = 0; i < N; i++)
{x[i] = -(i+1)/8.0;
y[i] = 6.022e23/x[i];};
data =
PG_make_graph_1d(A, Test Data #1, FALSE, N,
x, y, X Values, Y Values, 1, 0.0, 1);
PG_open_console(GSTEST, MONOCHROME, 1,
0.05, 0.7, 0.9, 0.20);
/* set up the left window */
SCR_dev =
PG_make_device(s, COLOR, PGS Test A);
PG_white_background(SCR_dev, TRUE);
PG_turn_data_id(SCR_dev, ON);
PG_open_device(SCR_dev, 0.05, 0.2, 0.45, 0.45);
/* set up the right window */
SCR_dew =
PG_make_device(s, COLOR, PGS Test B);
PG_white_background(SCR_dew, FALSE);
PG_turn_data_id(SCR_dew, ON);
PG_open_device(SCR_dew, 0.5, 0.2, 0.45, 0.45);
/* set up the hard copy device */
PS_dev =
PG_make_device(PS, MONOCHROME, PGS Test);
PG_turn_data_id(PS_dev, ON);
PG_open_device(PS_dev, 0.0, 0.0, 0.0, 0.0);
PG_set_plot_type(SCR_dev, CARTESIAN);
PG_draw_graph(SCR_dev, data);
PG_set_plot_type(PS_dev, CARTESIAN);
PG_draw_graph(PS_dev, data);
SC_pause();
PG_set_plot_type(SCR_dew, POLAR);
PG_draw_graph(SCR_dew, data);
PG_set_plot_type(PS_dev, POLAR);
PG_draw_graph(PS_dev, data);
SC_pause();
PG_set_plot_type(SCR_dev, INSEL);
PG_draw_graph(SCR_dev, data);
PG_set_plot_type(PS_dev, INSEL);
PG_draw_graph(PS_dev, data);
SC_pause();
for (i = 0; i < N; i++)
{x[i] = i/8.0;
y[i] = cos(x[i]);};
data =
PG_make_graph_1d(B, Test Data #2, FALSE, N,
x, y, X Values, Y Values, 2, 0.0, 1);
PG_turn_grid(SCR_dev, ON);
PG_turn_grid(SCR_dew, ON);
PG_turn_grid(PS_dev, ON);
PG_set_plot_type(SCR_dew, POLAR);
PG_draw_graph(SCR_dew, data);
PG_set_plot_type(PS_dev, POLAR);
PG_draw_graph(PS_dev, data);
SC_pause();
PG_set_plot_type(SCR_dev, INSEL);
PG_draw_graph(SCR_dev, data);
PG_set_plot_type(PS_dev, INSEL);
PG_draw_graph(PS_dev, data);
SC_pause();
PG_set_plot_type(SCR_dew, CARTESIAN);
PG_draw_graph(SCR_dew, data);
PG_set_plot_type(PS_dev, CARTESIAN);
PG_draw_graph(PS_dev, data);
SC_pause();
PG_close_device(SCR_dev);
PG_close_device(SCR_dew);
PG_close_device(PS_dev);
exit(0);}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
7.5
Contour Plots
This program illustrates the PGS contour plotting functionality.
#include
pgs.h
#define NPLOTS 1
PG_graph
*dataset;
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* MAIN - start it off here */
main()
{int i, k, l, kmax, lmax, kxl;
int id, lncolor, lnstyle, centering;
REAL *x, *y, *f, r, t, lnwidth;
REAL xmin, xmax, ymin, ymax, fmin, fmax;
PG_device *SCR_dev, *PS_dev;
dataset = MAKE_N(
PG_graph, NPLOTS);
mark = MAKE_N(int, NPLOTS);
/* set up the graphics window */
SCR_dev =
PG_make_device(WINDOW, COLOR, PGS Contour Test);
PG_open_device(SCR_dev, 0.05, 0.2, 0.45, 0.45);
PS_dev =
PG_make_device(PS, MONOCHROME, PGS Contour Test);
PG_open_device(PS_dev, 0.0, 0.0, 0.0, 0.0);
PG_set_viewport_pos(SCR_dev, 0.25, 0.15);
PG_set_viewport_shape(SCR_dev, 0.5, 0.0, 0.5/0.3333);
PG_white_background(SCR_dev, TRUE);
PG_set_border_width(SCR_dev, 5);
/* set up data */
kmax = 20;
lmax = 20;
xmin = -5.0;
xmax = 5.0;
ymin = -5.0;
ymax = 5.0;
kxl = kmax*lmax;
x = MAKE_N(REAL, kxl);
y = MAKE_N(REAL, kxl);
f = MAKE_N(REAL, kxl);
id = A;
lncolor = SCR_dev->BLUE;
lnwidth = 0.0;
lnstyle = SOLID;
centering = FALSE;
for (k = 0; k < kmax; k++)
for (l = 0; l < lmax; l++)
{i = l*kmax + k;
x[i] = k/10.0 - 5.0;
y[i] = l/10.0 - 5.0;
r = x[i]*x[i] + y[i]*y[i];
t = 5.0*atan(y[i]/(x[i] + SMALL));
r = pow(r, 0.125);
f[i] = exp(-r)*(1.0 + 0.1*cos(t));};
PG_iso_limit(f, kxl, &fmin, &fmax);
dataset =
PG_make_graph_r2_r1(id, contour, FALSE,
kmax, lmax, centering, x, y, f,
xy, f,
lncolor, lnwidth, lnstyle);
data->info =
PG_set_tds_info(data->info, PLOT_CONTOUR, CARTESIAN,
lnstyle, lncolor, 10, 1.0,
lnwidth, 0.0, 0.0, 0.0, HUGE);
PG_contour_plot(SCR_dev, dataset);
PG_contour_plot(PS_dev, dataset);
SC_pause();
PG_close_device(SCR_dev);
PG_close_device(PS_dev);
exit(0);}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
7.6
Image Plots
PGS has facilities for manipulating cell array data and rendering such data sets. In PGS these are referred to as image plots. The following program generates and plots some images.
#include
pgs.h
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
main()
{int k, l;
int X_max, Y_max;
double dx, dy, x, y, sf;
char *s;
PG_palette *pl;
PG_image *calc_im;
PG_device *SCR_dev, *SCR_dew, *PS_dev;
unsigned char *bf, *p;
X_max = 250;
Y_max = 250;
calc_im =
PG_make_image(Test Image, SC_CHAR_S,
0.0, 0.0, 0.0, 0.0, -1.0, 1.0,
X_max, Y_max, 4, NULL);
if (calc_im == NULL)
{PRINT(stdout, CANT ALLOCATE IMAGE);
exit(1);};
PG_open_console(GSIMTS, MONOCHROME, 1,
0.05, 0.7, 0.9, 0.20);
SCR_dev =
PG_make_device(WINDOW, COLOR, PGS Image Test);
PG_background_white(SCR_dev, FALSE;
PG_open_device(SCR_dev, 0.05, 0.1, 0.4, 0.4);
SCR_dew =
PG_make_device(s, COLOR, PGS Image Test);
PG_background_white(SCR_dew, TRUE);
PG_open_device(SCR_dew, 0.55, 0.1, 0.4, 0.4);
PS_dev =
PG_make_device(PS, COLOR, PGS Test);
PG_open_device(PS_dev, 0.0, 0.0, 0.0, 0.0);
PG_set_viewport(SCR_dev, 0.0, 1.0, 0.0, 1.0);
PG_set_window(SCR_dev, 0.0, 1.0, 0.0, 1.0);
PG_set_viewport(SCR_dew, 0.0, 1.0, 0.0, 1.0);
PG_set_window(SCR_dew, 0.0, 1.0, 0.0, 1.0);
/* draw the first image */
bf = calc_im->buffer;
pl =
PG_set_palette(SCR_dev, bw);
sf = pl->n_pal_colors;
for (l = 0; l < Y_max; l++)
{for (k = 0; k < X_max; k++)
*bf++ = sf*((double) k)*((double) (Y_max - l - 1))/
((double) Y_max*X_max);};
PG_draw_image(SCR_dev, calc_im, Test Data A);
PG_set_palette(PS_dev, bw);
PG_draw_image(PS_dev, calc_im, Test Data HC);
SC_pause();
/* draw the second image */
dx = 2.0*PI/((double) X_max);
dy = 2.0*PI/((double) Y_max);
bf = calc_im->buffer;
pl =
PG_set_palette(SCR_dew, rainbow);
sf = pl->n_pal_colors;
for (l = 0; l < Y_max; l++)
{for (k = 0; k < X_max; k++)
{x = ((double) k)*dx;
y = ((double) (Y_max - l - 1))*dy;
*bf++ = sf*(0.5 + 0.5*sin(x)*cos(y));};};
PG_clear_window(SCR_dew);
PG_draw_image(SCR_dew, calc_im, Test Data B);
SC_pause();
PG_close_device(SCR_dev);
PG_close_device(SCR_dew);
PG_close_device(PS_dev);
PG_rl_image(calc_im);
exit(0);}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
7.7
Surface Plots
PGS also has the ability to render data sets as wire-frame meshes with hidden line removal. The following program shows how this is done.
#include pgs.h
#define N_POINTS 10
static void
DECLARE(draw_set, (PG_device *SCR_dev, PG_device *PS_dev,
PG_device *CGM_dev, REAL *rz, REAL *rs, REAL *ext,
REAL *rx, REAL *ry, int n_pts,
double xmn, double xmx, double ymn, double ymx,
double theta, double phi, double width,
int color, int style, int type, int *maxes)),
DECLARE(print_help, (byte));
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
main(argc, argv)
int argc;
char **argv;
{int i, k, l;
int maxes[2], X_max, Y_max, n_pts, use_color, type;
double x, y, dx, dy, theta, phi, dp;
char *s, t[MAXLINE], *token;
PG_device *SCR_dev, *PS_dev, *CGM_dev;
REAL *rx, *ry, *rz, *rs, *px, *py, *pz, *ps, *ext;
X_max = N_POINTS;
Y_max = N_POINTS;
use_color = FALSE;
type = PLOT_WIRE_MESH;
dp = 0.0;
for (i = 1; i < argc; i++)
{if (argv[i][0] == -)
{switch (argv[i][1])
{case c : use_color = TRUE;
break;
case p : dp = ATOF(argv[++i]);
break;
case s : type = PLOT_SURFACE;
break;
case w : type = PLOT_WIRE_MESH;
break;
case z : X_max = Y_max = atoi(argv[++i]);
break;};}
else
break;};
maxes[0] = X_max;
maxes[1] = Y_max;
n_pts = X_max*Y_max;
PG_open_console(GSSFTS, MONOCHROME, 1,
0.55, 0.1, 0.4, 0.8);
if (use_color)
SCR_dev = PG_make_device(WINDOW, COLOR, PGS Surface Test);
else
SCR_dev = PG_make_device(WINDOW, MONOCHROME,
PGS Surface Test);
PG_open_device(SCR_dev, 0.1, 0.1, 0.4, 0.4);
if (type == PLOT_SURFACE)
PG_set_palette(SCR_dev, spectrum);
rx = px = MAKE_N(REAL, n_pts);
ry = py = MAKE_N(REAL, n_pts);
rz = pz = MAKE_N(REAL, n_pts);
if (type == PLOT_SURFACE)
rs = ps = MAKE_N(REAL, n_pts);
else
rs = ps = pz;
ext = MAKE_N(REAL, 4);
ext[0] = -1;
ext[1] = 1;
ext[2] = -1;
ext[3] = 1;
/* draw the first image */
dx = 2.0*PI/((double) (X_max - 1));
dy = 2.0*PI/((double) (Y_max - 1));
for (l = 0; l < Y_max; l++)
{for (k = 0; k < X_max; k++)
{*px++ = x = ((double) k)*dx;
*py++ = y = ((double) l)*dy;
*pz++ = cos(y);
if (type == PLOT_SURFACE)
*ps++ = sin(x);};};
if (dp == 0.0)
{while (TRUE)
{PRINT(stdout, Viewing Angle: );
GETLN(t, MAXLINE, stdin);
if ((token = strtok(t, ,)) == NULL)
break;
theta = DEG_RAD*ATOF(token);
if ((token = strtok(NULL, ,)) == NULL)
break;
phi = DEG_RAD*ATOF(token);
draw_set(SCR_dev, PS_dev, CGM_dev,
rz, rs, ext, rx, ry,
n_pts,
0.0, 2.0*PI, 0.0, 2.0*PI,
theta, phi,
0.0, SCR_dev->BLUE, SOLID,
type, maxes);};}
else
{for (phi = 0.0; phi <= 90.0; phi += dp)
{draw_set(SCR_dev, PS_dev, CGM_dev,
rz, rs, ext, rx, ry,
n_pts,
0.0, 2.0*PI, 0.0, 2.0*PI,
0.0, DEG_RAD*phi,
0.0, SCR_dev->BLUE, SOLID,
type, maxes);};};
PG_close_device(SCR_dev);
exit(0);}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* DRAW_SET - draw a complete set of plots */
static void draw_set(SCR_dev, PS_dev, CGM_dev, rz, rs, ext, rx, ry,
n_pts, xmn, xmx, ymn, ymx, theta, phi,
width, color, style, type, maxes)
PG_device *SCR_dev, *PS_dev, *CGM_dev;
REAL *rz, *rs, *ext, *rx, *ry;
int n_pts;
double xmn, xmx, ymn, ymx, theta, phi, width;
int color, style, type;
int *maxes;
{PG_draw_surface(SCR_dev, rz, rs, ext, rx, ry,
n_pts,
xmn, xmx, ymn, ymx, theta, phi, width, color,
style, type, Test Data,
Logical-Rectangular, maxes);
return;}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
7.8
Vector Plots
PGS can render 2 dimensional vector fields. The following program demonstrates this capability.
7.9
FORTRAN API Example
c
c GSTEST.F - test of PGS FORTRAN API
c
c -------------------------------------------------------------------
c -------------------------------------------------------------------
program gsftst
integer pgmkdv
integer idev, idvp
double precision x1, y1, x2, y2
double precision x(5), y(5), u(4), v(4)
character*8 names, namep
character*10 name2, name3
character*12 name4
c ... set up the window
names = WINDOW
name2 = COLOR
name3 = PGS Test A
idev = pgmkdv(6, names, 5, name2, 10, name3)
x1 = 0.05
y1 = 0.2
x2 = 0.45
y2 = 0.45
call pgopen(idev, x1, y1, x2, y2)
c ... set up the PS device
namep = PS
name2 = MONOCHROME
name3 = gsftst
idvp = pgmkdv(2, namep, 10, name2, 6, name3)
x1 = 0.0
y1 = 0.0
x2 = 0.0
y2 = 0.0
call pgopen(idvp, x1, y1, x2, y2)
call pgclsc(idev)
call pgclsc(idvp)
c ... set up the view port and world coordinate system
x1 = 0.1
x2 = 0.9
y1 = 0.1
y2 = 0.9
call pgsvwp(idev, x1, x2, y1, y2)
call pgsvwp(idvp, x1, x2, y1, y2)
x1 = 0.0
x2 = 10.0
y1 = -15.0
y2 = 30.0
call pgswcs(idev, x1, x2, y1, y2)
call pgswcs(idvp, x1, x2, y1, y2)
c ... draw a bounding box
x1 = 0.0
x2 = 10.0
y1 = -15.0
y2 = 30.0
call pgdrbx(idev, x1, x2, y1, y2)
call pgdrbx(idvp, x1, x2, y1, y2)
c ... write a string
x1 = 5.0
y1 = 0.0
name4 = TEXT STRING
100 format(1p, e10.2)
call pgwrta(idev, x1, y1, 11, name4)
call pgwrta(idvp, x1, y1, 11, name4)
c ... draw a line
x1 = 1.0
x2 = 9.0
y1 = -4.0
y2 = -1.0
call pgdrln(idev, x1, y1, x2, y2)
call pgdrln(idvp, x1, y1, x2, y2)
c ... do a vector plot
x(1) = 3.0
y(1) = 4.0
u(1) = -0.5
v(1) = -0.25
x(2) = 4.0
y(2) = 4.0
u(2) = 0.5
v(2) = -0.25
x(3) = 4.0
y(3) = 5.0
u(3) = 0.5
v(3) = 0.0
x(4) = 3.0
y(4) = 5.0
u(4) = -0.5
v(4) = 0.5
call pgplvc(idev, x, y, u, v, 4)
call pgplvc(idvp, x, y, u, v, 4)
c ... draw and fill a polygon (color 4 is blue)
x(1) = 5.0
x(2) = 6.0
x(3) = 6.0
x(4) = 5.0
x(5) = 5.0
y(1) = 8.0
y(2) = 8.0
y(3) = 9.0
y(4) = 9.0
y(5) = 8.0
call pgfply(idev, x, y, 5, 4)
call pgfply(idvp, x, y, 5, 4)
call pgfnpl(idev)
call pgfnpl(idvp)
pause
c ... close the device
call pgclos(idev)
call pgclos(idvp)
call exit
end
c ------------------------------------------------------------------
c ------------------------------------------------------------------
8.0 Other
PACT Documentation
PGS depends on the SCORE and PML PACT libraries for certain key supporting functionalities. In turn PGS structures are used in ULTRA II, SX, and PANACEA. Some readers may find it helpful to refer to these and other PACT documents.
The list of PACT Documents is:
PACT Users Guide, UCRL-MA-112087
SCORE Users Manual, UCRL-MA-108976 Rev.1
PPC Users Manual UCRL-MA-108964 Rev.1
PML Users Manual, UCRL-MA-108965 Rev.1
PDBLib Users Manual, M-270 Rev.2
PGS Users Manual, UCRL-MA-108966 Rev.1 (this document)
PANACEA Users Manual, M-276 Rev.2
ULTRA II Users Manual, UCRL-MA-108967 Rev.1
PDBDiff Users Manual, UCRL-MA-108975 Rev.1
PDBView Users Manual, UCRL-MA-108968 Rev.1
SX Users Manual, UCRL-MA-112315