Merge pull request #2328 from KLayout/feature/issue-2326

Modifying the fit logic for issue #2326
This commit is contained in:
Matthias Köfferlein 2026-04-14 08:58:18 +02:00 committed by GitHub
commit 386e780d85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 1 deletions

View File

@ -3920,18 +3920,34 @@ LayoutViewBase::full_box () const
db::DBox bbox;
auto tv = cv_transform_variants_with_empty ();
// first, use the bounding box of actual drawn layout (issue #2326)
for (auto i = tv.begin (); i != tv.end (); ++i) {
const lay::CellView &cv = cellview (i->second);
if (cv.is_valid ()) {
double dbu = cv->layout ().dbu ();
bbox += (i->first * db::CplxTrans (dbu) * cv.context_trans ()) * cv.cell ()->bbox_with_empty ();
bbox += (i->first * db::CplxTrans (dbu) * cv.context_trans ()) * cv.cell ()->bbox ();
}
}
// if that is empty, use the bounding box computed while treating empty cells as
// dots at the origin of the cells
if (bbox.empty ()) {
for (auto i = tv.begin (); i != tv.end (); ++i) {
const lay::CellView &cv = cellview (i->second);
if (cv.is_valid ()) {
double dbu = cv->layout ().dbu ();
bbox += (i->first * db::CplxTrans (dbu) * cv.context_trans ()) * cv.cell ()->bbox_with_empty ();
}
}
}
// add annotations
for (lay::AnnotationShapes::iterator a = annotation_shapes ().begin (); ! a.at_end (); ++a) {
bbox += a->box ();
}
// produce a default if still empty and enlarge by some small amount to have a border
if (bbox.empty ()) {
bbox = db::DBox (0, 0, 0, 0); // default box
} else {