diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-08-20 11:53:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-20 11:53:31 +0200 |
commit | 5fd0bb6e652443ed3c10480103375f2589b51188 (patch) | |
tree | b064c045665327fd8c6a646233de2afba6a44450 | |
parent | 8ed64450f307d6251c49fd417537ae6c8c5b3135 (diff) | |
parent | f3fac0b0ef9bd7fc175740b87e1762fe432706ce (diff) | |
download | nextpnr-5fd0bb6e652443ed3c10480103375f2589b51188.tar.gz nextpnr-5fd0bb6e652443ed3c10480103375f2589b51188.tar.bz2 nextpnr-5fd0bb6e652443ed3c10480103375f2589b51188.zip |
Merge pull request #62 from YosysHQ/q3k/issue-57
gui: fix #57
-rw-r--r-- | gui/fpgaviewwidget.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 84a74587..0bbf80e2 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -240,9 +240,10 @@ void FPGAViewWidget::populateQuadTree(RendererData *data, const DecalXY &decal, continue; } + bool res = true; if (el.type == GraphicElement::TYPE_BOX) { // Boxes are bounded by themselves. - data->qt->insert(PickQuadTree::BoundingBox(x + el.x1, y + el.y1, x + el.x2, y + el.y2), element); + res = data->qt->insert(PickQuadTree::BoundingBox(x + el.x1, y + el.y1, x + el.x2, y + el.y2), element); } if (el.type == GraphicElement::TYPE_LINE || el.type == GraphicElement::TYPE_ARROW) { @@ -261,7 +262,11 @@ void FPGAViewWidget::populateQuadTree(RendererData *data, const DecalXY &decal, x1 += 0.01; y1 += 0.01; - data->qt->insert(PickQuadTree::BoundingBox(x0, y0, x1, y1), element); + res = data->qt->insert(PickQuadTree::BoundingBox(x0, y0, x1, y1), element); + } + + if (!res) { + NPNR_ASSERT_FALSE("populateQuadTree: could not insert element"); } } } @@ -450,8 +455,17 @@ void FPGAViewWidget::renderLines(void) NPNR_ASSERT(data->bbGlobal.w() != 0); NPNR_ASSERT(data->bbGlobal.h() != 0); + // Enlarge the bounding box slightly for the picking - when we insert + // elements into it, we enlarge their bounding boxes slightly, so + // we need to give ourselves some sagery margin here. + auto bb = data->bbGlobal; + bb.setX0(bb.x0() - 1); + bb.setY0(bb.y0() - 1); + bb.setX1(bb.x1() + 1); + bb.setY1(bb.y1() + 1); + // Populate picking quadtree. - data->qt = std::unique_ptr<PickQuadTree>(new PickQuadTree(data->bbGlobal)); + data->qt = std::unique_ptr<PickQuadTree>(new PickQuadTree(bb)); for (auto const &decal : belDecals) { populateQuadTree(data.get(), decal.first, PickedElement::fromBel(decal.second, decal.first.x, decal.first.y)); |