Skip to content

Commit 2b5c1d5

Browse files
committed
gui: LayoutViewer::searchNearestEdge use dbChipInst coordinates
Signed-off-by: LucasYuki <[email protected]>
1 parent 9716390 commit 2b5c1d5

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/gui/src/layoutViewer.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,16 @@ Rect LayoutViewer::getBounds() const
229229
{
230230
Rect bbox{0, 0, chip_->getWidth(), chip_->getHeight()};
231231

232-
for (auto chip : getChip()->getDb()->getChips()) {
233-
dbBlock* block = chip->getBlock();
232+
for (auto chip_inst : getChip()->getDb()->getChipInsts()) {
233+
bbox.merge(chip_inst->getBBox());
234+
235+
dbBlock* block = chip_inst->getMasterChip()->getBlock();
234236
if (!block) {
235237
continue;
236238
}
237-
bbox.merge(block->getBBox()->getBox());
238-
bbox.merge(block->getDieArea());
239+
Rect die_area = block->getDieArea();
240+
chip_inst->getTransform().apply(die_area);
241+
bbox.merge(die_area);
239242
}
240243
return bbox;
241244
}
@@ -491,10 +494,8 @@ void LayoutViewer::searchNearestViaEdge(
491494
}
492495
}
493496

494-
std::pair<LayoutViewer::Edge, bool> LayoutViewer::searchNearestEdge(
495-
const odb::Point& pt,
496-
bool horizontal,
497-
bool vertical)
497+
std::pair<LayoutViewer::Edge, bool>
498+
LayoutViewer::searchNearestEdge(odb::Point pt, bool horizontal, bool vertical)
498499
{
499500
if (!hasDesign()) {
500501
return {Edge(), false};
@@ -572,14 +573,20 @@ std::pair<LayoutViewer::Edge, bool> LayoutViewer::searchNearestEdge(
572573
pt.y() + search_radius);
573574
}
574575

575-
for (auto chip : getChip()->getDb()->getChips()) {
576-
dbBlock* block = chip->getBlock();
576+
for (auto chip_inst : getChip()->getDb()->getChipInsts()) {
577+
dbBlock* block = chip_inst->getMasterChip()->getBlock();
577578
if (!block) {
578579
continue;
579580
}
580581

581-
auto a = chip->getBBox();//block->getDieArea();
582-
std::cout << "(" << a.xMin() << ", " << a.xMax() << ") (" << a.yMin() << ", " << a.yMax() << ")" << std::endl;
582+
// Convert to the chip_inst coordinates
583+
dbTransform inverse_transform = chip_inst->getTransform();
584+
inverse_transform.invert();
585+
inverse_transform.apply(search_line);
586+
inverse_transform.apply(pt);
587+
auto& [p1, p2] = closest_edge;
588+
inverse_transform.apply(p1);
589+
inverse_transform.apply(p2);
583590

584591
// get die bounding box
585592
check_rect(block->getDieArea());
@@ -771,6 +778,13 @@ std::pair<LayoutViewer::Edge, bool> LayoutViewer::searchNearestEdge(
771778
}
772779
}
773780
}
781+
782+
// Convert back to the global coordinates
783+
dbTransform transform = chip_inst->getTransform();
784+
transform.apply(search_line);
785+
transform.apply(pt);
786+
transform.apply(p1);
787+
transform.apply(p2);
774788
}
775789

776790
const bool ok = edge_distance != std::numeric_limits<int>::max();

src/gui/src/layoutViewer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class LayoutViewer : public QWidget
314314

315315
using Edge = std::pair<odb::Point, odb::Point>;
316316
// search for nearest edge to point
317-
std::pair<Edge, bool> searchNearestEdge(const odb::Point& pt,
317+
std::pair<Edge, bool> searchNearestEdge(odb::Point pt,
318318
bool horizontal,
319319
bool vertical);
320320
void searchNearestViaEdge(

0 commit comments

Comments
 (0)