CDArraysImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, August 25, 1986 5:16:02 pm PDT
Last edited by: Christian Jacobi, August 27, 1986 7:51:23 pm PDT
A package which helps to draw arrays of arbitrary angled lines with ChipNDale
DIRECTORY
CDCells, CDGenerate, CDCurves, CD, CDDirectory, CDLayers, CDValue, CDPanel, CDRects, CDSequencer, CDCommandOpsExtras2, TerminalIO, CDPanelExtras;
CDArraysImpl: CEDAR PROGRAM
IMPORTS CDCells, CDGenerate, CDCurves, CDDirectory, CDLayers, CDValue, CDPanel, CDRects, CDCommandOpsExtras2, TerminalIO, CDPanelExtras =
BEGIN
Diags: CDGenerate.GeneratorProc = {
n, cnt: INT𡤀
p1, p2, d1, d2: CD.Position;
layer: CD.Layer ← CDLayers.CurrentLayer[design];
w: CD.Number ← CDLayers.LayerWidth[design, layer];
line: CD.Object; off: CD.Position;
CDPanel.RedisplayLabels[design];
n ← CDValue.FetchInt[design, $cdMLAn];
p1 ← [0, 0];
p2 ← [CDValue.FetchInt[design, $cdMLAsx], CDValue.FetchInt[design, $cdMLAsy]];
d1 ← [CDValue.FetchInt[design, $cdMLAdx0], CDValue.FetchInt[design, $cdMLAdy0]];
d2 ← [CDValue.FetchInt[design, $cdMLAdx1], CDValue.FetchInt[design, $cdMLAdy1]];
ob ← CDCells.CreateEmptyCell[];
FOR i: INT IN [0..n) DO
start: CD.Position ← [x: p1.x+i*d1.x+w/2, y: p1.y+i*d1.y+w/2];
stop: CD.Position ← [x: p2.x+i*d2.x+w/2, y: p2.y+i*d2.y+w/2];
IF start.x=stop.x OR start.y=stop.y THEN {
sz: CD.Position ← [ABS[stop.x-start.x]+w, ABS[stop.y-start.y]+w];
line ← CDRects.CreateRect[sz, layer];
off ← [MIN[start.x, stop.x]-w/2, MIN[start.y, stop.y]-w/2];
}
ELSE {
[line, off] ← CDCurves.CreateLine[points: LIST[start, stop], w: w, layer: layer];
};
IF line#NIL THEN {
cnt ← cnt+1;
[] ← CDCells.IncludeOb[cell: ob, ob: line, position: off, obCSystem: interrestCoords];
}
ENDLOOP;
IF cnt>0 THEN [] ← CDDirectory.Include[design: design, object: ob, alternateName: "x"]
ELSE ob ← NIL;
};
Redisplay: PROC [design: CD.Design] = {
CDPanelExtras.ReDisplay[design, $cdMLAsx];
CDPanelExtras.ReDisplay[design, $cdMLAsy];
CDPanelExtras.ReDisplay[design, $cdMLAdx0];
CDPanelExtras.ReDisplay[design, $cdMLAdy0];
CDPanelExtras.ReDisplay[design, $cdMLAdx1];
CDPanelExtras.ReDisplay[design, $cdMLAdy1];
};
DefineV0: PROC [comm: CDSequencer.Command] = {
TerminalIO.WriteRope["redefine D1 for multi lines array command\n"];
CDValue.StoreInt[comm.design, $cdMLAdx0, comm.pos.x-comm.sPos.x];
CDValue.StoreInt[comm.design, $cdMLAdy0, comm.pos.y-comm.sPos.y];
Redisplay[comm.design];
};
DefineV1: PROC [comm: CDSequencer.Command] = {
TerminalIO.WriteRope["redefine D2 for multi lines array command\n"];
CDValue.StoreInt[comm.design, $cdMLAdx1, comm.pos.x-comm.sPos.x];
CDValue.StoreInt[comm.design, $cdMLAdy1, comm.pos.y-comm.sPos.y];
Redisplay[comm.design];
};
Gen: PROC [comm: CDSequencer.Command] = {
ob: CD.Object;
p: CD.Position ← [MIN[comm.sPos.x, comm.pos.x], MIN[comm.sPos.y, comm.pos.y]];
Redisplay[comm.design];
ob ← CDGenerate.FetchNCall[table, comm.design, "MLA", FALSE];
IF ob=NIL THEN {
IF CDValue.FetchInt[comm.design, $cdMLAn]<1 THEN TerminalIO.WriteRope["bad repetition number; "];
TerminalIO.WriteRope["failed\n"]
}
ELSE [] ← CDCells.IncludeOb[design: comm.design, ob: ob, position: comm.sPos];
};
Draw: PROC [comm: CDSequencer.Command] = {
TerminalIO.WriteRope["draw multi lines array with vector\n"];
CDValue.StoreInt[comm.design, $cdMLAsx, comm.pos.x-comm.sPos.x];
CDValue.StoreInt[comm.design, $cdMLAsy, comm.pos.y-comm.sPos.y];
Redisplay[comm.design];
Gen[comm];
};
ReDraw: PROC [comm: CDSequencer.Command] = {
TerminalIO.WriteRope["re-draw multi lines from panel\n"];
Gen[comm];
};
table: CDGenerate.Table ← CDGenerate.AssertTable["USER"];
[] ← CDGenerate.Register[table, "MLA", Diags, FALSE];
CDPanel.DefineIntEntry[NIL, $cdMLAn, "array num:", 0, 2000, 0, 1];
CDPanel.DefineIntEntry[NIL, $cdMLAsx, "s[1].x:",,, 0, 0];
CDPanel.DefineIntEntry[NIL, $cdMLAsy, "s[1].y:",,, 0, 0];
CDPanel.DefineNewLine[];
CDPanel.DefineIntEntry[NIL, $cdMLAdx0, " Dxa:",,, 0, 0];
CDPanel.DefineIntEntry[NIL, $cdMLAdy0, "Dya:",,, 0, 0];
CDPanel.DefineIntEntry[NIL, $cdMLAdx1, "Dxb:",,, 0, 0];
CDPanel.DefineIntEntry[NIL, $cdMLAdy1, "Dyb:",,, 0, 0];
CDPanel.DefineNewLine[];
CDCommandOpsExtras2.RegisterWithMenu[menu: $RectProgramMenu, entry: "draw array with first line", key: $cdMLADraw, proc: Draw, doc: "array of arbitrary angled lines (size increased by 1 default width)"];
CDCommandOpsExtras2.RegisterWithMenu[menu: $RectProgramMenu, entry: "draw array from panel", key: $cdMLAReDraw, proc: ReDraw, doc: "array of arbitrary angled lines (size increased by 1 default width)"];
CDCommandOpsExtras2.RegisterWithMenu[menu: $RectProgramMenu, entry: " define Da for draw array", key: $cdMLAp0, proc: DefineV0, doc: "setup increment for first point of arrayed line"];
CDCommandOpsExtras2.RegisterWithMenu[menu: $RectProgramMenu, entry: " define Db for draw array", key: $cdMLAp1, proc: DefineV1, doc: "setup increment for second point of arrayed line"];
END.