Skip to content

Commit

Permalink
Merge branch 'issue-1934-partial'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Nov 30, 2024
2 parents e35aa97 + c25896e commit 3a07782
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 17 deletions.
63 changes: 46 additions & 17 deletions src/laybasic/laybasic/layFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
{
checkpoint ();

// 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 (! m_context_layers.empty ()) {

std::map<db::cell_index_type, bool>::const_iterator ctx = m_cells_with_context.find (cell.cell_index ());
Expand Down Expand Up @@ -517,7 +520,9 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
checkpoint ();

db::Box bbox;
if (text_info () && shape->is_text ()) {
if (! view ()->text_visible () && shape->is_text ()) {
// ignore texts if the view does not show them
} else if (text_info () && shape->is_text ()) {
db::CplxTrans t_dbu = db::CplxTrans (layout ().dbu ()) * t;
db::Text text;
shape->text (text);
Expand Down Expand Up @@ -569,32 +574,40 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
bool match = false;
double d = std::numeric_limits<double>::max ();

checkpoint ();

db::Point point (hit_box.center ());

// in point mode, test the edges and use a "closest" criterion
if (shape->is_polygon ()) {

bool any_valid_edge = false;
for (db::Shape::polygon_edge_iterator e = shape->begin_edge (); ! e.at_end (); ++e) {
test_edge (t, *e, d, match);
if ((*e).clipped (viewport_box).first) {
any_valid_edge = true;
test_edge (t, *e, d, match);
}
}

// test if inside the polygon
if (! match && inside_poly (shape->begin_edge (), point) >= 0) {
if (! match && any_valid_edge && inside_poly (shape->begin_edge (), point) >= 0) {
d = t.ctrans (poly_dist (shape->begin_edge (), point));
match = true;
}

} else if (shape->is_path ()) {

bool any_valid_edge = false;

// test the "spine"
db::Shape::point_iterator pt = shape->begin_point ();
db::Shape::point_iterator pt = shape->begin_point ();
if (pt != shape->end_point ()) {
db::Point p (*pt);
++pt;
for (; pt != shape->end_point (); ++pt) {
test_edge (t, db::Edge (p, *pt), d, match);
db::Edge e (p, *pt);
if (e.clipped (viewport_box).first) {
any_valid_edge = true;
test_edge (t, e, d, match);
}
p = *pt;
}
}
Expand All @@ -603,16 +616,19 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
db::Polygon poly;
shape->polygon (poly);
for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) {
test_edge (t, *e, d, match);
if ((*e).clipped (viewport_box).first) {
any_valid_edge = true;
test_edge (t, *e, d, match);
}
}

// test if inside the polygon
if (! match && inside_poly (poly.begin_edge (), point) >= 0) {
if (! match && any_valid_edge && inside_poly (poly.begin_edge (), point) >= 0) {
d = t.ctrans (poly_dist (poly.begin_edge (), point));
match = true;
}

} else if (shape->is_box () || shape->is_point () || shape->is_text ()) {
} else if (shape->is_box () || shape->is_point () || (shape->is_text () && view ()->text_visible ())) {

db::Box box = shape->bbox ();
if (text_info () && shape->is_text ()) {
Expand All @@ -628,13 +644,18 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
match = true;
} else {

bool any_valid_edge = false;

// convert to polygon and test those edges
db::Polygon poly (box);
for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) {
test_edge (t, *e, d, match);
if ((*e).clipped (viewport_box).first) {
any_valid_edge = true;
test_edge (t, *e, d, match);
}
}

if (! match && box.contains (hit_box.center ())) {
if (! match && any_valid_edge && box.contains (hit_box.center ())) {
d = t.ctrans (poly_dist (poly.begin_edge (), point));
match = true;
}
Expand Down Expand Up @@ -783,8 +804,13 @@ 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)
{
checkpoint ();

// 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;
Expand Down Expand Up @@ -864,8 +890,6 @@ InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const d

} else {

checkpoint ();

// look for instances to check here ..
db::Cell::touching_iterator inst = cell.begin_touching (search_box);
while (! inst.at_end ()) {
Expand Down Expand Up @@ -909,11 +933,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;
}
Expand Down
3 changes: 3 additions & 0 deletions src/laybasic/laybasic/layLayoutViewBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4079,6 +4079,9 @@ LayoutViewBase::transform (const db::DCplxTrans &tr)
void
LayoutViewBase::cancel_edits ()
{
// clear any messages
message ();

// the move service takes a special role here as it manages the
// transaction for the collective move operation.
mp_move_service->cancel ();
Expand Down

0 comments on commit 3a07782

Please sign in to comment.