GGDescribeImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by Bier on August 19, 1985 2:12:25 pm PDT
Contents: Printing out descriptions of gargoyle objects onto text streams, for debugging and feedback.
DIRECTORY
GGDescribe,
GGModelTypes,
GGTouch,
IO,
Rope;
GGDescribeImpl: CEDAR PROGRAM
IMPORTS GGTouch, IO, Rope
EXPORTS GGDescribe =
BEGIN
EntityGenerator: TYPE = GGModelTypes.EntityGenerator;
Cluster: TYPE = GGModelTypes.Cluster;
Outline: TYPE = GGModelTypes.Outline;
Sequence: TYPE = GGModelTypes.Sequence;
SequenceGenerator: TYPE = GGModelTypes.SequenceGenerator;
TouchItem: TYPE = GGModelTypes.TouchItem;
TouchItemGenerator: TYPE = GGTouch.TouchItemGenerator;
TouchGroup: TYPE = GGModelTypes.TouchGroup;
Traj: TYPE = GGModelTypes.Traj;
TrajGenerator: TYPE = GGModelTypes.TrajGenerator;
NotYetImplemented: PUBLIC SIGNAL = CODE;
DescribeCluster: PUBLIC PROC [cluster: Cluster] RETURNS [text: Rope.ROPE] = {
SIGNAL NotYetImplemented;
};
DescribeOutline: PUBLIC PROC [outline: Outline] RETURNS [text: Rope.ROPE] = {
SIGNAL NotYetImplemented;
};
DescribeTraj: PUBLIC PROC [traj: Traj] RETURNS [text: Rope.ROPE] = {
SELECT traj.role FROM
open => text ← IO.PutFR["an open trajectory with %g segments", [integer[traj.segCount]]];
fence => text ← IO.PutFR["a fence trajectory with %g segments", [integer[traj.segCount]]];
hole => text ← IO.PutFR["a hole trajectory with %g segments", [integer[traj.segCount]]];
ENDCASE => ERROR;
};
DescribeSegment: PUBLIC PROC [traj: Traj, segNum: NAT] RETURNS [text: Rope.ROPE] = {
segRope: Rope.ROPE;
segRope ← IO.PutFR["segment %g on ", [integer[segNum]]];
text ← Rope.Concat[segRope, DescribeTraj[traj]];
};
DescribeJoint: PUBLIC PROC [traj: Traj, jointNum: NAT] RETURNS [text: Rope.ROPE] = {
jointRope: Rope.ROPE;
jointRope ← IO.PutFR["joint %g on ", [integer[jointNum]]];
text ← Rope.Concat[jointRope, DescribeTraj[traj]];
};
DescribeSequence: PUBLIC PROC [seq: Sequence] RETURNS [text: Rope.ROPE] = {
seqRope: Rope.ROPE;
IF seq.parts.rest = NIL THEN
seqRope ← IO.PutFR["From joint %g to %g on ", [integer[seq.parts.first.start]], [integer[seq.parts.first.end]] ]
ELSE
seqRope ← IO.PutFR["Several parts of "];
text ← Rope.Concat[seqRope, DescribeTraj[seq.traj]];
};
DescribeItem: PROC [f: IO.STREAM, item: TouchItem] = {
SELECT item.touchingPartType FROM
joint => f.PutF["Item: joint on %g", [rope[DescribeTraj[item.traj]]]];
segment => f.PutF["Item: segment on %g", [rope[DescribeTraj[item.traj]]]];
ENDCASE => ERROR;
};
DescribeTouchGroup: PUBLIC PROC [group: TouchGroup] RETURNS [text: Rope.ROPE] = {
f: IO.STREAM;
touchGen: TouchItemGenerator;
f ← IO.ROS[];
f.PutF["TouchGroup: (%6.1f, %6.1f)\n", [real[group.point[1]]], [real[group.point[2]]]];
touchGen ← GGTouch.AllTouchItems[group];
FOR item: TouchItem ← GGTouch.NextTouchItem[touchGen], GGTouch.NextTouchItem[touchGen] UNTIL item = NIL DO
f.PutChar[IO.TAB];
DescribeItem[f, item];
f.PutChar[IO.CR];
ENDLOOP;
text ← IO.RopeFromROS[f];
};
END.