File: Graph.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited:
Sweetsun Chen, November 25, 1985 10:27:45 pm PST
Pradeep Sindhu April 8, 1986 10:46:41 am PST
DIRECTORY
ChoiceButtons USING [EnumTypeRef],
Containers USING [Container],
Imager USING [Box, Rectangle, VEC],
ImagerColor USING [RGB],
ImagerFont USING [Font],
Menus USING [Menu],
Real USING [NonTrappingNaN],
Rope USING [ROPE],
TiogaOps USING [Ref],
ViewerClasses USING [Viewer];
Graph: CEDAR DEFINITIONS = {
constants
NumberOfColors: INT = 16;
LastEntityColor: INT = 12;
NumberOfFonts: INT = 12;
NullBox: Imager.Box = [0.0, 0.0, 0.0, 0.0];
NullRect: Imager.Rectangle = [0.0, 0.0, 0.0, 0.0];
NullVec: Imager.VEC = [0.0, 0.0];
UnitLineWidth: REAL = 1.0;
NtNan: REAL = Real.NonTrappingNaN;
types
Viewer: TYPE = ViewerClasses.Viewer;
ROPE: TYPE = Rope.ROPE;
ColorIndex: TYPE = INT[0..NumberOfColors);
EntityColor: TYPE = ColorIndex[1..LastEntityColor];
FontIndex: TYPE = INT[0..NumberOfFonts);
GraphColors: TYPE = REF GraphColorsArray;
GraphColorsArray: TYPE = ARRAY ColorIndex OF ImagerColor.RGB;
GraphFonts: TYPE = REF GraphFontsArray;
GraphFontsArray: TYPE = ARRAY FontIndex OF GraphFont;
GraphFont: TYPE = RECORD[
family: ROPENIL,
bold, italic: BOOLFALSE,
vFontSize: INT ← 12,
pFontScale: REAL ← 13.0
];
texts
Texts: TYPE = LIST OF Text;
Text: TYPE = REF TextRec;
TextRec: TYPE = RECORD[
text: ROPENIL,
place: Imager.VEC ← [0.0, 0.0], -- location relative to origion and size of curvebox
fontIndex: FontIndex ← 0,
colorIndex: ColorIndex ← 0,
rotation: REAL ← 0.0, -- angle of rotation, ccw, in degrees.
justifX: JustifX ← left,
justifY: JustifY ← bottom,
id: INT ← 0 -- must be unique among all texts.
];
JustifX: TYPE = {left, center, right};
JustifY: TYPE = {top, center, bottom};
curves
EntityList: TYPE = LIST OF Entity;
CurveList: TYPE = EntityList;
Entity: TYPE = REF EntityRec;
Curve: TYPE = Entity;
EntityRec: TYPE = RECORD[
name, comment: ROPENIL,
colorIndex: ColorIndex ← 0,
mark: Mark ← none,
width: REAL ← UnitLineWidth,
oldValues: ValueList ← NIL,
group: EntityGroup ← NIL,
parent: NestedEntities ← NIL,
id: INT ← 0, -- unique among entities.
segments: SegmentDataList ← NIL, -- nil iff entity not plotted.
lastValue: ValueList ← NIL,
lastSegment: SegmentDataList ← NIL
];
ValueList: TYPE = LIST OF REAL;
Mark: TYPE = {none, round, square, diamond, cross, dollar, percent}; -- Ë¡. $%
SegmentDataList: TYPE = LIST OF SegmentData;
SegmentData: TYPE = REF SegmentDataRec;
SegmentDataRec: TYPE = RECORD [ok: BOOLFALSE, end, nx, ny, d0: REAL ← 0.0];
If not ok then the following is meaning less.
where nx and ny are the components of the unit normal vector, i.e., (sinq, -cosq);
d0 is the distance of the line (not the segment) to the origin;
end is the value at the right end point of the segment;
all in terms of real coordinates.
EntityGroup: TYPE = REF EntityGroupRec;
EntityGroupRec: TYPE = RECORD [
x: Entity ← NIL, -- x is not in ys or children.
ys: NestedEntities ← NIL,
id, length: INT ← 0
id must be unique among entity groups, of no use for now;
length is the number of values on each entity in the group.
];
NestedEntitiesList: TYPE = LIST OF NestedEntities;
NestedEntities: TYPE = REF NestedEntitiesRec;
NestedEntitiesRec: TYPE = RECORD[
name, comment: ROPENIL,
entityList: EntityList ← NIL,
parent: NestedEntities ← NIL,
children: NestedEntitiesList ← NIL,
node: TiogaOps.Ref ← NIL -- ** readonly for client.
];
graph
GRAPH: TYPE = REF GraphRec;
GraphRec: TYPE = RECORD [
entityList: EntityList ← NIL,
texts: Texts ← NIL,
bounds: Imager.Box ← NullBox, -- [xmin, ymin, xmax, ymax]
fileName: ROPENIL, -- suggested file name to save the graph.
auto: ARRAY AutoType OF BOOLALL[TRUE], -- true: on.
division: ARRAY XY OF INTALL[5],
caret: ARRAY CaretIndex OF CaretSpec ← ALL[NIL],
showSlope: BOOLFALSE,
target: ARRAY XY OF TargetSpec ← ALL[NIL],
grids: ARRAY XY OF BOOLALL[FALSE], -- true: on.
color: GraphColors ← NIL,
font: GraphFonts ← NIL
];
CaretIndex: TYPE = {primary, secondary, text};
CaretSpec: TYPE = REF CaretSpecRec;
CaretSpecRec: TYPE = RECORD[
place: Imager.VEC ← NullVec,
on: BOOLFALSE
];
CrosshairState: TYPE = RECORD[size: CrossHairSize ← nil, place: Imager.VEC ← [0.0, 0.0]];
CrosshairSize: TYPE = {nil, small, big};
XY: TYPE = {x, y};
TargetSpec: TYPE = REF TargetSpecRec;
TargetSpecRec: TYPE = RECORD[
value: REAL ← 0.0,
width: REAL ← UnitLineWidth,
colorIndex: ColorIndex ← 13,
on: BOOLFALSE
];
AutoType: TYPE = {divisions, bounds};
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,
userEditAllowed: BOOLTRUE,
mergingBounds: BOOLFALSE,
boundsToMerge: Imager.Box ← NullBox,
lastTextId, lastEntityId: INT ← -1,
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 ← gray, -- 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).
normalLegend: BOOLTRUE,
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,
spec, xys: Containers.Container ← NIL,
rule, table: Viewer ← NIL,
specVisible, xysVisible, tableVisible: BOOLFALSE,
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, textRotation,
entityId, entityName, entityCmt, entityColor, entityWidth, entityMark, --entityGroupId, --entityValues,
groupId, groupName, xId, yIds,
xyLabel, idOfy, xsecLabel, xat, values,
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 ← y,
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 = {y, plottedYs, allX};
Angle: TYPE = {degrees, radians};
curve hash table
EntityHashSize: INT = 128;
HashIndex: TYPE = INT[0..EntityHashSize);
EntityHash: TYPE = REF EntityHashArray;
EntityHashArray: TYPE = ARRAY HashIndex 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
];
PaintInfo: TYPE = REF PaintInfoRec;
PaintInfoRec: TYPE = RECORD[
action: PaintAction ← paint,
output: OutputType ← screen,
data: SELECT item: PaintItem FROM
all => [clear, updateDivBds: BOOLTRUE], -- clear: to clear screen or not
allCurves => [clear: BOOLTRUE],
rectangle => [
clear, updateDivBds: BOOLTRUE,
rect: Imager.Rectangle ← NullRect],
graphText => [text: Text ← NIL],
graphEntity => [entity: Entity ← NIL],
legend => [entity: Entity ← NIL, onlyOne: BOOLTRUE],
tails => [
x1, x2: REAL ← 0.0,
v1, v2: ValueList ← NIL,
entities: EntityList ← NIL],
target => [xy: XY ← x],
grid => [xy: XY ← x, long: BOOLTRUE],
ENDCASE
];
PaintAction: TYPE = {erase, paint};
OutputType: TYPE = {interpress, screen};
PaintItem: TYPE = {all, allCurves, rectangle, graphText, graphEntity, legend, tails, target, grid};
GraphProc: TYPE = PROC [handle: GraphHandle];
signal
Error: SIGNAL[atom: ATOM, info: ROPENIL];
}.
CHANGE LOG.
SChen, created at October 9, 1985 5:50:27 pm PDT.