<> <> <> <> <> DIRECTORY Graph USING [CaretIndex, CaretSpec, ColorIndex, Curve, FontIndex, GraphColors, GraphFonts, GraphHandle, GraphProc, JustifX, JustifY, Mark, NullBox, ROPE, TargetSpec, Text, UnitLineWidth, ValueList, XY], Imager USING [Box, VEC]; GraphOps: CEDAR DEFINITIONS = { OPEN Graph; <> <> <> White: ColorIndex = 0; -- reserved. better not to change this color. Red: ColorIndex = 1; Green: ColorIndex = 2; Blue: ColorIndex = 3; Yellow: ColorIndex = 4; Orange: ColorIndex = 5; Purple: ColorIndex = 6; GreenBlue: ColorIndex = 7; PurpleRed: ColorIndex = 8; OrangeYellow: ColorIndex = 9; GreenishBlue: ColorIndex = 10; YellowishOrange: ColorIndex = 11; YellowGreen: ColorIndex = 12; Gray: ColorIndex = 13; -- reserved. DarkGray: ColorIndex = 14; -- reserved. Black: ColorIndex = 15; -- reserved. <> TimesRoman10, LabelFont: FontIndex = 0; -- reserved. TimesRoman8, LegendFont: FontIndex = 1; -- reserved. TimesRoman12B: FontIndex = 2; TimesRoman10I: FontIndex = 3; TimesRoman10B: FontIndex = 4; Helvetica10: FontIndex = 5; Helvetica14B: FontIndex = 6; Gacha10: FontIndex = 7; Gacha8: FontIndex = 8; Hippo10: FontIndex = 9; Logo14: FontIndex = 10; Math8: FontIndex = 11; -- reserved. <<>> <> Lock, Unlock: GraphProc; NewGraph: PROC [ <> fileName, -- suggested file name to save the graph. <> <> <> groupName, -- name of the group of curves in this graph being created. comment, -- will show up on graph table following the name, but not on graph viewer. xName: ROPE _ NIL, autoBounds, autoDivisions: BOOL _ TRUE, bounds: Imager.Box _ NullBox, -- [xmin, ymin, xmax, ymax] divisions: ARRAY XY OF INT _ ALL[5], grids: ARRAY XY OF BOOL _ ALL[FALSE], -- true: on. targets: ARRAY XY OF TargetSpec _ ALL[NIL], carets: ARRAY CaretIndex OF CaretSpec _ ALL[NIL], showSlope: BOOL _ FALSE, -- slope between primary and secondary carets colors: GraphColors _ NIL, fonts: GraphFonts _ NIL, oldGraph: GraphHandle _ NIL, -- Create new viewer iff nil. replace: BOOL _ FALSE -- true: remove all existing curves and texts on old handle; false: merge new curves and texts with existing ones. ] RETURNS [newGraph: GraphHandle, groupId: INT]; <<>> <> <<1. SetXValues then call AddCurve for each y with values; or>> <<2. AddCurve (without values) for each y, then call AppendValues to append x and y values in ascending order of x.>> <<>> AddText: PROC [handle: GraphHandle, rope: ROPE, <> place: Imager.VEC _ [0.0, 0.0], -- location with respect to origion and relative to size of axes box fontIndex: FontIndex _ TimesRoman10, colorIndex: ColorIndex _ 15, -- black rotation: REAL _ 0.0, -- angle of rotation, ccw, in degrees. justifX: JustifX _ left, -- can be left, center, or right. justifY: JustifY _ bottom -- can be top, center, or bottom. ] RETURNS [text: Text]; <> SetXValues: PROC [handle: GraphHandle, groupId: INT, values: ValueList, reverse, discard: BOOL _ TRUE] RETURNS [x: Curve]; <> <> <> AddCurve: PROC [handle: GraphHandle, groupId: INT, name, comment: ROPE _ NIL, colorIndex: ColorIndex _ 0, -- If this argument is zero, a nonzero color index will be assigned for this curve automatically when it is plotted. mark: Mark _ none, width: REAL _ UnitLineWidth, values: ValueList _ NIL, reverse, discard: BOOL _ TRUE -- refer to values ] RETURNS [curve: Curve]; <> <> <> <> <> AppendValues: PROC [ handle: GraphHandle, groupId: INT, x: REAL, yvalues: ValueList, reverse, discard: BOOL _ TRUE]; <> <> <> <> <> SaveGraph: PROC[handle: GraphHandle, plottedOnly: BOOL _ TRUE] RETURNS [msg: ROPE]; <> <> }. LOG. SChen, October 26, 1985 3:48:07 pm PDT, created.