<<>> <> <> <> <> <> DIRECTORY FileInterpreter, FS, G3dInterpret, G3dBasic, G3dRender, G3dScene, G3dShape, G3dTool, ImagerColor, IO, List, Rope, StatementInterpreter, ViewerClasses; G3dInterpretImpl: CEDAR PROGRAM IMPORTS FileInterpreter, FS, G3dRender, G3dScene, G3dTool, IO, Rope, StatementInterpreter EXPORTS G3dInterpret ~ BEGIN <> InterpretTool: TYPE ~ G3dInterpret.InterpretTool; RenderTool: TYPE ~ G3dTool.Tool; ROPE: TYPE ~ Rope.ROPE; Error: PUBLIC SIGNAL [reason: ROPE] = CODE; <> Draw: G3dScene.SceneProc ~ { tool: G3dTool.Tool ¬ NARROW[data]; tool.shapes ¬ ps.context.shapes; G3dTool.PrepareForDrawing[tool]; G3dTool.Repaint[tool]; }; MakeInterpretTool: PUBLIC PROC [ fileName: ROPE, column: ViewerClasses.Column ¬ left, log: BOOL ¬ TRUE, renderTool: RenderTool ¬ NIL] RETURNS [a: InterpretTool] ~ { IF fileName # NIL THEN { symbols: FileInterpreter.Symbols ¬ FileInterpreter.CreateSymbolTable[NIL]; err: ROPE ¬ StatementInterpreter.InterpretStatement[ "{ OPEN G3dInterpret; NULL }",, LIST[symbols]]; IF err # NIL THEN Error[err]; a ¬ NEW[G3dInterpret.InterpretToolRep]; a.fileTool ¬ FileInterpreter.CreateTool[ symbols, fileName, "3dInterpret", column, a, log,,, Repeat, Abort, LIST[["Help", Help]]]; IF a.fileTool = NIL THEN Error["Can't find file"]; IF (a.renderTool ¬ renderTool) = NIL THEN a.renderTool ¬ G3dTool.MakeTool[name: "3dInterpret", nViews: 0, client: [data: a]]; IF NOT G3dTool.Context3dOk[a.renderTool] THEN Error["Bad 3d context!"]; G3dScene.RegisterProc["Draw", Draw, a.renderTool]; FileInterpreter.Execute[a.fileTool]; }; }; Log: G3dScene.LogProc ~ { a: InterpretTool ¬ NARROW[clientData]; FileInterpreter.WriteToLog[a.fileTool, rope]; }; Parse: PUBLIC PROC [rope: ROPE] ~ { a: InterpretTool ¬ GetInterpretTool[]; { ENABLE { FS.Error => {Log[error.explanation, a]; CONTINUE}; G3dScene.ParseError => {Log[explanation, a]; CONTINUE}; }; IF NOT G3dTool.Context3dOk[a.renderTool] THEN Error["Can't create 3d context"]; a.parseState ¬ G3dScene.Parse[ a.renderTool.context3d, rope, a.fileTool.cmd.out, Log,, a.fileTool.fileName, a, a.parseState]; IF a.parseState.errorMessage # NIL THEN Log[a.parseState.errorMessage, a]; }; }; Parses: PROC [key: ROPE, reals: LIST OF REAL ¬ NIL, ints: LIST OF INT ¬ NIL] ~ { AddToList: PROC [value: IO.Value] ~ { IF tail = NIL THEN values ¬ tail ¬ LIST[value] ELSE {tail.rest ¬ LIST[value]; tail ¬ tail.rest}; }; format: ROPE ¬ Rope.Cat[key, ": "]; values, tail: LIST OF IO.Value ¬ NIL; IF reals # NIL THEN FOR l: LIST OF REAL ¬ reals, l.rest WHILE l # NIL DO AddToList[IO.real[l.first]]; format ¬ Rope.Cat[format, "%g "]; ENDLOOP ELSE FOR l: LIST OF INT ¬ ints, l.rest WHILE l # NIL DO AddToList[IO.int[l.first]]; format ¬ Rope.Cat[format, "%g "]; ENDLOOP; IF values # NIL THEN Parse[IO.PutFLR[format, values]]; }; ParseReals: PUBLIC PROC [key: ROPE, values: LIST OF REAL] ~ {Parses[key, values]}; ParseInts: PUBLIC PROC [key: ROPE, values: LIST OF INT] ~ {Parses[key,, values]}; GetInterpretTool: PUBLIC PROC RETURNS [InterpretTool] ~ { RETURN[NARROW[FileInterpreter.GetClientData[]]]; }; Help: ViewerClasses.ClickProc ~ {G3dTool.OpenHelp["3dInterpret"]}; Repeat: FileInterpreter.ClientProc ~ { renderTool: G3dTool.Tool ¬ NARROW[clientData, InterpretTool].renderTool; renderTool.context3d ¬ NIL; renderTool.shapes ¬ NIL; }; Abort: FileInterpreter.ClientProc ~ { G3dRender.AbortRender[NARROW[clientData, InterpretTool].renderTool.context3d]; }; END. .. <> <> <> <<~ {>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<};>> <> <> <> <> <> <> <> <<};>> <<};>> <<>> <> <> <> <<};>> <<>> <> <> <<};>> <<>> <> <> <<};>> <<>>