CDMarkObjectsImpl.mesa   
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Created by: Bob Mayo, June 8, 1984 12:28:34 pm PDT
Redesigned by: Jacobi, September 10, 1984 5:04:14 pm PDT
Last Edited: Jacobi, May 29, 1985 10:42:56 am PDT
DIRECTORY
CDMarkObjects,
CD,
CDOrient,
CDProperties,
Rope USING [ROPE, Equal],
Imager,
ImagerPath;
CDMarkObjectsImpl: CEDAR PROGRAM    
IMPORTS CD, CDProperties, Rope, CDOrient, Imager, ImagerPath
EXPORTS CDMarkObjects =
BEGIN
MarkEnumerator: TYPE = CDMarkObjects.MarkEnumerator;
--PROC [markInstance: CD.Instance] RETURNS [quit: BOOL�LSE]
markAtom: PUBLIC ATOM ← $AlignmentMarkOb;
markOb: PUBLIC CD.Object;
markNameProperty: PUBLIC ATOM ← $SignalName;
myLayer: CD.Layer ← CD.combined;
objsProcs: REF CD.ObjectClass;
path: ImagerPath.Trajectory = CreateMarkPath[];
DrawMark: CD.DrawProc =
BEGIN
DrawPath: PROC [context: Imager.Context, ob: CD.Object, layer: CD.Layer] =
BEGIN
Imager.MaskFillTrajectory[context, path];
END;
IF pr.symbolics THEN {
pr.drawContext[pr, DrawPath, markOb, pos, orient, myLayer]
}
END;
WriteMark: CD.InternalWriteProc --PROC [me: Object]-- = {};
ReadMark: CD.InternalReadProc --PROC [] RETURNS [Object]-- = {RETURN [markOb]};
SetMarkName: PUBLIC PROC [markInstance: CD.Instance, name: Rope.ROPE] =
BEGIN
CDProperties.PutPropOnInstance[onto: markInstance, prop: markNameProperty, val: name]
END;
GetMarkName: PUBLIC PROC [markInstance: CD.Instance] RETURNS [name: Rope.ROPE] =
BEGIN
WITH CDProperties.GetPropFromInstance[from: markInstance, prop: markNameProperty] SELECT FROM
r: Rope.ROPE => name ← r;
ENDCASE => name ← "* bad name *";
END;
FindMark: PUBLIC PROC [cellOb: CD.Object←NIL, design: CD.Design←NIL, name: Rope.ROPE] RETURNS [inst: CD.Instance←NIL] =
BEGIN
Enumerate: MarkEnumerator = {
IF Rope.Equal[GetMarkName[markInstance], name] THEN {inst ← markInstance; quit←TRUE}
};
[] ← EnumerateMarks[cellOb: cellOb, design: design, proc: Enumerate];
END;
GetMarkPosition: PUBLIC PROC [markInstance: CD.Instance] RETURNS [CD.Position] =
--actually finds any position of a real origin
BEGIN
RETURN [CDOrient.MapPoint[
pointInCell: [x: 0, y: 0],
cellInstPos: markInstance.location,
cellSize: markInstance.ob.size,
cellInstOrient: markInstance.orientation
]]
END;
EnumerateMarks: PUBLIC PROC [cellOb: CD.Object←NIL, design: CD.Design←NIL, proc: MarkEnumerator] RETURNS [quit: BOOLFALSE] =
BEGIN
cp: CD.CellPtr;
IF cellOb#NIL THEN cp ← NARROW[cellOb.specificRef]
ELSE IF design#NIL THEN cp ← design^.actual.first.specific
ELSE ERROR;
FOR list: CD.InstanceList ← cp.contents, list.rest WHILE (list#NIL AND ~quit) DO
IF list.first.ob=markOb THEN {
quit ← proc[list.first]; -- do NOT catch errors
};
ENDLOOP;
END;
CreateMarkPath: PROC [] RETURNS [path: ImagerPath.Trajectory] =
BEGIN
path ← ImagerPath.MoveTo[[0, 0]];
path ← ImagerPath.LineTo[path, [0, 3]];
path ← ImagerPath.LineTo[path, [1, 2]];
path ← ImagerPath.LineTo[path, [3, 4]];
path ← ImagerPath.LineTo[path, [4, 3]];
path ← ImagerPath.LineTo[path, [2, 1]];
path ← ImagerPath.LineTo[path, [3, 0]];
path ← ImagerPath.LineTo[path, [0, 0]];
END;
Init: PROC[] =
BEGIN
objsProcs ← CD.RegisterObjectClass[markAtom];
objsProcs.drawMe ← DrawMark;
objsProcs.internalWrite ← WriteMark;
objsProcs.internalRead ← ReadMark;
objsProcs.description ← "mark";
objsProcs.symbolic ← TRUE;
markOb ← NEW[CD.ObjectRep ← [
class: objsProcs,
size: [4, 4],
layer: myLayer,
specificRef: markAtom
]];
END;
Init[];
END.