Corrected an issue with "flatten -doinplace" with no cell name

argument, which is supposed to flatten all selected instances.
After flattening, instead of deleting the instance from the
cell, it deleted the instance from the selection, leaving the
one in the cell.
This commit is contained in:
Tim Edwards 2023-07-28 15:25:42 -04:00
parent 89f1c4ee67
commit 6b5bd149fc
4 changed files with 70 additions and 5 deletions

View File

@ -2050,7 +2050,7 @@ CmdFlatten(w, cmd)
}
use = (CellUse *)HashGetValue(he);
UndoDisable();
DBFlattenInPlace(use, EditCellUse, xMask, dolabels, toplabels);
DBFlattenInPlace(use, EditCellUse, xMask, dolabels, toplabels, TRUE);
UndoEnable();
}
else
@ -2062,8 +2062,12 @@ CmdFlatten(w, cmd)
scx.scx_trans = SelectUse->cu_transform;
DBCellFlattenAllCells(&scx, EditCellUse, xMask, dolabels, toplabels);
/* Instances in SelectDef need to be removed. The 2nd */
/* argument TRUE causes the selection to be deleted. */
SelectDeleteUses("flattened", TRUE);
UndoEnable();
SelectClear();
}
return;
}

View File

@ -553,12 +553,13 @@ DBFlatCopyMaskHints(scx, xMask, targetUse)
*/
void
DBFlattenInPlace(use, dest, xMask, dolabels, toplabels)
DBFlattenInPlace(use, dest, xMask, dolabels, toplabels, doclear)
CellUse *use; /* Cell use to flatten */
CellUse *dest; /* Cell use to flatten into */
int xMask; /* Search mask for flattening */
bool dolabels; /* Option to flatten labels */
bool toplabels; /* Option to selectively flatten top-level labels */
bool doclear; /* Delete the original use if TRUE */
{
Label *lab;
SearchContext scx;
@ -678,7 +679,8 @@ DBFlattenInPlace(use, dest, xMask, dolabels, toplabels)
lab->lab_flags &= ~LABEL_GENERATE;
/* Remove the use from the parent def */
DBDeleteCell(scx.scx_use);
if (doclear)
DBDeleteCell(scx.scx_use);
/* Was: &scx.scx_use->cu_def->cd_bbox */
DBWAreaChanged(dest->cu_def, &scx.scx_use->cu_bbox,
@ -730,7 +732,7 @@ dbCellFlattenCellsFunc(scx, clientData)
toplabels = fad->fad_toplabels;
use = scx->scx_use;
DBFlattenInPlace(use, dest, xMask, dolabels, toplabels);
DBFlattenInPlace(use, dest, xMask, dolabels, toplabels, FALSE);
return 2;
}

View File

@ -145,6 +145,64 @@ SelectDelete(msg, do_clear)
if (do_clear) SelectClear();
}
/*
* ----------------------------------------------------------------------------
*
* SelectDeleteUses --
*
* Delete all cell uses in the edit cell that are selected.
* This function is used by "flatten -doinplace" when operating
* on a selection. Since selected instances are flattened, the
* instances need to be deleted from the cell. This routine is
* the same as SelectDelete() without the paint and label delete
* functions.
*
* Results:
* None.
*
* Side effects:
* Cell uses are removed from the edit cell. If there are selected
* uses that aren't in the edit cell, the user is warned.
*
* ----------------------------------------------------------------------------
*/
void
SelectDeleteUses(msg, do_clear)
char *msg; /* Some information to print in error messages.
* For example, if called as part of a move procedure,
* supply "moved". This will appear in messages of
* the form "only edit cell information was moved".
*/
bool do_clear; /* If TRUE, clear the select def before returning. */
{
bool nonEdit;
Rect editArea;
extern int selDelPaintFunc(), selDelCellFunc(), selDelLabelFunc();
if (EditCellUse == NULL)
{
TxError("The current cell is not editable.\n");
return;
}
(void) SelEnumCells(TRUE, &nonEdit, (SearchContext *) NULL,
selDelCellFunc, (ClientData) NULL);
if (nonEdit)
{
TxError("You selected one or more subcells that aren't children\n");
TxError(" of the edit cell. Only those in the edit cell were\n");
TxError(" %s.\n", msg);
}
DBReComputeBbox(EditCellUse->cu_def);
GeoTransRect(&RootToEditTransform, &SelectDef->cd_extended, &editArea);
DBWAreaChanged(EditCellUse->cu_def, &editArea, DBW_ALLWINDOWS,
(TileTypeBitMask *) NULL);
DRCCheckThis(EditCellUse->cu_def, TT_CHECKPAINT, &editArea);
if (do_clear) SelectClear();
}
/* Search function to delete paint. */
int

View File

@ -51,6 +51,7 @@ extern int SelEnumLabelsMirror();
/* Procedures to operate on the selection. */
extern void SelectDelete();
extern void SelectDeleteUses();
extern void SelectCopy();
extern void SelectTransform();
extern void SelectExpand();