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; 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 _ 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]; 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, November 21, 1985 8:24:48 pm PST 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; or 2. EnlistEntities then call AddCrossSection to append y values for each x (x must be in ascending order). 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. 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šœ/™/—J˜šÏk ˜ JšœžœŠžœ.žœ˜ËJšœžœžœ˜J˜—šœ žœž œžœ˜+J˜—Jšœž™žJ˜JšÏn œ ˜J˜šŸœžœ˜J™+šœ Ïc)˜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™iJ™—šŸœžœžœ˜/J™)Jšœžœ D˜dJšœ˜Jšœ ˜%Jšœ žœ &˜