CDX.mesa (part of ChipNDale)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi, September 10, 1984 9:20:09 am PDT
last edited by Ch. Jacobi, April 16, 1985 12:43:12 pm PST
DIRECTORY
CD, CDBasics;
CDX: CEDAR DEFINITIONS
IMPORTS CDBasics =
BEGIN
--Public interface between chipndale and outside clients.
--Maps chipndales complex and mutable (but fast on displaying)
--positioning mechanism to an immutable(1) "client" cordinate system.
--The Origin is a hypothtical point of an object; the client's coordinate
--system origin.
--(1)Only cells and some few other object classes implement
--the client origin really immutable.
ClientPosition: TYPE = CD.Position;
ClientRect: TYPE = CD.Rect;
ClientOrigin: PROC [ob: CD.ObPtr] RETURNS [pos: CD.DesignPosition];
--Returns the position of the client's object origin in objects internal cd coords
ClientIRect: PROC [ob: CD.ObPtr] RETURNS [ClientRect];
--Returns the interest rect in client's relative coords
ClientORect: PROC [ob: CD.ObPtr] RETURNS [ClientRect];
--Returns the real outside (cd coords) rect in client's relative coords
--Transfer between chipndale and client coordinates, both relative to the object
CDToClientPos: PROC [ob: CD.ObPtr, pos: CD.DesignPosition←[0, 0]] RETURNS [cPos: ClientPosition] =
INLINE {RETURN [CDBasics.SubPoints[pos, ClientOrigin[ob]]]};
ClientToCDPos: PROC [ob: CD.ObPtr, cPos: ClientPosition←[0, 0]] RETURNS [pos: CD.DesignPosition] =
INLINE {RETURN [CDBasics.AddPoints[cPos, ClientOrigin[ob]]]};
CDToClientRect: PROC [ob: CD.ObPtr, rect: CD.DesignRect] RETURNS [cRect: ClientRect] =
INLINE BEGIN
co: CD.DesignPosition = ClientOrigin[ob];
RETURN [ClientRect[x1: rect.x1-co.x, y1: rect.y1-co.y, x2: rect.x2-co.x, y2: rect.y2-co.y]]
END;
ClientToCDRect: PROC [ob: CD.ObPtr, cRect: ClientRect] RETURNS [rect: CD.DesignRect] =
INLINE BEGIN
co: CD.DesignPosition = ClientOrigin[ob];
RETURN [CD.DesignRect[x1: cRect.x1+co.x, y1: cRect.y1+co.y, x2: cRect.x2+co.x, y2: cRect.y2+co.y]]
END;
--Transfer between client object relative coordinates and chipndale global coordinates
MapClientPos: PROC [cPos: ClientPosition←[0, 0], app: CD.ApplicationPtr] RETURNS [globPos: CD.DesignPosition];
DeMapClientPos: PROC [globPos: CD.DesignPosition, app: CD.ApplicationPtr] RETURNS [cPos: ClientPosition];
MapClientRect: PROC [cRect: ClientRect, app: CD.ApplicationPtr] RETURNS [globRect: CD.DesignRect];
DeMapClientRect: PROC [globRect: CD.DesignRect, app: CD.ApplicationPtr] RETURNS [cRect: ClientRect];
PositionFromPairO: PROC [ob: CD.ObPtr,
cPos: ClientPosition←[0,0],
correspondingGlobPos: CD.DesignPosition←[0,0],
orientation: CD.Orientation𡤀
] RETURNS [appPos: CD.DesignPosition];
--Computes a position useable for an application, such that the
--client-origin relative point cPos is at the global position correspondingGlobPos
PositionFromPairI: PROC [ob: CD.ObPtr,
cPos: ClientPosition←[0,0],
correspondingGlobPos: CD.DesignPosition←[0,0],
orientation: CD.Orientation𡤀
] RETURNS [iPos: CD.DesignPosition];
--Computes the position of the interest rect, such that the client-origin
--relative point cPos is at the global position correspondingGlobPos
--Relative placement
CoordSystem: TYPE = {cdCoords, interrestCoords, originCoords};
-- cdCoords: chipndales internal and native coordinate system used for display
-- interrestCoords: base of interest-rects.
-- originCoords: invariant fake origin which never changes, but might be far off...
IncludeMode: TYPE = {doit, dontReposition, dontPropagate, dontInclude};
IncludeOb: PROC [design: CD.Design←NIL, cell: CD.ObPtr←NIL, ob: CD.ObPtr,
position: CD.Position←[0, 0], --evaluated before an eventual repositioning
orientation: CD.Orientation𡤀,
cellCSystem: CoordSystem←originCoords,
obCSystem: CoordSystem←originCoords,
mode: IncludeMode𡤍oit]
RETURNS [newApp: CD.ApplicationPtr, rep: BOOL];
--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 applications; cell is not changed at all.
--newApp: the new created application
--rep: Reposition was done or should be done, depending of mode
RemoveApp: PROC [design: CD.Design←NIL, cell: CD.ObPtr←NIL, app: CD.ApplicationPtr,
mode: IncludeMode𡤍oit] RETURNS [removed: BOOL, rep: BOOL];
--design (NIL: allowed, if cell really is not yet part of a design)
--cell (NIL: remove from design)
--  (design&cell NIL: Error)
--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 applications; cell is not changed at all.
--rep: Reposition was done or should be done, depending of mode
--implementing the origin
--Object class implementors business; calling these procedures for other purposes
-- (except if explicitely allowed by the comment of a procedure) will typically
-- produce chaos. These procedure implement an origin feature by using properties.
SimpleGetOrigin: PRIVATE PROC[ob: CD.ObPtr] RETURNS [CD.DesignPosition];
SimpleSetOrigin: PRIVATE PROC[ob: CD.ObPtr, new: CD.DesignPosition];
--does NOT do any notification
END.