GraphDisplay.mesa, Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited:
Sweetsun Chen, November 15, 1985 5:52:42 pm PST
DIRECTORY
Graph USING [Entity, GraphHandle, GraphProc, NullRect, PaintAction, Text, ValueList, XY, Viewer],
GraphPrivate,
GraphUtil USING [HandleNotNil, 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, clientOnly: BOOLTRUE] = {
IF HandleNotNil[handle] THEN { OPEN handle;
paintInfo.item ← all;
paintInfo.action ← paint;
paintInfo.clear ← clear;
IF clientOnly THEN PaintClient[handle]
ELSE IF ViewerNotNil[chart.viewer] THEN ViewerOps.PaintViewer[
viewer: chart.viewer,
hint: all,
clearClient: clear,
whatChanged: handle.paintInfo
];
chart.dirty ← FALSE;
IF clear THEN zoomPt1 ← zoomPt2 ← [];
};
}; -- PaintAll
PaintAllCurves: PUBLIC PROC [handle: GraphHandle, clear: BOOLFALSE] = {
refresh the axes and anything inside the axes.
IF HandleNotNil[handle] THEN {
handle.paintInfo.item ← allCurves;
handle.paintInfo.action ← paint;
handle.paintInfo.clear ← clear;
PaintClient[handle];
};
}; -- PaintAllCurves
PaintRect: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, clear: BOOLTRUE, rect: Imager.Rectangle ← NullRect] = {
IF HandleNotNil[handle] THEN { OPEN handle;
paintInfo.item ← rectangle;
paintInfo.action ← action;
paintInfo.clear ← clear;
paintInfo.rect ← rect;
PaintClient[handle];
};
}; -- PaintRect
PaintText: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, text: Text ← NIL] = {
IF HandleNotNil[handle] AND text # NIL THEN { OPEN handle;
paintInfo.item ← graphText;
paintInfo.action ← action;
paintInfo.text ← text;
paintInfo.clear ← FALSE;
PaintClient[handle];
};
}; -- PaintText
PaintEntity: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, entity: Entity ← NIL, withLegend: BOOLTRUE] = {
IF HandleNotNil[handle] AND entity # NIL THEN { OPEN handle;
paintInfo.item ← graphEntity;
paintInfo.action ← action;
paintInfo.entity ← entity;
paintInfo.clear ← FALSE;
PaintClient[handle];
IF withLegend THEN PaintLegend[handle, action, entity, TRUE];
};
}; -- PaintEntity
PaintTails: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, v1, v2: ValueList ← NIL, x1, x2: REAL ← 0.0, reversed: BOOLTRUE] = {
IF HandleNotNil[handle] AND v1 # NIL AND v2 # NIL THEN { OPEN handle;
paintInfo.item ← tails;
paintInfo.action ← action;
paintInfo.clear ← FALSE;
IF reversed THEN [paintInfo.v1, ] ← GraphUtil.ReverseValueList[v1, FALSE]
ELSE paintInfo.v1 ← v1;
IF reversed THEN [paintInfo.v2, ] ← GraphUtil.ReverseValueList[v2, FALSE]
ELSE paintInfo.v2 ← v2;
paintInfo.x1 ← x1;
paintInfo.x2 ← x2;
PaintClient[handle];
};
}; -- PaintTails
PaintTarget: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, choice: XY ← x] = {
IF HandleNotNil[handle] THEN { OPEN handle;
paintInfo.item ← target;
paintInfo.action ← action;
paintInfo.clear ← FALSE;
paintInfo.xy ← choice;
PaintClient[handle];
};
}; -- PaintTarget
PaintGrids: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, choice: XY ← x] = {
IF HandleNotNil[handle] THEN { OPEN handle;
paintInfo.item ← grid;
paintInfo.action ← action;
paintInfo.clear ← FALSE;
paintInfo.xy ← choice;
PaintClient[handle];
};
}; -- PaintGrids
PaintLegend: PUBLIC PROC [handle: GraphHandle, action: PaintAction ← paint, start: Entity, onlyOne: BOOLFALSE] = {
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;
paintInfo.item ← legend;
paintInfo.action ← action;
paintInfo.clear ← FALSE;
paintInfo.entity ← start;
paintInfo.onlyOne ← onlyOne;
PaintClient[handle];
};
}; -- PaintLegend
PaintClient: PUBLIC GraphProc = { OPEN handle;
viewer: Viewer ← handle.chart.viewer;
IF ViewerNotNil[viewer] THEN ViewerOps.PaintViewer[
viewer: viewer,
hint: client,
clearClient: FALSE,
whatChanged: handle.paintInfo
];
IF handle.paintInfo.action = erase THEN handle.chart.dirty ← TRUE;
}; -- PaintClient
}.
LOG.
SChen, created at October 9, 1985 6:10:49 pm PDT