mentor/derived/EuclidIE.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file Euclid.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE EuclidIE;

<*NOWARN*> IMPORT EuclidViewClass, ZeusClass, Zeus, Algorithm;
<*NOWARN*> IMPORT Euclid, EuclidAlgClass, View, Thread;
<*NOWARN*> IMPORT AlgorithmClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  SetupTriangleArgs = BRANDED REF RECORD
    a: REAL;
    b: REAL;
  END;

  SetupSquareArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    p2: Euclid.Id;
    p3: Euclid.Id;
    p4: Euclid.Id;
  END;

  LineALArgs = BRANDED REF RECORD
    show: BOOLEAN;
  END;

  TriangleArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    p2: Euclid.Id;
    p3: Euclid.Id;
    color: INTEGER;
  END;

  QuadArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    p2: Euclid.Id;
    p3: Euclid.Id;
    p4: Euclid.Id;
    color: INTEGER;
  END;

  ShearArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    p2: Euclid.Id;
    from: Euclid.Id;
    to: Euclid.Id;
  END;

  RotateTriangleArgs = BRANDED REF RECORD
    pivot: Euclid.Id;
    p1From: Euclid.Id;
    p1To: Euclid.Id;
    p2From: Euclid.Id;
    pt2To: Euclid.Id;
  END;

  RotateLineArgs = BRANDED REF RECORD
    pivot: Euclid.Id;
    pFrom: Euclid.Id;
    pTo: Euclid.Id;
  END;

  RotateAngleArgs = BRANDED REF RECORD
    pivot: Euclid.Id;
    p1From: Euclid.Id;
    p1To: Euclid.Id;
    p2From: Euclid.Id;
    pt2To: Euclid.Id;
  END;

  HighlightLineArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    p2: Euclid.Id;
    value: INTEGER;
    show: BOOLEAN;
  END;

  HighlightAngleArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    vertex: Euclid.Id;
    p2: Euclid.Id;
    value: INTEGER;
    show: BOOLEAN;
  END;

  RemoveArgs = BRANDED REF RECORD
    p1: Euclid.Id;
    p2: Euclid.Id;
    p3: Euclid.Id;
    p4: Euclid.Id;
    show: BOOLEAN;
  END;

  StepArgs = BRANDED REF RECORD
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | EuclidViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupTriangleArgs(varSetupTriangleArgs) => <*NOWARN*>
          view.oeSetupTriangle (
              varSetupTriangleArgs.a
                ,
              varSetupTriangleArgs.b
              )
      | SetupSquareArgs(varSetupSquareArgs) => <*NOWARN*>
          view.oeSetupSquare (
              varSetupSquareArgs.p1
                ,
              varSetupSquareArgs.p2
                ,
              varSetupSquareArgs.p3
                ,
              varSetupSquareArgs.p4
              )
      | LineALArgs(varLineALArgs) => <*NOWARN*>
          view.oeLineAL (
              varLineALArgs.show
              )
      | TriangleArgs(varTriangleArgs) => <*NOWARN*>
          view.oeTriangle (
              varTriangleArgs.p1
                ,
              varTriangleArgs.p2
                ,
              varTriangleArgs.p3
                ,
              varTriangleArgs.color
              )
      | QuadArgs(varQuadArgs) => <*NOWARN*>
          view.oeQuad (
              varQuadArgs.p1
                ,
              varQuadArgs.p2
                ,
              varQuadArgs.p3
                ,
              varQuadArgs.p4
                ,
              varQuadArgs.color
              )
      | ShearArgs(varShearArgs) => <*NOWARN*>
          view.oeShear (
              varShearArgs.p1
                ,
              varShearArgs.p2
                ,
              varShearArgs.from
                ,
              varShearArgs.to
              )
      | RotateTriangleArgs(varRotateTriangleArgs) => <*NOWARN*>
          view.oeRotateTriangle (
              varRotateTriangleArgs.pivot
                ,
              varRotateTriangleArgs.p1From
                ,
              varRotateTriangleArgs.p1To
                ,
              varRotateTriangleArgs.p2From
                ,
              varRotateTriangleArgs.pt2To
              )
      | RotateLineArgs(varRotateLineArgs) => <*NOWARN*>
          view.oeRotateLine (
              varRotateLineArgs.pivot
                ,
              varRotateLineArgs.pFrom
                ,
              varRotateLineArgs.pTo
              )
      | RotateAngleArgs(varRotateAngleArgs) => <*NOWARN*>
          view.oeRotateAngle (
              varRotateAngleArgs.pivot
                ,
              varRotateAngleArgs.p1From
                ,
              varRotateAngleArgs.p1To
                ,
              varRotateAngleArgs.p2From
                ,
              varRotateAngleArgs.pt2To
              )
      | HighlightLineArgs(varHighlightLineArgs) => <*NOWARN*>
          view.oeHighlightLine (
              varHighlightLineArgs.p1
                ,
              varHighlightLineArgs.p2
                ,
              varHighlightLineArgs.value
                ,
              varHighlightLineArgs.show
              )
      | HighlightAngleArgs(varHighlightAngleArgs) => <*NOWARN*>
          view.oeHighlightAngle (
              varHighlightAngleArgs.p1
                ,
              varHighlightAngleArgs.vertex
                ,
              varHighlightAngleArgs.p2
                ,
              varHighlightAngleArgs.value
                ,
              varHighlightAngleArgs.show
              )
      | RemoveArgs(varRemoveArgs) => <*NOWARN*>
          view.oeRemove (
              varRemoveArgs.p1
                ,
              varRemoveArgs.p2
                ,
              varRemoveArgs.p3
                ,
              varRemoveArgs.p4
                ,
              varRemoveArgs.show
              )
      | StepArgs(varStepArgs) => <*NOWARN*>
          view.oeStep (
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a EuclidViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | EuclidAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a EuclidAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE SetupTriangle (
      initiator: Algorithm.T;
       a, b: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupTriangleArgs
               , a := a
               , b := b
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetupTriangle);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetupTriangle;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetupTriangle;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SetupTriangle", OEDispatcher, zumeArgRec);
    END;
  END SetupTriangle;

PROCEDURE SetupSquare (
      initiator: Algorithm.T;
       p1, p2, p3, p4: Euclid.Id
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupSquareArgs
               , p1 := p1
               , p2 := p2
               , p3 := p3
               , p4 := p4
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetupSquare);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetupSquare;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetupSquare;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SetupSquare", OEDispatcher, zumeArgRec);
    END;
  END SetupSquare;

PROCEDURE LineAL (
      initiator: Algorithm.T;
       show: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(LineALArgs
               , show := show
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfLineAL);
      alg.stopAtEvent := alg.eventDataRec.stopAtLineAL;
      alg.waitAtEvent := alg.eventDataRec.waitAtLineAL;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "LineAL", OEDispatcher, zumeArgRec);
    END;
  END LineAL;

PROCEDURE Triangle (
      initiator: Algorithm.T;
       p1, p2, p3: Euclid.Id; color: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(TriangleArgs
               , p1 := p1
               , p2 := p2
               , p3 := p3
               , color := color
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfTriangle);
      alg.stopAtEvent := alg.eventDataRec.stopAtTriangle;
      alg.waitAtEvent := alg.eventDataRec.waitAtTriangle;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Triangle", OEDispatcher, zumeArgRec);
    END;
  END Triangle;

PROCEDURE Quad (
      initiator: Algorithm.T;
       p1, p2, p3, p4: Euclid.Id; color: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(QuadArgs
               , p1 := p1
               , p2 := p2
               , p3 := p3
               , p4 := p4
               , color := color
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfQuad);
      alg.stopAtEvent := alg.eventDataRec.stopAtQuad;
      alg.waitAtEvent := alg.eventDataRec.waitAtQuad;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Quad", OEDispatcher, zumeArgRec);
    END;
  END Quad;

PROCEDURE Shear (
      initiator: Algorithm.T;
       p1, p2, from, to: Euclid.Id
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ShearArgs
               , p1 := p1
               , p2 := p2
               , from := from
               , to := to
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfShear);
      alg.stopAtEvent := alg.eventDataRec.stopAtShear;
      alg.waitAtEvent := alg.eventDataRec.waitAtShear;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Shear", OEDispatcher, zumeArgRec);
    END;
  END Shear;

PROCEDURE RotateTriangle (
      initiator: Algorithm.T;
       pivot, p1From, p1To, p2From, pt2To: Euclid.Id
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(RotateTriangleArgs
               , pivot := pivot
               , p1From := p1From
               , p1To := p1To
               , p2From := p2From
               , pt2To := pt2To
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfRotateTriangle);
      alg.stopAtEvent := alg.eventDataRec.stopAtRotateTriangle;
      alg.waitAtEvent := alg.eventDataRec.waitAtRotateTriangle;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "RotateTriangle", OEDispatcher, zumeArgRec);
    END;
  END RotateTriangle;

PROCEDURE RotateLine (
      initiator: Algorithm.T;
       pivot, pFrom, pTo: Euclid.Id
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(RotateLineArgs
               , pivot := pivot
               , pFrom := pFrom
               , pTo := pTo
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfRotateLine);
      alg.stopAtEvent := alg.eventDataRec.stopAtRotateLine;
      alg.waitAtEvent := alg.eventDataRec.waitAtRotateLine;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "RotateLine", OEDispatcher, zumeArgRec);
    END;
  END RotateLine;

PROCEDURE RotateAngle (
      initiator: Algorithm.T;
       pivot, p1From, p1To, p2From, pt2To: Euclid.Id
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(RotateAngleArgs
               , pivot := pivot
               , p1From := p1From
               , p1To := p1To
               , p2From := p2From
               , pt2To := pt2To
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfRotateAngle);
      alg.stopAtEvent := alg.eventDataRec.stopAtRotateAngle;
      alg.waitAtEvent := alg.eventDataRec.waitAtRotateAngle;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "RotateAngle", OEDispatcher, zumeArgRec);
    END;
  END RotateAngle;

PROCEDURE HighlightLine (
      initiator: Algorithm.T;
       p1, p2: Euclid.Id; value: INTEGER; show: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HighlightLineArgs
               , p1 := p1
               , p2 := p2
               , value := value
               , show := show
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHighlightLine);
      alg.stopAtEvent := alg.eventDataRec.stopAtHighlightLine;
      alg.waitAtEvent := alg.eventDataRec.waitAtHighlightLine;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HighlightLine", OEDispatcher, zumeArgRec);
    END;
  END HighlightLine;

PROCEDURE HighlightAngle (
      initiator: Algorithm.T;
       p1, vertex, p2: Euclid.Id; value: INTEGER; show: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HighlightAngleArgs
               , p1 := p1
               , vertex := vertex
               , p2 := p2
               , value := value
               , show := show
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHighlightAngle);
      alg.stopAtEvent := alg.eventDataRec.stopAtHighlightAngle;
      alg.waitAtEvent := alg.eventDataRec.waitAtHighlightAngle;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HighlightAngle", OEDispatcher, zumeArgRec);
    END;
  END HighlightAngle;

PROCEDURE Remove (
      initiator: Algorithm.T;
       p1, p2, p3, p4: Euclid.Id; show: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(RemoveArgs
               , p1 := p1
               , p2 := p2
               , p3 := p3
               , p4 := p4
               , show := show
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfRemove);
      alg.stopAtEvent := alg.eventDataRec.stopAtRemove;
      alg.waitAtEvent := alg.eventDataRec.waitAtRemove;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Remove", OEDispatcher, zumeArgRec);
    END;
  END Remove;

PROCEDURE Step (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StepArgs
      );
      alg := NARROW(initiator, EuclidAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStep);
      alg.stopAtEvent := alg.eventDataRec.stopAtStep;
      alg.waitAtEvent := alg.eventDataRec.waitAtStep;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Step", OEDispatcher, zumeArgRec);
    END;
  END Step;

BEGIN
END EuclidIE.

interface View is in: