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; Traj: TYPE = GGModelTypes.Traj; TwoState: TYPE = AtomButtons.TwoState; Problem: PUBLIC SIGNAL [msg: Rope.ROPE] = Feedback.Problem; versionRope: Rope.ROPE; Init: PROC [] ~ { versionRope _ "8704.03"; }; FileoutSceneAndOptions: 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; }; FileoutSceneOnly: 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]]]; 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; }; 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]; }; CountEntities: PROC [entities: LIST OF REF ANY] RETURNS [count: NAT] = { count _ 0; FOR list: LIST OF REF ANY _ entities, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutEntity: 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; }; FileoutSlice: 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]; }; Init[]; END. DFile: GGFileOutImpl.mesa Last edited by Bier on January 28, 1987 8:54:58 pm PST Copyright c 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, April 3, 1987 2:16:39 pm PST 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"; FileoutAlignments[f, ggData]; Κ{– "cedar" style˜Iheadšœ™Iprocšœ6™6Jšœ Οmœ1™<šœt™tIcode™"—L˜šΟk ˜ Lšœ†žœ˜—L˜šœžœž˜Lšžœ>ž˜GLšžœ ˜—L˜Lšž˜˜Lšœžœ ˜5Lšœžœ˜1Lšœžœ˜'Lšœ žœ˜%Lšœžœ˜!Lšœžœ"˜:Lšœžœ˜!Lšœ žœ˜'Lšœžœ˜!Lšœžœ˜Lšœ žœ˜&L˜LšΟnœžœžœ žœ˜;L˜Lšœžœ˜—L˜šŸœžœ˜Mšœ™Mšœ™Mšœ™Mšœ™Mšœ™Mšœ™Mšœ™Mšœ™Mšœ™Mšœ™—Mšœ˜˜M˜—š Ÿœžœžœžœžœ!žœ˜[LšœK˜KLšœ žœ"˜2Lšœ,˜,Lšœ:˜:Lšœ:˜:L˜Lšœ6˜6š žœ žœžœ@žœ žœž˜hLšœ˜Lšžœ˜—Lšœ˜L˜—š Ÿœžœžœžœžœžœ˜SLšœD˜DLšœ žœ"˜2Lšœ,˜,Lšœ:˜:Lšœ:˜:L™Mšœ žœžœ˜Mšœ žœžœ˜Lšœ6˜6š žœ žœžœ@žœ žœž˜hLšœ˜Lšžœ˜—Lšœ˜L˜L˜—šŸœžœžœžœ&˜KMšžœžœžœžœ>˜^Mšœ˜šžœžœžœ˜Mšœ(˜(šžœDžœžœž˜`Mšœ)˜)Mšžœ˜—M˜—M˜L˜—šŸœžœžœžœ˜:Mšœ ˜ Mšœ˜Mšœ žœ˜Lšœ˜Mšœ7˜7Mšœ"˜"Mšœ žœžœ˜Lšœ˜Mšœ7˜7Mšœ"˜"Mšœ žœžœ˜Lšœ˜Mšœ8˜8Mšœ"˜"Mšœ žœžœ˜Lšœ˜Mšœ:˜:Mšœ"˜"Mšœ žœžœ˜Lšœ˜Mšœ*˜*Mšœ9˜9Mšœ%˜%Mšœ žœžœ˜Mšœ žœžœ˜Lšœ˜L˜—šŸ œžœ žœžœžœžœžœ žœ˜HLšœ ˜ šžœžœžœžœžœžœžœž˜CLšœ˜Lšžœ˜—Lšœ˜—L˜š Ÿ œžœžœžœ žœžœ˜8šžœžœž˜Lšœ'˜'L˜6Lšžœžœ˜—Lšœ˜L˜—š Ÿ œžœžœžœžœ˜:Lšœžœ#˜7LšœE˜EL˜Lšœ˜Lšœ žœžœ˜Lšœ žœžœ˜Lšœ˜L˜—L˜L˜Lšžœ˜—…—Μ‹