<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">DEFINITION MODULE Order;
FROM Graphics IMPORT COLOUR;
FROM Polygon  IMPORT POLYGON;
(*------------------------------------------------------------------------*)
(*  This module depends on Graphics and Polygon - NOT vice-versa. It is   *)
(*  an applications level module (or at least, NOT a low-level library    *)
(*  module) so this dependency is valid. I stipulate that any module      *)
(*  calling this one MUST be importing both Graphics and Polygon itself,  *)
(*  so the dependency is valid.                                           *)
(*------------------------------------------------------------------------*)
FROM SYSTEM IMPORT WORD;
EXPORT QUALIFIED
   ORDER,
   OpClass, HyperPOLY,
   DrawPROC, DefaultOrder, NewOrder, NextIs,
   ShuffleUp, Insert, Delete, ForAllMasks;
(*------------------------------------------------------------------------*)
(*  The data structure which this ordered list manager stores is this:    *)
(*  Each node is either a simple polygon, or it is a composite polygon    *)
(*  made up of operations on simple polygons or other composite polygons. *)
(*  The data structure stores the FORMULA for calculating the polygon     *)
(*  to be displayed. In the common case that this is a simple polygon,    *)
(*  the formula is the polygon itself.                                    *)
(*------------------------------------------------------------------------*)
TYPE
     ORDER;
     OpClass = (PolyLeaf, Unop, BinOp, Bloat, Transfm);
     HyperPOLY = POINTER TO RECORD
                     Opn    :INTEGER;
                     CASE NodeType :OpClass OF
                     PolyLeaf:  Leaf :POLYGON
                     |
                     Unop:      Mask :HyperPOLY
                     |
                     Binop:     Left, Right :HyperPOLY
                     |
                     Bloat:     Mask :HyperPOLY; Int :INTEGER
                     |
                     Transfm:   Mask :HyperPOLY;
                                swapXandY, negX, negY :BOOLEAN;
                                tx, ty                :INTEGER
                     END (* case *);
                     UserField  :WORD
                  END ;
   
     DrawPROC = PROCEDURE (HyperPOLY, ADDRESS) :BOOLEAN;
                        (* Cardinal is layer no.                    *)
                        (* Word is the current environment.         *)
                        (* Boolean set to TRUE if early quit wanted *)

PROCEDURE DefaultOrder () :ORDER;
                                         (* Get from somewhere secret  *)
PROCEDURE NewOrder     () :ORDER;
                                         (* Clear down for calls on... *)
PROCEDURE NextIs       (Mask :HyperPOLY; Colour :COLOUR; In :ORDER);
                                         (* Add layers in order.       *)
PROCEDURE NextPolyIs   (Mask :POLYGON; Colour :COLOUR; In :ORDER);
                                         (* Simple interface to above..*)
PROCEDURE ShuffleUp    (HiddenMask, VisibleMask :HyperPOLY; In :ORDER);
                                         (* bring a layer up from below.
                                            push the others down by 1. *)
PROCEDURE Insert       (NewMask, AbovePreviousMask :HyperPOLY; Into :ORDER);
                                         (* add a new layer to be drawn
                                            above the layer named      *)
PROCEDURE Delete       (HyperPOLY :CARDINAL; From :ORDER);
                                         (* remove a layer from the
                                            drawing order altogether   *)
PROCEDURE ForAllMasks (Draw :DrawPROC; Using :ORDER);
                                         (* apply a drawing procedure. *)
END Order.
</pre></body></html>