DIRECTORY Graphics USING [black, Color, Context, CurveTo, DrawStroke, DrawTo, LineTo, MoveTo, NewPath, Path, SetColor, SetCP, SetFat, white], PEBezier USING [Bezier, SegmentToBezier], PEDisplay, PETypes, PETrajectoryOps USING [ForAllVertices, IsAKnot, VertexProc], PEViewer USING [DrawInViewer, DrawProc], ViewerClasses USING [Viewer]; PEDisplayImpl: CEDAR PROGRAM IMPORTS Graphics, PEBezier, PETrajectoryOps, PEViewer EXPORTS PEDisplay = BEGIN OPEN PEBezier, PEDisplay, PETrajectoryOps, PETypes, PEViewer; white: Graphics.Color = Graphics.white; black: Graphics.Color = Graphics.black; grey: Graphics.Color = [r: 100, g: 100, b: 100]; DrawSegmentAndVertices: PUBLIC PROCEDURE [pathViewer: ViewerClasses.Viewer, segment: Segment, undo: BOOLEAN _ FALSE, background: BOOLEAN _ FALSE] = { DrawVertices[pathViewer, segment, undo, background]; DrawSegment[pathViewer, segment, undo, background]; }; DrawVertices: PUBLIC PROCEDURE [pathViewer: ViewerClasses.Viewer, segment: Segment, undo: BOOLEAN _ FALSE, background: BOOLEAN _ FALSE] = { DoDrawVertex: VertexProc = { DrawVertex[pathViewer, v.first, undo, background]; }; ForAllVertices[segment.vertices, DoDrawVertex]; }; DrawControlPoints: PUBLIC PROCEDURE [pathViewer: ViewerClasses.Viewer, segment: Segment, undo: BOOLEAN _ FALSE, background: BOOLEAN _ FALSE] = { DoDrawControlPoint: VertexProc = { IF ~IsAKnot[v] THEN DrawVertex[pathViewer, v.first, undo, background]; }; ForAllVertices[segment.vertices, DoDrawControlPoint]; }; DrawVertex: PUBLIC PROCEDURE [pathViewer: ViewerClasses.Viewer, vertex: Vertex, undo: BOOLEAN _ FALSE, background: BOOLEAN _ FALSE] = { DoDrawVertex: DrawProc = { side: REAL = 2.0; SELECT TRUE FROM undo => Graphics.SetColor[context, white]; background => Graphics.SetColor[context, grey]; ENDCASE => Graphics.SetColor[context, black]; IF vertex.fixed THEN { -- an X Graphics.SetCP[context, vertex.point.x - side, vertex.point.y - side]; Graphics.DrawTo[context, vertex.point.x + side, vertex.point.y + side]; Graphics.SetCP[context, vertex.point.x + side, vertex.point.y - side]; Graphics.DrawTo[context, vertex.point.x - side, vertex.point.y + side]; } ELSE { -- a box Graphics.SetCP[context, vertex.point.x - side, vertex.point.y - side]; Graphics.DrawTo[context, vertex.point.x + side, vertex.point.y - side]; Graphics.DrawTo[context, vertex.point.x + side, vertex.point.y + side]; Graphics.DrawTo[context, vertex.point.x - side, vertex.point.y + side]; Graphics.DrawTo[context, vertex.point.x - side, vertex.point.y - side]; }; }; DrawInViewer[pathViewer, DoDrawVertex]; }; DrawSegment: PUBLIC PROCEDURE [pathViewer: ViewerClasses.Viewer, segment: Segment, undo: BOOLEAN _ FALSE, background: BOOLEAN _ FALSE] = { DoDrawSegment: DrawProc = { path: Graphics.Path _ Graphics.NewPath[4]; bezier: Bezier; SELECT TRUE FROM segment.fp = NIL => { Graphics.MoveTo[self: path, x: segment.vertices.first.point.x, y: segment.vertices.first.point.y]; Graphics.LineTo[self: path, x: segment.vertices.first.point.x, y: segment.vertices.first.point.y]; }; segment.vertices.rest = NIL => { Graphics.MoveTo[self: path, x: segment.fp.point.x, y: segment.fp.point.y]; Graphics.LineTo[self: path, x: segment.vertices.first.point.x, y: segment.vertices.first.point.y]; }; ENDCASE => { bezier _ SegmentToBezier[segment]; Graphics.MoveTo[self: path, x: bezier.b0.x, y: bezier.b0.y]; Graphics.CurveTo[self: path, x1: bezier.b1.x, y1: bezier.b1.y, x2: bezier.b2.x, y2: bezier.b2.y, x3: bezier.b3.x, y3: bezier.b3.y]; }; SELECT TRUE FROM undo => Graphics.SetColor[context, white]; background => Graphics.SetColor[context, grey]; ENDCASE => Graphics.SetColor[context, black]; [] _ Graphics.SetFat[context, TRUE]; Graphics.DrawStroke[self: context, path: path]; }; IF segment # NIL THEN DrawInViewer[pathViewer, DoDrawSegment]; }; END. LPEDisplayImpl.mesa Written by Darlene Plebon on August 24, 1983 9:49 am Path display routines. This routine draws the specified segment and its vertices. If undo is true, the drawing color is white (to erase), otherwise it is grey when background is true and black when background is false. This routine draws the vertices of the specified segment. If undo is true, the drawing color is white (to erase), otherwise it is grey when background is true and black when background is false. This routine draws only the control point vertices of the specified segment. If undo is true, the drawing color is white (to erase), otherwise it is grey when background is true and black when background is false. This routine draws only the specified vertex. If undo is true, the drawing color is white (to erase), otherwise it is grey when background is true and black when background is false. This routine draws only the specified segment but not its vertices. If undo is true, the drawing color is white (to erase), otherwise it is grey when background is true and black when background is false. ʘJšœ™Jšœ4™4J˜J™J˜šÏk ˜ Jšœ œu˜ƒJšœ œ˜)Jšœ ˜ Jšœ˜Jšœœ'˜J˜—J˜Jšœ˜J˜—…—èO