CDInstances.mesa (A ChipNDale module)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, May 12, 1983 12:22 pm
last edited by Christian Jacobi, June 11, 1985 10:07:21 am PDT
--Procedures with vanilla stuff around instances
DIRECTORY
CD,
CDBasics,
CDOrient;
CDInstances: CEDAR DEFINITIONS
IMPORTS CDBasics, CDOrient =
BEGIN
--be carefull, InstanceList's are lists of pointers, distinguish between:
--procedures which modify the instance list, from procedures which don't
--procedures which modify the instances pointed to, from procedures which don't
--procedures which modify an instance list, from procedures which modify the instances
--procedures around one instance
PointToO: PROC [pos: CD.Position, inst: CD.Instance] RETURNS [BOOL] =
--returns "pos points to the inst", using its virtual coordinates
INLINE {RETURN [CDBasics.InsidePos[pos, InstRectO[inst]]]};
PointToI: PROC [pos: CD.Position, inst: CD.Instance] RETURNS [BOOL];
--returns "pos points to the instance", using its virtual coordinates
HitInstance: PROC[inst: CD.Instance, hitRect: CD.Rect] RETURNS [BOOL];
--returns "hitRect points to the instance"
InstRectO: PROC [inst: CD.Instance] RETURNS [CD.Rect] =
INLINE {RETURN [CDOrient.RectAt[inst.location, inst.ob.size, inst.orientation]]};
InstRectI: PROC [inst: CD.Instance] RETURNS [CD.Rect];
--interrest rect
NewInstance: PROC [ob: CD.Object,
location: CD.Position←[0,0], orientation: CD.Orientation𡤀,
selected: BOOLFALSE, properties: CD.Properties←NIL] RETURNS [CD.Instance];
--creates a new instance, does neither draw nor include it into any world
--modifies location such that interest-rect is at original location
Transform: PROC [inst: CD.Instance,
cellRect: CD.Rect, transformation: CD.Orientation];
--performs "transformation" to "inst"; the transformation occurs to the rect "cellRect".
--"cellRect" and "inst" in the same coordinate system
--transformation group NOT abelsch
Translate: PROC [inst: CD.Instance, offset: CD.Position] =
--translates inst^ by offset; inst, offset in same coordinate system
INLINE {inst.location ← CDBasics.AddPoints[inst.location, offset]};
--procedures inspecting an instance list
BoundingRectO: PROC[list: CD.InstanceList, selectedOnly: BOOLFALSE]
RETURNS [CD.Rect];
--real coordinates
--uses outer area's
BoundingRectI: PROC[list: CD.InstanceList, selectedOnly: BOOLFALSE]
RETURNS [CD.Rect];
--real coordinates
--uses interest area's
InstanceAt: PROC [il: CD.InstanceList, pos: CD.Position, selectedOnly: BOOLFALSE] RETURNS [CD.Instance];
--returns a reference to an instance at location pos (or NIL if there is none)
--uses interest area's
--procedures which modify the instances referenced by a list
TransformList: PROC[il: CD.InstanceList,
cellRect: CD.Rect, transformation: CD.Orientation];
TranslateList: PROC[il: CD.InstanceList, offset: CD.Position];
DeSelectList: PROC [list: CD.InstanceList];
AppendToList: PROC [inst, to: CD.InstanceList] RETURNS [CD.InstanceList];
--composes the lists "inst" and "to"
--the original list "to" might be destroyed and must be replaced by the returned list
--the original list "inst" is not touched
--procedures which handle the instance list but don't modify the instances
SplitPointed: PROC [from: CD.InstanceList, pos: CD.Position] RETURNS [pointed, others: CD.InstanceList];
--copyes the pointed instance references from "from" to "pointed"
--finds maximal 1 pointed instance
--copyes the non-pointed instance references from "from" to "others"
--does not make copies of the real instances
SplitSelected: PROC [from: CD.InstanceList] RETURNS [selected, others: CD.InstanceList];
--copyes the selected instance references from "from" to "selected"
--copyes the non-selected instance references from "from" to "others"
--returns new lists but same instances
OnlySelected: PROC[il: CD.InstanceList] RETURNS [selected: CD.InstanceList];
--returns new list but same instances
--procedures which create a new instance list, with new instances
CopyList: PROC[il: CD.InstanceList] RETURNS [CD.InstanceList];
--creates a new list with new instances
ComposedCopy: PROC[il: CD.InstanceList,
cellPos, cellSize: CD.Position, cellOrient: CD.Orientation] RETURNS [CD.InstanceList];
--makes a copy of "il" with world coordinates assumed that "il" has cell coordinates
--cellSize in cell coordinates, cellPos in world cordinates
--the new list points to new instances
DeComposedCopy: PROC[il: CD.InstanceList,
cellPos, cellSize: CD.Position, cellOrient: CD.Orientation] RETURNS [CD.InstanceList];
--makes a copy of "il" with cell coordinates assumed il has world coordinates
--cellSize in cell coordinates
--cellPos, cellOrient in world coordinates
--the new list points to new instances
END.