GraphDisplay.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited:
Sweetsun Chen, November 25, 1985 10:59:10 pm PST
DIRECTORY
Graph USING [Entity, EntityList, GraphHandle, PaintAction, PaintInfo, PaintInfoRec, Text, ValueList, XY, Viewer],
GraphPrivate,
GraphUtil USING [HandleNotNil, ReverseEntityList, ReverseValueList, ViewerNotNil],
Imager USING [Rectangle],
ViewerOps USING [PaintViewer];
GraphDisplay:
CEDAR
PROGRAM
IMPORTS GraphUtil, ViewerOps
EXPORTS GraphPrivate = {
OPEN Graph, GraphUtil;
This module deals with screen display (erase or paint).
All public proc's in the module call Print with proper PaintInfo, which in turn calls Draw in GraphDraw.
handle, handle.chart, and handle.chart.viewer should not be nil when any of these public paint procs are called.
PaintAll:
PUBLIC
PROC [handle: GraphHandle, clear, updateDivBds, clientOnly:
BOOL] = {
IF HandleNotNil[handle]
THEN {
OPEN handle;
info: PaintInfo ←
NEW[all PaintInfoRec ←
[data: all[clear: clear, updateDivBds: updateDivBds]]];
IF ViewerNotNil[chart.viewer]
THEN ViewerOps.PaintViewer[
viewer: chart.viewer,
hint: IF clientOnly THEN client ELSE all,
clearClient: clear,
whatChanged: info
];
IF clear
THEN {
chart.dirty ← FALSE;
zoomPt1 ← zoomPt2 ← [];
};
};
}; -- PaintAll
PaintAllCurves:
PUBLIC
PROC [handle: GraphHandle, clear:
BOOL] = {
refresh the axes and anything inside the axes.
IF HandleNotNil[handle]
THEN {
info: PaintInfo ←
NEW[allCurves PaintInfoRec ←
[action: paint, output: screen, data: allCurves[clear: clear]]];
PaintClient[handle, info];
};
}; -- PaintAllCurves
PaintRect:
PUBLIC
PROC [handle: GraphHandle, rect: Imager.Rectangle, clear, updateDivBds:
BOOL, action: PaintAction ← paint] = {
IF HandleNotNil[handle]
THEN {
OPEN handle;
info: PaintInfo ←
NEW[rectangle PaintInfoRec ←
[action: action, output: screen,
data: rectangle[clear: clear, updateDivBds: updateDivBds, rect: rect]]];
PaintClient[handle, info];
};
}; -- PaintRect
PaintText:
PUBLIC
PROC [handle: GraphHandle, text: Text, action: PaintAction ← paint] = {
IF HandleNotNil[handle]
AND text #
NIL
THEN {
OPEN handle;
info: PaintInfo ←
NEW[graphText PaintInfoRec ←
[action: action, output: screen, data: graphText[text: text]]];
PaintClient[handle, info];
};
}; -- PaintText
PaintEntity:
PUBLIC
PROC [handle: GraphHandle, entity: Entity, withLegend:
BOOL, action: PaintAction ← paint] = {
IF HandleNotNil[handle]
AND entity #
NIL
THEN {
OPEN handle;
info: PaintInfo ←
NEW[graphEntity PaintInfoRec ←
[action: action, output: screen, data: graphEntity[entity: entity]]];
PaintClient[handle, info];
IF withLegend THEN PaintLegend[handle, entity, action, TRUE];
};
}; -- PaintEntity
PaintLegend:
PUBLIC
PROC [handle: GraphHandle, start: Entity, action: PaintAction ← paint, onlyOne:
BOOL] = {
Plot legends of entities (starting from start).
If start is nil, clean the place after the last legend entry.
If onlyOne, only the legend for the starting entity is plotted.
IF HandleNotNil[handle]
THEN {
OPEN handle;
info: PaintInfo ←
NEW[legend PaintInfoRec ←
[action: action, output: screen, data: legend[entity: start, onlyOne: onlyOne]]];
PaintClient[handle, info];
};
}; -- PaintLegend
PaintTails:
PUBLIC
PROC [handle: GraphHandle, x1, x2:
REAL, v1, v2: ValueList, entities: EntityList, action: PaintAction ← paint, reversed:
BOOL ← TRUE] = {
IF HandleNotNil[handle]
AND v1 #
NIL
AND v2 #
NIL
THEN {
OPEN handle;
rV1, rV2: ValueList;
rEL: EntityList;
info: PaintInfo;
IF reversed
THEN {
[rV1, ] ← GraphUtil.ReverseValueList[v1, FALSE];
[rV2, ] ← GraphUtil.ReverseValueList[v2, FALSE];
rEL ← GraphUtil.ReverseEntityList[entities, TRUE];
}
ELSE {rV1 ← v1; rV2 ← v2; rEL ← entities};
info ←
NEW[tails PaintInfoRec ←
[action: action, output: screen, data: tails[x1, x2, rV1, rV2, rEL]]];
PaintClient[handle, info];
};
}; -- PaintTails
PaintTarget:
PUBLIC
PROC [handle: GraphHandle, choice:
XY, action: PaintAction ← paint] = {
IF HandleNotNil[handle]
THEN {
OPEN handle;
info: PaintInfo ←
NEW[target PaintInfoRec ←
[action: action, output: screen, data: target[xy: choice]]];
PaintClient[handle, info];
};
}; -- PaintTarget
PaintGrids:
PUBLIC
PROC [handle: GraphHandle, choice:
XY, long:
BOOL, action: PaintAction ← paint] = {
IF HandleNotNil[handle]
THEN {
OPEN handle;
info: PaintInfo ←
NEW[grid PaintInfoRec ←
[action: action, output: screen, data: grid[xy: choice, long: long]]];
PaintClient[handle, info];
};
}; -- PaintGrids
PaintClient:
PUBLIC
PROC [handle: GraphHandle, info: PaintInfo] = {
OPEN handle;
viewer: Viewer ← handle.chart.viewer;
IF ViewerNotNil[viewer]
THEN ViewerOps.PaintViewer[
viewer: viewer,
hint: client,
clearClient: FALSE,
whatChanged: info
];
IF info.action = erase THEN handle.chart.dirty ← TRUE;
}; -- PaintClient
}.
LOG.
SChen, created at October 9, 1985 6:10:49 pm PDT