CMosPDif.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, September 10, 1983 9:34 pm
last edited Christian Jacobi, March 20, 1985 9:46:27 am PST
DIRECTORY
CD,
CDApplications,
CDBasics,
CDRects,
CDIO,
CDLRUCache,
CDOrient,
CMos,
Rope,
TokenIO;
CMosPDif: CEDAR PROGRAM
IMPORTS CD, CDApplications, CDBasics, CDIO, CDLRUCache, CDRects, CDOrient, CMos, TokenIO =
BEGIN
lambda: CD.DesignNumber = CD.lambda;
wellSurround: CD.DesignNumber = CMos.wellSurround;
pForWellDiff: REF CD.ObjectProcs = CD.RegisterObjectType[$CMosPDifRect, CMos.cmos];
cache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 30, newProc: NewPDif];
dummySpecific: REF CMos.WellRectRep = NEW[CMos.WellRectRep];
NewPDif: PROC [] RETURNS [CD.ObPtr] = {
ob: CD.ObPtr ← NEW[CD.ObjectDefinition←[p: pForWellDiff]];
ob.specificRef ← dummySpecific;
RETURN [ob]
};
Init: PROC [] =
BEGIN
pForWellDiff.drawMe ← DrawWellDiffRect;
pForWellDiff.interestRect ← pForWellDiff.oldInsideRect ← InsideWellDiffRect;
pForWellDiff.showMeSelected ← ShowSelectedWellDiffRect;
pForWellDiff.hitInside ← HitInsideWellDiffRect;
pForWellDiff.internalRead ← ReadWellDif;
pForWellDiff.internalWrite ← WriteWellDif;
pForWellDiff.wireTyped ← TRUE;
pForWellDiff.describe ← Describe;
CDRects.UseAsCreateRect[CMos.wpdif, CreateWellDiffRect, pForWellDiff];
-- hack; here to reduce numbers of modules only
CDRects.UseAsCreateRect[CMos.bur, CDRects.CreateSaveRect];
CDRects.UseAsCreateRect[CMos.cut2, CDRects.CreateSaveRect];
END;
Describe: PROC[me: CD.ObPtr] RETURNS [Rope.ROPE] =
BEGIN
RETURN ["w-pdif"]
END;
WriteWellDif: CD.InternalWriteProc -- PROC [me: ObPtr] -- =
BEGIN
TokenIO.WriteInt[me.size.x-2*wellSurround];
TokenIO.WriteInt[me.size.y-2*wellSurround];
CDIO.WriteLayer[CMos.wpdif];
END;
ReadWellDif: CD.InternalReadProc --PROC [] RETURNS [ObPtr]-- =
BEGIN
x: INT = TokenIO.ReadInt[];
y: INT = TokenIO.ReadInt[];
l: CD.Layer = CDIO.ReadLayer[];
ob: CD.ObPtr = CreateWellDiffRect[[x, y], CMos.wpdif];
RETURN [ob]
END;
InsideWellDiffRect: PROC [ob: CD.ObPtr] RETURNS [CD.DesignRect] =
BEGIN
RETURN [CDBasics.Extend[CDBasics.RectAt[[0, 0], ob.size], -wellSurround]]
END;
ShowSelectedWellDiffRect: PROC [aptr: CD.ApplicationPtr, pos: CD.DesignPosition,
orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
pr.outLineProc[CDBasics.Extend[CDOrient.RectAt[pos, aptr.ob.size, orient], -(wellSurround)], pr]
END;
HitInsideWellDiffRect: PROC [aptr: CD.ApplicationPtr, hitRect: CD.DesignRect]
RETURNS [BOOL] =
BEGIN
RETURN [CDBasics.Intersect[
CDBasics.Extend[
CDApplications.ARectO[aptr],
-wellSurround],
hitRect]]
END;
CreateWellDiffRect: PROC [size: CD.DesignPosition, l: CD.Layer] RETURNS [CD.ObPtr] =
BEGIN
ob: CD.ObPtr ~ cache.UnusedOrNew[];
ob.p ← pForWellDiff;
ob.size ← CDBasics.AddSize[
[2*wellSurround, 2*wellSurround],
CDBasics.MaxPoint[size, [1, 1]]];
ob.layer ← CMos.wpdif;
RETURN [cache.ReplaceByAequivalent[ob]]
END;
DrawWellDiffRect: PROC [aptr: CD.ApplicationPtr, pos: CD.DesignPosition, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
r: CD.DesignRect = CDOrient.RectAt[pos, aptr.ob.size, orient];
inr: CD.DesignRect = CDBasics.Extend[r, -wellSurround];
pr.drawRect[inr, CMos.pdif, pr];
pr.drawRect[r, CMos.nwel, pr];
END;
Init[];
END.