PipalFromCDImpl.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Louis Monier January 18, 1988 10:05:47 am PST
Bertrand Serlet January 28, 1988 1:01:57 am PST
DIRECTORY CD, CDAtomicObjects, CDBasics, CDCells, CDDirectory, CDRects, CDSymbolicObjects, CDCurves, CDTexts, CMosB, Imager, ImagerColor, Pipal, PipalFromCD, PipalInt, PipalMask, PipalPaint, PipalWB, RefTab;
PipalFromCDImpl:
CEDAR
PROGRAM
IMPORTS CDAtomicObjects, CDBasics, CDCells, CDDirectory, CDRects, CDSymbolicObjects, CDCurves, CDTexts, CMosB, Imager, ImagerColor, Pipal, PipalInt, PipalMask, PipalWB, RefTab
EXPORTS PipalFromCD =
BEGIN OPEN PipalFromCD;
Objects
colorTable: ARRAY CD.Layer OF PipalPaint.Color ← ALL[Imager.black];
table: RefTab.Ref ← RefTab.Create[];
Convert:
PUBLIC
PROC [cdObject:
CD.Object]
RETURNS [object: Pipal.Object] ~ {
object ← RefTab.Fetch[table, cdObject].val;
IF object#NIL THEN RETURN;
object ←
SELECT
TRUE
FROM
CDRects.IsSimpleRect[cdObject] => ConvertCDRect[cdObject],
CDAtomicObjects.IsAtomicOb[cdObject] => ConvertCDAtomicObject[cdObject],
CDTexts.IsText[cdObject] => ConvertCDText[cdObject],
CDCells.IsCell[cdObject] => ConvertCDCell[cdObject],
CDSymbolicObjects.IsSymbolicOb[cdObject] => Pipal.CreateOverlay[NIL],
CDCurves.IsLine[cdObject] OR CDCurves.IsSpline[cdObject] OR CDCurves.IsPolygon[cdObject] OR CDCurves.IsFilledCurve[cdObject] => Pipal.CreateOverlay[NIL],
ENDCASE => Convert[CDDirectory.Expand1[cdObject].new];
[] ← RefTab.Store[table, cdObject, object];
};
CDToPipalSize:
PROC [size:
CD.Position]
RETURNS [PipalInt.Size] ~ {
RETURN[[size.x, size.y]];
};
ConvertCDRect:
PROC [cdObject:
CD.Object]
RETURNS [object: Pipal.Object] ~ {
object ← PipalMask.CreateBox[
size: CDToPipalSize[CDBasics.SizeOfRect[cdObject.bbox]],
layer: colorTable[cdObject.layer]];
};
ConvertCDAtomicObject:
PROC [cdObject:
CD.Object]
RETURNS [object: Pipal.Object] ~ {
object ← PipalMask.CreateBox[
size: CDToPipalSize[CDBasics.SizeOfRect[cdObject.bbox]],
layer: Imager.MakeGray[0.8]];
};
ConvertCDText:
PROC [cdObject:
CD.Object]
RETURNS [object: Pipal.Object] ~ {
text: CDTexts.TextSpecific ← NARROW[cdObject.specific];
object ← PipalWB.CreateBoxedText[text.text, CDToPipalSize[CDBasics.SizeOfRect[cdObject.bbox]]];
};
CDTransformToTransform:
PROC [cdT:
CD.Transformation]
RETURNS [ppT: PipalInt.Transformation] ~ {
RETURN[ [ translation: [cdT.off.x, cdT.off.y], orientation: VAL[ORD[cdT.orient]] ] ];
};
ConvertCDCell:
PROC [cdObject:
CD.Object]
RETURNS [object: Pipal.Object] ~ {
ConvertInstance: CDCells.InstEnumerator ~ {
child: Pipal.Object ← PipalInt.TransformObject[transformation: CDTransformToTransform[inst.trans], child: Convert[inst.ob]];
objects ← CONS[child, objects];
};
objects: Pipal.Objects ← NIL;
[] ← CDCells.EnumerateInstances[cdObject, ConvertInstance];
object ← Pipal.CreateOverlay[objects];
};
Initialization
colorTable[CMosB.ndif] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/NDif"];
colorTable[CMosB.pdif] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/PDif"];
colorTable[CMosB.pwellCont] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/PWelCont"];
colorTable[CMosB.nwellCont] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/NWelCont"];
colorTable[CMosB.wndif] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/NDif"];
colorTable[CMosB.wpdif] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/PDif"];
colorTable[CMosB.wpwellCont] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/PWelCont"];
colorTable[CMosB.wnwellCont] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/NWelCont"];
colorTable[CMosB.pwell] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/PWel"];
colorTable[CMosB.nwell] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/NWel"];
colorTable[CMosB.pol] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/Pol"];
colorTable[CMosB.met] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/Met"];
colorTable[CMosB.met2] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/Met2"];
colorTable[CMosB.ovg] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/Ovg"];
colorTable[CMosB.cut] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/Cut"];
colorTable[CMosB.cut2] ← ImagerColor.Find["Xerox/Research/ChipNDale/CMosB/Cut2"];
END.