From deae8c68b4da8473b7fb1247b88c52464a4e8aa2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 11 Apr 2026 17:34:15 +0200 Subject: [PATCH] Modifying the fit logic for issue #2326 The fit box is computed now the following way 1. Compute the bounding box of "visible" parts (i.e. treating empty cells as empty) 2. If that bounding box is empty, compute the bounding box using the previous scheme, where empty cells are treated as point-like with a single point at their origin --- src/laybasic/laybasic/layLayoutViewBase.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index b0c537a40..b24831c0c 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -3912,18 +3912,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 {