DIRECTORY GGBasicTypes, GGModelTypes, GGInterfaceTypes, GGSegmentTypes, Imager, ImagerTransformation, IO, Rope; GGTraj: CEDAR DEFINITIONS = BEGIN StrokeJoint: TYPE = Imager.StrokeJoint; BoundBox: TYPE = GGBasicTypes.BoundBox; CameraData: TYPE = GGModelTypes.CameraData; Circle: TYPE = GGBasicTypes.Circle; GGData: TYPE = GGInterfaceTypes.GGData; Joint: TYPE = GGSegmentTypes.Joint; Line: TYPE = GGBasicTypes.Line; Point: TYPE = GGBasicTypes.Point; Scene: TYPE = GGModelTypes.Scene; Segment: TYPE = GGSegmentTypes.Segment; Sequence: TYPE = GGModelTypes.Sequence; SelectionClass: TYPE = GGInterfaceTypes.SelectionClass; Traj: TYPE = GGModelTypes.Traj; TrajEnd: TYPE = GGModelTypes.TrajEnd; Vector: TYPE = GGBasicTypes.Vector; CreateTraj: PROC [point: Point] RETURNS [traj: Traj]; AddSegment: PROC [traj: Traj, trajEnd: TrajEnd, seg: Segment, segEnd: TrajEnd] RETURNS [success: BOOL]; CloseWithSegment: PROC [traj: Traj, seg: Segment, segEnd: TrajEnd]; CloseByDistorting: PROC [traj: Traj, distortEnd: TrajEnd]; OnlyChild: PROC [traj: Traj] RETURNS [BOOL]; CopyTrajFromRun: PROC [run: Sequence] RETURNS [copy: Traj]; CopyTrajFromRange: PROC [original: Traj, start: INT, len: INT] RETURNS [piece: Traj]; Concat: PROC [fixed: Traj, fixedEnd: TrajEnd, moving: Traj, movingEnd: TrajEnd] RETURNS [longer: Traj]; SpliceIn: PROC [run: Sequence, traj: Traj] RETURNS [newTraj: Traj]; ReverseTraj: PROC [traj: Traj]; IsClockwiseTraj: PROC [traj: Traj] RETURNS [BOOL]; IsClockwiseTrajTransformSeq: PROC [seq: Sequence, transform: ImagerTransformation.Transformation] RETURNS [BOOL]; GetBoundBox: PROC [traj: Traj] RETURNS [bBox: BoundBox]; UpdateBoundBox: PROC [traj: Traj]; CopyTraj: PROC [original: Traj] RETURNS [copy: Traj]; DrawSequenceFeedback: PROC [dc: Imager.Context, seq: Sequence, normalSeq: Sequence, camera: CameraData, quick: BOOL _ FALSE, selectClass: SelectionClass _ normal]; DrawTraj: PROC [dc: Imager.Context, traj: Traj]; DrawTrajSeq: PROC [dc: Imager.Context, seq: Sequence]; DrawTrajTransformSeq: PROC [dc: Imager.Context, selSeq: Sequence, transform: ImagerTransformation.Transformation]; DrawSelectionFeedback: PROC [traj: Traj, selectedParts, hotParts: Sequence, dc: Imager.Context, camera: CameraData, dragInProgress, caretIsMoving, hideHot, quick: BOOL]; AllStrokePropsAndColorsEqual: PROC [traj: Traj] RETURNS [BOOL]; TransformTraj: PROC [traj: Traj, transform: ImagerTransformation.Transformation]; TranslateTraj: PROC [traj: Traj, vector: Vector]; TransformSequence: PROC [seq: Sequence, transform: ImagerTransformation.Transformation]; HitType: TYPE = GGModelTypes.TrajPartType; DescribeHit: PROC [traj: Traj, hitType: HitType, segNum, cpNum, jointNum: INT] RETURNS [rope: Rope.ROPE]; Fileout: PROC [f: IO.STREAM, traj: Traj]; Filein: PROC [f: IO.STREAM, version: REAL] RETURNS [traj: Traj, hasCircle: BOOL _ FALSE]; FetchSegment: PROC [traj: Traj, index: NAT] RETURNS [seg: Segment]; FetchJoint: PROC [traj: Traj, index: NAT] RETURNS [joint: Joint]; FetchJointPos: PROC [traj: Traj, index: NAT] RETURNS [point: Point]; LastJointPos: PROC [traj: Traj] RETURNS [point: Point]; SetJointPos: PROC [traj: Traj, index: NAT, newPos: Point]; HiSegment: PROC [traj: Traj] RETURNS [highestIndex: NAT]; HiJoint: PROC [traj: Traj] RETURNS [highestIndex: NAT]; PreviousSegment: PROC [traj: Traj, segNum: NAT] RETURNS [prev: Segment]; PreviousSegmentNum: PROC [traj: Traj, segNum: NAT] RETURNS [prevNum: INT]; FollowingSegmentNum: PROC [traj: Traj, segNum: NAT] RETURNS [followNum: INT]; FollowingJoint: PROC [traj: Traj, index: NAT] RETURNS [nextIndex: INT]; IsEndJoint: PROC [traj: Traj, index: NAT] RETURNS [BOOL]; SetSelectedFields: PROC [seq: Sequence, selected: BOOL, selectClass: SelectionClass]; SaveSelection: PROC [traj: Traj, selectClass: SelectionClass, scene: Scene]; SaveSelectionInSequence: PROC [seq: Sequence, selectClass: SelectionClass]; ClearSelection: PROC [traj: Traj, selectClass: SelectionClass]; RemakeSelection: PROC [traj: Traj, scene: Scene, selectClass: SelectionClass]; PointsInDescriptor: PROC [seq: Sequence] RETURNS [pointGen: GGModelTypes.PointGenerator]; PointPairsInDescriptor: PROC [seq: Sequence] RETURNS [pointPairGen: GGModelTypes.PointPairGenerator]; NextPoint: PROC [pointGen: GGModelTypes.PointGenerator] RETURNS [pointAndDone: GGModelTypes.PointAndDone]; NextPointPair: PROC [pointGen: GGModelTypes.PointPairGenerator] RETURNS [pointPairAndDone: GGModelTypes.PointPairAndDone]; NearestSegment: PROC [testPoint: Point, seq: Sequence, tolerance: REAL] RETURNS [bestDist: REAL, bestSeg: NAT, bestPoint: Point, success: BOOL]; NearestJoint: PROC [testPoint: Point, seq: Sequence, tolerance: REAL] RETURNS [bestDist: REAL, bestJoint: NAT, bestPoint: Point, success: BOOL]; NearestControlPoint: PROC [testPoint: Point, seq: Sequence, tolerance: REAL] RETURNS [bestDist: REAL, bestSeg: NAT, bestControlPoint: NAT, bestPoint: Point, success: BOOL]; LineIntersection: PROC [seq: Sequence, line: Line] RETURNS [points: LIST OF Point, pointCount: NAT]; CircleIntersection: PROC [seq: Sequence, circle: Circle] RETURNS [points: LIST OF Point, pointCount: NAT]; SetArrows: PROC [traj: Traj, loArrow, hiArrow: BOOL]; SetTrajStrokeJoint: PROC [traj: Traj, strokeJoint: StrokeJoint]; GetTrajStrokeJoint: PROC [traj: Traj] RETURNS [strokeJoint: StrokeJoint]; IndexOfJoint: PROC [joint: Joint, traj: Traj] RETURNS [index: INT]; IndexOfSegment: PROC [segment: Segment, traj: Traj] RETURNS [index: INT]; END. ~GGTraj.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Last edited by Bier on November 13, 1986 4:52:20 pm PST Contents: Procedures to implement the Traj Slice Class. Trajectories consist of Segments. One motivation for creating this module now is the GGOutlineImpl is too big to compile. Routine Creation The lifetime of a trajectory goes something like this: It begins as a single point. The sole purpose of this point is to be an "endpoint" to which the first segment can be attached. Subsequent segments are also added to endpoints. In Gargoyle, trajectories never appear at the top level of a scene; they are always part of an outline. Usually a CreateTraj call will be followed immediately by a GGScene.CreateOutline call. Trajectory-Only Routines Will there be an arrowhead on the lo end of traj? On the hi end? Moves seg so that the specified end of seg coincides with the specified end of traj. In other words, seg is translated. If success = FALSE, AddSegment sends an error message to Feedback and returns. Like AddSegment, except that here we rotate, scale, and translate seg as needed so that both of its endpoints coincide with the endpoints of traj (which must not already be closed). The endpoint correspondence is made so that the hi end of traj touches the named (segEnd) end of seg, leaving the other ends to touch each other. Move either the first joint or the last joint (depending on the distortEnd argument) to coincide with the other end. This will reduce the number of joints in the trajectory by one (making all sequences which refer to this trajectory obsolete. new traj will have role = fence. Returns TRUE if traj's parent outline has no holes. Building Trajectories from Parts Creates a new trajectory from the consecutive set of segments described by run. All of the segments are copied, so run.traj is untouched. Like CopyTrajFromRun, but we specify the run with a start segment and a number of segments. Creates a new trajectory by concatenating two existing trajectories. Copies are made, so fixed and moving are unchanged. moving is translated so that its movingEnd touches the fixedEnd of fixed. Run describes a part of run.traj that is to be replaced by traj. The result is similar to Rope.Cat[Rope.Substr[...], newRope, Rope.Substr[...]] except that a Traj can be a circular structure. Orientation Fundamental Routines Drawing Transforming Individually translates each joint and control point of the trajectory. A convenience routine which does a TransformTraj, where transform is a simple translation. Textual Description Accessing Parts Returns traj.segCount-1 for both open and closed trajectories. Returns -1 if no PreviousSegmentNum Returns -1 if no FollowingSegmentNum segCount for open trajectories, segCount -1 for closed trajectories. Returns -1 if no FollowingJoint Parts Hit Testing Style Use sparingly: Returns -1 if it doesn't exist. ΚΡ˜J˜Icodešœ ™ Kšœ Οmœ1™˜QK™G—šŸ œžœ˜1KšœZ™Z—KšŸœžœA˜XK˜Kšœ™K™Kšœ žœ˜*Kš Ÿ œžœ9žœžœ žœ˜iKšŸœžœžœžœ˜)IprocšŸœžœžœžœ žœžœžœžœ˜YK˜Kšœ™K˜KšŸ œžœžœžœ˜CKšŸ œžœžœžœ˜AKšŸ œžœžœžœ˜DKšŸ œžœžœ˜7KšŸ œžœžœ˜:K˜šŸ œžœžœžœ˜9Kšœ>™>—KšŸœžœžœžœ˜7K˜KšŸœžœžœžœ˜Hš Ÿœžœžœžœ žœ˜JKšœŸ™#—š Ÿœžœžœžœ žœ˜MKšœŸ™$—š Ÿœžœžœžœ žœ˜GK™DKšœŸ™K˜—Kš Ÿ œžœžœžœžœ˜9K˜K™K™KšŸœžœžœ˜UK˜KšŸ œžœ9˜LKšŸœžœ.˜KKšŸœžœ+˜?KšŸœžœ9˜NK˜K™ K™KšŸœžœžœ)˜YKšŸœžœžœ1˜eKšŸ œžœ)žœ+˜jKšŸ œžœ-žœ3˜zK˜KšŸœžœ.žœžœ žœ žœžœ˜KšŸ œžœ.žœžœ žœ žœžœ˜KšŸœžœ.žœžœ žœ žœžœžœ˜¬K™Kš Ÿœžœžœ žœžœžœ˜dKš Ÿœžœ!žœ žœžœžœ˜jK™K˜KšŸ œžœ žœ˜5KšŸœžœ(˜@KšŸœžœžœ˜IK˜Kšœ™K™šŸ œžœžœ žœ˜CK™—KšŸœžœ žœ žœ˜IK˜Kšžœ˜K˜—…—T'£