mentor/derived/MaxflowTranscriptView.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 Maxflow.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE MaxflowTranscriptView;

<*NOWARN*> IMPORT TextPort, Rd, ZeusClass, Filter, R2, TextEditVBT;
<*NOWARN*> IMPORT Fmt, MFGraph, ZFmt, Wr, ZeusPanel, FormsVBT, VBT;
<*NOWARN*> IMPORT View, MaxflowViewClass, MFAlgs, MFViews;
<*NOWARN*> IMPORT GraphVBT, RefList, MFFmt;

<* 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;
    oeSetup := Setup;
    oeHighlightPath := HighlightPath;
    oeIncFlow := IncFlow;
    oeDecFlow := DecFlow;
    oeShowEdge := ShowEdge;
    oeRemoveHighlight := RemoveHighlight;
    oeFinalResult := FinalResult;
    ueAddVBTVertex := AddVBTVertex;
    ueAddVBTEdge := AddVBTEdge;
  END;

PROCEDURE TViewInit (view: T): T =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "init");
    RETURN MaxflowViewClass.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("MaxflowTranscriptView.fv");
    view.te := FormsVBT.GetVBT(view.fv, "transcript");
    TViewZTrace (view, "install");
    FormsVBT.AttachProc(view.fv, "clear", Clear, view);
    EVAL Filter.Replace (view, view.fv);
    MaxflowViewClass.T.install (view);
  END TViewInstall;

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

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

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

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

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

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

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

PROCEDURE Setup (view: T;  g: MFGraph.T; source: MFGraph.Vertex; sink: MFGraph.Vertex) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Setup ...")
       ELSE
          TViewTrace (view, "Setup "
          & MFAlgs.NullText(g)
          & " "
          & MFFmt.Ref(source)
          & " "
          & MFFmt.Ref(sink)
          )
       END
    END
    END
  END Setup;

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

PROCEDURE IncFlow (view: T;  edge: MFGraph.Edge; flow: REAL; number: CARDINAL; maxCapacity: REAL; capa: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "IncFlow ...")
       ELSE
          TViewTrace (view, "IncFlow "
          & MFViews.PrintEdge(edge)
          & " "
          & Fmt.Real(flow)
          & " "
          & Fmt.Int(number)
          & " "
          & Fmt.Real(maxCapacity)
          & " "
          & Fmt.Real(capa)
          )
       END
    END
    END
  END IncFlow;

PROCEDURE DecFlow (view: T;  edge: MFGraph.Edge; oldflow: REAL; newflow: REAL; number: CARDINAL; maxCapacity: REAL; capa: REAL) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "DecFlow ...")
       ELSE
          TViewTrace (view, "DecFlow "
          & MFViews.PrintEdge(edge)
          & " "
          & Fmt.Real(oldflow)
          & " "
          & Fmt.Real(newflow)
          & " "
          & Fmt.Int(number)
          & " "
          & Fmt.Real(maxCapacity)
          & " "
          & Fmt.Real(capa)
          )
       END
    END
    END
  END DecFlow;

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

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

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

PROCEDURE AddVBTVertex (view: T;  v: MFAlgs.MFVertex; pos: R2.T; label: TEXT) =
  <* LL = VBT.mu *>
  BEGIN
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "AddVBTVertex ...")
       ELSE
          TViewTrace (view, "AddVBTVertex "
            & MFFmt.Ref(v)
            & " "
            & R2.ToText(pos)
            & " "
            & MFAlgs.PrintText(label)
            )
       END
   END
  END AddVBTVertex;

PROCEDURE AddVBTEdge (view: T;  e: MFAlgs.MFEdge) =
  <* LL = VBT.mu *>
  BEGIN
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "AddVBTEdge ...")
       ELSE
          TViewTrace (view, "AddVBTEdge "
            & MFFmt.Ref(e)
            )
       END
   END
  END AddVBTEdge;

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, "Maxflow Transcript View", "Maxflow");
END MaxflowTranscriptView.

interface View is in:


interface GraphVBT is in: