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]; 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. †GraphOps.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last Edited: Sweetsun Chen, April 23, 1986 2:29:37 pm PST Pradeep Sindhu April 8, 1986 11:20:33 am PST constants: The following color and font indicies are merely some INT's. They are listed just for convenience when client doesn't change the default colors or fonts. color indicies font indicies To ensure data integrity, it's better to lock/unlock the GraphHandle before/after calling the following procs, except when calling NewGraph with oldGraph nil. all the arguments below can be unspecified. This suggested file name to save the graph may or may not be used, depending on whether the oldGraph and the original fileName is nil. If oldGraph is nil, this suggested name (or "Graph.graph", if it is empty) will be used; otherwise this suggested name will be used, if and only if the original file name for oldGraph is empty. Two methods to set x and y data after calling NewGraph: 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. all following arguments may be defaulted. If handle or rope are nil, then return nil and no Text is created. If values is nil then return nil without setting x values. reverse: the order of ValueList is reversed. discard: client no longer holds ownership of the ValueList. If handle = nil, or if number of values # number of x values for the group, then return nil and no curve is created. If x values has been set by calling SetXValues, then values must have the same length as the x values. If x values have not been set, then values must be nil, and x and y values should be appended by calling AppendValues. reverse: the order of ValueList is reversed. discard: client no longer holds ownership of the ValueList. Append trailing values for all curves for each new x. If yvalues = nil then noop. Make sure that the number of y values agrees with the total number of curves in this group. And the order of values agrees with the order in which curves were added to the group by calling AddCurve, or its reverse if reverse is true. reverse: the order of yvalues is reversed. discard: client no longer holds ownership of the ValueList. save currently plotted data (or all data on handle) to a file with handle.graph.fileName as name. msg is not nil if there is any problem saving the graph. Κ$˜J™ Jšœ Οmœ1™<šœ ™ Jšœ,™,Icode™,—J˜šΟk ˜ Jšœžœ‰žœ.žœ˜ΚJšœžœžœ˜J˜—šœ žœž œžœ˜+J˜—J™ Jšœ6žœa™šJ˜™JšœΟc-˜DJ˜J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜!J˜JšœŸ ˜#JšœŸ ˜'JšœŸ ˜$—J˜™ Jšœ(Ÿ ˜4Jšœ(Ÿ ˜4J˜J˜J˜J˜Jšœ˜Jšœ˜J˜J˜J˜JšœŸ ˜#—J™Jšœž™žJ˜JšΟn œ ˜J˜š œžœ˜J™+šœ Ÿ)˜3Jšœ†™†JšœX™XJšœi™i—JšœŸ8˜FJšœ ŸK˜TJšœžœžœ˜Jšœžœžœ˜'JšœŸ˜9Jš œ žœžœžœžœžœ˜$JšœžœžœžœžœžœžœŸ ˜2Jš œ žœžœžœžœžœ˜+Jš œžœ žœ žœžœ˜1Jšœ žœžœŸ-˜FJšœžœ˜Jšœžœ˜JšœžœŸ˜:Jšœ žœžœŸr˜ˆJšœžœ"žœ˜0—J™™7J™;J™qJ™—š œžœžœ˜/J™)JšœžœŸD˜dJšœ$˜$JšœŸ˜%Jšœ žœŸ&˜