PlotDemoImpl.mesa
Sweetsun Chen, August 2, 1985 2:20:16 pm PDT
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.
p : REAL = 3.14159;
PhaseShift: REAL = p/12.0;
timeIncrement: REAL = 4.0/100.0; -- 100 time increments in 4p
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*p;
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.