DEFINITION MODULE NewGraph;

(*
    Title    :  New (Simplified) drawing package
    LastEdit :  Thu May 24 22:14:20 1984
    Author   :  Graham Toal
    Acorn Computers VLSI Design Aids Group
*)

(*------------------------------------------------------------------------*)
(*  This package offers an extremely simple-minded view of graphics:      *)
(*  It is customised strongly to VLSI display, although it will cope      *)
(*  with any solid-area drawings.  Its main advantages are that it        *)
(*  has a hidden device representation which can be easily changed        *)
(*  using a command language, and that it WILL work on ANY graphics       *)
(*  hardware.                                                             *)
(*------------------------------------------------------------------------*)
(*                             IMPORTANT                                  *)
(*  In order to achieve this device independence, we must assume          *)
(*    1) NO TEXT                                                          *)
(*    2) NO LINE DRAWING *** WRONG = PSMITH ******                        *)
(*    3) NO FIXED SIZE MARKERS/ICONS                                      *)
(*             so don't waste too much time looking for them below.       *)
(*------------------------------------------------------------------------*)



IMPORT Polysys;

EXPORT QUALIFIED
          Device,
          DrawPolygon,
          Surface,
          Move,
          Line;
   
PROCEDURE Device (DeviceName :ARRAY OF CHAR);
(*
   Device:           Device control commands
   
   
                Device takes (possibly) multiple parameters as a single
             string.  The string can quite comfortably be passed
             straight through from a command interpreter. This
             interface avoids having to change the low-level definition
             module too often, and thus saves a lot of unnecessary
             recompilation.
             
             Device currently supports:
             
          Device ("bbc");
          Device ("epson");     use bbc stipple patterns tailored for B/W
          Device ("null");      No graphics output at all
          Device ("modula2");   Generate modula2 polysys commands

          
             and the following two devices which take optional parameters:
          
          Device ("hp 7221");
          Device ("hp 7580");

          of the form Device ("hp 7580, autoscale")
                  and Device ("hp 7221, scale = 150:1")
                  
                         "autoscale" enlarges the design to fit the
                         paper (this only works on the large plotter,
                         which can work out its own paper size)
                         and "scale = " takes a ratio of hundredths
                         of a micron to millimeters.
          
             Some calls on Device may change large sections of
          the "Punter" database, i.e. drawing procedures will
          change from "bbc areafill" to "hp outline" etc.
          
             Device can also be called to perform sundry actions
          such as drawing a frame around a plot, or drawing a
          grid.  They come under "device" in the guise of
          'Device control commands', as a sneaky way to avoid extra
          interface calls. The optional parameters described above
          may also be called on their own, and will affect the
          last device selected.
          
             Device ("clear") will reset a mixed text-graphics device
          to text-only mode.  This is offered as an alternative to
          calling BBC.Mode(0) as is done at present.  When applied
          to a plotter, it will allow the paper to be safely removed
          without loss of fingers.  At the next call of anything else,
          parameters will be restored to their previous values.

*)

PROCEDURE DrawPolygon (Poly  :Polysys.Polygon;
                       Layer,
                       How   :ARRAY OF CHAR);

(* DrawPolygon:      Draws a Polygon stored in chip units
                     to the scale defined by 'Surface'.


         Note that Drawpolygon assumes 'surface' has already been called.

         Finds out representation for 'layer' from
         Dictionary 'How'.  (* Comment wrong - ASK *)
   
         Returns device to text mode etc. after drawing.
            
         Typical calls would be:

            DrawPolygon (Layers [I], Tech.LayerName [I], CurDraw);
            DrawPolygon (Transistors, "ndiff & poly", "hp stipple");

         DrawPolygon can be called repeatedly to add further layers
         to a drawing. The drawing is not terminated until a change
         of device, a call of Device ("pause"), or a change of Surface.
         
*)


PROCEDURE Surface (Xl, Yb, Xr, Yt :INTEGER);

(* Surface:       Sets up paper size, drawing scale, and performs 'new frame'
                  Units are in chip units of 1/100 micron.
                  Encompasses "view port"  and  "window" of other packages.
                  
           Surface assumes "Device" has already set up a device.
        If not, it calls device with a default parameter gleaned
        from the new technology file entry 'default'.
        
           Surface clears screens, sets up text windows, resets plotters
        etc.  (Very) silly values are not checked for.
        Drawings are clipped to the surface given.
*)

PROCEDURE Move (ChipX, ChipY :INTEGER);

PROCEDURE Line (ChipX, ChipY :INTEGER);

(* PROCEDURE Colour (LayerName :ARRAY OF CHAR) *)

END NewGraph.
