DIRECTORY Rope USING [ROPE], IO USING [PutF, GetChar], Process USING [Milliseconds, MsecToTicks, Pause], COGDebug USING [in, out], COGVoronoi USING [MakeVertexObject, MakeEdgeObject, MakeRegionObject, VertexRec], COGDiagram USING [DEdge], COGDrawing USING [Drawing, Object, MakeDrawing, Add, RemoveLayers, Color, Size, black, AddPropertyButton, AddMenuAction, MenuProc, PutProp, PaintOrder, RepaintAll], COGVorTest; COGVorTestImpl: CEDAR PROGRAM IMPORTS IO, Process, COGDrawing, COGDebug, COGVoronoi EXPORTS COGVorTest = BEGIN OPEN Rope, IO, Draw: COGDrawing, Vor: COGVoronoi, Bug: COGDebug, Diag: COGDiagram, COGVorTest; theDrawing: PUBLIC Draw.Drawing _ NIL; ShowDelay: PUBLIC Process.Milliseconds _ 0; ShowRegion: PUBLIC PROC [e: Diag.DEdge, color: Draw.Color _ Draw.black, side: Draw.Size _ 0] = TRUSTED {Draw.Add [dr: theDrawing, obj: Vor.MakeRegionObject[e, color, side], order: 2]; Process.Pause[Process.MsecToTicks[ShowDelay]]}; ShowEdge: PUBLIC PROC [e: Diag.DEdge, color: Draw.Color _ Draw.black, width: Draw.Size _ 0] = TRUSTED {Draw.Add [dr: theDrawing, obj: Vor.MakeEdgeObject[e, color, width], order: 4]; Process.Pause[Process.MsecToTicks[ShowDelay]]}; ShowVertex: PUBLIC PROC [v: REF Vor.VertexRec, color: Draw.Color _ Draw.black, side: Draw.Size _ 0] = TRUSTED {Draw.Add [dr: theDrawing, obj: Vor.MakeVertexObject[v, color, side], order: 5]; Process.Pause[Process.MsecToTicks[ShowDelay]]}; CleanTheDrawing: PUBLIC PROC [repaint: BOOL _ FALSE]= BEGIN Draw.RemoveLayers [dr: theDrawing, minOrder: FIRST[Draw.PaintOrder], maxOrder: 2]; Draw.RemoveLayers [dr: theDrawing, minOrder: 4, maxOrder: LAST[Draw.PaintOrder]]; IF repaint THEN Draw.RepaintAll [theDrawing] END; SlowMode: Draw.MenuProc = BEGIN SELECT button FROM red => {ShowDelay _ (IF ShowDelay = 0 THEN 500 ELSE 2*ShowDelay)}; yellow => {ShowDelay _ 0}; blue => {ShowDelay _ (IF ShowDelay <= 500 THEN 0 ELSE ShowDelay/2)} ENDCASE => {} END; MenuCleanDrawing: Draw.MenuProc = BEGIN -- parameters: [parent: REF ANY, clientData: REF ANY, mouseButton] -- Called by the system when the "Clean" menu entry is activated. CleanTheDrawing[repaint: TRUE] -- Kludge: assumes the parent is theDrawing END; Bug.out.PutF["\nVorTestImpl: Hello! Say something: "]; [] _ Bug.in.GetChar[]; theDrawing _ Draw.MakeDrawing ["VORONOI DIAGRAM", drBox]; Draw.AddPropertyButton [theDrawing, $ENum]; Draw.AddPropertyButton [theDrawing, $VNum]; Draw.AddPropertyButton [theDrawing, $Voronoi]; Draw.AddMenuAction [dr: theDrawing, name: "Slow", Proc: SlowMode, needs: none, line: 0]; Draw.AddMenuAction [dr: theDrawing, name: "Clean", Proc: MenuCleanDrawing, needs: write, line: 0]; Draw.PutProp [theDrawing, $ENum, $TRUE]; Bug.out.PutF["\nVorTestImpl: Enjoy yourself. Bye!"] END. T-- COGVorTestImpl.mesa: basic setup for Voronoi testing programs -- last modified by Stolfi - October 16, 1982 6:42 pm -- To do: draw vertex and region numbers -- To do: merge with COGVoronoiImpl? -- To do: paint region, not point, in DVertexPainter when in dual mode -- To run: run COGAll; run COGVoronoiImpl; run COGVorTestImpl Κ– "Mesa" style˜IprocšΟcΟbΠbc*™@š5™5Kšœžœ ™(Kšœžœ™$Kšœžœ>™F—KšŸ"œœ™@KšœΟk œ œ œ œ œ œ0 œ œS œ œ«˜ΑKš žœ œ œ œ œ2 œ˜xKš œ œ  œY˜rKšž œ œ œ˜&Kšž œ œ˜+šΟn œ œ œJ ˜hKšœ˜—š‘œ œ œK ˜gKšœ€˜€—š ‘ œ œ œ œG ˜oKšœ˜—š ‘œ œ œ  œ œ˜5Kš  œ4 œa œ œ  œ œ˜κ—šžœ˜Kš œ œ œ œ œ œI œ œ œ œ œ˜ή—šžœ˜!Kš  œCœBœ œ!Ÿ  œ˜β—KšœΖ œ˜ΜJ˜—…— 6Œ