DIRECTORY Commander USING [CommandProc, Register], IO USING [int, PutFR], Graph USING [GraphHandle, ValueList], GraphOps USING [AddText, AddCurve, AppendValues, Black, Lock, NewGraph, SaveGraph, TimesRoman12B, Unlock], RealFns USING [Sin]; WavesImpl: CEDAR PROGRAM IMPORTS Commander, IO, GraphOps, RealFns = BEGIN Waves: Commander.CommandProc = { -- plot five sinusoidal curves. numberOfCurves: INT = 5; p : REAL = 3.14159; PhaseShift: REAL = p/12.0; timeIncrement: REAL = 4.0/100.0; -- 100 time increments in 4p graphHandle: Graph.GraphHandle _ NIL; groupId: INT; [graphHandle, groupId] _ GraphOps.NewGraph[ fileName: "Waves.graph", comment: "Waves.graph", -- will be displayed on controller table as group heading. bounds: [xmin: 0.0, ymin: -1.0, xmax: 4.0, ymax: 1.0] ]; IF graphHandle # NIL THEN { t, angle: REAL _ 0.0; GraphOps.Lock[graphHandle]; [] _ GraphOps.AddText[handle: graphHandle, rope: "Waves", place: [0.5, 1.1], fontIndex: GraphOps.TimesRoman12B, colorIndex: GraphOps.Black, rotation: 0.0, justifX: center, justifY: bottom]; FOR i: INT IN [1..numberOfCurves] DO [] _ GraphOps.AddCurve[handle: graphHandle, groupId: groupId, name: IO.PutFR["Wave # %g", IO.int[i]]]; ENDLOOP; WHILE t <= 4.0 DO values: Graph.ValueList _ NIL; -- LIST OF REAL angle _ t*p; FOR i: INT IN [1..numberOfCurves] DO values _ CONS[RealFns.Sin[angle], values]; angle _ angle - PhaseShift; ENDLOOP; GraphOps.AppendValues[handle: graphHandle, x: t, yvalues: values, groupId: groupId]; t _ t + timeIncrement; ENDLOOP; msg _ GraphOps.SaveGraph[graphHandle]; GraphOps.Unlock[graphHandle]; }; }; -- Waves Commander.Register["Waves", Waves, "An application of the GraphOps interface."]; END. LOG. Chen, July 29, 1985 6:19:35 pm PDT, created. ÒWavesImpl.mesa Sweetsun Chen, November 25, 1985 11:13:49 pm PST -- some constants -- create the graph. -- lock it -- put a title -- initialize curves. -- append x and y values. -- save and unlock it. Êc˜™Icode™0—J™šÏk ˜ Jšœ œ˜(Jšœœ˜Jšœœ˜%Jšœ œ\˜jJšœœ˜J˜—šœ œ˜Jšœ œ˜+—Jš˜J™šœ!Ïc˜@J™Jšœœ˜JšÏgÐgkœ Ÿ˜Jšœ œŸœ˜JšœœžÐgi˜=J˜Jšœ™Jšœ!œ˜%Jšœ œ˜ šœ+˜+Jšœ˜Jšœž:˜RJšœ5˜5J˜—J˜šœœœ˜Jšœ œ˜J™ Jšœ˜J˜J™šœ9˜9JšœQ˜QJšœ1˜1J˜—Jšœ™šœœœ˜$šœ+˜+Jšœœœ ˜:—Jšœ˜—J™Jšœ™šœ˜Jš œœžžž˜.Jšœ Ÿœ˜ šœœœ˜$Jšœ œ˜*Jšœ˜Jšœ˜—JšœT˜TJšœ˜Jšœ˜—J˜J™Jšœ&˜&Jšœ˜J˜—Jšœž˜ J˜—JšœP˜PJ˜Jšœ˜J˜šœ˜J˜,——…—Æ û