mentor/derived/EuclidTranscriptView.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:56:02 PST 1995 by kalsow  
      modified on Mon Jun  6 03:18:55 PDT 1994 by mhb   
      modified on Tue Feb 16 16:31:40 PST 1993 by johnh 

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

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


<* PRAGMA LL *>

MODULE EuclidTranscriptView;

<*NOWARN*> IMPORT EuclidViewClass, TextPort, Rd, ZeusClass, Filter;
<*NOWARN*> IMPORT TextEditVBT, Fmt, ZFmt, Wr, ZeusPanel, FormsVBT;
<*NOWARN*> IMPORT Euclid, VBT, View;

<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
    fv: FormsVBT.T := NIL;
    te: TextEditVBT.T := NIL;
  OVERRIDES
    init       := TViewInit;
    install    := TViewInstall;
    delete     := TViewDelete;
    snapshot   := TViewSnapshot;
    restore    := TViewRestore;
    config     := TViewConfig;
    reactivity := TViewReactivity;
    startrun   := TViewStartrun;
    endrun     := TViewEndrun;
    oeSetupTriangle := SetupTriangle;
    oeSetupSquare := SetupSquare;
    oeLineAL := LineAL;
    oeTriangle := Triangle;
    oeQuad := Quad;
    oeShear := Shear;
    oeRotateTriangle := RotateTriangle;
    oeRotateLine := RotateLine;
    oeRotateAngle := RotateAngle;
    oeHighlightLine := HighlightLine;
    oeHighlightAngle := HighlightAngle;
    oeRemove := Remove;
    oeStep := Step;
  END;

PROCEDURE TViewInit (view: T): T =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "init");
    RETURN EuclidViewClass.T.init (view, NIL);
  END TViewInit;

PROCEDURE Clear (<* UNUSED *> fv  : FormsVBT.T;
                 <* UNUSED *> name: TEXT;
                              cl  : REFANY;
                 <* UNUSED *> time: VBT.TimeStamp) =
  BEGIN
    TextPort.SetText(NARROW(cl, T).te.tp, "")
  END Clear;

PROCEDURE TViewInstall (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    view.fv := ZeusPanel.NewForm("EuclidTranscriptView.fv");
    view.te := FormsVBT.GetVBT(view.fv, "transcript");
    TViewZTrace (view, "install");
    FormsVBT.AttachProc(view.fv, "clear", Clear, view);
    EVAL Filter.Replace (view, view.fv);
    EuclidViewClass.T.install (view);
  END TViewInstall;

PROCEDURE TViewDelete (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "delete");
    EuclidViewClass.T.delete (view);
   END TViewDelete;

PROCEDURE TViewSnapshot (view: T; wr: Wr.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "snapshot");
    EuclidViewClass.T.snapshot (view, wr);
   END TViewSnapshot;

PROCEDURE TViewRestore (view: T; rd: Rd.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "restore");
    EuclidViewClass.T.restore (view, rd);
   END TViewRestore;

PROCEDURE TViewConfig (
    view: T;
    state: ZeusClass.StateChange;
    o: ZeusClass.T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "config");
    EuclidViewClass.T.config (view, state, o);
   END TViewConfig;

PROCEDURE TViewReactivity (view: T; <*UNUSED*> on: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace(view, "reactivity");
    EuclidViewClass.T.reactivity (view, TRUE);
  END TViewReactivity;

PROCEDURE TViewStartrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "startrun");
    EuclidViewClass.T.startrun (view);
   END TViewStartrun;

PROCEDURE TViewEndrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "endrun");
    EuclidViewClass.T.endrun (view);
  END TViewEndrun;
event handling methods:

PROCEDURE SetupTriangle (view: T;  a, b: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "SetupTriangle ...")
       ELSE
          TViewTrace (view, "SetupTriangle "
          & Fmt.Real(a)
          & " "
          & Fmt.Real(b)
          )
       END
    END
    END
  END SetupTriangle;

PROCEDURE SetupSquare (view: T;  p1, p2, p3, p4: Euclid.Id) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "SetupSquare ...")
       ELSE
          TViewTrace (view, "SetupSquare "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(p3)
          & " "
          & Fmt.Int(p4)
          )
       END
    END
    END
  END SetupSquare;

PROCEDURE LineAL (view: T;  show: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "LineAL ...")
       ELSE
          TViewTrace (view, "LineAL "
          & Fmt.Bool(show)
          )
       END
    END
    END
  END LineAL;

