CDSCheck.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, February 19, 1986 10:12:40 am PST
Last Edited by: Christian Jacobi, October 23, 1986 12:53:54 pm PDT
DIRECTORY Atom, CD, CDBasics, CDCSUtil, CDErrors, CDInstances, CDProperties, CDSequencer, CDSimpleRules, CDValue, CDViewer, CedarProcess, Process, Rope, TerminalIO, ViewerClasses, ViewerOps;
CDSCheck: CEDAR PROGRAM
IMPORTS Atom, CD, CDBasics, CDCSUtil, CDErrors, CDInstances, CDProperties, CDSequencer, CDSimpleRules, CDValue, CDViewer, CedarProcess, Process, Rope, TerminalIO, ViewerOps =
BEGIN
Message: PROC [comm: CDSequencer.Command] =
BEGIN
h: CDCSUtil.CDWorld ~ NARROW[comm.data];
errors: CDCSUtil.Tesselation ~ NARROW[CDProperties.GetProp[h.propRef, $err]];
layerName: Rope.ROPE ~ NARROW[CDProperties.GetProp[h.propRef, $layer]];
key: ATOM ~ Atom.MakeAtom[Rope.Concat["||ck-", layerName]];
IF CDValue.Fetch[h.design, key]=h.design.actual.first.dummyCell.ob THEN
CDErrors.RemoveMessages[h.design, NIL, key]
ELSE
CDErrors.RemoveAllMessages[h.design, key];
[] ← CDCSUtil.ExtractErrors[h, errors, Rope.Concat[layerName, " spacing"], key];
CDValue.Store[h.design, key, h.design.actual.first.dummyCell.ob];
END;
CheckSpacing: PROC [d: CD.Design, r: CD.Rect, layer: CD.Layer] =
BEGIN
h: CDCSUtil.CDWorld ← NEW[CDCSUtil.CDWorldRec ← [design: d, scaleNum: 2, clip: r, propRef: CD.InitPropRef[]]];
original: CDCSUtil.Tesselation ← CDCSUtil.Make[h, LIST[NEW[CDCSUtil.LayerDescRec←[layer]]]];
distRule: CD.Number ← CDSimpleRules.MinDist[layer, layer];
amount: INT ← (h.scaleNum*distRule)/2-1;
grown: CDCSUtil.Tesselation ← CDCSUtil.Grow[original, amount];
again: CDCSUtil.Tesselation ← CDCSUtil.Grow[grown, -amount];
errors: CDCSUtil.Tesselation ← CDCSUtil.AndNot[again, original];
CDProperties.PutProp[h.propRef, $err, errors];
CDProperties.PutProp[h.propRef, $layer, Atom.GetPName[CD.LayerKey[layer]]];
CDSequencer.ExecuteProc[proc: Message, queue: doQueueAndMark,
comm: NEW[CDSequencer.CommandRec ← [data: h, design: d]]
];
END;
CheckProcess: PROC [] =
BEGIN
d: CD.Design; md: CD.Number;
CedarProcess.SetPriority[CedarProcess.Priority[background]];
DO -- forever
v: ViewerClasses.Viewer ← CDViewer.LastViewer[];
IF v#NIL AND ViewerOps.FetchProp[v, $backCheck]=$y AND (d�Viewer.DesignOf[v])#NIL THEN {
r: CD.Rect ← CDViewer.VisibleRect[v]; --handle view rect only for speed up
--restrict further to pushed in cell
IF d.actual.rest#NIL THEN
r ← CDBasics.Intersection[r, CDInstances.InstRectO[d.actual.first.mightReplace]];
--restrict further to handy scales
IF r.y2-r.y1<150*d.technology.lambda THEN
FOR ll: LIST OF CD.Layer ← d.technology.usedLayers, ll.rest WHILE ll#NIL DO
IF (md�SimpleRules.MinDist[ll.first, ll.first])>0 THEN
CheckSpacing[d, CDBasics.Extend[r, md+d.technology.lambda], ll.first];
Process.Pause[Process.MsecToTicks[1]];
ENDLOOP;
};
d ← NIL; --gc
Process.Pause[Process.MsecToTicks[500]];
ENDLOOP;
END;
CheckStartCommand: PROC [comm: CDSequencer.Command] =
BEGIN
v: ViewerClasses.Viewer ← CDViewer.GetViewer[comm];
TerminalIO.PutRope[" start background checking for this viewer\n"];
IF v#NIL THEN ViewerOps.AddProp[v, $backCheck, $y];
END;
CheckStopCommand: PROC [comm: CDSequencer.Command] =
BEGIN
v: ViewerClasses.Viewer ← CDViewer.GetViewer[comm];
TerminalIO.PutRope[" stop background checking in this viewer\n"];
IF v#NIL THEN ViewerOps.AddProp[v, $backCheck, NIL];
END;
CDSequencer.ImplementCommand[$BackgroundCheckStart, CheckStartCommand,, dontQueue];
CDSequencer.ImplementCommand[$BackgroundCheckStop, CheckStopCommand,, dontQueue];
TRUSTED { Process.Detach[FORK CheckProcess[]] };
END.