PlotGraphTestImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Barth, August 25, 1986 12:32:39 pm PDT
Christian Le Cocq May 12, 1987 7:05:02 pm PDT
Test of the PlotGraph oscilloscope. Generates data
DIRECTORY
IO USING [PutFR, int],
PlotGraph,
Rope USING [ROPE, Cat],
Vector2;
PlotGraphTestImpl: CEDAR PROGRAM
IMPORTS PlotGraph, IO, Rope
~ BEGIN
VEC: TYPE ~ Vector2.VEC;
VecList: TYPE ~ LIST OF VEC;
DisplayList: TYPE = LIST OF DisplayListRec;
DisplayListRec: TYPE = RECORD [
name: Rope.ROPE,
analog: BOOLEANTRUE,
or: VEC,
list: VecList
];
plot: PlotGraph.Plot;
txt: PlotGraph.PlotText;
testGClass: PlotGraph.GraphClass ← NEW[PlotGraph.GraphClassRec ← [
insert: NIL,
delete: NIL,
enumerate: TestEnum
]];
dummyAxisData: PlotGraph.AxisData ← [1000.0, FALSE];
displayList: DisplayList;
m: INT;
index: CARDINAL ← 0;
window: PlotGraph.Rectangle ← [0.0, 0.0, 5000.0, 6400.0];
TestEnum: PROC [plot: PlotGraph.Plot, graph: PlotGraph.Graph, bounds: PlotGraph.Rectangle, eachPoint: PlotGraph.PointProc] RETURNS [invalidEnumeration: BOOLFALSE] ~ {
quit: BOOLEANFALSE;
vecList: VecList ← NARROW[graph.data];
FOR iVecList: VecList ← vecList, iVecList.rest UNTIL iVecList=NIL DO
IF eachPoint[iVecList.first.x, iVecList.first.y] THEN RETURN[TRUE];
ENDLOOP;
};
DataGenerator: PUBLIC PROC [numberOfItems: INT ← 1, length: INT ← 64, x0: REAL ← 0.0, analog: BOOLEANTRUE, yMult: REAL ← 1.0, oldDisplayList: DisplayList ← NIL] RETURNS [displayList: DisplayList] ~ {
generate numberOfItems lists of values named n0, n1...np.
displayList ← oldDisplayList;
FOR n: INT IN [0..numberOfItems) DO
displayList ← CONS[[
name: Rope.Cat["n", IO.PutFR["%d", IO.int[index ← SUCC[index]]]],
analog: analog,
or: [0.0, 0.0],
list: NIL], displayList];
FOR i: INT IN [0..length) DO
m ← (i /(3+n)) MOD 2;
displayList.first.list ← CONS[[x: i*2000.0 + x0, y: 5000.0*yMult*m], displayList.first.list];
ENDLOOP;
ENDLOOP;
};
plot ← PlotGraph.CreatePlot["Test"];
txt ← NEW[PlotGraph.PlotTextRec ← [
contents: "Test of PlotGraph",
bounds: [0.4, 0.5, 0.2, 0.1],
rotation: 90.0,
justifyX: center,
justifyY: center
]];
plot.texts ← LIST [txt];
plot.lowerBounds ← [0.0, 0.0];
plot.upperBounds ← [64*2000.0, 5000.0];
displayList ← DataGenerator[8];
displayList ← DataGenerator[numberOfItems: 4, analog: FALSE, yMult: 0.031, oldDisplayList: displayList] ;
dummyAxisData.visible ← TRUE;
FOR iDisplayList: DisplayList ← displayList, iDisplayList.rest UNTIL iDisplayList=NIL DO
plot.axis ← CONS[NEW[PlotGraph.AxisRec ← [
graphs: LIST[NEW[PlotGraph.GraphRec ← [
class: testGClass,
name: iDisplayList.first.name,
data: iDisplayList.first.list
]]],
bounds: [0.0, 0.0, 64*2000.0, 5000.0],
name: "axis name here",
style: IF iDisplayList.first.analog THEN analog ELSE hexaH,
axisData: [dummyAxisData, dummyAxisData]
]], plot.axis];
ENDLOOP;
plot.axis.first.style ← hexaV;
PlotGraph.RefreshPlot[plot: plot, within: window, eraseFirst: TRUE];
END.