GGSegment.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by Bier on December 29, 1986 4:27:27 pm PST
Contents: Procedures which implement the Gargoyle segment classes.
Stone, August 5, 1985 3:25:55 pm PDT
Pier, July 13, 1987 2:57:09 pm PDT
Kurlander August 28, 1986 6:13:29 pm PDT
Eisenman, September 17, 1987 3:36:48 pm PDT
Bier, May 19, 1989 11:26:37 am PDT
DIRECTORY
CubicPaths, CubicSplines, GGBasicTypes, GGInterfaceTypes, GGModelTypes, GGSegmentTypes, Imager, ImagerPath, ImagerTransformation;
GGSegment: CEDAR DEFINITIONS = BEGIN
NotFound: SIGNAL;
BitVector: TYPE = GGModelTypes.BitVector;
Point: TYPE = GGBasicTypes.Point;
Scene: TYPE = GGModelTypes.Scene;
Segment: TYPE = GGSegmentTypes.Segment;
SegmentClass: TYPE = GGSegmentTypes.SegmentClass;
SelectionClass: TYPE = GGSegmentTypes.SelectionClass;
DefaultData: TYPE = GGInterfaceTypes.DefaultData;
Vector: TYPE = GGBasicTypes.Vector;
ClassDef: TYPE = REF ClassDefRec;
ClassDefRec: TYPE = RECORD[type: ATOM, class: SegmentClass];
Making Segments (much like the Imager interface)
MakeLine: PROC [p0, p1: Point, props: LIST OF REF ANY] RETURNS [seg: Segment];
Create a straight line segment between the two points.
MakeBezier: PROC [p0, p1, p2, p3: Point, props: LIST OF REF ANY] RETURNS [seg: Segment];
Create a Bezier segment which passed thru p0 and p3, guided by p1 and p2.
MakeConic: PROC [p0, p1, p2: Point, r: REAL, props: LIST OF REF ANY] RETURNS [seg: Segment];
Let m be the midpoint of [p0, p2].
Let p be the point on [m, p1] such that Length[m, p]/Length[m, p1] = r.
The curve starts at p0, passes through p, and ends at p2.
It is a line if r=0; an ellipse if 0<r<1/2; a parabola if r=1/2; a hyperbola if 1/2<r<1.
The curve is bounded by the triangle [p0, p1, p2].
MakeArc: PROC [p0, p1, p2: Point, props: LIST OF REF ANY] RETURNS [seg: Segment];
Circular Arc through the three points
MakeCubicSpline: PROC [cps: CubicSplines.KnotSequence, type: CubicSplines.SplineType, props: LIST OF REF ANY] RETURNS [Segment];
Makes a segments of the types defined in CubicSplines.
Retrieving Segment Shape Parameters (for Gargoyle Clients, such as MatchTool)
BezierGetParams: PROC [seg: Segment] RETURNS [p0, p1, p2, p3: Point];
ConicGetParams: PROC [seg: Segment] RETURNS [p0, p1, p2: Point, r: REAL];
ConicSetRatio: PROC [seg: Segment, r: REAL];
ConicSetControlPoint: PROC [seg: Segment, p1: Point];
ArcGetParams: PROC [seg: Segment] RETURNS [p0, p1, p2: Point];
CubicSplineGetParams: PROC [seg: Segment] RETURNS [CubicPaths.Path];
General purpose segment routines
SetDefaults: PROC [seg: Segment, defaults: DefaultData];
CopySegment: PROC [seg: Segment] RETURNS [copy: Segment];
CopyLooks: PROC [from: Segment, to: Segment];
SameLooks: PROC [seg1: Segment, seg2: Segment] RETURNS [BOOL];
SameShape: PROC [seg1: Segment, seg2: Segment] RETURNS [same: BOOL];
UniformLooks: PROC [scene: Scene, selectClass: SelectionClass] RETURNS [seg: Segment];
Returns a "typical" segment if all the selected segments in the scene have equivalent looks. Returns NIL if their are non-uniform looking segments selected.
ReverseSegment: PROC [seg: Segment];
OpenUpSegment: PROC [seg: Segment];
FetchSegmentClass: PROC [type: ATOM] RETURNS [class: SegmentClass];
Currently implemented: $CubicSpline, $Bezier, $Conic, $Arc, $Line
Raises NotFound if class is not registered.
RegisterSegmentClass: PROC [classDef: ClassDef];
TransformSegment: PROC [seg: Segment, transform: ImagerTransformation.Transformation];
TranslateSegment: PROC [seg: Segment, vector: Vector];
MoveEndPointSegment: PROC [seg: Segment, lo: BOOL, newPoint: Point];
A convenience routine which does a TransformSegment, where transform is a simple translation.
Registers classes which may subsequently be found by FetchSegmentClass
Special purpose segment routines
DrawLine: PROC [dc: Imager.Context, p1, p2: Point, seg: Segment];
Draws a single straight segment from p1 to p2, using the color, width, and dash pattern defined in seg. Tries to use MaskVector if possible.
CSControlPointAdd: PROC [seg: Segment, pos: Point] RETURNS [Segment];
Adds control points to segments of the CubicSpline class
CSControlPointDelete: PROC [seg: Segment, cpVec: BitVector] RETURNS [Segment];
Returns a CubicSpline Segment with selected control points deleted.
BZSpecialTransformPath: PROC [seg: Segment, transform: ImagerTransformation.Transformation, lo, hi: BOOL, controlPoints: BitVector, loTransform, hiTransform: ImagerTransformation.Transformation, curveTo: ImagerPath.CurveToProc];
Used with special Bezier drag code.
BZControlPointMovedTo: PUBLIC PROC [seg: Segment, newPos: Point, controlPointNum: NAT];
The following NoOp procedures are implemented by GGSegmentImplB.
NoOpTightBoxProc: GGSegmentTypes.TightBoxProc;
NoOpSameShapeProc: GGSegmentTypes.SameShapeProc;
NoOpControlPointMoved: GGSegmentTypes.ControlPointMovedProc;
NoOpControlPointGet: GGSegmentTypes.ControlPointGetProc;
NoOpControlPointCount: GGSegmentTypes.ControlPointCountProc;
NoOpControlPointFieldSet: GGSegmentTypes.ControlPointFieldSetProc;
NoOpControlPointFieldGet: GGSegmentTypes.ControlPointFieldGetProc;
NoOpClosestControlPoint: GGSegmentTypes.ClosestControlPointProc;
NoOpClosestPointAndTangent: GGSegmentTypes.ClosestPointAndTangentProc;
NoOpLineIntersection: GGSegmentTypes.LineIntersectionProc;
NoOpCircleIntersection: GGSegmentTypes.CircleIntersectionProc;
NoOpAsSimpleCurve: GGSegmentTypes.AsSimpleCurveProc;
NoOpAsPolyline: GGSegmentTypes.AsPolylineProc;
NoOpJointNormal: GGSegmentTypes.JointNormalProc;
NoOpCPNormal: GGSegmentTypes.CPNormalProc;
NoOpAddJoint: GGSegmentTypes.AddJointProc;
NoOpFileOut: GGSegmentTypes.FileOutProc;
NoOpFileIn is not allowed.
END.