<> <> <> <> <<>> DIRECTORY Imager, Vector2, ViewerClasses; PlotGraph: CEDAR DEFINITIONS = BEGIN <> <> <> <> ROPE: TYPE = Imager.ROPE; VEC: TYPE = Imager.VEC; --maps into Vector2.VEC TYPE = RECORD [x, y: REAL] Rectangle: TYPE = Imager.Rectangle; -- x, y, w, h AxisList: TYPE ~ LIST OF Axis; GraphList: TYPE ~ LIST OF Graph; Viewer: TYPE ~ ViewerClasses.Viewer; WorldRectangle: Rectangle = [0.0, 0.0, 0.0, 0.0]; XY: TYPE = {X, Y}; Plot: TYPE = REF PlotRec; PlotRec: TYPE = RECORD [ private: PlotGraphPrivate _ NIL, name: REF READONLY ROPE _ NIL, selection: LIST OF REF ANY _ NIL, <> axis: AxisList _ NIL, -- in order from bottom to top texts: LIST OF PlotText _ NIL, lowerBounds: VEC, -- Min all X, Min all Y, upperBounds: VEC, -- Max all X, Max all Y over all graphs eventProc: EventProc _ NIL, -- To interprete events unknown by the NotifyProc data: REF ANY _ NIL -- Client data. ]; EventProc: TYPE = PROC [ plot: Plot, -- the clicked Plot axis: Axis, -- the clicked Axis (could be # of the selected Axis) pos: VEC, -- client coordinates of the mouse, if available. event: ATOM -- Atom specified by the Tip table ]; PlotGraphPrivate: TYPE = REF PlotGraphPrivateRec; PlotGraphPrivateRec: TYPE = RECORD [ viewer: Viewer, -- the Viewer used for the display locked: BOOL _ FALSE, -- the Plot is protected through a CONDITION, unlocked: CONDITION -- rather than through a monitor lock. ]; <<>> Axis: TYPE = REF AxisRec; AxisRec: TYPE = RECORD[ graphs: GraphList _ NIL, bounds: Rectangle, name: ROPE _ NIL, style: DrawingStyle _ analog, maxChars: NAT _ 8, -- used to determine the heigth of the hexaV style row axisData: ARRAY XY OF AxisData]; AxisData: TYPE = RECORD[ ticks: REAL _ 1.0, visible: BOOL _ TRUE, -- draw axis itself grid: BOOL _ FALSE]; DrawingStyle: TYPE = { analog, -- draws a segment between each point hexaH, -- writes the rope provided or the hexadecimal value of y horizontally hexaV -- writes the rope provided or the hexadecimal value of y vertically }; GraphClass: TYPE = REF GraphClassRec; GraphClassRec: TYPE = RECORD[ insert: GraphProc _ NIL, delete: GraphProc _ NIL, enumerate: GraphEnumerateProc _ NIL]; GraphProc: TYPE = PROC [graph: Graph, x, y: REAL]; GraphEnumerateProc: TYPE = PROC [plot: Plot, graph: Graph, bounds: Rectangle, eachPoint: PointProc, data: REF ANY _ NIL] RETURNS [invalidEnumeration: BOOL _ FALSE]; <> PointProc: TYPE = PROC [x, y: REAL, data: REF ANY _ NIL, rope: ROPE _ NIL] RETURNS [quit: BOOL _ FALSE]; <> <<>> Graph: TYPE = REF GraphRec; GraphRec: TYPE = RECORD[ class: GraphClass _ NIL, data: REF ANY _ NIL, name: ROPE _ NIL, mark: BOOL _ FALSE]; GraphPoint: TYPE = REF GraphPointRec; GraphPointRec: TYPE = RECORD[ graph: Graph, x, y: REAL]; PlotText: TYPE = REF PlotTextRec; PlotTextRec: TYPE = RECORD[ contents: ROPE _ NIL, wrt: Axis _ NIL, -- if nil then wrt entire plot bounds: Rectangle, -- w or h = 0.0 mean use bounding box of ROPE rotation: REAL _ 0.0, -- angle of rotation, ccw, in degrees justifyX: JustifyX _ left, justifyY: JustifyY _ bottom]; JustifyX: TYPE = {left, center, right}; JustifyY: TYPE = {top, center, bottom}; <> CreatePlot: PROC [name: ROPE _ NIL] RETURNS [plot: Plot]; <> <> LockPlot: PROC [plot: Plot]; UnlockPlot: PROC [plot: Plot]; RefreshPlot: PROC [plot: Plot, axis: AxisList _ NIL, graphs: GraphList _ NIL, within: Rectangle _ WorldRectangle, eraseFirst: BOOL _ FALSE]; <> DeletePlot: PROC [plot: Plot]; <> <> <> DeleteSelection: PROC [plot: Plot]; <> <> SelectAxis: PROC [plot: Plot, axis: Axis]; <> AddAxis: PROC [plot: Plot, axis: Axis]; <> GetSelectedAxis: PROC [plot: Plot] RETURNS [axis: Axis]; <> GetSelectedAxisList: PROC [plot: Plot] RETURNS [axisList: LIST OF Axis]; <> InsertAxis: PROC [plot: Plot, axis, after: Axis]; DeleteAxis: PROC [plot: Plot, axis: Axis]; MoveAxis: PROC [plot: Plot, axis, after: Axis]; XChangeAxis: PROC [plot: Plot, axis1, axis2: Axis]; CopyAxis: PROC [axis: Axis] RETURNS [duplicate: Axis]; <> <> SelectGraph: PROC [plot: Plot, graph: Graph]; <> <<>> AddGraph: PROC [plot: Plot, graph: Graph]; <> <<>> GetSelectedGraph: PROC [plot: Plot] RETURNS [graph: Graph]; <> <<>> GetSelectedGraphList: PROC [plot: Plot] RETURNS [graphList: LIST OF Graph]; <> <<>> <> SelectPoint: PROC [plot: Plot, point: GraphPoint]; <> <<>> AddPoint: PROC [plot: Plot, point: GraphPoint]; <> <<>> GetSelectedPoint: PROC [plot: Plot] RETURNS [point: GraphPoint]; <> <<>> GetSelectedPointList: PROC [plot: Plot] RETURNS [pointList: LIST OF GraphPoint]; <> <<>> InsertPoint: PROC [graph: Graph, x, y: REAL] RETURNS [ok: BOOL _ TRUE]; <> <<>> DeletePoint: PROC [graph: Graph, x, y: REAL] RETURNS [ok: BOOL _ TRUE]; <> <<>> <> SelectText: PROC [plot: Plot, text: PlotText]; <> <<>> AddText: PROC [plot: Plot, text: PlotText]; <> <<>> GetSelectedText: PROC [plot: Plot] RETURNS [text: PlotText]; <> <<>> GetSelectedTextList: PROC [plot: Plot] RETURNS [textList: LIST OF PlotText]; <> <<>> MoveText: PROC [plot: Plot, text: PlotText, position: Imager.VEC]; <> <<>> RotateText: PROC [plot: Plot, text: PlotText, alpha: REAL]; <> <<>> END. <> <> <> <> <> <> <> <<>> <<>>