<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">(*******************************************************************)
(** Release history:                                              **)
(**    17th January 1985   version 1.0.0 First port to new world  **)
(*******************************************************************)
DEFINITION MODULE Graphics;
(*
    Title    :  Graphics
    LastEdit :  Thu Jan 10 17:03:29 1985
    Author   :  Graham Toal
    Acorn Computers VLSI Design Aids Group
*)
FROM Polysys IMPORT POLYGON;
FROM Streams IMPORT Stream;
EXPORT QUALIFIED
                 Configure,
                 GSTREAM,
                 gstream,
                 COLOUR, TEXT, MARKER, CURSOR,
                 colour, text, marker, cursor,
                 SetLineColour, SetAreaColour, SetTextStyle, SetCursor,
                 Surface, Command,
                 Colour, TextStyle, Marker, Cursor,
                 MoveTo, LineTo, TextAt, MarkerAt, ReadCursor,
                 Box, TextBox, DrawPolygon,
                 FindInput, FindOutput, FindInOut, Delete, Update;
TYPE
     gstream; colour; text; marker; cursor;
     
     COLOUR  = POINTER TO RECORD
                  Implementation : colour
               END;

     TEXT    = POINTER TO RECORD
                  Implementation : text
               END;

     MARKER  = POINTER TO RECORD
                  Implementation : marker
               END;

     CURSOR  = POINTER TO RECORD
                  Implementation : cursor
               END;

     GSTREAM = POINTER TO RECORD
                  xl, yb, xr, yt,              (* Window bounds    *)
                  x, y,                        (* Current position *)
                  lastx, lasty,                (* Last position    *)
                  vxl, vyb, vxr, vyt,          (* Viewport co-ords *)
                  ScaleFactor    : INTEGER;    (* magnification X  *)
                  Colour         : COLOUR;
  (* WARNING - SEE END OF FILE FOR COMMENT ON COLOURS *)
                  Text           : TEXT;
                  Cursor         : CURSOR;
                  DiagStream     : Stream;
                  Implementation : gstream
               END;

PROCEDURE Configure(InputStream: Stream);
(*------------------------------------------------------------------------*)
(*  Configure reads a data-base file and calls the appropriate device-    *)
(*  drivers to update their tables.                                       *)
(*------------------------------------------------------------------------*)

(*--------------------------------------------------------------------------*)
(* These commands take a text description and return a token for future use *)
(*--------------------------------------------------------------------------*)
PROCEDURE Colour   (Stream :GSTREAM; Text:ARRAY OF CHAR):COLOUR;
PROCEDURE TextStyle(Stream :GSTREAM; Text:ARRAY OF CHAR):TEXT;
PROCEDURE Marker   (Stream :GSTREAM; Text:ARRAY OF CHAR):MARKER;
PROCEDURE Cursor   (Stream :GSTREAM; Text:ARRAY OF CHAR):CURSOR;
(*------------------------------------------------------------------------*)
(*      Access procedures to set attributes in stream attribute block     *)
(*------------------------------------------------------------------------*)
PROCEDURE SetLineColour(Stream:GSTREAM; Co:COLOUR);
PROCEDURE SetAreaColour(Stream:GSTREAM; Co:COLOUR);
PROCEDURE SetTextStyle (Stream:GSTREAM; Te:TEXT);
PROCEDURE SetCursor    (Stream:GSTREAM; Cu:CURSOR);
(*------------------------------------------------------------------------*)
(* These commands have a direct action on the device.  The 'Command'      *)
(* interface is provided as a general escape mechanism for very device-   *)
(* specific commands                                                      *)
(*------------------------------------------------------------------------*)
PROCEDURE Surface(Stream:GSTREAM; Xl,Yb,Xr,Yt:INTEGER);
PROCEDURE Command(Stream:GSTREAM; Comm:ARRAY OF CHAR):INTEGER;
    (* General purpose integer result must be type co-erced in order to
       do anything useful with it. Normally, call will be of the form
       (for example) 'Junk := Command (HPdev, "view")'
       Current commands are:
       "A0" "A1" "A2" etc.  "hp7221c" "hp7585b" "view" "scale &lt;integer&gt;"
       "xonxoff" (also "hp", "bighp")
       All device setup calls should be made before a call to 'Surface'
       at which point they take effect.
     *)
