DIRECTORY Graph USING [CaretIndex, CaretSpec, ColorIndex, Entity, FontIndex, GraphColors, GraphFonts, GraphHandle, GraphProc, JustifX, JustifY, Mark, NullBox, ROPE, TargetSpec, Text, UnitLineWidth, ValueList, XY], Imager USING [Box, VEC]; GraphOps: CEDAR DEFINITIONS = { OPEN Graph; 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]; Lock, Unlock: GraphProc; 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 _ 0, colorIndex: ColorIndex _ 15, -- black rotation: REAL _ 0.0, -- angle of rotation, ccw, in degrees. justifX: JustifX _ left, justifY: JustifY _ bottom ] RETURNS [text: Text]; SetXValues: PROC [handle: GraphHandle, values: ValueList, groupId: INT _ 0, reverse, discard: BOOL _ TRUE] RETURNS [xEntity: Entity]; AddCurve: PROC [handle: GraphHandle, values: ValueList, groupId: INT _ 0, 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, reverse, discard: BOOL _ TRUE -- refer to values ] RETURNS [curve: Entity]; EnlistEntity: PROC [handle: GraphHandle, groupId: INT _ 0, 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 ] RETURNS [curve: Entity _ NIL]; AddCrossSection: PROC [ handle: GraphHandle, x: REAL, yvalues: ValueList, groupId: INT _ 0, reverse, discard: BOOL _ TRUE]; }. LOG. SChen, October 26, 1985 3:48:07 pm PDT, created. 0GraphOps.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last Edited: Sweetsun Chen, November 17, 1985 2:52:40 am PST all the arguments below can be unspecified. This suggested file name to save the graph may or may not be used, depend on whether the oldGraph is nil. If oldGraph is nil, this name (or "Graph.graph", if it is empty) will be used, otherwise the original file name for oldGraph retains. Two methods to set x and y data after calling NewGraph: 1. SetXValues then call AddCurve for each y; or 2. EnlistEntities then call AddCrossSection to append y values for each x (x must be in ascending order). To ensure data integrity, it's better to acquire lock on the handle calling the following procs. (I.e., GraphPrivate.Lock[handle]; procA[handle, ...]; procB[handle, ...]; ... GraphPrivate.Unlock[handle]; ) 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 number of values # number of x values, then return nil and no curve is created. 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. If number of y values is not the same as before then the cross section is not appended. reverse: the order of ValueList is reversed. discard: client no longer holds ownership of the ValueList. Ê~˜J™ Jšœ Ïmœ1™<šœ ™ Jšœ/™/—J˜šÏk ˜ JšœžœŠžœ.žœ˜ËJšœžœžœ˜J˜—šœ žœž œžœ˜+J˜—šÏnœžœ˜J™+šœ Ïc)˜3Jšœñ™ñ—Jšœ 8˜FJšœ  K˜TJšœžœžœ˜Jšœžœžœ˜'Jšœ ˜9Jš œ žœžœžœžœžœ˜$Jšœžœžœžœžœžœžœ  ˜2Jš œ žœžœžœžœžœ˜+Jš œžœ žœ žœžœ˜1Jšœ žœžœ -˜FJšœžœ˜Jšœžœ˜Jšœžœ ˜:Jšœ žœžœ r˜ˆJšœžœ"žœ˜0—J™™7J™/J™iJ™—™gJ™J™J™J™J™J™J˜—JšŸ œ ˜J˜šŸœžœžœ˜/J™)Jšœžœ D˜dJšœ˜Jšœ ˜%Jšœ žœ &˜