The Private parts of GMatrix

The first 8 variables are from the BGI functions. GraphDriver and GraphMode are codes for the highest resolution screen available on the machine. MaxX and MaxY is the number of pixels in the x and y axes. MaxColors is the maximum number of colors in the display. Most of this information is available in the structures maintained by the BGI and the autodetection functions. The structure viewinfo contains most of this information after a call to the BGI function detect. The structure lineinfo contains a discription of the line types and thicknesses. Consult the Borland library reference manuals about these variables.

Two vectors hrefs and vrefs contain the locations of horizontal and vertical reference lines. The user can specify at most 20 horizontal and 20 vertical reference lines. The members are stored in a circular fashion: the 21'st reference line overwrites the 1'st reference line. The variables nvrefs and nhrefs count how many reference lines have been declared. The number of horizontal lines that will be displayed will be 20 if nhrefs is 20 or more. Only the 20 most recently declared lines will be displayed.

The next two functions control the output. Pause() allows the graph to be displayed until a key is pressed. It will also terminate the program if you press the ESC key. gprintf() is similar to printf() in C. The first two arguments are the locations of output relative to the current viewport. The variable argument list contains a format string for output, and a list of variables. This function calls sprintf() to create the string in 140 character buffer. This is dangerous if you put more than 140 characters for output since you will overwrite memory in ths sprintf() call.

The data is stored in the virtual matrix grf . The data matrix has 4 columns. The first is the graph number, the second is the symbol to be used for displaying the graph, the third is the data for the x axis, and the fourth is the data for the y-axis. You can have as many graphs stored in grf as you want. The number of graphs is stored in the variable grfnum. You add them by concatenating the graphs vertically. There is a public member function for this. The data for the graph is supplied in a kx2 matrix where the first column is the x data and the second is the y data. The symbols and graph counts are maintaned automatically.

The last function plotpoint() puts a symbol at point (ix,iy) relative to the current viewport.