[Top] [Prev] [Next] [Bottom]

7.2 3-D Graphics Control Functions

7.2.1 Getting a Window

Calling Sequence

window3 ( [n] [, dump = val] [, hcp = filename])


If n is specified, make window n the active window (open a window if necessary). If n is not specified, connect to the active window, or open one if none is active. Associate the hardopy file named filename with the window if hcp is specified; this will be postscript if the name ends in .ps, or cgm if it ends in .cgm. The style sheet associated with the window will be "nobox.gs", i. e., a plain window with no axes (except possibly a gnomon). The dump keyword, if 1, causes the color palette to be dumped to the hcp file with each frame that is sent there (otherwise hardcopy plots will be in greyscale).

7.2.2 Displaying the Gnomon

Webster's defines a gnomon as ``an object that by its position...serves as an indicator.'' In 3-D PyGist, the gnomon is a small diagram of the coordinate axes that appears in the lower left corner of a 3-D plot, if this capability has been turned on.

Calling Sequence

gnomon ( [onoff] [, chr = <labels>] )
set_default_gnomon ( [onoff])


gnomon toggles the gnomon display if onoff is omitted. If onoff is present and non-zero turn on the gnomon. If zero, turn it off. set_default_gnomon allows the user to specify what the default gnomon is to be when the default idler is called (see the discussion in "The variable _draw3 and the idler" on page 60, and "The Default Idler" on page 60.)

The gnomon shows the x, y, and z axis directions in the object coordinate system. The directions are labeled. The labels default to X, Y, and Z, but may be specified to be something else by using the keyword chr. <labels> must be a Python list consisting of three character strings.The gnomon is always infinitely far behind the object (away from the camera).

There is a mirror-through-the-screen-plane ambiguity in the display which is resolved in two ways: (1) the (x, y, z) coordinate system is right-handed, and (2) If the tip of an axis projects into the screen, its label is drawn in opposite polarity to the other text in the screen.

7.2.3 Plotting the Display List

The only way that the display list can be plotted is by an invocation of the function draw3. The user may control when this function gets called. To have a new plot appear totally under user control, set _draw3 to 0 (i. e., execute set_draw3_ (0)) and then call draw3 only when you want the plot to appear. To have a plot appear automatically after each plot command is given, _draw3 should be set to 1 and the idler should be set to some function which calls draw3. The details are in "The variable _draw3 and the idler" on page 60.

Calling Sequence

[lims = ] draw3 ( [called_as_idler = <val>])
limits (lims [0], lims [1], lims [2], lims [3])


The function draw3 traverses the display list and executes each function on the list with the list of arguments supplied. Assuming that the list is not empty, this means that the frame specified by this list will be displayed. If the parameter called_as_idler is present and is nonzero, then a fma (frame advance) call will be made first, meaning that the current display will be erased before the new one is plotted. Otherwise the new display will appear on top of the old.

draw3 always attempts to return a list of four items [xmin, xmax, ymin, ymax] which give the maximum and minimum of the x and y coordinates actually plotted to the PyGist window. Calling the limits function with these four values as limits will scale the graph properly. One could also perform computations with these limits (for example, to force x and y to the same scale, or to shrink the graph a little to force it well inside the borders of the window). If you like the way your graphs look, then there is no reason to deal with these numbers.

We apologize for this messy kludge; we have encountered timing problems and other difficulties with the Gist limits calculating process which we have not been able to solve except by computing our own limits.

7.2.4 The variable _draw3 and the idler

_draw3 is an internal 3-D PyGist variable accessible to the user only by means of the access functions described below. _draw3, in conjunction with a function called an idler, determines whether, after a plot function and its arguments have been placed on the display list, some further action takes place. The default idler (see below) will cause the graph to be plotted each time it is called; and it will be called immediately after the plot function has been added to the display list, provided _draw3 is nonzero.

Calling Sequences for _draw3 Access Functions

set_draw3 (n)
n = get_draw3 ( )


The first function is used to set _draw3 to n (default 0), and the second, to read its current setting.

Calling Sequences to Set Idlers

clear_idler ( )
set_idler (func_name)
set_default_idler ( )
call_idler ( )


The function clear_idler sets the idler function to a routine which does nothing. It will be called after each plot function adds to the display list (if _draw3 is nonzero), but will do nothing. set_idler allows the user to define an action for 3-D PyGist to take after each plot function call adds to the display list. func_name must be callable with no arguments. It will be called only if _draw3 is nonzero. set_default_idler will set the idler to call the function whose code is given below. call_idler gives you the capability to call the idler yourself, if you wish.

The Default Idler

Below is the code for the default idler.

def _draw3_idler ( ) :
global _default_gnomon
orient3 ()
if current_window () == -1 :
window3 (0)
else :
window3 (current_window ())
gnomon (_default_gnomon)
lims = draw3 (1)
if lims == None :
else :
limits (lims [0], lims [1], lims [2], lims [3])

[Top] [Prev] [Next] [Bottom]

Copyright © 1997,Regents of the University of California. All rights reserved.