File: GGFileOutImpl.mesa
Last edited by Bier on May 14, 1987 12:44:00 pm PDT
Copyright © 1986 by Xerox Corporation. All rights reserved.
Contents: Facilities for creating text files and writing out a human-readable version of a gargoyle object database
Pier, May 12, 1987 4:19:41 pm PDT
DIRECTORY
Atom, FileNames, GGBasicTypes, AtomButtons, Feedback, GGFileOut, GGInterfaceTypes, GGModelTypes, GGScene, GGParseOut, GGSegmentTypes, IO, Rope;
GGFileOutImpl: CEDAR PROGRAM
IMPORTS Atom, FileNames, AtomButtons, Feedback, GGScene, GGParseOut, IO
EXPORTS GGFileOut =
BEGIN
EntityGenerator: TYPE = GGModelTypes.EntityGenerator;
FenceHoleOpen: TYPE = GGModelTypes.FenceHoleOpen;
GGData: TYPE = GGInterfaceTypes.GGData;
Outline: TYPE = GGModelTypes.Outline;
Point: TYPE = GGBasicTypes.Point;
ScalarButtonClient: TYPE = AtomButtons.ScalarButtonClient;
Scene: TYPE = GGModelTypes.Scene;
Segment: TYPE = GGSegmentTypes.Segment;
Slice: TYPE = GGModelTypes.Slice;
SliceGenerator: TYPE = GGModelTypes.SliceGenerator;
Traj: TYPE = GGModelTypes.Traj;
TwoState: TYPE = AtomButtons.TwoState;
Problem: PUBLIC SIGNAL [msg: Rope.ROPE] = Feedback.Problem;
versionRope: Rope.ROPE;
Init: PROC [] ~ {
versionRope ← "8610.29";
versionRope ← "8612.04";
versionRope ← "8701.13";
versionRope ← "8701.135";
versionRope ← "8701.23";
versionRope ← "8701.26";
versionRope ← "8701.28";
versionRope ← "8701.30";
versionRope ← "8702.11";
versionRope ← "8702.26";
versionRope ← "8704.03";
versionRope ← "8705.14";
};
FileoutSceneAndOptionsOLDD: PUBLIC PROC [f: IO.STREAM, ggData: GGData, fileName: Rope.ROPE] = {
entityGen: EntityGenerator ← GGScene.TopLevelEntitiesInScene[ggData.scene];
entityCount: NAT ← GGScene.EntityCount[entityGen];
fileName ← FileNames.GetShortName[fileName];
f.PutF["Gargoyle file for scene: %g\n", [rope[fileName]]];
f.PutF["Produced by version %g\n\n", [rope[versionRope]]];
FileoutAlignments[f, ggData];
f.PutF["Entities: [%g]:\n\n", [integer[entityCount]]];
FOR entity: REF ANY ← GGScene.NextEntity[entityGen], GGScene.NextEntity[entityGen] UNTIL entity = NIL DO
FileoutEntity[f, entity];
ENDLOOP;
};
FileoutSceneAndOptions: PUBLIC PROC [f: IO.STREAM, ggData: GGData, fileName: Rope.ROPE] = {
sliceGen: SliceGenerator ← GGScene.TopLevelSlicesInScene[ggData.scene];
sliceCount: NAT ← CountSlices[ggData.scene];
fileName ← FileNames.GetShortName[fileName];
f.PutF["Gargoyle file for scene: %g\n", [rope[fileName]]];
f.PutF["Produced by version %g\n\n", [rope[versionRope]]];
FileoutAlignments[f, ggData];
f.PutF["Entities: [%g]:\n\n", [integer[sliceCount]]];
FOR slice: Slice ← GGScene.NextSlice[sliceGen], GGScene.NextSlice[sliceGen] UNTIL slice = NIL DO
FileoutSlice[f, slice];
ENDLOOP;
};
FileoutSceneOnlyOLDD: PUBLIC PROC [f: IO.STREAM, scene: Scene, fileName: Rope.ROPE] = {
entityGen: EntityGenerator ← GGScene.TopLevelEntitiesInScene[scene];
entityCount: NAT ← GGScene.EntityCount[entityGen];
fileName ← FileNames.GetShortName[fileName];
f.PutF["Gargoyle file for scene: %g\n", [rope[fileName]]];
f.PutF["Produced by version %g\n\n", [rope[versionRope]]];
FileoutAlignments[f, ggData];
f.PutChar[IO.CR];
f.PutChar[IO.CR];
f.PutF["Entities: [%g]:\n\n", [integer[entityCount]]];
FOR entity: REF ANY ← GGScene.NextEntity[entityGen], GGScene.NextEntity[entityGen] UNTIL entity = NIL DO
FileoutEntity[f, entity];
ENDLOOP;
};
FileoutSceneOnly: PUBLIC PROC [f: IO.STREAM, scene: Scene, fileName: Rope.ROPE] = {
sliceGen: SliceGenerator ← GGScene.TopLevelSlicesInScene[scene];
sliceCount: NAT ← CountSlices[scene];
fileName ← FileNames.GetShortName[fileName];
f.PutF["Gargoyle file for scene: %g\n", [rope[fileName]]];
f.PutF["Produced by version %g\n\n", [rope[versionRope]]];
FileoutAlignments[f, ggData];
f.PutChar[IO.CR];
f.PutChar[IO.CR];
f.PutF["Entities: [%g]:\n\n", [integer[sliceCount]]];
FOR slice: Slice ← GGScene.NextSlice[sliceGen], GGScene.NextSlice[sliceGen] UNTIL slice = NIL DO
FileoutSlice[f, slice];
ENDLOOP;
};
PrintButtonValues: PROC [f: IO.STREAM, firstButton: ScalarButtonClient] = {
IF firstButton = NIL THEN SIGNAL Problem[msg: "There should always be a dummy first button."];
firstButton ← firstButton.next;
IF firstButton # NIL THEN {
f.PutF["%g", [real[firstButton.value]]];
FOR thisButton: ScalarButtonClient ← firstButton.next, thisButton.next UNTIL thisButton = NIL DO
f.PutF[", %g", [real[thisButton.value]]];
ENDLOOP;
};
};
FileoutAlignments: PROC [f: IO.STREAM, ggData: GGData] = {
firstButton: ScalarButtonClient;
stateInfo: TwoState;
midPointsOn: BOOL;
f.PutF["Slope: "];
firstButton ← ggData.hitTest.slopeHeader.scalarButtons;
PrintButtonValues[f, firstButton];
f.PutChar[IO.CR];
f.PutF["Angle: "];
firstButton ← ggData.hitTest.angleHeader.scalarButtons;
PrintButtonValues[f, firstButton];
f.PutChar[IO.CR];
f.PutF["Radius: "];
firstButton ← ggData.hitTest.radiusHeader.scalarButtons;
PrintButtonValues[f, firstButton];
f.PutChar[IO.CR];
f.PutF["LineDistance: "];
firstButton ← ggData.hitTest.distanceHeader.scalarButtons;
PrintButtonValues[f, firstButton];
f.PutChar[IO.CR];
f.PutF["Midpoints: "];
stateInfo ← ggData.hitTest.midpointButton;
midPointsOn ← AtomButtons.GetButtonState[stateInfo] = on;
GGParseOut.WriteBOOL[f, midPointsOn];
f.PutChar[IO.CR];
f.PutChar[IO.CR];
};
CountSlices: PROC [scene: Scene] RETURNS [count: NAT] = {
sliceGen: SliceGenerator ← GGScene.TopLevelSlicesInScene[scene];
count ← 0;
FOR slice: Slice ← GGScene.NextSlice[sliceGen], GGScene.NextSlice[sliceGen] UNTIL slice = NIL DO
count ← count + 1;
ENDLOOP;
};
FileoutEntityOLDD: PROC [f: IO.STREAM, entity: REF ANY] = {
WITH entity SELECT FROM
slice: Slice => FileoutSlice[f, slice];
outline: Outline => outline.class.fileout[outline, f];
ENDCASE => ERROR;
};
FileoutSliceOLDD: PUBLIC PROC [f: IO.STREAM, slice: Slice] = {
className: Rope.ROPE ← Atom.GetPName[slice.class.type];
f.PutF["Slice (class: %g) [%g]:\n", [rope[className]], [integer[0]]];
f.PutF["Data: "];
slice.class.fileout[slice, f];
f.PutChar[IO.CR];
f.PutChar[IO.CR];
};
FileoutSlice: PUBLIC PROC [f: IO.STREAM, slice: Slice] = {
className: Rope.ROPE ← Atom.GetPName[slice.class.type];
f.PutF["%g\n", [rope[className]] ];
slice.class.fileout[slice, f];
f.PutChar[IO.CR];
f.PutChar[IO.CR];
};
Init[];
END.