CDBasicCommands.mesa (part of Chipndale)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi June 29, 1983 4:44 pm
last edited Christian Jacobi July 28, 1984 6:58:48 pm PDT
DIRECTORY
CD,
CDCommands,
CDOps,
CDOrient,
CDRects,
CDSequencer,
TerminalIO,
CDInline;
CDBasicCommands: CEDAR PROGRAM
IMPORTS CDCommands, CDOps, CDSequencer, TerminalIO, CDRects, CDInline =
BEGIN
AddARect: PROC[design: CD.Design, r: CD.DesignRect, l: CD.Level] =
BEGIN
ob: CD.ObPtr;
sz: CD.DesignPosition ← CDInline.SizeOfRect[r];
orient: CD.Orientation ← CDOrient.original;
IF sz.y<sz.x THEN {
w: CD.DesignNumber ← sz.x;
sz.x ← sz.y;
sz.y ← w;
orient ← CDOrient.rotate90
};
IF sz.x<=0 THEN {TerminalIO.WriteRope["Empty object not included\n"]; RETURN};
ob ← CDRects.CreateRect[sz, l];
CDOps.AddAnObject[
design: design,
ob: ob,
location: CDInline.BaseOfRect[r],
orientation: orient]
END;
AddRect: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Add rect\n"];
AddARect[comm.design, CDInline.ToRect[comm.sPos, comm.pos], comm.l];
END;
AddWire: PROC [comm: CDSequencer.Command] =
--uses pos, sPos, n (for width), b (for firstHorizontal), l (for level)
BEGIN
InternalAddWire[comm: comm, firstOnly: FALSE]
END;
ContinueWire: PROC [comm: CDSequencer.Command] =
BEGIN
InternalAddWire[comm: comm, firstOnly: TRUE]
END;
InternalAddWire: PROC [comm: CDSequencer.Command, firstOnly: BOOLFALSE] =
--this procedure knows EXACTLY the algorithm used for showing
--temporary wires in the cursor part
BEGIN
start: CD.DesignPosition ← comm.sPos;
stop: CD.DesignPosition ← comm.pos;
wireWidth: CD.DesignNumber ← comm.n;
IF wireWidth=0 THEN {AddRect[comm]; RETURN};
TerminalIO.WriteRope["Add wire\n"];
IF --firstHorizontal-- comm.b THEN {
IF stop.x<=start.x AND stop.x>=start.x-wireWidth
AND (stop.y<start.y OR stop.y>start.y+wireWidth) THEN { --crazy vertical wire
IF ABS[start.y-stop.y]<CD.lambda THEN
{TerminalIO.WriteRope[" Empty Wire not added\n"]; RETURN};
stop.x ← start.x+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l];
RETURN
};
--not only crazy vertical
IF stop.y>=start.y AND stop.y<=start.y+wireWidth THEN { --horizontal wire
stop.y ← start.y+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l]
}
ELSE { --L shaped (firsthorizontal)
IF start.x<=stop.x THEN {stop.x ← stop.x+wireWidth}
ELSE {t: CD.Number=stop.x; stop.x ← start.x; start.x ← t};
stop.y ← start.y+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l];
IF firstOnly THEN RETURN;
start.x ← comm.pos.x; stop.y ← comm.pos.y; stop.x ← start.x+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l];
}
}
ELSE { -- NOT firstHorizontalVC --
IF stop.y<=start.y AND stop.y>=start.y-wireWidth
AND (stop.x<start.x OR stop.x>start.x+wireWidth) THEN { --crazy horizontal wire
IF ABS[stop.x-start.x]<CD.lambda THEN
{TerminalIO.WriteRope[" Empty Wire not added\n"]; RETURN};
stop.y ← start.y+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l];
RETURN
};
-- not only crazy horizontal
IF stop.x>=start.x AND stop.x<=start.x+wireWidth THEN { --vertical wire
stop.x ← start.x+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l]
}
ELSE { --L shaped (firstVertical)
IF start.y<=stop.y THEN {stop.y ← stop.y+wireWidth}
ELSE {t: CD.Number = stop.y; stop.y ← start.y; start.y ← t};
stop.x ← start.x+wireWidth;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l];
IF firstOnly THEN RETURN;
start.y ← comm.pos.y; stop.y ← start.y+wireWidth; stop.x ← comm.pos.x;
AddARect[comm.design, CDInline.ToRect[start, stop], comm.l];
}
}
END;
DeleteSelected: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Delete selected\n"];
CDCommands.DeleteSelected[comm.design]
END;
DeletePointed: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Delete pointed\n"];
CDCommands.DeletePointed[comm.design, comm.pos]
END;
Undelete: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Undelete\n"];
CDCommands.Undelete[comm.design]
END;
AbortCommand: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Try to abort current command\n"];
CDSequencer.AbortTheCommand[comm.design]
END;
CDSequencer.ImplementCommand[$AbortCommand, AbortCommand,, dontQueue];
CDSequencer.ImplementCommand[$DrawRect, AddRect];
CDSequencer.ImplementCommand[$DrawWire, AddWire];
CDSequencer.ImplementCommand[$ContinueWire, ContinueWire];
CDSequencer.ImplementCommand[$DeleteS, DeleteSelected];
CDSequencer.ImplementCommand[$DeleteP, DeletePointed];
CDSequencer.ImplementCommand[$Undel, Undelete];
END.