PWPins.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet, June, 1985 0:20:20 am PDT
Bertrand Serlet, February 6, 1986 11:31:24 am PST
DIRECTORY
CD USING [Instance, Object, Orientation, Position, PropList, Rect],
CDSymbolicObjects USING [InstEnumerator],
Rope USING [ROPE];
PWPins: CEDAR DEFINITIONS =
BEGIN
Types and Definitions
ROPE: TYPE = Rope.ROPE;
Side: TYPE = {bottom, right, top, left, none};
The convention for getting the side of a pin is to see if the pin is located on the border of the InterestRect of the ob. For pins at a corner, the biggest direction is the relevant one. This is not a Hack, because in fact only the dimension parallel to the side of the pin is meaningful.
GetSide: PROC [ob: CD.Object, pin: CD.Instance] RETURNS [side: Side];
Enumeration of pins
This proc enumerates in random order all pins, even the ones found in the deepest levels of the hierarchy of ob. The instances passed to eachPin are new instances, with all properties (e.g. the name) copied, so that the coordinate system refers to the one of ob. EnumerateDeepPins uses the expand proc for objects of unknown class. Changes on pins while the enumeration may or may not be seen. If the flag stopEnumerateDeepPins is TRUE, the recursion stops on instances of cells which have a non-nil $StopEnumerateDeepPins property, i.e. those instances will not be enumerated.
EnumerateDeepPins: PROC [ob: CD.Object, eachPin: InstanceEnumerator, stopEnumerateDeepPins: BOOLTRUE] RETURNS [quit: BOOL];
InstanceEnumerator: TYPE = CDSymbolicObjects.InstEnumerator; -- [inst: CD.Instance] RETURNS [quit: BOOL ← FALSE]
The following function is a speed up of EnumerateDeepPins when the only pins wanted are the ones which intersect the border of the InterestRect, i.e. pins such as GetSide.isOnBorder is TRUE.
EnumerateEdgePins: PROC [ob: CD.Object, eachPin: InstanceEnumerator, stopEnumerateDeepPins: BOOLTRUE] RETURNS [quit: BOOL];
Creation of cells by copying (and changing) some pins
The following procs parse an object, extract all pins along the edges, and creates a new cell having an instance of the object, and changed pins. If the flag stopEnumerateDeepPins is TRUE, the property $StopEnumerateDeepPins is added on the instance, so that EnumerateDeepPins will only enumerate the copied pins next call. There are two ways of specifying how to change pins, by specifying either the new pin or the new name. In both cases NIL pins/names are not copied.
ChangePins: PUBLIC PROC [ob: CD.Object, changePinProc: ChangePinProc ← DefaultChangePinProc, stopEnumerateDeepPins: BOOLTRUE] RETURNS [cell: CD.Object];
ChangePinProc: TYPE = PROC [oldPin: CD.Instance] RETURNS [newPin: CD.Instance ← NIL];
DefaultChangePinProc: ChangePinProc; -- {newPinoldPin}; Identity change
RenamePins: PUBLIC PROC [ob: CD.Object, renameProc: RenameProc ← DefaultRenameProc, stopEnumerateDeepPins: BOOLTRUE] RETURNS [cell: CD.Object];
RenameProc: TYPE = PROC [oldRope: ROPE] RETURNS [newRope: ROPENIL];
DefaultRenameProc: RenameProc; -- {newRope ← oldRope}; Identity renaming
Useful in many RenameProcs for indexing names. e.g. Index["foo", 4]="foo[4]"
Index: PROC [rope: ROPE, index: INT] RETURNS [indexedRope: ROPE];
Backdoor for defining the semantics of the enumeration of pins for various object classes.
EnumerationProc: TYPE = PROC [ob: CD.Object, location: CD.Position ← [0, 0], orientation: CD.Orientation ← 0, properties: CD.PropList ← NIL, eachPin: InstanceEnumerator, stopEnumerateDeepPins: BOOL, filter: FilterProc] RETURNS [quit: BOOLFALSE];
EnumerateDeepPinsInContext: EnumerationProc;
enumerationProcProp: ATOM; -- Atom hanging on various Object Classes
FilterProc: TYPE = PROC [subRect: CD.Rect] RETURNS [isSubInteresting: BOOLTRUE];
CopyInstance: PROC [oldInst: CD.Instance] RETURNS [newInst: CD.Instance];
Convenient PROC
NewInstance: PROC [ob: CD.Object, location: CD.Position ← [0,0], orientation: CD.Orientation𡤀, properties: CD.PropList←NIL] RETURNS [CD.Instance];
TransformInstance: PROC [instInCell: CD.Instance, cellSize: CD.Position, locationOfCellInWorld: CD.Position, orientationOfCellInWorld: CD.Orientation] RETURNS [instInWorld: CD.Instance];
Convenient PROC
END.