Skip to content

Commit 7d6e5dc

Browse files
committed
gui: add highlighting of edge types and cell spacing table
Signed-off-by: Peter Gadfort <[email protected]>
1 parent 541c3d0 commit 7d6e5dc

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

src/gui/src/dbDescriptors.cpp

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ void DbMasterDescriptor::getMasterEquivalent(sta::dbSta* sta,
945945

946946
// get list of instances of that type
947947
void DbMasterDescriptor::getInstances(odb::dbMaster* master,
948-
std::set<odb::dbInst*>& insts) const
948+
std::set<odb::dbInst*>& insts)
949949
{
950950
for (auto inst : master->getDb()->getChip()->getBlock()->getInsts()) {
951951
if (inst->getMaster() == master) {
@@ -5120,9 +5120,60 @@ bool DbMasterEdgeTypeDescriptor::getBBox(const std::any& object,
51205120
return false;
51215121
}
51225122

5123+
void DbMasterEdgeTypeDescriptor::highlightEdge(
5124+
odb::dbMaster* master,
5125+
odb::dbMasterEdgeType* edge,
5126+
Painter& painter,
5127+
const std::optional<int>& pen_width)
5128+
{
5129+
if (pen_width) {
5130+
painter.saveState();
5131+
painter.setPenWidth(pen_width.value());
5132+
}
5133+
5134+
std::set<odb::dbInst*> insts;
5135+
DbMasterDescriptor::getInstances(master, insts);
5136+
for (auto inst : insts) {
5137+
if (!inst->getPlacementStatus().isPlaced()) {
5138+
continue;
5139+
}
5140+
5141+
const odb::Rect rect = inst->getBBox()->getBox();
5142+
5143+
switch (edge->getEdgeDir()) {
5144+
case odb::dbMasterEdgeType::TOP:
5145+
painter.drawLine(rect.ur(), rect.ul());
5146+
break;
5147+
case odb::dbMasterEdgeType::RIGHT:
5148+
painter.drawLine(rect.lr(), rect.ur());
5149+
break;
5150+
case odb::dbMasterEdgeType::LEFT:
5151+
painter.drawLine(rect.ll(), rect.ul());
5152+
break;
5153+
case odb::dbMasterEdgeType::BOTTOM:
5154+
painter.drawLine(rect.lr(), rect.ll());
5155+
break;
5156+
}
5157+
}
5158+
5159+
if (pen_width) {
5160+
painter.restoreState();
5161+
}
5162+
}
5163+
51235164
void DbMasterEdgeTypeDescriptor::highlight(const std::any& object,
51245165
Painter& painter) const
51255166
{
5167+
auto* edge = getObject(object);
5168+
for (auto* lib : db_->getLibs()) {
5169+
for (auto* master : lib->getMasters()) {
5170+
for (auto* master_edge : master->getEdgeTypes()) {
5171+
if (master_edge == edge) {
5172+
DbMasterEdgeTypeDescriptor::highlightEdge(master, edge, painter);
5173+
}
5174+
}
5175+
}
5176+
}
51265177
}
51275178

51285179
void DbMasterEdgeTypeDescriptor::visitAllObjects(
@@ -5223,6 +5274,18 @@ bool DbCellEdgeSpacingDescriptor::getBBox(const std::any& object,
52235274
void DbCellEdgeSpacingDescriptor::highlight(const std::any& object,
52245275
Painter& painter) const
52255276
{
5277+
auto rule = getObject(object);
5278+
for (auto* lib : db_->getLibs()) {
5279+
for (auto* master : lib->getMasters()) {
5280+
for (auto* edge : master->getEdgeTypes()) {
5281+
if (rule->getFirstEdgeType() == edge->getEdgeType()) {
5282+
DbMasterEdgeTypeDescriptor::highlightEdge(master, edge, painter, 1);
5283+
} else if (rule->getSecondEdgeType() == edge->getEdgeType()) {
5284+
DbMasterEdgeTypeDescriptor::highlightEdge(master, edge, painter, 2);
5285+
}
5286+
}
5287+
}
5288+
}
52265289
}
52275290

52285291
void DbCellEdgeSpacingDescriptor::visitAllObjects(

src/gui/src/dbDescriptors.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ class DbMasterDescriptor : public BaseDbDescriptor<odb::dbMaster>
137137
odb::dbMaster* master,
138138
std::set<odb::dbMaster*>& masters);
139139

140+
static void getInstances(odb::dbMaster* master,
141+
std::set<odb::dbInst*>& insts);
142+
140143
protected:
141144
Properties getDBProperties(odb::dbMaster* master) const override;
142145

143146
private:
144-
void getInstances(odb::dbMaster* master, std::set<odb::dbInst*>& insts) const;
145-
146147
sta::dbSta* sta_;
147148
};
148149

@@ -880,6 +881,10 @@ class DbMasterEdgeTypeDescriptor
880881
bool getBBox(const std::any& object, odb::Rect& bbox) const override;
881882

882883
void highlight(const std::any& object, Painter& painter) const override;
884+
static void highlightEdge(odb::dbMaster* master,
885+
odb::dbMasterEdgeType* edge,
886+
Painter& painter,
887+
const std::optional<int>& pen_width = {});
883888

884889
void visitAllObjects(
885890
const std::function<void(const Selected&)>& func) const override;

0 commit comments

Comments
 (0)