********************************************************************
* NOTE: This file is generated automatically from the event * definition file ShortestPath.evt. ********************************************************************<* PRAGMA LL *> MODULEOUTPUT and UPDATE event handling methods:; <*NOWARN*> IMPORT TextConv, ObLibM3, ObLibUI, SynWr, Obliq; <*NOWARN*> IMPORT ObliqParser, Rd, Filter, Fmt, ObLibAnim, ZFmt; <*NOWARN*> IMPORT ZeusPanel, ObValue, TextWr, View, VBT, Thread; <*NOWARN*> IMPORT ShortestPathViewClass, TextRd, Rsrc; CONST ViewName = "SPGraph.obl"; TYPE T = ShortestPathViewClass.T BRANDED OBJECT object : Obliq.Val; env : Obliq.Env; wr : TextWr.T; swr : SynWr.T; parser : ObliqParser.T; OVERRIDES <* LL.sup < VBT.mu *> startrun := Startrun; <* LL.sup < VBT.mu *> oeNewVertex := NewVertex; oeNewEdge := NewEdge; oeStartFind := StartFind; oePromote := Promote; oeConsider := Consider; oeTraceback := Traceback; <* LL.sup = VBT.mu *> END; ShortestPathSPGraphObliqView PROCEDURENewVertex (view: T; name: TEXT; x, y: REAL) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "NewVertex") THEN Invoke (view, "NewVertex", "" & TextConv.Encode(name) & "," & Fmt.Real(x) & "," & Fmt.Real(y) ) END END NewVertex; PROCEDURENewEdge (view: T; name, from, to, orientation: TEXT) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "NewEdge") THEN Invoke (view, "NewEdge", "" & TextConv.Encode(name) & "," & TextConv.Encode(from) & "," & TextConv.Encode(to) & "," & TextConv.Encode(orientation) ) END END NewEdge; PROCEDUREStartFind (view: T; from, to: TEXT) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "StartFind") THEN Invoke (view, "StartFind", "" & TextConv.Encode(from) & "," & TextConv.Encode(to) ) END END StartFind; PROCEDUREPromote (view: T; edge: TEXT; sIndex, dIndex: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "Promote") THEN Invoke (view, "Promote", "" & TextConv.Encode(edge) & "," & Fmt.Int(sIndex) & "," & Fmt.Int(dIndex) ) END END Promote; PROCEDUREConsider (view: T; edge: TEXT; sIndex, dIndex: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "Consider") THEN Invoke (view, "Consider", "" & TextConv.Encode(edge) & "," & Fmt.Int(sIndex) & "," & Fmt.Int(dIndex) ) END END Consider; PROCEDURETraceback (view: T; edge: TEXT; sIndex, dIndex: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "Traceback") THEN Invoke (view, "Traceback", "" & TextConv.Encode(edge) & "," & Fmt.Int(sIndex) & "," & Fmt.Int(dIndex) ) END END Traceback; PROCEDURERegisterView () = BEGIN ZeusPanel.RegisterView(New, "SPGraph.obl", "ShortestPath") END RegisterView; PROCEDURENew (): View.T = BEGIN RETURN NEW(T).init(NIL) END New; CONST ObliqStackSizeMultiplier = 8; TYPE Closure = Thread.SizedClosure OBJECT view: T; OVERRIDES apply := ForkedStartrun; END; PROCEDUREStartrun (view: T) = <* LL.sup < VBT.mu *> BEGIN EVAL Thread.Join( Thread.Fork( NEW(Closure, view := view, stackSize := ObliqStackSizeMultiplier * Thread.GetDefaultStackSize()))); END Startrun; PROCEDUREForkedStartrun (cl: Closure): REFANY = VAR rd: Rd.T; view := cl.view; BEGIN IF view.parser = NIL THEN view.wr := TextWr.New(); view.swr := SynWr.New(view.wr); view.parser := ObliqParser.New(view.swr); END; view.object := NIL; TRY rd := Rsrc.Open(ViewName, ZeusPanel.GetPath()); view.env := ParseRd(view.parser, ViewName, rd); WITH obj = Obliq.Lookup("view", view.env) DO IF NOT ISTYPE(obj, ObValue.ValObj) THEN ZeusPanel.ReportError( "not an Obliq object in '" & ViewName & "'") ELSIF FieldDefined (obj, "graphvbt") THEN WITH graphvbt = NARROW(Obliq.ObjectSelect(obj, "graphvbt"), ObLibAnim.ValGraph).vbt DO LOCK VBT.mu DO EVAL Filter.Replace(view, graphvbt) END END; view.object := obj; ELSIF FieldDefined (obj, "rectsvbt") THEN WITH rectsvbt = NARROW(Obliq.ObjectSelect(obj, "rectsvbt"), ObLibAnim.ValRects).vbt DO LOCK VBT.mu DO EVAL Filter.Replace(view, rectsvbt) END END; view.object := obj; ELSIF FieldDefined (obj, "formsvbt") THEN WITH formsvbt = NARROW(Obliq.ObjectSelect(obj, "formsvbt"), ObLibUI.ValForm).vbt DO LOCK VBT.mu DO EVAL Filter.Replace(view, formsvbt) END END; view.object := obj; ELSE ZeusPanel.ReportError( "cannot find 'graphvbt', 'rectsvbt', or 'formsvbt' in '" & ViewName & "'") END END EXCEPT | Rsrc.NotFound => ZeusPanel.ReportError("cannot find '" & ViewName & "'") | ObValue.Error (packet) => OblError(view, packet) | ObValue.Exception (packet) => OblException(view, packet) END; RETURN NIL; END ForkedStartrun; PROCEDUREParseRd (p: ObliqParser.T; name: TEXT; rd: Rd.T): Obliq.Env RAISES {ObValue.Error, ObValue.Exception} = VAR env := Obliq.EmptyEnv(); BEGIN ObliqParser.ReadFrom(p, name, rd, TRUE); TRY LOOP EVAL ObliqParser.EvalPhrase(p, ObliqParser.ParsePhrase(p), env) END EXCEPT ObliqParser.Eof => (* clean exit of loop *) END; RETURN env END ParseRd; PROCEDUREInvoke (view: T; event, args: TEXT) = VAR exp := "view." & event & "(" & args & ");"; name := "Zeus Event <" & event & ">"; BEGIN ObliqParser.ReadFrom (view.parser, name, TextRd.New(exp), FALSE); TRY EVAL Obliq.EvalTerm(ObliqParser.ParseTerm(view.parser), view.env) EXCEPT | ObliqParser.Eof => <* ASSERT FALSE *> | ObValue.Error (packet) => OblError(view, packet) | ObValue.Exception (packet) => OblException(view, packet) END END Invoke; PROCEDUREFieldDefined (object: Obliq.Val; event: TEXT): BOOLEAN = BEGIN TRY RETURN object # NIL AND Obliq.ObjectHas(object, event) EXCEPT | ObValue.Error => | ObValue.Exception => END; RETURN FALSE END FieldDefined; PROCEDUREOblError (view: T; packet: ObValue.ErrorPacket) = BEGIN Obliq.ReportError(view.swr, packet); ZeusPanel.ReportError( "Obliq error: " & TextWr.ToText(view.wr)) END OblError; PROCEDUREOblException (view: T; packet: ObValue.ExceptionPacket) = BEGIN Obliq.ReportException(view.swr, packet); ZeusPanel.ReportError( "Obliq exception: " & TextWr.ToText(view.wr)) END OblException; BEGIN SynWr.Setup(); ObliqParser.PackageSetup(); ObLibM3.PackageSetup(); ObLibUI.PackageSetup(); ObLibAnim.PackageSetup(); RegisterView (); END ShortestPathSPGraphObliqView.