<> <> <> DIRECTORY CD, CDBasics, CDCells, CDDirectory, CDInstances, CDOrient, CDProperties, Rope, CDSimpleCells; CDSimpleCellsImpl: CEDAR PROGRAM IMPORTS CD, CDBasics, CDCells, CDDirectory, CDInstances, CDOrient, CDProperties, Rope EXPORTS CDSimpleCells = BEGIN InstRec: TYPE = CDSimpleCells.InstRec; Direction: TYPE = CDSimpleCells.Direction; CreateSimpleCell: PUBLIC PROC [design: CD.Design, contents: LIST OF InstRec, cellName: Rope.ROPE _ NIL, direction: Direction _ right, alignHigh: BOOL _ FALSE] RETURNS [CD.Object] = BEGIN r: CD.Rect _ [0, 0, 0, 0]; c: CD.Object = CDCells.CreateEmptyCell[]; inst: CD.Instance; pos: CD.Position _ [0, 0]; IF Rope.IsEmpty[cellName] THEN cellName _ "-SimpleCell"; NARROW[c.specificRef, CD.CellPtr].name _ cellName; FOR list: LIST OF InstRec _ contents, list.rest WHILE list#NIL DO sz: CD.Position; IF list.first.ob=NIL THEN LOOP; sz _ CDOrient.OrientedSize[CDBasics.SizeOfRect[CD.InterestRect[list.first.ob]], list.first.orient]; SELECT direction FROM right => {pos.x _ r.x2}; left => {pos.x _ r.x1-sz.x}; up => {pos.y _ r.y2}; down => {pos.y _ r.y1-sz.y}; none => {pos _ [0, 0]}; ENDCASE => ERROR; IF alignHigh THEN SELECT direction FROM right, left => {pos.y _ -sz.y}; up, down => {pos.x _ -sz.x}; none => {pos _ [-sz.x, -sz.y]}; ENDCASE => ERROR; inst _ CDCells.IncludeOb[cell: c, ob: list.first.ob, position: [pos.x+list.first.dX, pos.y+list.first.dY], orientation: list.first.orient, cellCSystem: cdCoords, obCSystem: interrestCoords, mode: dontPropagate ].newInst; r _ CDInstances.InstRectI[inst]; IF list.first.properties#NIL THEN inst.properties _ CDProperties.AppendProps[inst.properties, list.first.properties]; IF ~Rope.IsEmpty[list.first.name] THEN CDProperties.PutPropOnInstance[inst, $InstanceName, list.first.name]; ENDLOOP; [] _ CDCells.RepositionCell[c, NIL]; IF design#NIL THEN [] _ CDDirectory.Include[design, c]; RETURN[c] END; END.