DEFINITION MODULE DIG;
    (*
    This module defines the graphics primitives. These can be used in
    a rather machine independent fashion. The routine "GInitDevice"
    must be called prior to any graphics command so that the device
    can be initialized. The graphics commands are written out to the
    file whoes name is passed to GInitDevice. The graphics file can then
    be given to the respective device driver.
    *)

EXPORT QUALIFIED 
    (* TYPE *) GArrowHead, GLineType, GFontType, GJustType, GDeviceType,
               GColorType,
    (* VAR  *) GDevice   ,
    (* PROC *) GSlope, GInitDevice,
               GErase, GWindow, GMapWindow, GMove, GDraw,
               GBox, GCircle, GEllipse, GArc, GLine, GPolyLine, GArrow,
               GSpline, GSetLinePattern, GSetFont, GSetCharSize,
               GCharCellSize, GText, GSetColor, GWrapUp;

TYPE 
     GArrowHead = ( LeftHead, RightHead, BothHead, NoHead );
     GLineType  = ( GInvisible, GSolid, GDashed, GDotted );
     GFontType  = ( HardWare, Roman, Stick, Script, Gothic );
     GJustType  = ( LeftJustify, CenterJustify, RightJustify );
     GDeviceType= ( hp7221, hp7550, hp7580, hp7470, hp7475, hp7220, 
                    vt125, tek, tek15 );
     GColorType = ( Gblack,Gblue,Ggreen,Gred,Gorange,Gcyan,Gyellow,
                    Gmagenta,Gwhite );

VAR
    GDevice : GDeviceType;

PROCEDURE GSlope( x1,y1 : REAL (* in *);
                  x2,y2 : REAL (* out*)  ): REAL;

PROCEDURE GInitDevice(
    HardXleft  : REAL; (* in *)
    HardYbot   : REAL; (* in *)
    HardXright : REAL; (* in *)
    HardYtop   : REAL; (* in *)
    Baudrate   : INTEGER; (* in *)      (* tektronics needs this *)
    Gfile      : ARRAY OF CHAR (* in *)  );
    (*
    This routine must be invoked before any plotting can be done. It
    initializes the graphics device. HardBottom and HardTop define the
    physical limit for the cursor movement. 
    All graphics commands are written out to "Gfile" in binary format.
    The device drivers can then be invoked and given this file for actual
    plotting.
    *)
    
PROCEDURE GErase( );
    (*
    Erase the plotting surface.
    *)
    
PROCEDURE GWindow(
    LowerX : REAL; (* in *)
    LowerY : REAL; (* in *)
    UpperX : REAL; (* in *)
    UpperY : REAL  (* in *) );
    (*
    Defines the physical region of interest where plotting will be done.
    The soft clip region.
    *)

PROCEDURE GMapWindow(
    Xmin : REAL; (* in *)
    Ymin : REAL; (* in *)
    Xmax : REAL; (* in *)
    Ymax : REAL  (* in *) );
    (*
    Maps the SoftClip window with these limits so that world coordinates
    can be used instead ot physical device coordinates.
    *)
    
PROCEDURE GMove(
    X : REAL; (* in *)
    Y : REAL  (* in *) );
    (*
    Moves the cursor to this location.
    *)
    
PROCEDURE GDraw(
    X : REAL; (* in *)
    Y : REAL  (* in *) );
    (*
    Draws a line from current cursor position to this X,Y. Current line
    pattern will be used.
    *)
    
PROCEDURE GBox(
    Xleft  : REAL; (* in *)
    Ybot   : REAL; (* in *)
    Xright : REAL; (* in *)
    Ytop   : REAL  (* in *) );
    (*
    Draws a box with (Xleft,Ybot) at lower left and (Xright,Ytop) at right
    top.
    *)

PROCEDURE GCircle(
    CX : REAL; (* in *)
    CY : REAL; (* in *)
    Radius : REAL (* in *) );
    (*
    Draws a circle centerd at{CX,CY and radius "Radius".
    *)

PROCEDURE GEllipse(
    CX : REAL; (* in *)
    CY : REAL; (* in *)
    SemiMajAxis : REAL; (* in *)
    SemiMinAxis : REAL  (* in *) );
    (*
    Draws an ellipse centered at CX,CY.
    *)

PROCEDURE GArc(
    X1,Y1 : REAL; (* in *)
    X2,Y2 : REAL; (* in *)
    X3,Y3 : REAL; (* in *)
    Heading : GArrowHead (* in *) );
    (*
    Draws an arc through the three coordinates.
    *)

PROCEDURE GLine(
    BegX : REAL; (* in *)
    BegY : REAL; (* in *)
    EX : REAL; (* in *)
    EY : REAL  (* in *) );
    (*
    Draws a line from BX,BY to EX,EY.
    *)

PROCEDURE GPolyLine(
    X    : ARRAY OF REAL; (* in *)
    Y    : ARRAY OF REAL; (* in *)
    Npts : CARDINAL       (* in *) );
    (*
    Draws a line through all x,y.
    *)

PROCEDURE GArrow(
    BegX : REAL; (* in *)
    BegY : REAL; (* in *)
    EX : REAL; (* in *)
    EY : REAL; (* in *)
    Heading : GArrowHead (* in *) );

PROCEDURE GSpline(
    BegX : REAL; (* in *)
    BegY : REAL; (* in *)
    EX   : REAL; (* in *)
    EY   : REAL; (* in *)
    GuideCount : CARDINAL; (* in *)
    GuideX     : ARRAY OF REAL; (* in *)
    GuideY     : ARRAY OF REAL; (* in *)
    Heading : GArrowHead (* in *) );
    (*
    Draw a spline from BX,BY to EX,EY using GuideX,GuideY as tracking points.
    Heading indicates the tyoe of arrow head to draw at the ends.
    *)

PROCEDURE GSetLinePattern(
    Pat : GLineType (* in *) );

PROCEDURE GSetFont(
    Font : GFontType (* in *) );

PROCEDURE GSetCharSize(
    VAR Cht  : REAL; (* in/out *)
    VAR Cwid : REAL; (* in/out *)
    VAR Slant: REAL (* in/out *) );
    (*
    Set the character hite and width. If however, the hite and/or size are 
    not available, the hite and/or width are set to the nearest available.
    Slant is the Italic tilt in degrees w.r.t vertical.
    *)

PROCEDURE GCharCellSize(
    Cht : REAL; (* in *)
    Cwid: REAL; (* in *)
    VAR Cellht : REAL; (* out *)
    VAR Cellwid: REAL  (* out *) );
    (*
    Returns the size of the character cell that can hold a character of
    hite and width = Cht,Cwid.
    *)

PROCEDURE GText(
    X    : REAL; (* in *)
    Y    : REAL; (* in *)
    Text : ARRAY OF CHAR; (* in *)
    Cht  : REAL; (* in *)
    Cwid : REAL; (* in *)
    Rot  : REAL; (* in *)
    Just : GJustType (* in *) );
    (*
    displays a line of text at X,Y. The character size is controlled by
    Cht,Cwid. Rot controls how much to rotate the line of text w.r.t the
    horizontal. Just controls whether the line will be left, right or center
    justified. The base line falls on top of h the characters.
    *)
PROCEDURE GSetColor( col : GColorType (* in *) );
    (*
    Set the color to one out the GColorTypes.
    *)
PROCEDURE GWrapUp( );
    (*
    Must be called at the end to do some clean up.
    *)

END DIG.
