DIRECTORY CD, CDCells, CDCreateLabels, CDPinObjects, CDProperties, CDRects, CDUtils, HashTable, Imager, ImagerFont, IO, PW, PWPins, Real, Rope, VFonts; CDUtilsImpl: CEDAR PROGRAM IMPORTS CD, CDCells, CDCreateLabels, CDPinObjects, CDProperties, CDRects, HashTable, ImagerFont, IO, PWPins, Real, Rope, VFonts EXPORTS CDUtils = BEGIN Signal: SIGNAL = CODE; ROPE: TYPE = CDUtils.ROPE; cache: HashTable.Table _ HashTable.Create[equal: HashTable.RopeEqual, hash: HashTable.HashRope]; Store: PROC[name: ROPE, obj: CD.Object] = {[]_HashTable.Store[cache, name, obj]}; Fetch: PROC[name: ROPE] RETURNS[obj: CD.Object] = {RETURN[NARROW[HashTable.Fetch[cache, name].value, CD.Object]]}; BlankCell: PUBLIC PROC[size: CD.Position] RETURNS[cell: CD.Object] ~ { cellPtr: CD.CellPtr; found: BOOL _ FALSE; name: ROPE _ IO.PutFR["Dummy-%g-%g", IO.int[size.x], IO.int[size.y]]; IF size.x=0 OR size.y=0 THEN RETURN[NIL]; cell _ Fetch[name]; IF cell#NIL THEN RETURN[cell]; cell _ CDCells.CreateEmptyCell[]; cellPtr _ NARROW[cell.specificRef]; cellPtr.contents _ CONS[NEW[CD.InstanceRep _ [ob: CDRects.CreateRect[size, CD.backGround]] ], cellPtr.contents]; Store[name, cell]}; ObjName: PUBLIC PROC[obj: CD.Object] RETURNS[name: ROPE] = { IF obj=NIL THEN RETURN[NIL]; IF obj.specificRef=NIL THEN RETURN[NIL]; IF NOT ISTYPE[obj.specificRef, CD.CellPtr] THEN RETURN[NIL]; RETURN[NARROW[obj.specificRef, CD.CellPtr].name]}; ObjSize: PUBLIC PROC[obj: CD.Object] RETURNS[size: CD.Position] = {RETURN[CD.InterestSize[obj]]}; font1: Imager.Font _ VFonts.EstablishFont [family:"Helvetica", size: 7, bold: TRUE, italic: FALSE, defaultOnFailure: FALSE]; font2: Imager.Font _ VFonts.EstablishFont [family:"Helvetica", size: 14, bold: TRUE, italic: FALSE, defaultOnFailure: FALSE]; ScaledText: PUBLIC PROC[text: ROPE, box: CD.Position, layer: CD.Layer] RETURNS[cell: CD.Object] = { Scale: PROC[font: Imager.Font] RETURNS[scale: INT] = { extents: ImagerFont.Extents _ ImagerFont.RopeBoundingBox[font, text]; strSize: CD.Position; IF box.x<4 OR box.y<4 THEN RETURN[0]; strSize.x _ Real.RoundI[extents.rightExtent+extents.leftExtent]; strSize.y _ Real.RoundI[extents.ascent+extents.descent]; scale _ MIN[box.x/strSize.x, box.y/strSize.y]}; scaleFactor: INT _ Scale[font2]; IF scaleFactor>0 THEN RETURN[CDCreateLabels.CreateTextCell[NIL, text, font2, scaleFactor, layer]]; scaleFactor _ Scale[font1]; IF scaleFactor>0 THEN RETURN[CDCreateLabels.CreateTextCell[NIL, text, font1, scaleFactor, layer]]; RETURN[NIL] }; RenamePins: PUBLIC PROC[ object: CD.Object, pinNameProc: CDUtils.PinNameProc] RETURNS[newObject: CD.Object] = { KeepPinOnEdge: CDPinObjects.InstanceEnumerator = { newRope: ROPE; newInst: CD.Instance; side: PWPins.Side; side _ PWPins.GetSide[object, inst]; IF side=none THEN RETURN; newRope _ pinNameProc[inst, side]; IF Rope.IsEmpty[newRope] THEN RETURN; newInst _ NEW[CD.InstanceRep _ [ ob: CDPinObjects.CreatePinOb[inst.ob.size], location: inst.location, orientation: inst.orientation ]]; CDProperties.CopyProps[inst.properties, newInst]; CDPinObjects.SetName[newInst, newRope]; newCellPtr.contents _ CONS[newInst, newCellPtr.contents] }; newCellPtr: CD.CellPtr; inst: CD.Instance _ NEW[CD.InstanceRep _ [ob: object]]; CDProperties.PutPropOnInstance[inst, $StopEnumerateDeepPins, $StopEnumerateDeepPins]; newObject _ CDCells.CreateEmptyCell[]; newCellPtr _ NARROW[newObject.specificRef]; [] _ PWPins.EnumerateDeepPins[object, KeepPinOnEdge]; newCellPtr.contents _ CONS[inst, newCellPtr.contents]; CDCells.SetInterestRect[newObject, CD.InterestRect[object]]; RETURN[newObject] }; END. ŒCDUtilsImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last Edited by Curry, March 10, 1986 11:20:09 am PST ʘšœ™Jšœ<™