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, October 20, 1986 1:01:13 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, CDCommandOps, TerminalIO;
CDArraysImpl: CEDAR PROGRAM
IMPORTS CDCells, CDGenerate, CDCurves, CDDirectory, CDLayers, CDValue, CDPanel, CDRects, CDCommandOps, TerminalIO =
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.Redisplay[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, trans: [off, original]];
}
ENDLOOP;
IF cnt>0 THEN [] ← CDDirectory.Include[design: design, object: ob, alternateName: "x"]
ELSE ob ← NIL;
};
Redisplay: PROC [design: CD.Design] = {
[] ← CDPanel.ToDisplay[design, $cdMLAsx];
[] ← CDPanel.ToDisplay[design, $cdMLAsy];
[] ← CDPanel.ToDisplay[design, $cdMLAdx0];
[] ← CDPanel.ToDisplay[design, $cdMLAdy0];
[] ← CDPanel.ToDisplay[design, $cdMLAdx1];
[] ← CDPanel.ToDisplay[design, $cdMLAdy1];
};
DefineV0: PROC [comm: CDSequencer.Command] = {
TerminalIO.PutRope["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.PutRope["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[context, comm.design, "MLA", FALSE];
IF ob=NIL THEN {
IF CDValue.FetchInt[comm.design, $cdMLAn]<1 THEN TerminalIO.PutRope["bad repetition number; "];
TerminalIO.PutRope["failed\n"]
}
ELSE [] ← CDCells.IncludeOb[design: comm.design, ob: ob, trans: [comm.sPos, original]];
};
Draw: PROC [comm: CDSequencer.Command] = {
TerminalIO.PutRope["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.PutRope["re-draw multi lines from panel\n"];
Gen[comm];
};
context: CDGenerate.Context ← CDGenerate.AssertContext["USER"];
[] ← CDGenerate.Register[context, "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[];
CDCommandOps.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)"];
CDCommandOps.RegisterWithMenu[menu: $RectProgramMenu, entry: "draw array from panel", key: $cdMLAReDraw, proc: ReDraw, doc: "array of arbitrary angled lines (size increased by 1 default width)"];
CDCommandOps.RegisterWithMenu[menu: $RectProgramMenu, entry: " define Da for draw array", key: $cdMLAp0, proc: DefineV0, doc: "setup increment for first point of arrayed line"];
CDCommandOps.RegisterWithMenu[menu: $RectProgramMenu, entry: " define Db for draw array", key: $cdMLAp1, proc: DefineV1, doc: "setup increment for second point of arrayed line"];
END.