********************************************************************
* NOTE: This file is generated automatically from the event * definition file UnionFind.evt. ********************************************************************<* PRAGMA LL *> MODULEOUTPUT and UPDATE event handling methods:; <*NOWARN*> IMPORT ObLibM3, ObLibUI, SynWr, Obliq, ObliqParser, Rd; <*NOWARN*> IMPORT Filter, Fmt, ObLibAnim, ZFmt, UnionFindViewClass; <*NOWARN*> IMPORT ZeusPanel, ObValue, TextWr, View, VBT, Thread; <*NOWARN*> IMPORT TextRd, Rsrc; CONST ViewName = "ChangeParent.obl"; TYPE T = UnionFindViewClass.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 *> oeSetup := Setup; oeNewSet := NewSet; oeFinishedSets := FinishedSets; oeStartFind := StartFind; oeEndFind := EndFind; oeStartDoFind := StartDoFind; oeStepUp := StepUp; oeFound := Found; oeStepDown := StepDown; oeChangeParent := ChangeParent; oeEndDoFind := EndDoFind; oeStartUnion := StartUnion; oeFoundFirst := FoundFirst; oeCompareRanks := CompareRanks; oeUnite := Unite; oeEndUnion := EndUnion; <* LL.sup = VBT.mu *> END; UnionFindChangeParentObliqView PROCEDURESetup (view: T; ) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "Setup") THEN Invoke (view, "Setup", "" ) END END Setup; PROCEDURENewSet (view: T; nm: TEXT) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "NewSet") THEN Invoke (view, "NewSet", "" & ZFmt.Text(nm) ) END END NewSet; PROCEDUREFinishedSets (view: T; numSets: INTEGER; usesRanks: BOOLEAN) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "FinishedSets") THEN Invoke (view, "FinishedSets", "" & ZFmt.Int(numSets) & "," & ZFmt.Bool(usesRanks) ) END END FinishedSets; PROCEDUREStartFind (view: T; id: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "StartFind") THEN Invoke (view, "StartFind", "" & ZFmt.Int(id) ) END END StartFind; PROCEDUREEndFind (view: T; id: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "EndFind") THEN Invoke (view, "EndFind", "" & ZFmt.Int(id) ) END END EndFind; PROCEDUREStartDoFind (view: T; id: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "StartDoFind") THEN Invoke (view, "StartDoFind", "" & ZFmt.Int(id) ) END END StartDoFind; PROCEDUREStepUp (view: T; child, parent: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "StepUp") THEN Invoke (view, "StepUp", "" & ZFmt.Int(child) & "," & ZFmt.Int(parent) ) END END StepUp; PROCEDUREFound (view: T; id: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "Found") THEN Invoke (view, "Found", "" & ZFmt.Int(id) ) END END Found; PROCEDUREStepDown (view: T; child, parent: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "StepDown") THEN Invoke (view, "StepDown", "" & ZFmt.Int(child) & "," & ZFmt.Int(parent) ) END END StepDown; PROCEDUREChangeParent (view: T; child, parent, root: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "ChangeParent") THEN Invoke (view, "ChangeParent", "" & ZFmt.Int(child) & "," & ZFmt.Int(parent) & "," & ZFmt.Int(root) ) END END ChangeParent; PROCEDUREEndDoFind (view: T; id: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "EndDoFind") THEN Invoke (view, "EndDoFind", "" & ZFmt.Int(id) ) END END EndDoFind; PROCEDUREStartUnion (view: T; id1, id2: INTEGER; bothRoots: BOOLEAN) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "StartUnion") THEN Invoke (view, "StartUnion", "" & ZFmt.Int(id1) & "," & ZFmt.Int(id2) & "," & ZFmt.Bool(bothRoots) ) END END StartUnion; PROCEDUREFoundFirst (view: T; id1: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "FoundFirst") THEN Invoke (view, "FoundFirst", "" & ZFmt.Int(id1) ) END END FoundFirst; PROCEDURECompareRanks (view: T; id1, id2: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "CompareRanks") THEN Invoke (view, "CompareRanks", "" & ZFmt.Int(id1) & "," & ZFmt.Int(id2) ) END END CompareRanks; PROCEDUREUnite (view: T; child, parent, pRank: INTEGER) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "Unite") THEN Invoke (view, "Unite", "" & ZFmt.Int(child) & "," & ZFmt.Int(parent) & "," & ZFmt.Int(pRank) ) END END Unite; PROCEDUREEndUnion (view: T; ) = <* LL.sup < VBT.mu *> BEGIN IF FieldDefined(view.object, "EndUnion") THEN Invoke (view, "EndUnion", "" ) END END EndUnion; PROCEDURERegisterView () = BEGIN ZeusPanel.RegisterView(New, "ChangeParent.obl", "UnionFind") 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 UnionFindChangeParentObliqView.