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
DIRECTORY
CD,
CDBasics,
CDCallSpecific,
CDCommandOps,
CDInstances,
CDLayers,
CDMenus,
CDOps,
CDProperties,
CDRects,
CDSequencer,
CDSimpleOps,
CDValue,
CDViewer,
CDVArrow,
CDVPrivate,
CDVScale,
IO,
Rope,
TerminalIO,
ViewerClasses USING [Viewer];
CDExtraCommands: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDCallSpecific, CDCommandOps, CDInstances, CDLayers, CDMenus, CDOps, CDProperties, CDRects, CDSequencer, CDSimpleOps, CDValue, CDVArrow, CDViewer, CDVScale, IO, Rope, TerminalIO =
BEGIN
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.WriteRope[Rope.Cat[" ", CDOps.LayerName[layer], "\n"]];
CDLayers.SetCurrentLayer[comm.design, layer];
}
ELSE TerminalIO.WriteRope[" NOT DONE\n"];
CDOps.ReOrderInstance[comm.design, inst]
}
END;
GetScaleRec: PROC [x: REF] RETURNS [CDVScale.ScaleRec] =
BEGIN
WITH x SELECT FROM
my: CDVPrivate.VRef => RETURN [my.scale]
ENDCASE => ERROR
END;
GridComm: PROC [comm: CDSequencer.Command] =
BEGIN
GetScaleRec: PROC [x: REF] RETURNS [CDVScale.ScaleRec] =
BEGIN
WITH x SELECT FROM
my: CDVPrivate.VRef => RETURN [my.scale]
ENDCASE => {
TerminalIO.WriteRope["no viewer\n"];
ERROR ABORTED
}
END;
scale: CDVScale.ScaleRec;
TerminalIO.WriteRope["move to grid positions\n"];
scale ← GetScaleRec[comm.ref];
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,, doQueue];
CDSequencer.ImplementCommand[$IncreaseByWidth, IncreaseByWidthComm];
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"];
CDSequencer.ImplementCommand[$ShowErrors, ShowErrorComm,, doQueue];
CDSequencer.ImplementCommand[$SelectAllErrors, SelectAllErrorsComm,, doQueue];
CDMenus.CreateEntry[$SpecialMenu, "un-delete", $Undel];
CDMenus.CreateEntry[$SpecialMenu, "abort command", $AbortCommand];
CDMenus.CreateEntry[$SpecialMenu, "select all", $SelectAll];
CDMenus.CreateEntry[$SpecialMenu, "de-select", $DeSelectS];
CDMenus.CreateEntry[$SpecialMenu, "statistic", $Statistic];
CDMenus.CreateEntry[$SpecialMenu, "move to grid", $MoveToGrid];
CDMenus.CreateEntry[$SpecialMenu, "lengthen by w", $IncreaseByWidth];
CDMenus.CreateEntry[$SpecialMenu, "select next error", $ShowErrors];
CDMenus.CreateEntry[$SpecialMenu, "select all error msg's", $SelectAllErrors];
CDMenus.CreateEntry[$GlobalMenu, "IO", $IOMenu];
CDMenus.CreateEntry[$GlobalMenu, "directory", $DirectoryMenu];
CDMenus.CreateEntry[$GlobalMenu, "cells", $CellMenu];
CDMenus.CreateEntry[$GlobalMenu, "imports", $ImportMenu];
CDMenus.CreateEntry[$GlobalMenu, "names & prop", $NameMenu];
CDMenus.CreateEntry[$GlobalMenu, "text & prop ", $TextPropertyMenu];
CDMenus.CreateEntry[$GlobalMenu, "programs", $ProgramMenu];
CDMenus.CreateEntry[$GlobalMenu, "viewer", $ViewerMenu];
CDMenus.CreateEntry[$GlobalMenu, "special", $SpecialMenu];
END.