Corrected an issue in computing the extended (includes area of

label text) vs. non-extended bounding box of a cell when doing
"getcell" (and probably a number of other commands/functions, as
well).  A function was always computing the extended bounding box
and then setting both the normal and extended bounding boxes of
the cell to this value, resulting in incorrect cell selections.
This commit is contained in:
R. Timothy Edwards 2025-08-26 11:00:20 -04:00
parent d2acdac901
commit e04307c085
4 changed files with 34 additions and 18 deletions

View File

@ -1 +1 @@
8.3.545 8.3.546

View File

@ -1945,7 +1945,7 @@ CmdWriteall(
option = Lookup(cmd->tx_argv[1], writeallOpts); option = Lookup(cmd->tx_argv[1], writeallOpts);
if (option < 0) if (option < 0)
{ {
TxError("Usage: %s [force|modified|noupdate [cellname ...]]\n", TxError("Usage: %s [force|modified [cellname ...]]\n",
cmd->tx_argv[0]); cmd->tx_argv[0]);
return; return;
} }

View File

@ -30,19 +30,32 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
typedef struct dbcellboundstruct typedef struct dbcellboundstruct
{ {
Rect *area; Rect *area;
bool extended; Rect *extended;
bool found; bool found;
} DBCellBoundStruct; } DBCellBoundStruct;
/* /*
* -------------------------------------------------------------------- * --------------------------------------------------------------------
* DBBoundCellPlane ---
*
* Find the extents of all subcells of the cell "def", both the
* extent of geometry (rect) and the extent of geometry plus any
* labels extending outside the extent of geometry (extended).
*
* Results:
* TRUE if subcells were found and measured; FALSE if no subcells
* were found (in which case "extended" and "rect" may not be
* valid).
*
* Side effects:
* Values may be recorded in "extended" and "rect".
* -------------------------------------------------------------------- * --------------------------------------------------------------------
*/ */
int int
DBBoundCellPlane(def, extended, rect) DBBoundCellPlane(def, extended, rect)
CellDef *def; CellDef *def;
bool extended; Rect *extended;
Rect *rect; Rect *rect;
{ {
TreeFilter filter; TreeFilter filter;
@ -70,24 +83,18 @@ dbCellBoundFunc(use, fp)
CellUse *use; CellUse *use;
TreeFilter *fp; TreeFilter *fp;
{ {
Rect *bbox;
DBCellBoundStruct *cbs; DBCellBoundStruct *cbs;
cbs = (DBCellBoundStruct *)fp->tf_arg; cbs = (DBCellBoundStruct *)fp->tf_arg;
bbox = &use->cu_bbox;
if (cbs->found) if (cbs->found)
{ {
if (cbs->extended) GeoInclude(&use->cu_extended, cbs->extended);
GeoInclude(&use->cu_extended, cbs->area);
else
GeoInclude(&use->cu_bbox, cbs->area); GeoInclude(&use->cu_bbox, cbs->area);
} }
else else
{ {
if (cbs->extended) *cbs->extended = use->cu_extended;
*cbs->area = use->cu_extended;
else
*cbs->area = use->cu_bbox; *cbs->area = use->cu_bbox;
cbs->found = TRUE; cbs->found = TRUE;
} }

View File

@ -619,7 +619,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
/* /*
* Include area of subcells separately * Include area of subcells separately
*/ */
if ((foundAny = DBBoundCellPlane(cellDef, TRUE, &rect)) > 0) if ((foundAny = DBBoundCellPlane(cellDef, &extended, &rect)) > 0)
area = rect; area = rect;
for (pNum = PL_PAINTBASE; pNum < DBNumPlanes; pNum++) for (pNum = PL_PAINTBASE; pNum < DBNumPlanes; pNum++)
@ -634,7 +634,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
} }
/* /*
* Include the area of labels, too. * Include the area of label anchors, too.
*/ */
for (label = cellDef->cd_labels; label != NULL; label = label->lab_next) for (label = cellDef->cd_labels; label != NULL; label = label->lab_next)
{ {
@ -656,7 +656,11 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
} }
} }
extended = area; /* Make sure the extended bounding box includes the area of all
* paint material just found, then include the area of all text
* in the current cell.
*/
GeoInclude(&area, &extended);
if (foundAny) if (foundAny)
{ {
for (label = cellDef->cd_labels; label != NULL; label = label->lab_next) for (label = cellDef->cd_labels; label != NULL; label = label->lab_next)
@ -673,6 +677,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
degenerate = TRUE; degenerate = TRUE;
area.r_xbot = area.r_ybot = 0; area.r_xbot = area.r_ybot = 0;
area.r_xtop = area.r_ytop = 1; area.r_xtop = area.r_ytop = 1;
extended = area;
} }
else degenerate = FALSE; else degenerate = FALSE;
@ -687,7 +692,11 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
if (area.r_ybot == area.r_ytop) if (area.r_ybot == area.r_ytop)
area.r_ytop = area.r_ybot + 1; area.r_ytop = area.r_ybot + 1;
if (degenerate) extended = area; if (extended.r_xbot == extended.r_xtop)
extended.r_xtop = extended.r_xbot + 1;
if (extended.r_ybot == extended.r_ytop)
extended.r_ytop = extended.r_ybot + 1;
/* Did the bounding box change? If not then there's no need to /* Did the bounding box change? If not then there's no need to
* recompute the parents. If the cell has no material, then * recompute the parents. If the cell has no material, then