SampledCurveEdit.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Michael Plass, January 8, 1986 2:51:47 pm PST
Maureen Stone, September 25, 1987 4:14:53 pm PDT
DIRECTORY ViewerClasses USING [Viewer, ViewerRec], Imager USING [Context];
SampledCurveEdit: CEDAR DEFINITIONS
~ BEGIN
Viewer: TYPE ~ ViewerClasses.Viewer;
PointKind: TYPE ~ {sample, knot, corner, open};
sample - the point is a sample along a smooth curve.
knot - hint that this is a good place to decompose the curve into pieces.
corner - hint to avoid smoothing this spot off.
open - used in list headers for open trajectories.
MarkedPoint: TYPE ~ RECORD [
x, y: REAL,
isHeader: BOOLEANFALSE,
kind: PointKind
];
PointList: TYPE ~ LIST OF MarkedPoint;
Trajectory: TYPE ~ PointList;
Every trajectory has a list head, marked by isHeader=TRUE. For an open trajectory, kind=open in the header, and the coordinates are ignored. For a closed trajectory, the coordinates are a copy of the coordinates in the last sample.
Outline: TYPE ~ LIST OF Trajectory;
No header on this list.
PointModifier: TYPE = REF PointModifierRep;
PointModifierRep: TYPE = RECORD [
pointModifyProc: PointModifyProc,
data: REF
];
PointModifyProc: TYPE ~ PROC [self: PointModifier, pointList: PointList, count: INT] RETURNS [changed: BOOLEANTRUE, newCount: INT ← -1];
The PointModifyProc may alter pointList.rest.first, pointList.rest.rest.first, etc.
Note the list begins with the point before the first one to be modified.
If newCount >= 0, the selection count is altered.
RegisterPointModifer: PROC [atom: ATOM, pointModifier: PointModifier];
The pointModifyProc will be called with the currently selected points when the viewer receives the specified atom as input from the menu or tip table. Repaints will be managed automatically.
CopyTrajectory: PROC [trajectory: Trajectory] RETURNS [Trajectory];
MalformedTrajectory: ERROR;
CopyOutline: PROC [outline: Outline] RETURNS [Outline];
GetOutline: PROC [viewer: Viewer] RETURNS [Outline];
Returns a copy of the viewer's current outline.
ObtainOutline: PROC [viewer: Viewer] RETURNS [Outline];
Returns the viewer's current outline, and sets it to NIL. Use this when you really don't want to copy, but need ownership of the outline.
SetOutline: PROC [viewer: Viewer, outline: Outline];
Sets the outline in the viewer; does NOT copy.
CreateViewer: PROC [info: ViewerClasses.ViewerRec] RETURNS [Viewer];
UserPaint: TYPE ~ REF UserPaintRec;
UserPaintRec: TYPE = RECORD[
proc: PROC [context: Imager.Context, data: REF],
data: REF
];
RegisterUserPaint: PROC [viewer: Viewer, userPaint: UserPaint];
The registered paint proc will be called when the viewer is refreshed.
NotifyUserPaint: PROC [viewer: Viewer, userPaint: UserPaint];
Queue a call back to userPaint.
AddMenuItem: PROC [viewer: Viewer, atom: ATOM];
Adds a menu item to the viewer that sends an atom to the notify proc.
END.