Skip to content

Commit e4f795a

Browse files
authored
Merge pull request #7854 from gadfort/gui-guides
gui: minor fixes to guide code
2 parents b7e58f8 + bc444a0 commit e4f795a

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

src/gui/src/dbDescriptors.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,8 @@ std::set<odb::Line> DbNetDescriptor::convertGuidesToLines(
14681468
break;
14691469
}
14701470
}
1471-
lines.emplace(p0, p1);
1471+
lines.emplace(p0, center);
1472+
lines.emplace(center, p1);
14721473

14731474
if (guide->isConnectedToTerm()) {
14741475
std::vector<odb::Point> anchors = {p0, center, p1};
@@ -1641,18 +1642,22 @@ void DbNetDescriptor::highlight(std::any object, Painter& painter) const
16411642
if (!guides.empty()) {
16421643
draw_flywires = false;
16431644

1644-
// draw outlines of guides
1645-
std::vector<odb::Rect> guide_rects;
1646-
guide_rects.reserve(guides.size());
1647-
for (const auto* guide : guides) {
1648-
guide_rects.push_back(guide->getBox());
1649-
}
1650-
painter.saveState();
1651-
painter.setBrush(painter.getPenColor(), gui::Painter::Brush::kNone);
1652-
for (const odb::Polygon& outline : odb::Polygon::merge(guide_rects)) {
1653-
painter.drawPolygon(outline);
1645+
if (guides.begin()->getBox().minDXDY() * painter.getPixelsPerDBU()
1646+
>= kMinGuidePixelWidth) {
1647+
// draw outlines of guides, dont draw if less that kMinGuidePixelWidth
1648+
// pixels
1649+
std::vector<odb::Rect> guide_rects;
1650+
guide_rects.reserve(guides.size());
1651+
for (const auto* guide : guides) {
1652+
guide_rects.push_back(guide->getBox());
1653+
}
1654+
painter.saveState();
1655+
painter.setBrush(painter.getPenColor(), gui::Painter::Brush::kNone);
1656+
for (const odb::Polygon& outline : odb::Polygon::merge(guide_rects)) {
1657+
painter.drawPolygon(outline);
1658+
}
1659+
painter.restoreState();
16541660
}
1655-
painter.restoreState();
16561661

16571662
painter.saveState();
16581663
Painter::Color highlight_color = painter.getPenColor();

src/gui/src/dbDescriptors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ class DbNetDescriptor : public BaseDbDescriptor<odb::dbNet>
222222
odb::dbObject* getSink(const std::any& object) const;
223223

224224
static const int kMaxIterms = 10000;
225+
static constexpr double kMinGuidePixelWidth = 10.0;
225226
};
226227

227228
class DbITermDescriptor : public BaseDbDescriptor<odb::dbITerm>

0 commit comments

Comments
 (0)