mentor/derived/BresenhamIE.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 Bresenham.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE BresenhamIE;

<*NOWARN*> IMPORT BresenhamAlgClass, ZeusClass, Zeus, Algorithm;
<*NOWARN*> IMPORT BresenhamViewClass, View, Thread, AlgorithmClass;

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

TYPE
  SetupArgs = BRANDED REF RECORD
    width: INTEGER;
    height: INTEGER;
    show: BOOLEAN;
  END;

  NewLineArgs = BRANDED REF RECORD
    x0: INTEGER;
    y0: INTEGER;
    x1: INTEGER;
    y1: INTEGER;
  END;

  ErrorInitArgs = BRANDED REF RECORD
  END;

  ShowPixelArgs = BRANDED REF RECORD
    x: INTEGER;
    y: INTEGER;
    p1: INTEGER;
    p2: INTEGER;
  END;

  FindErrorArgs = BRANDED REF RECORD
    p: INTEGER;
  END;

  ChangeErrorArgs = BRANDED REF RECORD
    p: INTEGER;
  END;

  CompareErrorArgs = BRANDED REF RECORD
    p: INTEGER;
  END;

  ShowNextPixelArgs = BRANDED REF RECORD
    p: INTEGER;
  END;

  MoveArgs = BRANDED REF RECORD
    p: INTEGER;
  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
    | BresenhamViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              varSetupArgs.width
                ,
              varSetupArgs.height
                ,
              varSetupArgs.show
              )
      | NewLineArgs(varNewLineArgs) => <*NOWARN*>
          view.oeNewLine (
              varNewLineArgs.x0
                ,
              varNewLineArgs.y0
                ,
              varNewLineArgs.x1
                ,
              varNewLineArgs.y1
              )
      | ErrorInitArgs(varErrorInitArgs) => <*NOWARN*>
          view.oeErrorInit (
              )
      | ShowPixelArgs(varShowPixelArgs) => <*NOWARN*>
          view.oeShowPixel (
              varShowPixelArgs.x
                ,
              varShowPixelArgs.y
                ,
              varShowPixelArgs.p1
                ,
              varShowPixelArgs.p2
              )
      | FindErrorArgs(varFindErrorArgs) => <*NOWARN*>
          view.oeFindError (
              varFindErrorArgs.p
              )
      | ChangeErrorArgs(varChangeErrorArgs) => <*NOWARN*>
          view.oeChangeError (
              varChangeErrorArgs.p
              )
      | CompareErrorArgs(varCompareErrorArgs) => <*NOWARN*>
          view.oeCompareError (
              varCompareErrorArgs.p
              )
      | ShowNextPixelArgs(varShowNextPixelArgs) => <*NOWARN*>
          view.oeShowNextPixel (
              varShowNextPixelArgs.p
              )
      | MoveArgs(varMoveArgs) => <*NOWARN*>
          view.oeMove (
              varMoveArgs.p
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a BresenhamViewClass, so just ignore *)
    END
  END OEDispatcher;

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

PROCEDURE Setup (
      initiator: Algorithm.T;
       width, height: INTEGER; show: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
               , width := width
               , height := height
               , show := show
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Setup", OEDispatcher, zumeArgRec);
    END;
  END Setup;

PROCEDURE NewLine (
      initiator: Algorithm.T;
       x0, y0, x1, y1: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewLineArgs
               , x0 := x0
               , y0 := y0
               , x1 := x1
               , y1 := y1
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewLine);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewLine;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewLine;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewLine", OEDispatcher, zumeArgRec);
    END;
  END NewLine;

PROCEDURE ErrorInit (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ErrorInitArgs
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfErrorInit);
      alg.stopAtEvent := alg.eventDataRec.stopAtErrorInit;
      alg.waitAtEvent := alg.eventDataRec.waitAtErrorInit;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "ErrorInit", OEDispatcher, zumeArgRec);
    END;
  END ErrorInit;

PROCEDURE ShowPixel (
      initiator: Algorithm.T;
       x, y, p1, p2: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ShowPixelArgs
               , x := x
               , y := y
               , p1 := p1
               , p2 := p2
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfShowPixel);
      alg.stopAtEvent := alg.eventDataRec.stopAtShowPixel;
      alg.waitAtEvent := alg.eventDataRec.waitAtShowPixel;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "ShowPixel", OEDispatcher, zumeArgRec);
    END;
  END ShowPixel;

PROCEDURE FindError (
      initiator: Algorithm.T;
       p: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FindErrorArgs
               , p := p
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFindError);
      alg.stopAtEvent := alg.eventDataRec.stopAtFindError;
      alg.waitAtEvent := alg.eventDataRec.waitAtFindError;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "FindError", OEDispatcher, zumeArgRec);
    END;
  END FindError;

PROCEDURE ChangeError (
      initiator: Algorithm.T;
       p: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ChangeErrorArgs
               , p := p
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfChangeError);
      alg.stopAtEvent := alg.eventDataRec.stopAtChangeError;
      alg.waitAtEvent := alg.eventDataRec.waitAtChangeError;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "ChangeError", OEDispatcher, zumeArgRec);
    END;
  END ChangeError;

PROCEDURE CompareError (
      initiator: Algorithm.T;
       p: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CompareErrorArgs
               , p := p
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCompareError);
      alg.stopAtEvent := alg.eventDataRec.stopAtCompareError;
      alg.waitAtEvent := alg.eventDataRec.waitAtCompareError;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "CompareError", OEDispatcher, zumeArgRec);
    END;
  END CompareError;

PROCEDURE ShowNextPixel (
      initiator: Algorithm.T;
       p: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ShowNextPixelArgs
               , p := p
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfShowNextPixel);
      alg.stopAtEvent := alg.eventDataRec.stopAtShowNextPixel;
      alg.waitAtEvent := alg.eventDataRec.waitAtShowNextPixel;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "ShowNextPixel", OEDispatcher, zumeArgRec);
    END;
  END ShowNextPixel;

PROCEDURE Move (
      initiator: Algorithm.T;
       p: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(MoveArgs
               , p := p
      );
      alg := NARROW(initiator, BresenhamAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfMove);
      alg.stopAtEvent := alg.eventDataRec.stopAtMove;
      alg.waitAtEvent := alg.eventDataRec.waitAtMove;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Move", OEDispatcher, zumeArgRec);
    END;
  END Move;

BEGIN
END BresenhamIE.

interface View is in: