DIRECTORY CD, CDInstances, CDBasics, CDCells, CDDirectory, CDOps, CDOrient; CDCellsImpl2: CEDAR PROGRAM IMPORTS CD, CDInstances, CDBasics, CDCells, CDDirectory, CDOps, CDOrient EXPORTS CDCells = BEGIN CoordSystem: TYPE = CDCells.CoordSystem; IncludeOb: PUBLIC PROC [design: CD.Design_NIL, cell: CD.Object_NIL, ob: CD.Object, position: CD.Position_[0, 0], --evaluated before an eventual repositioning orientation: CD.Orientation_0, cellCSystem: CoordSystem_originCoords, obCSystem: CoordSystem_interrestCoords, mode: CDCells.IncludeMode_doit] RETURNS [newInst: CD.Instance, rep: BOOL_FALSE] = BEGIN cp: CD.CellPtr; obInterestRect: CD.Rect = CD.InterestRect[ob]; IF ob=NIL THEN ERROR CD.Error[callingError, "Include NIL ob"]; IF cell=NIL THEN { IF design=NIL THEN cp _ NIL ELSE cp _ design^.actual.first.specific; } ELSE { cp _ NARROW[cell.specificRef]; SELECT cellCSystem FROM originCoords => position _ CDBasics.AddPoints[position, CD.ClientOrigin[cell]]; interrestCoords => position _ CDBasics.AddPoints[position, CDBasics.BaseOfRect[CD.InterestRect[cell]]]; ENDCASE --cdCoords-- => NULL; }; newInst _ NEW[CD.InstanceRep _ [ ob: ob, location: CDBasics.SubPoints[ position, --in cell coordinate system CDBasics.BaseOfRect[ --correction for object coordinate system CDOrient.MapRect[ itemInCell: (SELECT obCSystem FROM interrestCoords => obInterestRect, originCoords => CDBasics.RectAt[CD.ClientOrigin[ob], [0, 0]], cdCoords => CDBasics.RectAt[[0, 0], ob.size], ENDCASE => ERROR ), cellSize: ob.size, cellInstOrient: orientation, cellInstPos: [0, 0] ] ] ], orientation: orientation, selected: FALSE ]]; IF cp#NIL AND mode#dontInclude THEN { cp.contents _ CONS[newInst, cp.contents]; --does not yet change insideRect !! IF cell#NIL THEN { rep _ ~CDBasics.Inside[CDInstances.InstRectO[newInst], CDBasics.RectAt[[0, 0], cell.size]] OR (cp.useDIr AND ~CDBasics.Inside[ CDOrient.MapRect[ itemInCell: obInterestRect, cellSize: ob.size, cellInstOrient: orientation, cellInstPos: newInst.location], CD.InterestRect[cell] ] ); IF rep AND mode=doit THEN [] _ CDCells.RepositionCell[cell, design]; IF mode#dontPropagate THEN CDDirectory.PropagateChange[cell, design]; }; --cell#NIL IF design#NIL AND mode=doit THEN { IF cell=NIL THEN CDOps.RedrawInstance[design, newInst, FALSE] ELSE CDOps.DelayedRedraw[design] }; }; END; RemoveInstance: PUBLIC PROC [design: CD.Design_NIL, cell: CD.Object_NIL, inst: CD.Instance, mode: CDCells.IncludeMode_doit] RETURNS [removed: BOOL_FALSE, rep: BOOL_FALSE] = BEGIN cp: CD.CellPtr; IF inst=NIL THEN ERROR CD.Error[callingError, "Remove NIL inst"]; IF cell=NIL THEN { IF design=NIL THEN ERROR CD.Error[callingError, "Remove from NIL cell"]; cp _ design^.actual.first.specific; } ELSE { cp _ NARROW[cell.specificRef]; }; IF cp#NIL AND mode#dontInclude THEN { IF cp.contents#NIL THEN { IF cp.contents.first=inst THEN { removed _ TRUE; cp.contents _ cp.contents.rest } ELSE FOR list: CD.InstanceList _ cp.contents, list.rest WHILE list.rest#NIL DO IF list.rest.first=inst THEN { removed _ TRUE; list.rest _ list.rest.rest; EXIT } ENDLOOP; }; IF cell#NIL THEN { r: CD.Rect = CDInstances.InstRectO[inst]; rep _ r.x1<=0 OR r.y1<=0 OR r.x2>=cell.size.x OR r.y2>=cell.size.y; IF ~rep AND cp.useDIr THEN { rep _ r.x1<=cp.ir.x1 OR r.y1<=cp.ir.y1 OR r.x2>=cp.ir.x2 OR r.y2>=cp.ir.y2; }; IF rep AND mode=doit THEN [] _ CDCells.RepositionCell[cell, design]; IF mode#dontPropagate THEN CDDirectory.PropagateChange[cell, design]; }; --cell#NIL IF design#NIL AND mode=doit THEN { IF cell=NIL THEN CDOps.RedrawInstance[design, inst] ELSE CDOps.DelayedRedraw[design] }; }; END; END. CDCellsImpl2.mesa (part of ChipNDale) Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. by Ch. Jacobi, September 10, 1984 9:20:09 am PDT last edited by Ch. Jacobi, March 14, 1986 10:42:44 am PST {outerCoordinates, innerCoordinates, clientCoordinates}; --design (NIL: allowed, if cell really is not yet part of a design) --cell (NIL: include into design; assumes the designs origin at [0, 0]) -- (design&cell NIL: simply create an application) --ob: object to include in cell --position: ... --orientation: of ob inside cell --cellCSystem: tells reference point in cell (for designs: [0, 0] anyway) --obCSystem: reference point of object --mode: -- doit: normal case everything is done -- dontReposition: speed up hack -- Caution: makes temporary a wrong coordinate system! cell is -- not legal until repositioning is called to clean up. -- Has no effect if cell is NIL. -- Does not cause redrawing of the design. -- dontPropagate: speed up hack. -- does neither reposition nor propagate the changed event; cell gets -- an illegal state until repositioning and change-propagation occurs. -- dontInclude: hack to create instances; cell is not changed at all. --newInst: the new created application --rep: Reposition was done or should be done, depending of mode --prepare cell and position relative to cell --handle position: -- realPos _ (clientPos+cellOrigin) - (position of object origin at fake [0,0] pos) --include, handle propagation and reposition --prepare cell --remove, handle propagation and reposition Κ‘˜codešœ&™&Kšœ Οmœ7™BKšœ0™0Kšœ9™9K˜—šΟk ˜ Kšžœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ —K˜šΠbl œžœžœ˜Kšžœžœ>˜HKšžœ ˜—Kšžœ˜K˜šœ žœ˜)Kšœ8™8—K™K˜šΟn œžœžœ žœžœžœžœžœ ˜SKšœ žœΟc,˜KKšœ žœ˜Kšœ(˜(Kšœ(˜(šœ ˜ Kšžœ žœžœžœ˜1—KšœC™CKšœG™GKšœ3™3Kšœ#™#Kšœ™Kšœ!™!KšœI™IKšœ&™&Kšœ™Kšœ(™(Kšœ!™!Kšœ‘œ6™AKšœ8™8Kšœ!™!Kšœ+™+Kšœ!™!KšœG™GKšœH™HKšœF™FKšœ&™&Kšœ?™?Kšž˜Kšœžœ ˜Kšœžœžœ˜.Kš žœžœžœžœžœ'˜>Kšœ,™,šžœžœžœ˜Kšžœžœžœž˜Kšžœ$˜(K˜—šžœ˜Kšœžœ˜šžœ ž˜Kšœ8žœ˜Ošœ;˜;Kšœžœ˜,—Kšžœ‘ œžœ˜—K˜—Kšœ™KšœU™Ušœ žœžœ˜ Kšœ˜šœ˜Kšœ ‘˜%šœ‘)˜>šœ˜šœ žœ ž˜"Kšœ"˜"Kšœ!žœ˜>Kšœ-˜-Kšžœž˜Kšœ˜—Kšœ˜Kšœ˜Kšœ˜K˜—K˜—K˜—Kšœ˜Kšœ žœ˜K˜—Kšœ-™-šžœžœžœžœ˜%Kšœžœ‘#˜Mšžœžœžœ˜šœ˜KšœU˜UKšžœ˜šœ ž˜šœ˜šœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ!˜!—Kšœžœ˜Kšœ˜—K˜——Kšžœžœ žœ+˜DKšžœžœ+˜EKšœ‘ ˜ —šžœžœžœ žœ˜"Kšžœžœžœ'žœ˜=Kšžœ˜ K˜—K˜—Kšžœ˜—K˜š œžœžœ žœžœžœžœžœ ˜\Kš œ žœ žœžœžœžœ˜PKšž˜Kšœžœ ˜Kš žœžœžœžœžœ(˜AKšœ™šžœžœžœ˜Kš žœžœžœžœžœ-˜HKšœ#˜#K˜—šžœ˜Kšœžœ˜K˜—Kšœ,™,šžœžœžœžœ˜%šžœ žœžœ˜šžœžœ˜ Kšœ žœ˜Kšœ˜K˜—šž˜š žœžœ'žœ žœž˜Išžœžœ˜Kšœ žœ˜Kšœ˜Kšž˜Kšœ˜—Kšžœ˜——K˜—šžœžœžœ˜Kšœžœ$˜)Kšœžœ žœžœ˜Cšžœžœ žœ˜Kšœžœžœžœ˜KK˜—Kšžœžœ žœ+˜DKšžœžœ+˜EKšœ‘ ˜ —šžœžœžœ žœ˜"Kšžœžœžœ#˜3Kšžœ˜ K˜—K˜—Kšžœ˜—K˜Kšžœ˜K˜—…—2ί