Added an option "-dobox" to the "flatten" command, which flattens

just the area inside the cursor box.  This is important for certain
methods like stepped fill pattern generation.
This commit is contained in:
Tim Edwards 2020-12-29 11:51:15 -05:00
parent 18b4375790
commit 1426f5921f
1 changed files with 26 additions and 6 deletions

View File

@ -1929,7 +1929,7 @@ CmdFlatten(w, cmd)
TxCommand *cmd; TxCommand *cmd;
{ {
int rval, xMask; int rval, xMask;
bool dolabels, toplabels, invert; bool dolabels, dobox, toplabels, invert;
char *destname; char *destname;
CellDef *newdef; CellDef *newdef;
CellUse *newuse; CellUse *newuse;
@ -1940,6 +1940,7 @@ CmdFlatten(w, cmd)
xMask = CU_DESCEND_ALL; xMask = CU_DESCEND_ALL;
dolabels = TRUE; dolabels = TRUE;
toplabels = FALSE; toplabels = FALSE;
dobox = FALSE;
rval = 0; rval = 0;
if (cmd->tx_argc > 2) if (cmd->tx_argc > 2)
@ -1965,6 +1966,9 @@ CmdFlatten(w, cmd)
{ {
switch(cmd->tx_argv[i][3]) switch(cmd->tx_argv[i][3])
{ {
case 'b':
dobox = (invert) ? FALSE : TRUE;
break;
case 'l': case 'l':
dolabels = (invert) ? FALSE : TRUE; dolabels = (invert) ? FALSE : TRUE;
break; break;
@ -1979,7 +1983,7 @@ CmdFlatten(w, cmd)
break; break;
default: default:
TxError("options are: -nolabels, -nosubcircuits " TxError("options are: -nolabels, -nosubcircuits "
"-novendor, -dotoplabels\n"); "-novendor, -dotoplabels, -dobox\n");
break; break;
} }
} }
@ -2006,7 +2010,6 @@ CmdFlatten(w, cmd)
(void) StrDup(&(newuse->cu_id), "Flattened cell"); (void) StrDup(&(newuse->cu_id), "Flattened cell");
DBSetTrans(newuse, &GeoIdentityTransform); DBSetTrans(newuse, &GeoIdentityTransform);
newuse->cu_expandMask = CU_DESCEND_SPECIAL; newuse->cu_expandMask = CU_DESCEND_SPECIAL;
UndoDisable();
flatDestUse = newuse; flatDestUse = newuse;
if (EditCellUse) if (EditCellUse)
@ -2014,9 +2017,28 @@ CmdFlatten(w, cmd)
else else
scx.scx_use = (CellUse *)w->w_surfaceID; scx.scx_use = (CellUse *)w->w_surfaceID;
scx.scx_area = scx.scx_use->cu_def->cd_bbox; if (dobox)
{
CellDef *boxDef;
if (!ToolGetBox(&boxDef, &scx.scx_area))
{
TxError("Put the box in a window first.\n");
return;
}
else if (boxDef != scx.scx_use->cu_def)
{
TxError("The box is not in the edit cell!\n");
return;
}
}
else
scx.scx_area = scx.scx_use->cu_def->cd_bbox;
scx.scx_trans = GeoIdentityTransform; scx.scx_trans = GeoIdentityTransform;
UndoDisable();
DBCellCopyAllPaint(&scx, &DBAllButSpaceAndDRCBits, xMask, flatDestUse); DBCellCopyAllPaint(&scx, &DBAllButSpaceAndDRCBits, xMask, flatDestUse);
if (dolabels) if (dolabels)
FlatCopyAllLabels(&scx, &DBAllTypeBits, xMask, flatDestUse); FlatCopyAllLabels(&scx, &DBAllTypeBits, xMask, flatDestUse);
@ -2033,5 +2055,3 @@ CmdFlatten(w, cmd)
UndoEnable(); UndoEnable();
} }