DIRECTORY CD USING [Rect], Commander USING [CommandProc, Register], IO USING [BreakProc, CharClass, EndOf, EndOfStream, Error, GetChar, GetInt, GetLineRope, GetTokenRope, int, Put, PutF, PutFR, Reset, RIS, rope, STREAM], Process USING [Detach], Rope USING [Cat, Length, ROPE, SkipOver, Substr], RopeList USING [Compare, Cons, Sort], SXQuadTree USING [Store, QuadTreeRoot, Rectangle], ViewerIO USING [CreateViewerStreams], ViewerTools USING [FindExistingViewer, InhibitUserEdits, Viewer]; SXTest: CEDAR MONITOR IMPORTS Commander, IO, Process, Rope, RopeList, SXQuadTree, ViewerIO, ViewerTools = BEGIN ROPE: TYPE = Rope.ROPE; windowCount: INT _ 0; -- a count of the number of test windows created. counter: INT _ 0; -- general purpose; quadTree: SXQuadTree.QuadTreeRoot; MakeTestWindow: ENTRY Commander.CommandProc = BEGIN title: ROPE; windowCount _ windowCount+1; title _ IO.PutFR ["Spinifex maintenance test window # %g", IO.int[windowCount]]; TRUSTED {Process.Detach[FORK Test [title]];} END; MakeQTTestWindow: ENTRY Commander.CommandProc = BEGIN title: ROPE; windowCount _ windowCount+1; title _ IO.PutFR ["Spinifex Quad Tree test window # %g", IO.int[windowCount]]; TRUSTED {Process.Detach[FORK QTTest [title]];} END; MakeCoreTestWindow: ENTRY Commander.CommandProc = BEGIN title: ROPE; windowCount _ windowCount+1; title _ IO.PutFR ["SX Core test %g", IO.int[windowCount]]; TRUSTED {Process.Detach[FORK CoreTest [title]];} END; Test: PROC[title: ROPE] = BEGIN parList: ROPE; parameters, sortedPar: LIST OF ROPE; in, out: IO.STREAM; nothingToDo: BOOL; [in: in, out: out] _ ViewerIO.CreateViewerStreams[title]; DO -- Read a parameter list, terminated by a CR: ENABLE IO.Error => IF ec = SyntaxError THEN { IO.Reset [in]; out.PutF ["\nIncorrect input. Please retype.\n\n"]; LOOP} ELSE EXIT; IO.PutF [stream: out, format: "%lType a parameter list and terminate with CR to sort it:\n%l", v1: IO.rope["e"], v2: IO.rope["E"]]; parList _ IO.GetLineRope[in]; [parameters, nothingToDo] _ PiecifyParameters [parList]; IF nothingToDo THEN {out.Put [IO.rope["Par list empty\n"]]; LOOP}; sortedPar _ SortParameters [parameters]; parList _ RebuildParList [sortedPar]; IO.PutF [stream: out, format: "%l\nThe sorted parameter list is:%l\n%g\n\n", v1: IO.rope["b"], v2: IO.rope["B"], v3: IO.rope[parList]]; ENDLOOP; END; -- Test CoreTest: PROC[title: ROPE] = BEGIN in, out: IO.STREAM; viewer: ViewerTools.Viewer; [in: in, out: out] _ ViewerIO.CreateViewerStreams [title]; viewer _ ViewerTools.FindExistingViewer [title]; ViewerTools.InhibitUserEdits [viewer] END; -- CoreTest QTTest: PROC[title: ROPE] = BEGIN nr: REF INT; r: CD.Rect; rect: REF SXQuadTree.Rectangle; in, out: IO.STREAM; [in: in, out: out] _ ViewerIO.CreateViewerStreams [title]; DO -- Read a parameter list, terminated by a CR: ENABLE IO.Error => IF ec = SyntaxError THEN { IO.Reset [in]; out.PutF ["\nIncorrect input. Please retype.\n\n"]; LOOP} ELSE EXIT; IO.PutF [stream: out, format: "%lType lower left and upper right coordinates and terminate with CR to insert the rectangle:\n%l", v1: IO.rope["e"], v2: IO.rope["E"]]; r.x1 _ IO.GetInt [in]; r.y1 _ IO.GetInt [in]; r.x2 _ IO.GetInt [in]; r.y2 _ IO.GetInt [in]; counter _ SUCC [counter]; nr _ NEW [INT]; nr^ _ counter; rect _ NEW [SXQuadTree.Rectangle]; rect.interestBound _ r; rect.dimDecr _ [0, 0, 0, 0]; rect.nodeInformation _ nr; quadTree _ SXQuadTree.Store [quadTree, rect]; IO.PutF [stream: out, format: "\nRectangle %g inserted in quadtree, size: %g, %g; %g, %g.\n\n", v1: IO.int [counter], v2: IO.int [quadTree.size.x1], v3: IO.int [quadTree.size.y1], v4: IO.int [quadTree.size.x2], v5: IO.int [quadTree.size.y2]]; ENDLOOP; END; -- QTTest PiecifyParameters: PROCEDURE [r: ROPE] RETURNS [rList: LIST OF ROPE, empty: BOOL] = BEGIN ParProc: IO.BreakProc = {RETURN [IF char = ', THEN sepr ELSE other]}; buffer: IO.STREAM ~ IO.RIS [rope: r]; -- reconvert rope into stream rope: ROPE; length, nonSpace: INT; -- Skip leading parenthesis IF IO.GetChar [buffer] # '{ THEN ERROR; empty _ IO.EndOf [buffer]; DO -- rip off subrope until next comma and add to list of ropes BEGIN rope _ IO.GetTokenRope[stream: buffer, breakProc: ParProc ! IO.EndOfStream => GOTO eos].token; nonSpace _ Rope.SkipOver [s: rope, pos: 0, skip: " "]; length _ Rope.Length [base: rope]; IF (nonSpace < length) AND (nonSpace > 0) THEN rope _ Rope.Substr[base: rope, start: nonSpace, len: length-nonSpace]; rList _ RopeList.Cons [list: rList, r: rope]; EXITS eos => RETURN [rList, empty] END ENDLOOP; END; -- PiecifyParameters SortParameters: PROCEDURE [unsorted: LIST OF ROPE] RETURNS [sorted: LIST OF ROPE] = BEGIN sorted _ RopeList.Sort[list: unsorted, compareProc: RopeList.Compare] END; -- SortParameters RebuildParList: PROCEDURE [list: LIST OF ROPE] RETURNS [rope: ROPE] = BEGIN rope _ "{"; rope _ Rope.Cat [r1: "{", r2: list.first]; FOR l: LIST OF ROPE _ list.rest, l.rest WHILE l # NIL DO rope _ Rope.Cat [r1: rope, r2: ", ", r3: l.first] ENDLOOP; END; -- RebuildParList Commander.Register [key: "Test", proc: MakeTestWindow, doc: "A simple Spinifex test program"]; Commander.Register [key: "QTTest", proc: MakeQTTestWindow, doc: "Spinifex quad tree test program"]; Commander.Register [key: "CoreTest", proc: MakeCoreTestWindow, doc: "Prints the contents of the current core sesign created by Spinifex"]; END.  File: SXTest.mesa Last Edited by: Beretta, June 17, 1985 5:26:35 pm PDT gbb January 7, 1986 6:27:25 pm PST Puts up a test window. Puts up a test window. Puts up a test window. Creates typescript window separate from CommandTool with given title. Creates typescript window separate from CommandTool with given title. Creates typescript window separate from CommandTool with given title. The rope is piecified into a list of parameters. Sorts the list of ropes Rebuilds the parameters list from the list of parameters Κ B˜J– "Cedar" stylešœ™™5Icode™"—unitšΟk ˜ Kšœœ˜Kšœ œ˜(Kšœœ}œœ˜˜Kšœœ ˜Kš œœœœœ˜1Kšœ œ˜%Kšœ œ"˜2Kšœ œ˜%Kšœ œ0˜A—šœœ˜Kšœ œ?˜T—Lš˜Kšœœœ˜Kšœ œΟc1˜GKšœ œž˜%Kšœ"˜"LšΟnœœ˜3šœ žœ™Kšœœ˜ Kšœ˜Kšœœ1œ˜PKšœœ˜,Kšœ˜—LšŸœœ˜5šœ žœ™Kšœœ˜ Kšœ˜Kšœœ/œ˜NKšœœ˜.Kšœ˜—LšŸœœ˜7šœ žœ™Kšœœ˜ Kšœ˜Kšœœœ˜:Kšœœ˜0Kšœ˜—LšŸœœœ˜šœE™EKšœ œ˜Kšœœœœ˜$Kšœ œœ˜Kšœ œ˜Lšœ9˜9šœž*Πckž˜1šœœ ˜šœœ˜Kšœ ˜Kšœ4˜4Kšœ˜—Kšœœ˜ —Kšœaœœ ˜ƒKšœ œ˜Kšœ8˜8Kšœ œ œœ˜BKšœ(˜(Kšœ%˜%K•StartOfExpansion―[stream: STREAM, format: ROPE _ NIL, v1: IO.Value _ [null[]], v2: IO.Value _ [null[]], v3: IO.Value _ [null[]], v4: IO.Value _ [null[]], v5: IO.Value _ [null[]]]šœOœœœ˜ˆKšœ˜—Kšœž˜ —LšŸœœœ˜#šœE™EKšœ œœ˜Kšœ˜Lšœ:˜:Kšœ0˜0Kšœ%˜%Kšœž ˜—LšŸœœœ˜!šœE™EKšœœœ˜ Kšœœ˜ Kšœœ˜Kšœ œœ˜Lšœ:˜:šœž* ž˜1šœœ ˜šœœ˜Kšœ ˜Kšœ4˜4Kšœ˜—Kšœœ˜ —Kšœ„œœ ˜¦Kšœœœ ˜.Kšœœœ ˜.Kšœ œ ˜Kšœœœ˜Kšœœ˜"Kšœ˜Kšœ˜Kšœ˜Kšœ-˜-K–―[stream: STREAM, format: ROPE _ NIL, v1: IO.Value _ [null[]], v2: IO.Value _ [null[]], v3: IO.Value _ [null[]], v4: IO.Value _ [null[]], v5: IO.Value _ [null[]]]š œbœœœœœ˜ςKšœ˜—Kšœž ˜—šŸœ œœœ œœœ œ˜SJ™0Lš˜Kš œ œœœ œœ ˜EK–)[rope: ROPE, oldStream: STREAM _ NIL]š œœœœœ ž˜CKšœœ˜ Kšœœ˜Lšž˜Kšœœœœ˜'Kšœœ˜šœž<˜?–-[stream: STREAM, breakProc: IO.BreakProc]š˜Kšœœ3œœ ˜^K–)[s: ROPE, pos: INT _ 0, skip: ROPE]šœ6˜6K–[base: ROPE]šœ"˜"–9[base: ROPE, start: INT _ 0, len: INT _ 2147483647]šœœ˜.KšœF˜F—Kšœ-˜-š˜Kšœœ˜—Kš˜—Jšœ˜—Lšœž˜—šŸœ œ œœœœ œœœ˜SJ™Lš˜K–;[list: LIST OF ROPE, compareProc: RopeList.CompareProc]šœE˜ELšœž˜—–[]šŸœ œœœœœœ˜EJ™8Lš˜Kšœ ˜ K–l[r1: ROPE _ NIL, r2: ROPE _ NIL, r3: ROPE _ NIL, r4: ROPE _ NIL, r5: ROPE _ NIL, r6: ROPE _ NIL]šœ*˜*š œœœœœœ˜8J–l[r1: ROPE _ NIL, r2: ROPE _ NIL, r3: ROPE _ NIL, r4: ROPE _ NIL, r5: ROPE _ NIL, r6: ROPE _ NIL]šœ1˜1Jšœ˜—Lšœž˜—Kšœ^˜^Kšœc˜cKšœŠ˜ŠJ˜Iprocšœ˜J˜—…—ΐ!