<> <> <<>> DIRECTORY BasicTime USING [Now], Commander USING [CommandProc, Register], IO USING [int, PutFR], Plot USING [AddVector, CreateSpec, CreateViewer, RealSequence, RopeSequence, SavePlot, Vector], RealFns USING [Sin], Rope USING[ROPE], ViewerClasses USING [Viewer]; PlotDemoImpl: CEDAR PROGRAM IMPORTS BasicTime, Commander, IO, Plot, RealFns = BEGIN <<>> PlotDemo: Commander.CommandProc = { -- plot twelve sinusoidal curves. PhaseShift: REAL = timeIncrement: REAL = 4.0/100.0; -- 100 time increments in 4 t, angle: REAL _ 0.0; viewer: ViewerClasses.Viewer; <<>> <<-- initialize names of curves.>> names: REF Plot.RopeSequence _ NEW[Plot.RopeSequence[12]]; FOR i: CARDINAL IN [0..12) DO names[i] _ IO.PutFR["Wave # %g. ", IO.int[i+1]]; ENDLOOP; <<>> <<-- create the plot viewer>> viewer _ Plot.CreateViewer[ Plot.CreateSpec[file: "Waves.plot", title: "Waves", time: BasicTime.Now[], bounds: [0, -1.0, 4.0, 1.0], nCurvesMax: 12, legendEntries: names]]; <<-- generate the curves as funtions of t.>> WHILE t <= 4.0 DO vector: Plot.Vector _ NEW[Plot.RealSequence[13]]; -- a "vertical" cross-section of the plot. vector[0] _ t; angle _ t* FOR i: CARDINAL IN [1..12] DO vector[i] _ RealFns.Sin[angle]; angle _ angle - PhaseShift; ENDLOOP; Plot.AddVector[viewer, vector]; t _ t + timeIncrement; ENDLOOP; <<-- save into a plot file.>> msg _ Plot.SavePlot[viewer, "Waves.plot"]; }; -- PlotDemo Commander.Register[ "PlotDemo", PlotDemo, "Demonstration of the curve plotting package."]; END. LOG. Chen, July 29, 1985 6:19:35 pm PDT, created.