home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / WGRAPH.DEF < prev    next >
Text File  |  1993-02-15  |  4KB  |  109 lines

  1. DEFINITION MODULE WGraph;
  2.  
  3.     (********************************************************)
  4.     (*                            *)
  5.     (*        Graph module For GWindows.        *)
  6.     (*                            *)
  7.     (*  Programmer:        S.P.Lontis, P. Moylan.        *)
  8.     (*  Last edited:    15 February 1993        *)
  9.     (*  Status:                        *)
  10.     (*    Basically working, but still fiddling with    *)
  11.     (*    the details.                    *)
  12.     (*                            *)
  13.     (*    It's not clear whether OpenGraph needs so many    *)
  14.     (*    parameters.  Also not clear how bar graphs    *)
  15.     (*    fit into the overall picture.            *)
  16.     (*                            *)
  17.     (********************************************************)
  18.  
  19. FROM GWindows IMPORT 
  20.      (* type *)   Window;
  21.  
  22. (************************************************************************)
  23.  
  24. TYPE
  25.     Graph;        (* is private *)
  26.     
  27.     (* Types of graphs that can be drawn.    *)
  28.  
  29.     GraphType = (linear, loglinear, loglog, bar);
  30.  
  31.     (* Line Types that can be used.    *)
  32.  
  33.     LineType  = (dots, joined, vertical, normal);
  34.  
  35.     (* Marker Types for individual points plotted.    *)
  36.  
  37.     MarkType  = (none, square, cross, plus, diamond);
  38.  
  39.     BarType = (One, Two, Three, Four, Five);
  40.  
  41. (************************************************************************)
  42.  
  43. PROCEDURE OpenGraph (VAR (*OUT*) G: Graph;  w: Window;  GrphType: GraphType;
  44.             LnType: LineType; xst, yst, xen, yen: CARDINAL;
  45.             xmin, ymin, xmax, ymax: LONGREAL;  Mark: MarkType);
  46.  
  47.     (* Creates graph G in window w.  The Graph will occupy a rectangle    *)
  48.     (* with a bottom left corner of (xs,ys) and top right corner of    *)
  49.     (* (xe,ye) relative to the window. The range of values which can be    *)
  50.     (* plotted is from (xmin,ymin) to (xmax,ymax).  NOTE: for a bar    *)
  51.     (* graph, xmin gives the width of the bars and xmax gives the    *)
  52.     (* distance between different bars.                    *)
  53.  
  54. PROCEDURE DrawXAxis (G: Graph;  xinc: LONGREAL;
  55.             yoffset, DecPlaces: CARDINAL;  numbering: BOOLEAN);
  56.  
  57.     (* Draws the x-axis for a graph; xinc is the distance between tick    *)
  58.     (* marks, and yoffset gives the distance that the axis will lie    *)
  59.     (* below the line y=ys (ys is defined in OpenGraph).  The option    *)
  60.     (* yoffset <> 0 allows for the case where more than one graph    *)
  61.     (* occupies the same window, since the graphs may have different    *)
  62.     (* scales.  DecPlaces gives the number of decimal places that will    *)
  63.     (* be used.  If numbering is FALSE, the axis is drawn but not    *)
  64.     (* labelled.                            *)
  65.  
  66. PROCEDURE DrawYAxis (G: Graph;  yinc: LONGREAL;
  67.             xoffset, DecPlaces: CARDINAL;  numbering: BOOLEAN);
  68.  
  69.     (* Draws the y-axis for a graph; yinc is the space between tick    *)
  70.     (* marks, and xoffset gives the distance that the axis will lie to    *)
  71.     (* the left of the line x=xs (xs is defined in OpenGraph).        *)
  72.     (* DecPlaces gives the number of decimal places that will be used.    *)
  73.     (* If numbering is FALSE, the axis is drawn but not labelled.    *)
  74.  
  75. PROCEDURE DrawAxes (G: Graph;
  76.     xinc: LONGREAL;  yoffset, xdecplaces: CARDINAL;  numberx: BOOLEAN;
  77.     yinc: LONGREAL;  xoffset, ydecplaces: CARDINAL;  numbery: BOOLEAN);
  78.  
  79.     (* Draws both the X and Y axes.  See the definitions of        *)
  80.     (* DrawXAxis and DrawYAxis above.                    *)
  81.  
  82. PROCEDURE AddPoint (G: Graph;  x, y: LONGREAL);
  83.  
  84.     (* For lines of type                        *)
  85.     (*        'dots'    : only the marker will be displayed.        *)
  86.     (*        'joined': draws a line from the last point and marker.    *)
  87.     (*        'vertical' : draws a vertical line and a marker.    *)
  88.     (* NOTE: lines of type 'normal' are used for discontinuous graphs    *)
  89.     (* and are not drawn using this procedure.                *)
  90.     (* Points outside the region (xmin <= x <= xmax, ymin <= y <= ymax    *)
  91.     (* will be clipped.                            *)
  92.  
  93. PROCEDURE DrawLines (G: Graph;  x, y: ARRAY OF LONGREAL);
  94.  
  95.     (* Allows vectors of x and y points to be drawn.  Refer to        *)
  96.     (* procedure AddPoint for specifications of the line types.        *)
  97.  
  98. PROCEDURE DrawLine (G: Graph;  x0, y0, x1, y1: LONGREAL);
  99.  
  100.     (* Used for drawing discontinuous lines.  The line is drawn between    *)
  101.     (* (x0,y0) and (x1,y1) relative to graph G.                *)
  102.  
  103. PROCEDURE BarGraph (G: Graph;  y: ARRAY OF LONGREAL;  del: CARDINAL;  bt: BarType);
  104.  
  105.     (* Displays a BarGraph of the vector y.  Parameter del gives the    *)
  106.     (* number of stripes per bar, in the case of striped fill patterns.    *)
  107.  
  108. END WGraph.
  109.