DIRECTORY PETypes, PEViewer USING [DrawProc, MenuLabelRec], Rope USING [ROPE]; PathEditor: CEDAR DEFINITIONS = BEGIN OPEN PETypes; Point: TYPE = PETypes.Point; PathData: TYPE = REF ANY; MoveToProc: TYPE = PROCEDURE [p1: Point]; LineToProc: TYPE = PROCEDURE [p1: Point]; CurveToProc: TYPE = PROCEDURE [p1, p2, p3: Point]; DrawProc: TYPE = PEViewer.DrawProc; ButtonHitProc: TYPE = PROCEDURE[event: ATOM, x, y: REAL]; MenuLabel: TYPE = PEViewer.MenuLabelRec; BooleanSpecification: TYPE = {on, off, toggle}; VertexType: TYPE = {frontKnot, rearKnot, intermediateKnot, controlPoint}; CurveType: TYPE = {point, line, bezier}; CreatePathViewer: PROCEDURE [name: Rope.ROPE, menuLabels: LIST OF MenuLabel, buttonProc: ButtonHitProc _ NIL, redrawProc: DrawProc _ NIL] RETURNS [pathData: PathData]; DrawInPathViewer: PROCEDURE [pathData: PathData, drawProc: DrawProc]; Redraw: PUBLIC PROCEDURE [pathData: PathData, erase: BOOLEAN _ FALSE]; FlushImage: PROCEDURE [pathData: PathData]; NewTrajectory: PROCEDURE [pathData: PathData]; SetActiveTrajectory: PROCEDURE [pathData: PathData, where: Point] RETURNS [activeTrajectorySet: BOOLEAN, hitPoint: Point]; TrajectoryIsEmpty: PROCEDURE [pathData: PathData] RETURNS [empty: BOOLEAN]; DeleteActiveTrajectory: PROCEDURE [pathData: PathData]; GetTrajectoryFile: PROCEDURE [pathData: PathData, fileName: Rope.ROPE]; StoreTrajectoryFile: PUBLIC PROCEDURE [pathData: PathData, fileName: Rope.ROPE]; EnumerateTrajectories: PROCEDURE [pathData: PathData, moveToProc: MoveToProc, lineToProc: LineToProc, curveToProc: CurveToProc]; AddKnotToFront: PROCEDURE [pathData: PathData, position: Point]; AddCubicToFront: PROCEDURE [pathData: PathData, cp1, cp2, knot: Point]; AddKnotToRear: PROCEDURE [pathData: PathData, position: Point]; AddCubicToRear: PROCEDURE [pathData: PathData, cp1, cp2, knot: Point]; SplitSegment: PROCEDURE [pathData: PathData, where: Point]; AdjustSegmentSplit: PROCEDURE [pathData: PathData, where: Point]; ConfirmSegmentSplit: PROCEDURE[pathData: PathData]; AddControlPoint: PROCEDURE [pathData: PathData, where, position: Point]; CloseActiveTrajectory: PROCEDURE [pathData: PathData]; OpenActiveTrajectory: PROCEDURE [pathData: PathData]; DeleteVertex: PROCEDURE [pathData: PathData, vertex: Point]; SetActiveVertex: PROCEDURE [pathData: PathData, where: Point] RETURNS [activeVertexSet: BOOLEAN, vertex: Point]; GetActiveVertex: PROCEDURE [pathData: PathData] RETURNS [activeVertexSet: BOOLEAN, vertex: Point]; MoveActiveVertex: PROCEDURE [pathData: PathData, newPosition: Point]; SetContinuity: PROCEDURE [pathData: PathData, knot: Point, continuity: BooleanSpecification]; FixControlPoint: PROCEDURE [pathData: PathData, controlPoint: Point, fixed: BooleanSpecification]; EnumerateActiveTrajectory: PROCEDURE [pathData: PathData, moveToProc: MoveToProc, lineToProc: LineToProc, curveToProc: CurveToProc]; HitTestVertices: PROCEDURE [pathData: PathData, where: Point] RETURNS [closeToVertex: BOOLEAN, vertexType: VertexType, vertex: Point]; HitTestCurves: PROCEDURE [pathData: PathData, where: Point] RETURNS [closeToCurve: BOOLEAN, curveType: CurveType, p0, p1, p2, p3: Point, hitPoint: Point]; END. ΈPathEditor.mesa Written by Darlene Plebon on August 23, 1983 5:08 pm Routines providing a client interface to the Path Editor. Routines which operate on the entire image. This routine creates a viewer for the Path Editor. The viewer is created with the supplied name and menu labels. Client supplied routines are called to process button hits and when the entire viewer must be redrawn for some reason. This routine must be called before any others. It returns a pointer to Path Editor data which must be passed in all subsequent calls from the client. This routine calls the client supplied routine with the Path Editor viewer's context so it can draw in the Path Editor's viewer. This routine redraws the entire image. The viewer may be erased first, if desired. This routine flushes the contents of the image, so the client can start over. Routines which operate on entire trajectories. This routine creates a new trajectory and makes it the active trajectory. The trajectory is not actually created until an operation is performed which gives it some contents (e.g. AddKnotToFront). This routine makes the trajectory which is closest to the specified point the active trajectory. A trajectory must be made active before its contents can be edited. When a trajectory is first set active, the active vertex or active segment are unset (i.e. NIL). The specified position must be "close to" (i.e. whithin a certain minimum distance of) a trajectory in order for the operation to be carried out. This routine returns an indication of whether the active trajectory was in fact set and the position of the point on the active trajectory which is closest to the specified point. This routine determines if the active trajectory currently has any contents. This routine deletes the active trajectory. This routine reads the specified trajectory file into the path editor. The trajectories read in are appended to those already in the image. This routine writes a text representation of the trajectories in the path editor to a file. This routine enumerates all the segments in the all the trajectories. Client specified routines are called for each line segment, and bezier curve in each trajectory. The moveToProc is called for the first point (FP) of each trajectory. Routines which operate on (the contents of) the active trajectory. This routine extends the active trajectory by adding a knot (and thus a segment) to its front end. This routine adds a cubic curve segment to the front of the active trajectory. The cubic is defined by the bezier vertices: knot, cp2, cp1, FP, where FP is the first knot in the original path. This routine extends the active trajectory by adding a knot (and thus a segment) to its rear end. This routine adds a cubic curve segment to the rear (end) of the active trajectory. The cubic is defined by the bezier vertices: LP, cp1, cp2, knot, where LP is the last knot in the original path. This routine splits the segment in the active trajectory which is nearest the specified position at the point which is closest to the specified position. The specified position must be "close to" (i.e. whithin a certain minimum distance of) a segment of the active trajectory in order for the operation to be carried out. This routine also updates the display to reflect the two new segments and saves appropriate information for reversing the action. A call to this routine may be followed by zero or more calls to AdjustSegmentSplit. Finally, ConfirmSegmentSplit must be called to clean up the display. This routine moves the knot at which a bezier segment is split into two segments. This routine confirms a segment split. That is, it makes it permanent. This routine basically cleans up the display a bit. This routine adds a control point to the specified segment (the segment in the active trajectory which is closest to "where"). Position specifies the position of the new control point. If the segment already contained one control point, the new control point is added before or after the current one depending on the the distance from "where" to the line segments defined by the existing control point and the two knots of the segment. If "where" is closer to the line segment defined by the existing control point and the first knot, the new control point is inserted before the existing one; otherwise it is inserted following the existing control point in the segment. If the segment already contains two control points, no action is performed. This routine makes the active trajectory a closed trajectory. This routine makes the active trajectory an open trajectory. This routine deletes the vertex (which may be a knot or a control point) in the active trajectory which is closest to the specified point. The specified point must be "close to" (i.e. whithin a certain minimum distance of) a vertex in the active trajectory in order for the operation to be carried out. This routine makes the vertex of the active trajectory which is closest to the specified point the active vertex. A vertex must be made active before it can be moved. The specified position must be "close to" (i.e. whithin a certain minimum distance of) a segment in the active trajectory in order for the operation to be carried out. This routine returns an indication of whether the active vertex was in fact set and the position of the active vertex. The routines for adding knots and control points also set the active vertex. The NewImage, DeleteVertex and AddCubic routines unset the active vertex. This routine returns an indication of whether the active vertex is set and the position of the active vertex. This routine moves the active vertex (which may be a knot or a control point) closest to the specified point to the specfied new position. This routine sets the continuity requirements at the vertex in the active trajectory which is closest to the specified location. The specified point (knot) must be "close to" (i.e. within a certain minimum distance of) a vertex in the active trajectory in order for the operation to be carried out. This operation only applies to knots. The client can specify that continuity is required (on), that continuity is not required (off), or that the current continuity requirement setting is to be toggled. When continuity is requested, the positions of some vertices may be altered to satisfy the request. This routine sets the indicator of whether the vertex in the active trajectory which is closest to the specified location is fixed (i.e. may not be moved unless explicitly requested by the client) or not fixed (i.e. may be moved without a client request in order to satisfy continuity requirements at some other vertex). The specified point (knot) must be "close to" (i.e. within a certain minimum distance of) a vertex in the active trajectory in order for the operation to be carried out. This operation only applies to control points. The client can specify that the vertex be fixed (on), that the vertex can be moved (off), of that the current setting is to be toggled. This routine enumerates all the segments in the active trajectory. Client specified routines are called for each line segment, and bezier curve in the trajectory. The moveToProc is called for the first point (FP) of the active trajectory. This routine determines the vertex in the active trajectory which is closest to the specified point. Only those vertices which are in the active trajectory and within a threshold distance of the point are considered. This routine returns an indication of whether the point is close to a vertex, and if so, the position of the closest vertex and its type. This routine determines the curve segment in the active trajectory which is closest to the specified point. Only those segments which are in the active trajectory and within a threshold distance of the point are considered. This routine returns an indication of whether the point is close to a curve segment, and if so, the position of the vertices of the segment, its type, and the point on the curve closest to the specified point. Κ‚˜Iproc– "Cedar" stylešœ™K– "Cedar" stylešœ4™4J™J™9J˜šΟk ˜ Jšœ˜Jšœ œ˜(Jšœœœ˜—J˜Jšœ œ œ˜J˜Jš œ˜J˜Jšœœ˜J˜Jšœ œœœ˜J˜JšΟn œœ œ ˜)J˜Jšž œœ œ ˜)J˜Jšž œœ œ˜2J˜Jšžœœ˜#J˜Jš ž œœ œœœ˜9J˜Jšœ œ˜(J˜Jšœœ˜/J˜Jšœ œ9˜IJ˜Jšœ œ˜(J˜J™+J˜šžœ œ œœœ(œœœ˜§J™—J˜šžœ œ*˜EJ™€—J˜šžœœ œœ˜FJ™S—J˜šž œ œ˜+JšœM™M—J˜J™.J™šž œ œ˜.J™Ε—J™šžœ œ$œœ˜zJ™Ο—J™šžœ œœ œ˜KJšœL™L—J˜šžœ œ˜7J™+—J™šžœ œ%œ˜GJ™Œ—J˜šžœœ œ%œ˜PJ™[—I modheader˜šžœ œ`˜€J™ξ—J™JšœB™BJ™šžœ œ'˜@Jšœb™b—J˜šžœ œ-˜GJšœΑ™Α—J˜šž œ œ'˜?Jšœa™a—J˜šžœ œ-˜FJšœΕ™Ε—J˜šž œ œ$˜;Jšœΰ™ΰ—J˜šžœ œ$˜AJ™Q—J˜šžœ œ˜3J™|—J˜šžœ œ.˜HJšœπ™π—J˜šžœ œ˜6J™=—J˜šžœ œ˜5J™<—J˜šž œ œ%˜