CDInstances.mesa (A ChipNDale module)
Copyright © 1983, 1986 by Xerox Corporation. All rights reserved.
by Christian Jacobi, May 12, 1983 12:22 pm
last edited by Christian Jacobi, March 14, 1986 2:13:10 pm PST
--Procedures with vanilla stuff around instances
DIRECTORY
CD,
CDBasics,
CDOrient;
CDInstances:
CEDAR
DEFINITIONS
IMPORTS CDBasics, CDOrient =
BEGIN
--Contents
--be careful, 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 inspecting an instance or a list
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];
--interest rect
BoundingRectO:
PROC[list:
CD.InstanceList, selectedOnly:
BOOL←
FALSE]
RETURNS [
CD.Rect];
--real coordinates
--uses outer area's
BoundingRectI:
PROC[list:
CD.InstanceList, selectedOnly:
BOOL←
FALSE]
RETURNS [
CD.Rect];
--real coordinates
--uses interest area's
InstanceAt:
PROC [il:
CD.InstanceList, pos:
CD.Position, selectedOnly:
BOOL←
FALSE]
RETURNS [
CD.Instance];
--returns a an instance at location pos (or NIL if there is none)
--uses interest area's
--procedures which modify the instance or list in place
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]};
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 make new the instances
SplitSelected:
PROC [il:
CD.InstanceList]
RETURNS [selected, others:
CD.InstanceList];
--copyes the selected instance refs from "il" to "selected"
--copyes the non-selected instance refs from "il" 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
NewInst:
PROC [ob:
CD.Object,
location: CD.Position←[0,0], orientation: CD.Orientation𡤀,
selected: BOOL ← FALSE, properties: CD.PropList←NIL] RETURNS [CD.Instance];
--creates a new instance, does neither draw nor include it into any world
NewInstI:
PROC [ob:
CD.Object,
location: CD.Position←[0,0], orientation: CD.Orientation𡤀,
selected: BOOL ← FALSE, properties: CD.PropList←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
Copy:
PROC [inst:
CD.Instance]
RETURNS [
CD.Instance];
--makes a copy
Composed:
PROC[inst:
CD.Instance, cellPos, cellSize:
CD.Position, cellOrient:
CD.Orientation]
RETURNS [
CD.Instance];
--makes a composed copy
DeComposed:
PROC[inst:
CD.Instance, cellPos, cellSize:
CD.Position, cellOrient:
CD.Orientation]
RETURNS [
CD.Instance];
--makes a decomposed copy
CopyList:
PROC[il:
CD.InstanceList]
RETURNS [
CD.InstanceList];
--creates a new list with new, copied instances
ComposedList:
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
DeComposedList:
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.