SampledCurveEdit.mesa
Michael Plass, November 8, 1983 11:56 am
DIRECTORY ViewerClasses, ViewerOps;
SampledCurveEdit: CEDAR DEFINITIONS IMPORTS ViewerOps ~ 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: BOOLEAN];
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.
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.
AddMenuItem: PROC [atom: ATOM];
Adds a menu item (to the class and all instances) that sends an atom to the notify proc.
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.
NewTIP: PROC;
Forces reload of the tip table.
CreateViewer: PROC [info: ViewerClasses.ViewerRec] RETURNS [Viewer] ~ INLINE {
RETURN [ViewerOps.CreateViewer[$SampledCurveEdit, info]];
};
END.