From 692967921a7a6d29017df1845bac863bba9edeae Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 30 Nov 2024 21:35:06 +0100 Subject: [PATCH] Selecting instances only if one edge is visible This is supposed to avoid that you select guard ring cells for example and move them while working on small details. --- src/laybasic/laybasic/layFinder.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index 0b3303d05..313a480e0 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -783,8 +783,11 @@ InstFinder::checkpoint () } void -InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const db::Box & /*scan_box*/, const db::DCplxTrans & /*vp*/, const db::ICplxTrans &t, int level) +InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const db::Box & /*scan_box*/, const db::DCplxTrans &vp, const db::ICplxTrans &t, int level) { + // Viewport in current cell coordinate space (DBU) + db::Box viewport_box = (vp * db::CplxTrans (layout ().dbu ()) * t).inverted () * db::DBox (0, 0, view ()->viewport ().width (), view ()->viewport ().height ()); + if (! point_mode ()) { ++*mp_progress; @@ -909,11 +912,16 @@ InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const d // convert to polygon and test those edges db::Polygon poly (cell_inst.complex_trans (*p) * db::Polygon (ibox)); + bool any_valid_edge = false; for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) { - test_edge (t, *e, d, match); + // only consider edges that cut through the viewport + if ((*e).clipped (viewport_box).first) { + any_valid_edge = true; + test_edge (t, *e, d, match); + } } - if (! match && db::inside_poly (poly.begin_edge (), search_box.center ())) { + if (! match && any_valid_edge && db::inside_poly (poly.begin_edge (), search_box.center ())) { d = t.ctrans (poly_dist (poly.begin_edge (), search_box.center ())); match = true; }