(*------------------------------------------------------------------------*)
(* The current line colour is an attribute held in the GSTREAM.           *)
(*------------------------------------------------------------------------*)
PROCEDURE MoveTo(Stream:GSTREAM;X,Y:INTEGER);
PROCEDURE LineTo(Stream:GSTREAM;X,Y:INTEGER);
(*------------------------------------------------------------------------*)
(* Markers are drawn with their centre on the point given. The marker is  *)
(* geometrically defined elsewhere, and a handle to it is got from the    *)
(* 'Marker' procedure; e.g. Marker (Arrow, "-&gt;")                          *)
(*------------------------------------------------------------------------*)
PROCEDURE MarkerAt(Stream:GSTREAM; X,Y:INTEGER; Ma:MARKER);
(*------------------------------------------------------------------------*)
(* This text command draws text from the point given. see also 'TextBox'  *)
(*------------------------------------------------------------------------*)
PROCEDURE TextAt(Stream:GSTREAM; X,Y:INTEGER; Text:ARRAY OF CHAR);
(*------------------------------------------------------------------------*)
(* These are area-action commands: TextBox puts the text in the box as    *)
(* best as it can                                                         *)
(*------------------------------------------------------------------------*)
PROCEDURE Box    (Stream:GSTREAM; Xl,Yb,Xr,Yt:INTEGER);
PROCEDURE TextBox(Stream:GSTREAM; Xl,Yb,Xr,Yt:INTEGER; Text:ARRAY OF CHAR);
PROCEDURE DrawPolygon(Stream:GSTREAM; Polygon:POLYGON);
(*------------------------------------------------------------------------*)
(* Functions returning stream handles:  These can also be had from the    *)
(* device-specific modules, such as HP. This module offers a generic      *)
(* entry to the system for ease of use.  An HP output stream would be     *)
(* opened by HP := FindOutput ("hp7221c");                                *)
(* WARNING: Not yet implemented: use HP.FindOutput for the moment.        *)
(*------------------------------------------------------------------------*)
PROCEDURE FindInput(Qual:ARRAY OF CHAR):GSTREAM;
PROCEDURE FindOutput(Qual:ARRAY OF CHAR):GSTREAM;
PROCEDURE FindInOut(Qual:ARRAY OF CHAR):GSTREAM;
PROCEDURE Delete(Stream:GSTREAM);
PROCEDURE Update(Stream:GSTREAM);
(*-------------------------------------------------------------------------*)
(* The four input co-ords allow a vast variety of initial cursor display   *)
(* on raster devices.  Possibilities include dragged boxes, stretched      *)
(* boxes, 45 degree snap lines etc.  The 'text' parameter returned will be *)
(* a device independant mapping of the returned value from a pick.         *)
(* There is a possibility of returning entire command strings in this way  *)
(* using a menu mechanism yet to be determined.                            *)
(*-------------------------------------------------------------------------*)
PROCEDURE ReadCursor(Stream:GSTREAM;Xl,Yb,Xr,Yt:INTEGER;VAR X,Y:INTEGER;
                     VAR Text:ARRAY OF CHAR);
END Graphics.

(*

   After defining this module, I found that it was useful to have two concepts
of 'current colour': One is that which is used when calling 'LineTo', and the
other is that which is used when drawing polygons.

The effect is that the following sequence

   SetLineColour (Green);
   SetAreaColour (Red);
   DrawPolygon (Square);
   MoveTo (0,0); LineTo (100,100)
   
would generate a line in GREEN, not red.

To be consistent, the current x and y co-ords stored in the
graphics stream should also not be affected by the drawing of the
polygon, however this has not yet been implemented.

*)
</pre></body></html>