File: GraphPrivate.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited:
Sweetsun Chen, October 21, 1985 10:17:45 pm PDT
DIRECTORY
ChoiceButtons USING [EnumTypeRef],
Containers USING [Container],
Imager USING [ConstantColor, Context, Rectangle],
ImagerFont USING [Font],
Graph USING [AutoType, CaretIndex, ColorIndex, GRAPH, Entity, EntityColor, EntityGroup, EntityList, FontIndex, GraphColorsArray, GraphFontsArray, JustifX, JustifY, LastEntityColor, Mark, NullRect, ROPE, Text, Texts, XY, ValueList, Viewer],
Menus USING [Menu],
TiogaButtons USING [TiogaButton],
TiogaOps USING [Ref];
GraphPrivate: CEDAR DEFINITIONS = { OPEN Graph;
types
GraphHandle: TYPE = REF GraphHandleRec; -- the root of everything
GraphHandleRec: TYPE = RECORD[
texts and entities
allTexts: Texts ← NIL,
entityGroupList: EntityGroupList ← NIL,
entityHash: EntityHash ← NIL,
controller: Controller ← NIL, -- nil iff no controller viewer.
chart: Chart ← NIL,
graph: Graph.GRAPHNIL,
lastEntityColor: EntityColor ← LastEntityColor,
imagerFonts: ARRAY OutputType OF Fonts ← ALL[NIL],
vars useful for drawing
zoomPt1, zoomPt2: RECORD[set: BOOLFALSE, x, y: REAL ← 0.0] ← [],
backgroundIndex: BackgroundIndex ← white, -- for display only.
colorMap: ColorMap ← mine,
colorMode: ColorMode ← color,
paintInfo: PaintInfo ← NIL,
realRect, axesRect: Imager.Rectangle ← NullRect,
All refer to the axes box. But realRect is for real data; and axesRect is for screen.
scale, step: ARRAY XY OF REALALL[0.0],
scale = (d screen)/(d real); step is the step size betw ticks (for real data).
windowTooLow: BOOLFALSE,
waitingGraph: BOOLFALSE,
selectProcId: INT ← 0,
selectProc: PROCESSNIL,
meaningful to GraphEdit.SelectEntity and GraphEdit.ClosestEntity.
lock
locked: BOOLFALSE,
unlocked: CONDITION
];
Chart: TYPE = REF ChartRec; -- graph viewer and its data
ChartRec: TYPE = RECORD[
viewer: Viewer ← NIL,
caretState: ARRAY CaretIndex OF CaretState ← ALL[NIL],
dirty: BOOLFALSE,
autoRepaint: BOOLTRUE,
selectedText: Text ← NIL,
selectedEntity: Entity ← NIL,
selectedEntityGroup: EntityGroup ← NIL -- no use in this version.
];
CaretState: TYPE = REF CaretStateRec;
CaretStateRec: TYPE = RECORD[
x, y: INTEGER ← 0,
visible, toBlink: BOOLFALSE
"visible" here means that it can be seen on the chart at this moment.
it may be termperarily false (disappear) due to blinking effect.
blinking can be manifested only if graph.caret[index].visible is true.
];
Controller: TYPE = REF ControllerRec; -- controller viewer and its data
ControllerRec: TYPE = RECORD[
viewer: Viewer ← NIL,
menu: Menus.Menu ← NIL,
panel: Containers.Container ← NIL,
table: Viewer ← NIL,
panelVisible, tableNormalized: BOOLFALSE,
panelHeight: INTEGER ← 400, -- (397 is enough to show everything)
textsParent: TiogaOps.Ref ← NIL,
swDivisions, divX, divY,
swBounds, xmin, ymin, xmax, ymax: Viewer ← NIL,
swCaret: ARRAY CaretIndex OF Viewer ← ALL[NIL],
caretPlace: ARRAY CaretIndex OF ARRAY XY OF Viewer ← ALL[ALL[NIL]],
swSlope, slope: Viewer ← NIL,
swTarget, targetValue, targetWidth, targetColor: ARRAY XY OF Viewer ← ALL[NIL],
swGrid: ARRAY XY OF Viewer ← ALL[NIL],
colorIndex, red, green, blue,
fontIndex, fontFamily, swBold, swItalic, vFontSize, pFontScale,
textId, textContent, textPlaceX, textPlaceY, textColor, textFont,
xValues,
entityId, entityName, entityColor, entityWidth, entityMark, --entityGroupId, --entityValues,
groupId, groupName, xId, yIds,
xsectionX, xsectionYs,
argument: Viewer ← NIL,
justifXRef, justifYRef, markRef, operandRef, angleRef: ChoiceButtons.EnumTypeRef ← NIL,
auto: ARRAY AutoType OF BOOLALL[TRUE],
caretOn: ARRAY CaretIndex OF BOOLALL[FALSE],
targetOn, gridOn: ARRAY XY OF BOOLALL[FALSE],
slopeOn, boldOn, italicOn: BOOLFALSE,
justifX: JustifX ← center,
justifY: JustifY ← bottom,
mark: Mark ← none,
operand: Operand ← allY,
angle: Angle ← radians
];
Fonts: TYPE = REF FontArray;
FontArray: TYPE = ARRAY FontIndex OF ImagerFont.Font;
EntityGroupList: TYPE = LIST OF EntityGroup;
ControlAction: TYPE = {resume, update, remove, next, find, noop};
Operand: TYPE = {x, y, allY};
Angle: TYPE = {degrees, radians};
curve hash table
EntityHashSize: INT = 32;
EntityHash: TYPE = REF EntityHashArray;
EntityHashArray: TYPE = ARRAY [0..EntityHashSize) OF EntityList;
BackgroundIndex: TYPE = {white, gray, darkGray, black, unknown};
ColorMode: TYPE = {color, bw};
ColorMap: TYPE = {mine, cedar, default, replace};
MaxStep: CARDINAL = 6;
StepCount: TYPE = INTEGER[0..MaxStep);
BWLineState: TYPE = REF LineStateRec;
LineStateRec: TYPE = RECORD[
step: StepCount ← 0,
progress: REAL ← 0.0
];
GraphProc: TYPE = PROC [handle: GraphHandle ← NIL];
GraphPlaceProc: TYPE = PROC [handle: GraphHandle ← NIL, sx, sy: INTEGER ← 0];
GraphAtomProc: TYPE = PROC [handle: GraphHandle ← NIL, atom: ATOM];
PaintInfo: TYPE = REF PaintInfoRec;
PaintInfoRec: TYPE = RECORD[
item: PaintItem ← all,
action: PaintAction ← paint,
output: OutputType ← screen,
clear: BOOLTRUE, -- useful when item = all or rect.
rect: Imager.Rectangle ← NullRect, -- useful when item = rect.
text: Text ← NIL, -- useful when item = text.
entity: Entity ← NIL, -- useful when item = entity.
v1, v2: ValueList ← NIL, -- useful when item = tails. v1 is the y values at x1.
x1, x2: REAL ← 0.0, -- useful when item = tails.
xy: XY ← x
];
PaintAction: TYPE = {erase, paint};
OutputType: TYPE = {interpress, screen};
PaintItem: TYPE = {all, rectangle, graphText, graphEntity, tails, target, grid};
public vars
defaultColorsArray: GraphColorsArray;
defaultFontsArray: GraphFontsArray;
systemColor: ARRAY ColorIndex OF Imager.ConstantColor; -- exported from GraphViewer.mesa
procedures
implemented by GraphController:
ShowController: GraphProc;
IsController: PROC [viewer: Viewer] RETURNS [BOOL];
implemented by GraphDisplay:
PaintAll: PROC [handle: GraphHandle, clear, clientOnly: BOOLTRUE];
PaintRect: PROC [handle: GraphHandle, action: PaintAction ← paint, clear: BOOLTRUE, rect: Imager.Rectangle ← NullRect];
PaintText: PROC [handle: GraphHandle, action: PaintAction ← paint, text: Text ← NIL];
PaintEntity: PROC [handle: GraphHandle, action: PaintAction ← paint, entity: Entity ← NIL];
PaintTails: PROC [handle: GraphHandle, action: PaintAction ← paint, v1, v2: ValueList ← NIL, x1, x2: REAL ← 0.0];
PaintTarget: PROC [handle: GraphHandle, action: PaintAction ← paint, choice: XY ← x];
PaintGrids: PROC [handle: GraphHandle, action: PaintAction ← paint, choice: XY ← x];
Paint: GraphProc;
implemented by GraphDraw:
Draw: PROC [context: Imager.Context ← NIL, handle: GraphHandle];
implemented by GraphEdit:
SwitchAuto: PROC [handle: GraphHandle, type: AutoType ← bounds];
SwitchCaretVisibility,
SwitchCaretBlinking: PROC [handle: GraphHandle, index: CaretIndex ← primary];
SwitchTarget,
SwitchGrid: PROC [handle: GraphHandle, xy: XY ← x];
SelectPoint,
SelectEntity,
SlideOnSameCurve,
SelectText,
MoveSelText,
ZoomIn,
ZoomOut,
ZoomPoint: GraphPlaceProc;
ErasePrimary,
MoveXhair2To1,
EraseSelEntity,
ShowSelEntityOnPanel,
JumpLeftAnyCurve,
JumpRightAnyCurve,
JumpUpAnyCurve,
JumpDownAnyCurve,
JumpLeftSameCurve,
JumpRightSameCurve,
EraseSelText,
ShowSelTextOnPanel,
ZoomWithZoomPts,
ClearZoomBox: GraphProc;
SlideLeftNSteps,
SlideRightNSteps: PROC [handle: GraphHandle, nSteps: INT ← 0];
implemented by GraphFile:
HandleFromFile: PROC [file: ROPENIL] RETURNS [handle: GraphHandle ← NIL, msg: ROPENIL];
GetGraph: PROC [handle: GraphHandle, file: ROPENIL] RETURNS [msg: ROPENIL];
SaveGraph: PROC [viewer: Viewer, toFile: ROPENIL] RETURNS [msg: ROPENIL];
WriteGraphFile: PROC [ref: REF ANY, file: ROPENIL] RETURNS [msg: ROPENIL];
WriteDataFile: PROC [graph: GRAPHNIL, file: ROPENIL] RETURNS [msg: ROPENIL];
implemented by GraphMenus:
ChartMenus, ControllerMenus: PROC [] RETURNS [menu: Menus.Menu];
implemented by GraphMonitor:
Lock: GraphProc;
Unlock: GraphProc;
IsLocked: PROC [handle: GraphHandle] RETURNS [BOOL];
CallWithLock: PROC [handle: GraphHandle, proc: GraphProc ← NIL];
LockedPlaceProc: PROC [handle: GraphHandle, sx, sy: INTEGER ← 0, proc: GraphPlaceProc ← NIL];
LockedAtomProc: PROC [handle: GraphHandle, atom: ATOM, proc: GraphAtomProc ← NIL];
Wait: PROC;
implemented by GraphPanel:
FlipToggleOnPanel: GraphAtomProc;
MakePanel: PROC [handle: GraphHandle] RETURNS [lastHeight: INTEGER];
implemented by GraphOperations:
Operate: GraphAtomProc;
implemented by GraphRemove:
PanelRemove: GraphAtomProc;
RemoveText: PROC[handle: GraphHandle, text: Text];
RemoveEntity: PROC[handle: GraphHandle, entity: Entity];
implemented by GraphResume:
Resume: GraphAtomProc;
ShowText: PROC [handle: GraphHandle, text: Text ← NIL];
ShowEntity: PROC [handle: GraphHandle, entity: Entity ← NIL];
ResumeTextFields: PROC[handle: GraphHandle, text: Text ← NIL];
ResumeEntityFields: PROC [handle: GraphHandle, entity: Entity ← NIL];
implemented by GraphTable:
MakeTable: PROC[handle: GraphHandle, lastHeight: INTEGER];
AddTextButton: PROC [handle: GraphHandle, text: Text ← NIL] RETURNS [b: TiogaButtons.TiogaButton ← NIL];
AddEntityButton: PROC [handle: GraphHandle, entity: Entity ← NIL] RETURNS [b: TiogaButtons.TiogaButton ← NIL];
implemented by GraphUpdate:
Update: GraphAtomProc;
implemented by GraphViewer:
ShowChart: GraphProc;
IsGraphViewer: PROC [viewer: Viewer] RETURNS [BOOL];
}.
CHANGE LOG.
SChen, created at October 9, 1985 5:50:44 pm PDT.