PROCEDURE Triangle (view: T;  p1, p2, p3: Euclid.Id; color: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Triangle ...")
       ELSE
          TViewTrace (view, "Triangle "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(p3)
          & " "
          & Fmt.Int(color)
          )
       END
    END
    END
  END Triangle;

PROCEDURE Quad (view: T;  p1, p2, p3, p4: Euclid.Id; color: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Quad ...")
       ELSE
          TViewTrace (view, "Quad "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(p3)
          & " "
          & Fmt.Int(p4)
          & " "
          & Fmt.Int(color)
          )
       END
    END
    END
  END Quad;

PROCEDURE Shear (view: T;  p1, p2, from, to: Euclid.Id) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Shear ...")
       ELSE
          TViewTrace (view, "Shear "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(from)
          & " "
          & Fmt.Int(to)
          )
       END
    END
    END
  END Shear;

PROCEDURE RotateTriangle (view: T;  pivot, p1From, p1To, p2From, pt2To: Euclid.Id) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "RotateTriangle ...")
       ELSE
          TViewTrace (view, "RotateTriangle "
          & Fmt.Int(pivot)
          & " "
          & Fmt.Int(p1From)
          & " "
          & Fmt.Int(p1To)
          & " "
          & Fmt.Int(p2From)
          & " "
          & Fmt.Int(pt2To)
          )
       END
    END
    END
  END RotateTriangle;

PROCEDURE RotateLine (view: T;  pivot, pFrom, pTo: Euclid.Id) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "RotateLine ...")
       ELSE
          TViewTrace (view, "RotateLine "
          & Fmt.Int(pivot)
          & " "
          & Fmt.Int(pFrom)
          & " "
          & Fmt.Int(pTo)
          )
       END
    END
    END
  END RotateLine;

PROCEDURE RotateAngle (view: T;  pivot, p1From, p1To, p2From, pt2To: Euclid.Id) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "RotateAngle ...")
       ELSE
          TViewTrace (view, "RotateAngle "
          & Fmt.Int(pivot)
          & " "
          & Fmt.Int(p1From)
          & " "
          & Fmt.Int(p1To)
          & " "
          & Fmt.Int(p2From)
          & " "
          & Fmt.Int(pt2To)
          )
       END
    END
    END
  END RotateAngle;

PROCEDURE HighlightLine (view: T;  p1, p2: Euclid.Id; value: INTEGER; show: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "HighlightLine ...")
       ELSE
          TViewTrace (view, "HighlightLine "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(value)
          & " "
          & Fmt.Bool(show)
          )
       END
    END
    END
  END HighlightLine;

PROCEDURE HighlightAngle (view: T;  p1, vertex, p2: Euclid.Id; value: INTEGER; show: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "HighlightAngle ...")
       ELSE
          TViewTrace (view, "HighlightAngle "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(vertex)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(value)
          & " "
          & Fmt.Bool(show)
          )
       END
    END
    END
  END HighlightAngle;

PROCEDURE Remove (view: T;  p1, p2, p3, p4: Euclid.Id; show: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Remove ...")
       ELSE
          TViewTrace (view, "Remove "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          & " "
          & Fmt.Int(p3)
          & " "
          & Fmt.Int(p4)
          & " "
          & Fmt.Bool(show)
          )
       END
    END
    END
  END Remove;

PROCEDURE Step (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Step ...")
       ELSE
          TViewTrace (view, "Step "
          )
       END
    END
    END
  END Step;

PROCEDURE TViewZTrace (view: T; t: TEXT) =
  BEGIN
    IF view.fv # NIL THEN
      IF FormsVBT.GetBoolean(view.fv, "zeus") THEN
        TextPort.PutText(view.te.tp, "**zeus:  " & t & "\n");
        TextPort.Normalize(view.te.tp, LAST(INTEGER))
      END
    END
  END TViewZTrace;

PROCEDURE TViewTrace (view: T; t: TEXT) =
  BEGIN
    TextPort.PutText(view.te.tp, "--event: " & t & "\n");
    TextPort.Normalize(view.te.tp, LAST(INTEGER))
  END TViewTrace;

PROCEDURE TViewNew (): View.T =
  BEGIN
    RETURN NEW(T).init()
  END TViewNew;

BEGIN
  ZeusPanel.RegisterView
      (TViewNew, "Euclid Transcript View", "Euclid");
END EuclidTranscriptView.

interface View is in: