CDExtraCommands.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, July 11, 1983 3:42 pm
last edited Christian Jacobi, March 29, 1986 6:11:17 pm PST
Last Edited by: Jacobi July 25, 1986 12:17:41 pm PDT
Last Edited by: Christian Jacobi, September 4, 1986 3:54:09 pm PDT
DIRECTORY
Atom,
CD,
CDBasics,
CDCallSpecific,
CDCommandOps,
CDCommandOpsExtras3,
CDInstances,
CDLayers,
CDIO,
CDOps,
CDPanel,
CDProperties,
CDRects,
CDSequencer,
CDSimpleOps,
CDValue,
CDViewer,
CDVArrow,
CDVPrivate,
CDVScale,
IO,
ProcessProps,
Rope,
TiogaMenuOps,
TerminalIO,
ViewerClasses USING [Viewer],
ViewerOps;
CDExtraCommands: CEDAR PROGRAM
IMPORTS Atom, CD, CDBasics, CDCallSpecific, CDCommandOps, CDCommandOpsExtras3, CDInstances, CDIO, CDLayers, CDOps, CDPanel, CDProperties, CDRects, CDSequencer, CDSimpleOps, CDValue, CDVArrow, CDViewer, CDVScale, IO, ProcessProps, TiogaMenuOps, TerminalIO, ViewerOps =
BEGIN
WithWDir: PROC [wDir: Rope.ROPE, proc: PROC] = {
ProcessProps.AddPropList[
propList: Atom.PutPropOnList[NIL, $WorkingDirectory, wDir],
inner: proc
];
};
HelpComm: PROC [comm: CDSequencer.Command] =
BEGIN
Do: PROC [] = {
v: ViewerClasses.Viewer ← TiogaMenuOps.Open["CDCrib.tioga"];
IF v#NIL THEN ViewerOps.OpenIcon[v];
};
WithWDir[CDIO.GetWorkingDirectory[NIL], Do];
TerminalIO.WriteRope["for more documentation, open also\n ChipNDaleIntroduction.tioga\n ChipNDaleDoc.tioga\n ChipNDaleToolsDoc.tioga\n"];
END;
verbosity: INT ← 1;
CoordinatesCommand: PROC [comm: CDSequencer.Command] =
BEGIN
WriteInLambda: PROC [n: CD.Number] = {
TerminalIO.WriteRope[CDCommandOps.LambdaRope[n, lambda]]
};
lambda: INT ← comm.design.technology.lambda;
TerminalIO.WriteRope["coordinates [\024]"]; -- \024 prints as greek lambda
TerminalIO.WriteRope[" down: ("];
WriteInLambda[comm.sPos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.sPos.y];
TerminalIO.WriteRope[") up: ("];
WriteInLambda[comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y];
TerminalIO.WriteRope[") dist: ("];
WriteInLambda[comm.pos.x-comm.sPos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y-comm.sPos.y];
TerminalIO.WriteRope[")\n"];
END;
SetArrow: PROC [comm: CDSequencer.Command] =
BEGIN
WriteInLambda: PROC [n: CD.Number] = {
TerminalIO.WriteRope[CDCommandOps.LambdaRope[n, lambda]]
};
lambda: INT ← comm.design.technology.lambda;
TerminalIO.WriteRope["set arrow at ("];
WriteInLambda[comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y];
TerminalIO.WriteRope[")\024\n"];
CDVArrow.ShowArrow[comm.design, comm.pos];
END;
RemoveArrow: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["remove arrow\n"];
CDVArrow.RemoveArrow[comm.design];
END;
ArrowInformation: PROC [comm: CDSequencer.Command] =
BEGIN
WriteInLambda: PROC [n: CD.Number] = {
TerminalIO.WriteRope[CDCommandOps.LambdaRope[n, lambda]]
};
lambda: INT ← comm.design.technology.lambda;
WITH CDValue.Fetch[comm.design, $arrow, design] SELECT FROM
class: REF CD.Position => {
TerminalIO.WriteRope[" arrow at: ("];
WriteInLambda[class.x];
TerminalIO.WriteRope[","];
WriteInLambda[class.y];
TerminalIO.WriteRope[") up: ("];
WriteInLambda[comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y];
TerminalIO.WriteRope[") dist: ("];
WriteInLambda[class.x-comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[class.y-comm.pos.y];
TerminalIO.WriteRope[")\n"];
}
ENDCASE => NULL;
END;
StatisticCommand: PROC [comm: CDSequencer.Command] =
BEGIN
WriteInLambda: PROC [n: CD.Number] = {
TerminalIO.WriteRope[CDCommandOps.LambdaRope[n, lambda]]
};
lambda: INT ← comm.design.technology.lambda;
countTot: INT ← 0;
countSel: INT ← 0;
countInvis: INT ← 0;
isDesign: BOOL FALSE;
rect: CD.Rect ← CDBasics.universe;
v: ViewerClasses.Viewer ← CDViewer.GetViewer[comm];
inst: CD.Instance;
TerminalIO.WriteRope["statistic "];
IF v#NIL THEN rect ← CDViewer.VisibleRect[v];
IF ~CDBasics.NonEmpty[rect] THEN rect ← CDBasics.universe;
FOR l: CD.InstanceList ← CDOps.InstList[comm.design], l.rest WHILE l#NIL DO
countTot ← countTot+1;
IF l.first.selected THEN {
IF ~CDBasics.Intersect[rect, CDInstances.InstRectI[l.first]] THEN countInvis ← countInvis+1;
countSel ← countSel+1;
inst ← l.first
}
ENDLOOP;
TerminalIO.WriteF["%g objects; %g selected\n", IO.int[countTot], IO.int[countSel]];
IF countSel=1 THEN {
TerminalIO.WriteRope[CDCommandOps.InstRope[inst, verbosity]];
IF verbosity>0 THEN {
ir: CD.Position ← CD.InterestSize[inst.ob];
TerminalIO.WriteRope[" at: ("];
WriteInLambda[inst.location.x];
TerminalIO.WriteRope[","];
WriteInLambda[inst.location.y];
TerminalIO.WriteRope[")\024 i-size: ("]; --\024 prints as greek lambda
WriteInLambda[ir.x];
TerminalIO.WriteRope[","];
WriteInLambda[ir.y];
TerminalIO.WriteRope[")\024 orientation-code:"]; --\024 prints as greek lambda
TerminalIO.WriteInt[inst.orientation];
};
TerminalIO.WriteLn[];
};
ArrowInformation[comm];
IF countInvis#0 THEN
TerminalIO.WriteF1[" **** %g invisible selected object(s)\n", IO.int[countInvis]];
END;
SelectIfLayer: CDCallSpecific.CallProc =
BEGIN
IF inst.ob.layer#NARROW[x, REF CD.Layer]^ THEN {done←FALSE; RETURN};
IF inst.selected THEN RETURN;
inst.selected ← TRUE;
repaintMe ← TRUE
END;
AddSelectLayer: PROC [comm: CDSequencer.Command] =
BEGIN
reflev: REF CD.Layer ← NEW[CD.Layer ← CDLayers.CurrentLayer[comm.design]];
n: INT ← CDCallSpecific.CallForAll[design: comm.design, whatElse: SelectIfLayer, x: reflev];
TerminalIO.WriteF["select all %g objects: (%g)\n", IO.rope[CDOps.LayerName[reflev^]], IO.int[n]];
END;
SetLayerCommand: PROC [comm: CDSequencer.Command] =
BEGIN
inst: CD.Instance = CDCommandOps.TheInstance[comm, "set default layer"];
IF inst#NIL THEN {
layer: CD.Layer = inst.ob.layer;
IF inst.ob.class.wireTyped AND CDProperties.GetLayerProp[layer, $DontUse]=NIL THEN {
TerminalIO.WriteRopes[" ", CDOps.LayerName[layer], "\n"];
CDLayers.SetCurrentLayer[comm.design, layer];
}
ELSE TerminalIO.WriteRope[" NOT DONE\n"];
CDOps.ReOrderInstance[comm.design, inst]
}
END;
GridComm: PROC [comm: CDSequencer.Command] =
BEGIN
GetScaleRec: PROC [comm: CDSequencer.Command] RETURNS [CDVScale.ScaleRec] =
BEGIN
v: ViewerClasses.Viewer ← CDViewer.GetViewer[comm];
IF v#NIL THEN
WITH v.data SELECT FROM
my: CDVPrivate.VRef => RETURN [my.scale]
ENDCASE => NULL;
TerminalIO.WriteRope["no viewer\n"]; ERROR ABORTED
END;
scale: CDVScale.ScaleRec;
TerminalIO.WriteRope["move to grid positions\n"];
scale ← GetScaleRec[comm];
FOR l: CD.InstanceList ← CDOps.InstList[comm.design], l.rest WHILE l#NIL DO
IF l.first.selected THEN {
pos: CD.Position ← CDBasics.BaseOfRect[CDInstances.InstRectI[l.first]];
vPos: CD.Position ← CDVScale.DesignToViewerPosition[scale, pos];
gridded: CD.Position ← CDVScale.ViewerToDesignPosition[scale, vPos];
CDOps.RedrawInstance[comm.design, l.first];
l.first.location ← CDBasics.AddPoints[l.first.location, CDBasics.SubPoints[gridded, pos]];
CDOps.RedrawInstance[comm.design, l.first, FALSE];
};
ENDLOOP;
END;
IncreaseByWidthComm: PROC [comm: CDSequencer.Command] =
BEGIN
cnt: INT ← 0;
TerminalIO.WriteRope["increase wire length by width: "];
FOR l: CD.InstanceList ← CDOps.InstList[comm.design], l.rest WHILE l#NIL DO
IF l.first.selected AND l.first.ob.class.wireTyped AND ~l.first.ob.class.symbolic THEN {
oldSize: CD.Position ← l.first.ob.size;
newSize: CD.Position ← [x: oldSize.x, y: oldSize.x+oldSize.y];
newOb: CD.Object ← CDRects.CreateRect[newSize, l.first.ob.layer];
IF newOb#NIL THEN {l.first.ob ← newOb; cnt ← cnt+1};
CDOps.RedrawInstance[comm.design, l.first, TRUE];
};
ENDLOOP;
TerminalIO.WriteF1[" %g objects\n", IO.int[cnt]];
END;
ShowErrorComm: PROCEDURE [comm: CDSequencer.Command] =
BEGIN
applList: CD.InstanceList = CDOps.InstList[comm.design];
foundSome: BOOLFALSE;
TerminalIO.WriteRope[ "show error "];
FOR a: CD.InstanceList ← applList, a.rest WHILE a#NIL DO
IF a.first.ob.layer=CD.errorLayer THEN {
inst: CD.Instance = a.first;
foundSome ← TRUE;
IF ~inst.selected THEN {
eRect: CD.Rect = CDInstances.InstRectI[inst];
inst.selected ← TRUE;
CDOps.DelayedRedraw[comm.design, eRect, FALSE];
TerminalIO.WriteRopes[CDCommandOps.InstRope[inst], "\n"];
FOR vl: CDViewer.ViewerList ← CDViewer.ViewersOf[comm], vl.rest WHILE vl#NIL DO
CDViewer.ShowAndScale[viewer: vl.first, rect: CDBasics.Extend[eRect, 30*comm.design.technology.lambda] ];
ENDLOOP;
CDOps.ReOrderInstance[comm.design, inst];
EXIT
}
};
REPEAT FINISHED =>
IF foundSome THEN TerminalIO.WriteRope["all errors in this cell are already selected\n"]
ELSE TerminalIO.WriteRope[ "no errors in this cell\n"]
ENDLOOP;
END;
SelectAllErrorsComm: PROC [comm: CDSequencer.Command] =
BEGIN
cnt: INT ← 0;
CDSimpleOps.DeselectAll[comm.design];
FOR l: CD.InstanceList ← CDOps.InstList[comm.design], l.rest WHILE l#NIL DO
IF l.first.ob.layer=CD.errorLayer THEN {
cnt ← cnt+1;
l.first.selected ← TRUE;
CDOps.RedrawInstance[comm.design, l.first, FALSE]
}
ENDLOOP;
TerminalIO.WriteF["%g error(s) selected\n", IO.int[cnt]];
END;
lambda: CD.Number = 1;
CDSequencer.ImplementCommand[$SetLayerP, SetLayerCommand,, doQueue];
CDSequencer.ImplementCommand[$AddSelectLayer, AddSelectLayer,, doQueue];
CDSequencer.ImplementCommand[$Coordinates, CoordinatesCommand,, doQueue];
CDSequencer.ImplementCommand[$Statistic, StatisticCommand,, doQueue];
CDSequencer.ImplementCommand[$SetArrow, SetArrow,, doQueue];
CDSequencer.ImplementCommand[$RemoveArrow, RemoveArrow,, doQueue];
CDSequencer.ImplementCommand[$MoveToGrid, GridComm];
CDSequencer.ImplementCommand[$IncreaseByWidth, IncreaseByWidthComm];
CDSequencer.ImplementCommand[$Help, HelpComm,, dontQueue];
CDCommandOps.ImplementSpecificCommand[specificAtom: $ChangeLayer, tipBase: "ChangeLayer", useFor: "SFXA"];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Widen", useFor: "SFXA", x: NEW[CD.Position←[lambda, 0]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Narrow", useFor: "SFXA", x: NEW[CD.Position←[-lambda, 0]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Shorten", useFor: "SFXA", x: NEW[CD.Position←[0, -lambda]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Lengthen", useFor: "SFXA", x: NEW[CD.Position←[0, lambda]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Default, useFor: "SFXA"];
CDCommandOps.ImplementSpecificCommand[specificAtom: $IncCount, text: "Inc count", useFor: "SFXA"];
CDCommandOps.ImplementSpecificCommand[specificAtom: $DecCount, text: "Dec count", useFor: "SFXA"];
CDCommandOpsExtras3.RegisterCurrentLayerCommand[key: $LayerComment, layer: CD.commentLayer];
CDCommandOpsExtras3.RegisterCurrentLayerCommand[key: $LayerGreen, layer: CD.FetchLayer[NIL, $green]];
CDCommandOpsExtras3.RegisterCurrentLayerCommand[key: $LayerYellow, layer: CD.FetchLayer[NIL, $yellow]];
CDCommandOpsExtras3.RegisterCurrentLayerCommand[key: $LayerRed, layer: CD.FetchLayer[NIL, $red]];
CDCommandOpsExtras3.RegisterCurrentLayerCommand[key: $LayerBlue, layer: CD.FetchLayer[NIL, $blue]];
CDSequencer.ImplementCommand[$ShowErrors, ShowErrorComm,, doQueue];
CDSequencer.ImplementCommand[$SelectAllErrors, SelectAllErrorsComm,, doQueue];
CDPanel.DefineButton[name: " menu", command: $GlobalMenu, topLine: TRUE];
CDPanel.DefineButton[name: " help", command: $Help, topLine: TRUE];
END.