GraphUtil.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited:
Sweetsun Chen, November 17, 1985 0:21:11 am PST
DIRECTORY
Buttons USING [Button],
Graph USING [BackgroundIndex, Chart, ColorIndex, Controller, Entity, EntityGroup, EntityGroupList, EntityList, GraphHandle, GraphProc, NullBox, NullRect, NullVec, OutputType, ROPE, SegmentDataList, Text, Texts, ValueList, Viewer, XY],
Imager USING [Box, ConstantColor, Rectangle, VEC],
ImagerColor USING [RGB],
ImagerColorDefs USING [ConstantColor],
ImagerFont USING [Font];
GraphUtil:
CEDAR
DEFINITIONS = {
OPEN Graph;
error checking
Error: SIGNAL[atom: ATOM, info: ROPE ← NIL];
RaiseError: PROC [atom: ATOM, msg: ROPE ← NIL];
BlinkMsg: PROC [msg: ROPE ← NIL];
HandleNotNil: PROC [handle: GraphHandle, msg: ROPE ← NIL, debug: BOOL ← FALSE] RETURNS [ok: BOOL];
ChartNotNil: PROC [chart: Chart, msg: ROPE ← NIL, debug: BOOL ← FALSE] RETURNS [ok: BOOL];
ViewerNotNil: PROC [viewer: Viewer, msg: ROPE ← NIL, debug: BOOL ← FALSE] RETURNS [ok: BOOL];
GraphViewerExits: PROC [handle: GraphHandle, msg: ROPE ← NIL, debug: BOOL ← FALSE] RETURNS [ok: BOOL];
ControllerNotNil: PROC [c: Controller, msg: ROPE ← NIL, debug: BOOL ← FALSE] RETURNS [ok: BOOL];
ControllerViewerExits: PROC [handle: GraphHandle, msg: ROPE ← NIL, debug: BOOL ← FALSE] RETURNS [ok: BOOL];
BoundsValid: PROC [box: Imager.Box ← NullBox] RETURNS [BOOL];
DivisionsValid: PROC [divX, divY: INT] RETURNS [BOOL];
RectangleValid: PROC[rect: Imager.Rectangle ← NullRect] RETURNS [BOOL];
colors
ColorValueOk: PROC [value: REAL ← 0.0, blinkMsg: BOOL ← TRUE] RETURNS [ok: BOOL ← TRUE];
ForegroundColor: PROC [background: BackgroundIndex ← white, output: OutputType ← screen] RETURNS [Imager.ConstantColor];
BackgroundColor: PROC [background: BackgroundIndex ← white, output: OutputType ← screen] RETURNS [Imager.ConstantColor];
UseMyColors: PROC [handle: GraphHandle];
SetColor: PROC [index: ColorIndex ← 0, rgb: ImagerColor.RGB ← [0, 0, 0]] RETURNS [ImagerColorDefs.ConstantColor];
UseDefaultColors: PROC [handle: GraphHandle ← NIL];
UseCedarColors: PROC [];
SetCursorForBackgroundIndex: PROC [bkgnd: BackgroundIndex ← white];
UseDefaultFonts:
PROC [handle: GraphHandle];
handle must not be nil !!
UseMyFonts:
PROC [handle: GraphHandle];
handle can not be nil !! display is not altered.
coordinates and coordinates transformation
InViewer: PROC [viewer: Viewer ← NIL, x, y: INTEGER ← 0] RETURNS [BOOL];
CrossSegment: PROC [xseg, yseg: SegmentDataList ← NIL, at: REAL ← 0.0] RETURNS [ok: BOOL ← FALSE, v1, v2: Imager.VEC ← NullVec];
InterOrExtraPolate: PROC [v1, v2: Imager.VEC ← NullVec, x: REAL ← 0.0] RETURNS [REAL];
Crosssection: PROC [xseg, yseg: SegmentDataList ← NIL, at: REAL ← 0.0] RETURNS [ok: BOOL ← FALSE, value: REAL];
RealToScreen: PROC [handle: GraphHandle, r: REAL ← 0.0, xy: XY ← x] RETURNS [REAL];
RealToScreenI: PROC [handle: GraphHandle, r: REAL ← 0.0, xy: XY ← x] RETURNS [INTEGER];
RealToScreenRel: PROC [handle: GraphHandle, r: REAL ← 0.0, xy: XY ← x] RETURNS [REAL];
RealVecToScreenVec: PROC [handle: GraphHandle, vec: Imager.VEC ← NullVec] RETURNS [Imager.VEC];
ScreenToReal: PROC [handle: GraphHandle, s: REAL ← 0.0, xy: XY ← x] RETURNS [REAL];
ScreenIToReal: PROC [handle: GraphHandle, s: INTEGER ← 0, xy: XY ← x] RETURNS [REAL];
ScreenIToRealVec: PROC [handle: GraphHandle ← NIL, sx, sy: INTEGER ← 0] RETURNS [Imager.VEC ← NullVec];
TextPosToChartPos: PROC [axesRect: Imager.Rectangle ← NullRect, textPos: Imager.VEC ← NullVec] RETURNS [chartPos: Imager.VEC ← NullVec];
ChartPosToTextPos: PROC [axesRect: Imager.Rectangle ← NullRect, chartPos: Imager.VEC ← NullVec] RETURNS [textPos: Imager.VEC ← NullVec];
TextRect: PROC[text: Text ← NIL, font: ImagerFont.Font ← NIL, axesRect: Imager.Rectangle ← NullRect] RETURNS [rect: Imager.Rectangle ← NullRect, hotPoint: Imager.VEC ← NullVec];
panel fields
SetToggleColor: PROC[switch: Buttons.Button ← NIL, on: BOOL ← TRUE, paint: BOOL ← TRUE] RETURNS [BOOL];
SetIntField: PROC [field: Viewer ← NIL, value: INT ← 0];
GetIntField: PROC [field: Viewer ← NIL, showMsg: BOOL ← TRUE] RETURNS [msg: ROPE ← NIL, int: INT ← 0];
SetRealField: PROC [field: Viewer ← NIL, value: REAL ← 0.0];
GetRealField: PROC [field: Viewer ← NIL, showMsg: BOOL ← TRUE] RETURNS [msg: ROPE ← NIL, real: REAL ← 0.0];
text and entity
FullName: PROC [entity: Entity] RETURNS [fullName: ROPE];
FontHeight: PROC [font: ImagerFont.Font] RETURNS [height: REAL];
RopeSize: PROC [rope: ROPE, font: ImagerFont.Font] RETURNS [width, height: REAL];
RemoveTextFromList: PROC [text: Text, texts: Texts];
RemoveEntityFromList: PROC [entity: Entity, entityList: EntityList];
TextFromId: PROC [texts: Texts, id: INT] RETURNS [text: Text];
EntityFromId: PROC [ref: REF ANY, id: INT] RETURNS [entity: Entity];
SpecIndexedText: PROC [controller: Controller, texts: Texts] RETURNS [text: Text];
SpecIndexedEntity:
PROC [controller: Controller, ref:
REF
ANY ←
NIL]
RETURNS [entity: Entity];
killOld below only "partially" kills the old list.
ReverseTexts: PROC [old: Texts, killOld: BOOL ← TRUE] RETURNS [new: Texts];
ReverseEntityList: PROC [old: EntityList, killOld: BOOL ← TRUE] RETURNS [new: EntityList];
ReverseValueList: PROC [old: ValueList, killOld: BOOL ← TRUE] RETURNS [new, last: ValueList];
CopyValueList: PUBLIC PROC [old: ValueList, killOld: BOOL ← TRUE] RETURNS [new, last: ValueList];
ReverseSDL: PROC [old: SegmentDataList, killOld: BOOL ← TRUE] RETURNS [new, last: SegmentDataList ← NIL]; -- killOld only "partially" kill the old.
InitSegEnd: PROC [entity: Entity];
SetSegments: PUBLIC PROC [entity: Entity]; -- called when x and y's segment.end's are intialized.
InitSegAll: PROC [entity: Entity];
UpdateSegEnd: PROC [entity: Entity, values: ValueList];
UpdateSegAll: PROC [entity: Entity, values: ValueList];
LengthOfVL: PROC [valueList: ValueList] RETURNS [INT];
LengthOfEL: PROC [entityList: EntityList, group: EntityGroup ← NIL] RETURNS [INT];
LengthOfSDL: PROC [segmentDataList: SegmentDataList ← NIL] RETURNS [INT];
AppendX: PROC [xEntity: Entity, newx: REAL] RETURNS [oldx: REAL];
AppendY: PROC [entity: Entity, y, x1, x2: REAL] RETURNS [oldy: REAL];
AppendTexts: PROC [first, second: Texts] RETURNS [new: Texts];
AppendEntityList: PROC [first, second: EntityList] RETURNS [new: EntityList];
AppendEGL: PROC [first, second: EntityGroupList] RETURNS [new: EntityGroupList];
NewTextId: PROC [handle: GraphHandle, tryId: INT] RETURNS [newId: INT];
NewEntityId: PROC [handle: GraphHandle, tryId: INT] RETURNS [newId: INT];
NewGroupId: PROC [handle: GraphHandle, tryId: INT] RETURNS [newId: INT];
graph
MergeGraph: PROC [handle: GraphHandle, graph: GRAPH, paint: BOOL ← TRUE];
ReplaceGraph: PROC[handle: GraphHandle, graph: GRAPH, paint: BOOL ← TRUE];
strings
FileFromSelection: PROC [wDir: ROPE ← NIL] RETURNS [file, msg: ROPE ← NIL];
ReplaceFileExt: PROC [file: ROPE, extension: ROPE ← NIL] RETURNS [new: ROPE];
WDirOfViewer: PROC [viewer: Viewer] RETURNS [wDir: ROPE ← NIL];
viewer, handle, properties
HandleFromViewer: PROC [viewer: Viewer ← NIL] RETURNS [GraphHandle];
VanillaHandle: PROC [] RETURNS [GraphHandle];
Cleanup: PROC [handle: GraphHandle, full: BOOL ← TRUE] RETURNS [GraphHandle];
AddProp: PROC [object: REF ANY, prop: ATOM, val: REF ANY];
FetchProp: PROC [object: REF ANY, prop: ATOM] RETURNS [val: REF ANY];
misc
Almost: PROC [p, q: REAL] RETURNS [a: BOOL ← TRUE];
DataBounds: PROC [entityList: EntityList ← NIL] RETURNS [Imager.Box];
Print: GraphProc;
NotANumber:
PROC [r:
REAL]
RETURNS [
BOOL] =
INLINE {
RETURN[LOOPHOLE[r, LONG CARDINAL] = 17740000001B]};
NotANan:
PROC [r:
REAL]
RETURNS [
BOOL] =
INLINE {
RETURN[LOOPHOLE[r, LONG CARDINAL] # 17740000001B]};
}.
LOG.
SChen, August 14, 1985 7:30:22 pm PDT, created.