mentor/derived/BresenhamAlgClass.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:48:22 PST 1995 by kalsow  
      modified on Wed Feb 17 16:46:18 PST 1993 by johnh   
      modified on Thu Sep 24 10:59:20 PDT 1992 by mhb     

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

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


MODULE BresenhamAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, Fmt, Algorithm, Wr, ZeusPanel;
<*NOWARN*> IMPORT FormsVBT, VBT, Text, ZeusUtil;

<* PRAGMA LL *>
Fix any FormsVBT errors; don't handle exceptions for them.
<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
      OVERRIDES
        <* LL = VBT.mu *>
        init := BresenhamDefaultInit;
        snapshot := BresenhamDefaultSnapshot;
        restore := BresenhamDefaultRestore;
        updateEventCounts := BresenhamDefaultUpdateCts;
      END;

PROCEDURE BresenhamDefaultInit (v: T): Algorithm.T =
  <* LL = VBT.mu *>
  PROCEDURE Attach (id: TEXT; proc: FormsVBT.Proc) =
    BEGIN
      FormsVBT.AttachProc(v.eventData, id, proc, v);
    END Attach;
  BEGIN
    v.eventData := ZeusPanel.NewForm("BresenhamEventData.fv");
    Attach("stopatCodeEvents", BresenhamDoIt);
    Attach("waitatCodeEvents", BresenhamDoIt);
    Attach("eventCounts", BresenhamRefreshCts);
    Attach("stopAtSetup", BresenhamDoIt);
    Attach("waitAtSetup", BresenhamDoIt);
    Attach("stopAtNewLine", BresenhamDoIt);
    Attach("waitAtNewLine", BresenhamDoIt);
    Attach("stopAtErrorInit", BresenhamDoIt);
    Attach("waitAtErrorInit", BresenhamDoIt);
    Attach("stopAtShowPixel", BresenhamDoIt);
    Attach("waitAtShowPixel", BresenhamDoIt);
    Attach("stopAtFindError", BresenhamDoIt);
    Attach("waitAtFindError", BresenhamDoIt);
    Attach("stopAtChangeError", BresenhamDoIt);
    Attach("waitAtChangeError", BresenhamDoIt);
    Attach("stopAtCompareError", BresenhamDoIt);
    Attach("waitAtCompareError", BresenhamDoIt);
    Attach("stopAtShowNextPixel", BresenhamDoIt);
    Attach("waitAtShowNextPixel", BresenhamDoIt);
    Attach("stopAtMove", BresenhamDoIt);
    Attach("waitAtMove", BresenhamDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END BresenhamDefaultInit;

PROCEDURE BresenhamDoIt (           fv : FormsVBT.T;
                           e  : TEXT;
                           arg: REFANY;
                <*UNUSED*> t  : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    IF Text.Equal(e, "stopatCodeEvents") THEN
      NARROW(arg, T).stopatCodeEvents :=
          FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    END;
    IF Text.Equal(e, "waitatCodeEvents") THEN
      NARROW(arg, T).waitatCodeEvents :=
          FormsVBT.GetInteger(fv, "waitatCodeEvents");
    END;
    IF Text.Equal(e, "stopAtSetup") THEN
      NARROW(arg, T).eventDataRec.stopAtSetup :=
          FormsVBT.GetBoolean(fv, "stopAtSetup");
    END;
    IF Text.Equal(e, "waitAtSetup") THEN
      NARROW(arg, T).eventDataRec.waitAtSetup :=
          FormsVBT.GetInteger(fv, "waitAtSetup");
    END;
    IF Text.Equal(e, "stopAtNewLine") THEN
      NARROW(arg, T).eventDataRec.stopAtNewLine :=
          FormsVBT.GetBoolean(fv, "stopAtNewLine");
    END;
    IF Text.Equal(e, "waitAtNewLine") THEN
      NARROW(arg, T).eventDataRec.waitAtNewLine :=
          FormsVBT.GetInteger(fv, "waitAtNewLine");
    END;
    IF Text.Equal(e, "stopAtErrorInit") THEN
      NARROW(arg, T).eventDataRec.stopAtErrorInit :=
          FormsVBT.GetBoolean(fv, "stopAtErrorInit");
    END;
    IF Text.Equal(e, "waitAtErrorInit") THEN
      NARROW(arg, T).eventDataRec.waitAtErrorInit :=
          FormsVBT.GetInteger(fv, "waitAtErrorInit");
    END;
    IF Text.Equal(e, "stopAtShowPixel") THEN
      NARROW(arg, T).eventDataRec.stopAtShowPixel :=
          FormsVBT.GetBoolean(fv, "stopAtShowPixel");
    END;
    IF Text.Equal(e, "waitAtShowPixel") THEN
      NARROW(arg, T).eventDataRec.waitAtShowPixel :=
          FormsVBT.GetInteger(fv, "waitAtShowPixel");
    END;
    IF Text.Equal(e, "stopAtFindError") THEN
      NARROW(arg, T).eventDataRec.stopAtFindError :=
          FormsVBT.GetBoolean(fv, "stopAtFindError");
    END;
    IF Text.Equal(e, "waitAtFindError") THEN
      NARROW(arg, T).eventDataRec.waitAtFindError :=
          FormsVBT.GetInteger(fv, "waitAtFindError");
    END;
    IF Text.Equal(e, "stopAtChangeError") THEN
      NARROW(arg, T).eventDataRec.stopAtChangeError :=
          FormsVBT.GetBoolean(fv, "stopAtChangeError");
    END;
    IF Text.Equal(e, "waitAtChangeError") THEN
      NARROW(arg, T).eventDataRec.waitAtChangeError :=
          FormsVBT.GetInteger(fv, "waitAtChangeError");
    END;
    IF Text.Equal(e, "stopAtCompareError") THEN
      NARROW(arg, T).eventDataRec.stopAtCompareError :=
          FormsVBT.GetBoolean(fv, "stopAtCompareError");
    END;
    IF Text.Equal(e, "waitAtCompareError") THEN
      NARROW(arg, T).eventDataRec.waitAtCompareError :=
          FormsVBT.GetInteger(fv, "waitAtCompareError");
    END;
    IF Text.Equal(e, "stopAtShowNextPixel") THEN
      NARROW(arg, T).eventDataRec.stopAtShowNextPixel :=
          FormsVBT.GetBoolean(fv, "stopAtShowNextPixel");
    END;
    IF Text.Equal(e, "waitAtShowNextPixel") THEN
      NARROW(arg, T).eventDataRec.waitAtShowNextPixel :=
          FormsVBT.GetInteger(fv, "waitAtShowNextPixel");
    END;
    IF Text.Equal(e, "stopAtMove") THEN
      NARROW(arg, T).eventDataRec.stopAtMove :=
          FormsVBT.GetBoolean(fv, "stopAtMove");
    END;
    IF Text.Equal(e, "waitAtMove") THEN
      NARROW(arg, T).eventDataRec.waitAtMove :=
          FormsVBT.GetInteger(fv, "waitAtMove");
    END;
  END BresenhamDoIt;

PROCEDURE BresenhamRefreshCts (
                <*UNUSED*> fv  : FormsVBT.T;
                <*UNUSED*> e   : TEXT;
                           arg : REFANY;
                <*UNUSED*> t   : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    NARROW(arg, T).updateEventCounts(FALSE);
  END BresenhamRefreshCts;

PROCEDURE FromFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    alg.stopatCodeEvents :=
        FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    alg.waitatCodeEvents :=
        FormsVBT.GetInteger(fv, "waitatCodeEvents");
    alg.eventDataRec.stopAtSetup :=
        FormsVBT.GetBoolean(fv, "stopAtSetup");
    alg.eventDataRec.waitAtSetup :=
        FormsVBT.GetInteger(fv, "waitAtSetup");
    alg.eventDataRec.stopAtNewLine :=
        FormsVBT.GetBoolean(fv, "stopAtNewLine");
    alg.eventDataRec.waitAtNewLine :=
        FormsVBT.GetInteger(fv, "waitAtNewLine");
    alg.eventDataRec.stopAtErrorInit :=
        FormsVBT.GetBoolean(fv, "stopAtErrorInit");
    alg.eventDataRec.waitAtErrorInit :=
        FormsVBT.GetInteger(fv, "waitAtErrorInit");
    alg.eventDataRec.stopAtShowPixel :=
        FormsVBT.GetBoolean(fv, "stopAtShowPixel");
    alg.eventDataRec.waitAtShowPixel :=
        FormsVBT.GetInteger(fv, "waitAtShowPixel");
    alg.eventDataRec.stopAtFindError :=
        FormsVBT.GetBoolean(fv, "stopAtFindError");
    alg.eventDataRec.waitAtFindError :=
        FormsVBT.GetInteger(fv, "waitAtFindError");
    alg.eventDataRec.stopAtChangeError :=
        FormsVBT.GetBoolean(fv, "stopAtChangeError");
    alg.eventDataRec.waitAtChangeError :=
        FormsVBT.GetInteger(fv, "waitAtChangeError");
    alg.eventDataRec.stopAtCompareError :=
        FormsVBT.GetBoolean(fv, "stopAtCompareError");
    alg.eventDataRec.waitAtCompareError :=
        FormsVBT.GetInteger(fv, "waitAtCompareError");
    alg.eventDataRec.stopAtShowNextPixel :=
        FormsVBT.GetBoolean(fv, "stopAtShowNextPixel");
    alg.eventDataRec.waitAtShowNextPixel :=
        FormsVBT.GetInteger(fv, "waitAtShowNextPixel");
    alg.eventDataRec.stopAtMove :=
        FormsVBT.GetBoolean(fv, "stopAtMove");
    alg.eventDataRec.waitAtMove :=
        FormsVBT.GetInteger(fv, "waitAtMove");
  END FromFV;

<*UNUSED*>
PROCEDURE ToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutBoolean(fv, "stopatCodeEvents", alg.stopatCodeEvents);
    FormsVBT.PutInteger(fv, "waitatCodeEvents", alg.waitatCodeEvents);
    FormsVBT.PutBoolean(fv, "stopAtSetup",
                        alg.eventDataRec.stopAtSetup);
    FormsVBT.PutInteger(fv, "waitAtSetup",
                        alg.eventDataRec.waitAtSetup);
    FormsVBT.PutBoolean(fv, "stopAtNewLine",
                        alg.eventDataRec.stopAtNewLine);
    FormsVBT.PutInteger(fv, "waitAtNewLine",
                        alg.eventDataRec.waitAtNewLine);
    FormsVBT.PutBoolean(fv, "stopAtErrorInit",
                        alg.eventDataRec.stopAtErrorInit);
    FormsVBT.PutInteger(fv, "waitAtErrorInit",
                        alg.eventDataRec.waitAtErrorInit);
    FormsVBT.PutBoolean(fv, "stopAtShowPixel",
                        alg.eventDataRec.stopAtShowPixel);
    FormsVBT.PutInteger(fv, "waitAtShowPixel",
                        alg.eventDataRec.waitAtShowPixel);
    FormsVBT.PutBoolean(fv, "stopAtFindError",
                        alg.eventDataRec.stopAtFindError);
    FormsVBT.PutInteger(fv, "waitAtFindError",
                        alg.eventDataRec.waitAtFindError);
    FormsVBT.PutBoolean(fv, "stopAtChangeError",
                        alg.eventDataRec.stopAtChangeError);
    FormsVBT.PutInteger(fv, "waitAtChangeError",
                        alg.eventDataRec.waitAtChangeError);
    FormsVBT.PutBoolean(fv, "stopAtCompareError",
                        alg.eventDataRec.stopAtCompareError);
    FormsVBT.PutInteger(fv, "waitAtCompareError",
                        alg.eventDataRec.waitAtCompareError);
    FormsVBT.PutBoolean(fv, "stopAtShowNextPixel",
                        alg.eventDataRec.stopAtShowNextPixel);
    FormsVBT.PutInteger(fv, "waitAtShowNextPixel",
                        alg.eventDataRec.waitAtShowNextPixel);
    FormsVBT.PutBoolean(fv, "stopAtMove",
                        alg.eventDataRec.stopAtMove);
    FormsVBT.PutInteger(fv, "waitAtMove",
                        alg.eventDataRec.waitAtMove);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfSetup",
                        Fmt.Int(alg.eventDataRec.ctOfSetup));
    FormsVBT.PutText(fv, "ctOfNewLine",
                        Fmt.Int(alg.eventDataRec.ctOfNewLine));
    FormsVBT.PutText(fv, "ctOfErrorInit",
                        Fmt.Int(alg.eventDataRec.ctOfErrorInit));
    FormsVBT.PutText(fv, "ctOfShowPixel",
                        Fmt.Int(alg.eventDataRec.ctOfShowPixel));
    FormsVBT.PutText(fv, "ctOfFindError",
                        Fmt.Int(alg.eventDataRec.ctOfFindError));
    FormsVBT.PutText(fv, "ctOfChangeError",
                        Fmt.Int(alg.eventDataRec.ctOfChangeError));
    FormsVBT.PutText(fv, "ctOfCompareError",
                        Fmt.Int(alg.eventDataRec.ctOfCompareError));
    FormsVBT.PutText(fv, "ctOfShowNextPixel",
                        Fmt.Int(alg.eventDataRec.ctOfShowNextPixel));
    FormsVBT.PutText(fv, "ctOfMove",
                        Fmt.Int(alg.eventDataRec.ctOfMove));
  END CountsToFV;

PROCEDURE BresenhamDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfSetup := 0;
      v.eventDataRec.ctOfNewLine := 0;
      v.eventDataRec.ctOfErrorInit := 0;
      v.eventDataRec.ctOfShowPixel := 0;
      v.eventDataRec.ctOfFindError := 0;
      v.eventDataRec.ctOfChangeError := 0;
      v.eventDataRec.ctOfCompareError := 0;
      v.eventDataRec.ctOfShowNextPixel := 0;
      v.eventDataRec.ctOfMove := 0;
    END;
    CountsToFV (v.eventData, v);
  END BresenhamDefaultUpdateCts;

PROCEDURE BresenhamDefaultSnapshot (v: T; wr: Wr.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TRY
      Wr.PutChar(wr, '(')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultSnapshot write error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultSnapshot: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.snapshot(wr)
    EXCEPT
      FormsVBT.Error (msg) =>
        RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultSnapshot FV error: "
          & msg);
    ELSE
      RAISE ZeusClass.Error(
        "BresenhamAlgClass.BresenhamDefaultSnapshot error");
    END;
    Algorithm.T.snapshot(v, wr);
    TRY
      Wr.PutChar(wr, ')')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultSnapshot write error");
    END;
  END BresenhamDefaultSnapshot;

PROCEDURE BresenhamDefaultRestore (v: T; rd: Rd.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    IF rd = NIL THEN RETURN END;
    IF NOT ZeusUtil.EatChar(rd, '(') THEN
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultRestore read error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultRestore: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.restore(rd);
      v.updateEventCounts(FALSE);
      FromFV(v.eventData, v);
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultRestore error");
    END;
    Algorithm.T.restore(v, rd);
    IF NOT ZeusUtil.EatChar(rd, ')') THEN
      RAISE ZeusClass.Error(
          "BresenhamAlgClass.BresenhamDefaultRestore read error");
    END;
  END BresenhamDefaultRestore;

BEGIN
END BresenhamAlgClass.