File: CSTest.mesa
Last Edited by: Beretta, June 17, 1985 5:26:35 pm PDT
gbb March 25, 1986 2:06:40 pm PST
DIRECTORY
Commander USING [CommandProc, Register],
CStitching,
CSMonitor,
IO USING [Error, GetInt, int, PutF, PutF1, PutFR, Reset, rope, STREAM],
Process USING [Detach],
Rope USING [ROPE],
ViewerIO USING [CreateViewerStreams];
CSTest: CEDAR MONITOR
IMPORTS Commander, CStitching, CSMonitor, IO, Process, ViewerIO =
BEGIN
ROPE: TYPE = Rope.ROPE;
windowCount: INT ← 0; -- a count of the number of test windows created.
counter: INT ← 0; -- general purpose;
MakeTestWindow: ENTRY Commander.CommandProc = BEGIN
Puts up a test window.
title: ROPE;
windowCount ← windowCount+1;
title ← IO.PutFR ["CS maintenance test window # %g", IO.int[windowCount]];
TRUSTED {Process.Detach[FORK Test [title]];}
END;
Test: PROC [title: ROPE] = BEGIN
Creates typescript window separate from CommandTool with given title.
nr, value: REF INT;
r, s: CStitching.Rect;
plane: CStitching.Tesselation = CStitching.NewTesselation [];
t: CStitching.Tile;
in, out: IO.STREAM;
[in: in, out: out] ← ViewerIO.CreateViewerStreams [title];
[] ← CSMonitor.Monitor [plane, title, NIL];
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: "%lLower left and upper right coord. of rect. (terminate with CR): %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;
CStitching.ChangeRect [plane, r, nr];
IO.PutF1 [out, " Rectangle %g inserted.\n", IO.int[nr^]];
t ← CStitching.FindTile [plane, [r.x2-r.x1, r.y2-r.y1]];
value ← NARROW [t.value, REF INT];
s ← CStitching.Area [t];
IO.PutF [stream: out,
format: "\nRectangle %g found in plane: %g, %g; %g, %g.\n\n",
v1: IF value = NIL THEN IO.rope ["NIL"] ELSE IO.int [value^],
v2: IO.int [s.x1],
v3: IO.int [s.y1],
v4: IO.int [s.x2],
v5: IO.int [s.y2]];
ENDLOOP;
END; -- Test
Commander.Register [key: "Test", proc: MakeTestWindow, doc: "A simple CS test program"];
END.