CMosPDif.mesa (part of Chipndale)
by Christian Jacobi September 10, 1983 9:34 pm
last edited Christian Jacobi December 14, 1983 3:37 pm
DIRECTORY
CD,
CDRects,
CDIO,
CDLRUCache,
CDOrient,
CDInline,
CDApplications,
CMos,
TokenIO;
CMosPDif:
CEDAR
PROGRAM
IMPORTS CD, CDIO, CDLRUCache, CDRects, CDOrient, CDInline, CDApplications, 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.insideRect ← InsideWellDiffRect;
pForWellDiff.showMeSelected ← ShowSelectedWellDiffRect;
pForWellDiff.hitInside ← HitInsideWellDiffRect;
pForWellDiff.internalRead ← ReadWellDif;
pForWellDiff.internalWrite ← WriteWellDif;
pForWellDiff.wireTyped ← TRUE;
CDRects.UseAsCreateRect[CMos.pdif, CreateWellDiffRect, pForWellDiff];
-- hack; here to reduce numbers of modules only
CDRects.UseAsCreateRect[CMos.bur, CDRects.CreateSaveRect];
CDRects.UseAsCreateRect[CMos.cut2, CDRects.CreateSaveRect];
END;
WriteWellDif:
CD.InternalWriteProc
-- PROC [me: ObPtr] -- =
BEGIN
TokenIO.WriteInt[me.size.x-2*wellSurround];
TokenIO.WriteInt[me.size.y-2*wellSurround];
CDIO.WriteLevel[me.level];
END;
ReadWellDif:
CD.InternalReadProc
--PROC [] RETURNS [ObPtr]-- =
BEGIN
x: INT = TokenIO.ReadInt[];
y: INT = TokenIO.ReadInt[];
l: CD.Level = CDIO.ReadLevel[];
ob: CD.ObPtr = CreateWellDiffRect[[x, y], l];
RETURN [ob]
END;
InsideWellDiffRect:
PROC [ob:
CD.ObPtr]
RETURNS [
CD.DesignRect] =
BEGIN
RETURN [CDInline.Extend[CDInline.RectAt[[0, 0], ob.size], -wellSurround]]
END;
ShowSelectedWellDiffRect:
PROC [aptr:
CD.ApplicationPtr, pos:
CD.DesignPosition,
orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
pr.outLineProc[CDInline.Extend[CDOrient.RectAt[pos, aptr.ob.size, orient], -(wellSurround)], pr]
END;
HitInsideWellDiffRect:
PROC [aptr:
CD.ApplicationPtr, hitRect:
CD.DesignRect]
RETURNS [BOOL] =
BEGIN
RETURN [CDInline.Intersect[
CDInline.Extend[
CDApplications.ApplicationRect[aptr],
-wellSurround],
hitRect]]
END;
CreateWellDiffRect:
PROC [size:
CD.DesignPosition, l:
CD.Level]
RETURNS [
CD.ObPtr] =
BEGIN
ob: CD.ObPtr ~ cache.UnusedOrNew[];
ob.p ← pForWellDiff;
ob.size ← CDInline.AddSize[
[2*wellSurround, 2*wellSurround],
CDInline.MaxPoint[size, [0, 0]]];
ob.level ← l;
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 = CDInline.Extend[r, -wellSurround];
pr.drawRect[inr, aptr.ob.level, pr];
pr.drawRect[r, CMos.nwel, pr];
END;
Init[];
END.