DIRECTORY CD, CDBasics, CDCells, CDDirectory USING [Fetch, Include, Name], CDOrient USING [MapRect], CDProperties, CDX USING [IncludeOb], Convert USING [RopeFromInt], PWBasics, Rope USING [Cat, ROPE], TerminalIO USING [WriteRope]; PWBasicsImpl: CEDAR PROGRAM IMPORTS CD, CDBasics, CDCells, CDDirectory, CDOrient, CDProperties, CDX, Convert, Rope, TerminalIO EXPORTS PWBasics = BEGIN OPEN PWBasics; ROPE: PUBLIC TYPE = Rope.ROPE; Output: PUBLIC PROC [r1, r2, r3, r4, r5, r6: ROPE _ NIL] = { TerminalIO.WriteRope[Rope.Cat[r1, r2, r3, r4, r5, r6]] }; RopeFromCell: PUBLIC PROC [cell: CD.ObPtr] RETURNS [rope: ROPE] = { rope _ Rope.Cat["Cell ", NameFromObj[cell]] }; RopeFromPos: PUBLIC PROC [pos: CD.Position] RETURNS [rope: ROPE] = { rope _ Rope.Cat["[", Convert.RopeFromInt[pos.x], ", ", Convert.RopeFromInt[pos.y], "]"]; }; RopeFromRect: PUBLIC PROC [rect: CD.Rect] RETURNS [rope: ROPE] = { rope _ Rope.Cat[ "[", Convert.RopeFromInt[rect.x1], ", ", Convert.RopeFromInt[rect.y1], ", ", Rope.Cat[Convert.RopeFromInt[rect.x2], ", ", Convert.RopeFromInt[rect.y2], "]"]] }; ObjFromName: PUBLIC PROC [design: CD.Design, name: ROPE] RETURNS [object: CD.ObPtr _ NIL] = BEGIN found: BOOL; IF name=NIL THEN RETURN; [found: found, object: object] _ CDDirectory.Fetch[design, name]; IF ~found THEN Output["Object '", name, "' does not exist in directory. NIL object used instead.\n"]; END; NameFromObj: PUBLIC PROC [object: CD.ObPtr] RETURNS [name: ROPE _ NIL] = BEGIN IF object=NIL THEN RETURN; name _ CDDirectory.Name[object]; END; GetLocation: PUBLIC PROC [appl: CD.ApplicationPtr, obj: CD.ObPtr] RETURNS [location: CD.Position] = { location _ CDBasics.SubPoints[ CDBasics.BaseOfRect[ CDOrient.MapRect[CD.InterestRect[appl.ob], appl.ob.size, appl.orientation, appl.location]], CDBasics.BaseOfRect[CD.InterestRect[obj]]] }; GetISize: PUBLIC PROC [obj: CD.ObPtr] RETURNS [size: CD.Position] = { size _ CDBasics.SizeOfRect[CD.InterestRect[obj]] }; SizeX: PUBLIC IntFromRectProc = {size _ rect.x2-rect.x1}; SizeY: PUBLIC IntFromRectProc = {size _ rect.y2-rect.y1}; IncludeApplication: PUBLIC PROC [cell, subcell: CD.ObPtr, location: CD.Position _ [0, 0], orientation: CD.Orientation _ CD.combined] RETURNS [newAppl: CD.ApplicationPtr] = { newAppl _ CDX.IncludeOb[ design: NIL, cell: cell, ob: subcell, position: location, orientation: orientation, cellCSystem: interrestCoords, obCSystem: interrestCoords, mode: dontPropagate ].newApp }; RepositionCell: PUBLIC PROC [design: CD.Design, cell: CD.ObPtr, name: ROPE _ NIL] = BEGIN [] _ CDCells.RepositionCell[cell, NIL]; -- NIL because cell is not yet included in design IF design#NIL THEN Include[design, cell, name]; END; Include: PUBLIC PROC [design: CD.Design, object: CD.ObPtr, name: ROPE _ NIL] = { IF CDProperties.GetPropFromObject[from: object, prop: $Owner]#design THEN IF ~CDDirectory.Include[design, object, name] THEN ERROR; }; AppendProps: PUBLIC PROC [newObj, obj: CD.ObPtr] = { FOR l: CDProperties.Properties _ obj.properties, l.rest WHILE l#NIL DO IF ISTYPE[l.first.key, ATOM] AND CDProperties.GetPropFromObject[newObj, l.first.key]=NIL THEN { p: CDProperties.PropertyProcs = CDProperties.FetchProcs[l.first.key]; IF p#NIL AND p.makeCopy#NIL THEN CDProperties.PutPropOnObject[ newObj, l.first.key, p.makeCopy[l.first.key, l.first.val]]; }; ENDLOOP; }; END. ¦PWBasicsImpl.mesa, Created by Bertrand Serlet Last Edited by Bertrand Serlet, May 2, 1985 1:47:03 am PDT Last Edited by: Monier, February 7, 1985 4:53:57 pm PST All the data structures common to low-level stretch algorithms, and some commonly used ops on those data types. Also contains all the stuff for error messages, warnings, bugs ... -- Utilities -- Converting from PWLow to PW If name=NIL or if name is not found, returns NIL Gets the name from the object. If object=NIL returns NIL -- Geometric primitives The following primitive allow the use of the interestRectangle coordinates only Gives the size of the interest Rect -- Creation of a new cell -- Inclusion of an application of a subCell in a cell -- When all inclusions have been made, this proc should be called. Assumptions are that object is a cell and that Size and InterestRect are meaningless and need being recomputed. If design is given, the cell is added to to directory, if not previously done. If name is given, it is the preferred name of the new cell. As CDDirectory.Include, but may include the same cell twice in the same design Adds the properties of obj which are copiable to the ones of newObj, ʘ™J™J™:J™7—J˜J™oJ™BJ™J™šÏk œ˜ J˜Jšœ˜Jšœ ˜ Jšœ˜Jšœ œ˜)Jšœ œ ˜Jšœ ˜ Jšœœ ˜Jšœœ˜Jšœ ˜ Jšœœœ˜Jšœ œ ˜J˜J˜—šÏb œœœ˜J•StartOfExpansion[]šœ[˜bJšœ ˜Jšœ˜Jšœ ˜J˜™ J™JšÐbkœœœœ˜J˜š žœœœœœ˜