Skip to content

Commit 09354a3

Browse files
authored
Merge pull request #9032 from gadfort/gui-wire-descriptors
gui: add wire/swire/sbox descriptors
2 parents 983c927 + b4c158e commit 09354a3

File tree

3 files changed

+328
-16
lines changed

3 files changed

+328
-16
lines changed

src/gui/src/dbDescriptors.cpp

Lines changed: 265 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,12 +1696,8 @@ void DbNetDescriptor::highlight(const std::any& object, Painter& painter) const
16961696
drawPathSegmentWithGraph(net, sink_object, painter);
16971697
}
16981698

1699-
odb::dbWireShapeItr it;
1700-
it.begin(wire);
1701-
odb::dbShape shape;
1702-
while (it.next(shape)) {
1703-
painter.drawRect(shape.getBox());
1704-
}
1699+
auto* wire_descriptor = Gui::get()->getDescriptor<odb::dbWire*>();
1700+
wire_descriptor->highlight(wire, painter);
17051701
} else {
17061702
auto guides = net->getGuides();
17071703
if (!guides.empty()) {
@@ -1809,15 +1805,9 @@ void DbNetDescriptor::highlight(const std::any& object, Painter& painter) const
18091805
}
18101806

18111807
// Draw special (i.e. geometric) routing
1808+
auto* swire_descriptor = Gui::get()->getDescriptor<odb::dbSWire*>();
18121809
for (auto swire : net->getSWires()) {
1813-
for (auto sbox : swire->getWires()) {
1814-
if (sbox->getDirection() == odb::dbSBox::OCTILINEAR) {
1815-
painter.drawOctagon(sbox->getOct());
1816-
} else {
1817-
odb::Rect rect = sbox->getBox();
1818-
painter.drawRect(rect);
1819-
}
1820-
}
1810+
swire_descriptor->highlight(swire, painter);
18211811
}
18221812
}
18231813

@@ -1868,6 +1858,18 @@ Descriptor::Properties DbNetDescriptor::getDBProperties(odb::dbNet* net) const
18681858
props.push_back({"Buffer tree", gui->makeSelected(BufferTree(net))});
18691859
}
18701860

1861+
odb::dbWire* wire = net->getWire();
1862+
if (wire != nullptr) {
1863+
props.push_back({"Wire", gui->makeSelected(wire)});
1864+
}
1865+
SelectionSet swires;
1866+
for (auto* swire : net->getSWires()) {
1867+
swires.insert(gui->makeSelected(swire));
1868+
}
1869+
if (!swires.empty()) {
1870+
props.push_back({"Special wires", swires});
1871+
}
1872+
18711873
return props;
18721874
}
18731875

@@ -5011,7 +5013,12 @@ bool DbBoxDescriptor::lessThan(const std::any& l, const std::any& r) const
50115013
Descriptor::Properties DbBoxDescriptor::getDBProperties(odb::dbBox* box) const
50125014
{
50135015
Properties props;
5016+
populateProperties(box, props);
5017+
return props;
5018+
}
50145019

5020+
void DbBoxDescriptor::populateProperties(odb::dbBox* box, Properties& props)
5021+
{
50155022
auto* gui = Gui::get();
50165023

50175024
switch (box->getOwnerType()) {
@@ -5084,8 +5091,6 @@ Descriptor::Properties DbBoxDescriptor::getDBProperties(odb::dbBox* box) const
50845091
} else if (auto* via = box->getBlockVia()) {
50855092
props.push_back({"Block via", gui->makeSelected(via)});
50865093
}
5087-
5088-
return props;
50895094
}
50905095

50915096
odb::dbBox* DbBoxDescriptor::getObject(const std::any& object) const
@@ -5108,6 +5113,88 @@ odb::dbTransform DbBoxDescriptor::getTransform(const std::any& object) const
51085113

51095114
//////////////////////////////////////////////////
51105115

5116+
DbSBoxDescriptor::DbSBoxDescriptor(odb::dbDatabase* db)
5117+
: BaseDbDescriptor<odb::dbSBox>(db)
5118+
{
5119+
}
5120+
5121+
std::string DbSBoxDescriptor::getName(const std::any& object) const
5122+
{
5123+
odb::Rect box;
5124+
getBBox(object, box);
5125+
5126+
std::string shape_text
5127+
= fmt::format("({}, {}), ({}, {})",
5128+
Property::convert_dbu(box.xMin(), false),
5129+
Property::convert_dbu(box.yMin(), false),
5130+
Property::convert_dbu(box.xMax(), false),
5131+
Property::convert_dbu(box.yMax(), false));
5132+
5133+
return fmt::format("SBox of {}: {}",
5134+
getObject(object)->getOwnerType().getString(),
5135+
shape_text);
5136+
}
5137+
5138+
std::string DbSBoxDescriptor::getTypeName() const
5139+
{
5140+
return "SBox";
5141+
}
5142+
5143+
bool DbSBoxDescriptor::getBBox(const std::any& object, odb::Rect& bbox) const
5144+
{
5145+
bbox = getObject(object)->getBox();
5146+
return true;
5147+
}
5148+
5149+
void DbSBoxDescriptor::highlight(const std::any& object, Painter& painter) const
5150+
{
5151+
auto* box = getObject(object);
5152+
5153+
if (box->getDirection() == odb::dbSBox::OCTILINEAR) {
5154+
painter.drawOctagon(box->getOct());
5155+
} else {
5156+
odb::Rect rect = box->getBox();
5157+
painter.drawRect(rect);
5158+
}
5159+
}
5160+
5161+
void DbSBoxDescriptor::visitAllObjects(
5162+
const std::function<void(const Selected&)>& func) const
5163+
{
5164+
}
5165+
5166+
Descriptor::Properties DbSBoxDescriptor::getDBProperties(odb::dbSBox* box) const
5167+
{
5168+
Properties props;
5169+
5170+
auto* gui = Gui::get();
5171+
5172+
DbBoxDescriptor::populateProperties(box, props);
5173+
5174+
props.push_back({"SWire", gui->makeSelected(box->getSWire())});
5175+
props.push_back({"Shape type", box->getWireShapeType().getString()});
5176+
std::string direction;
5177+
switch (box->getDirection()) {
5178+
case odb::dbSBox::UNDEFINED:
5179+
direction = "Undefined";
5180+
break;
5181+
case odb::dbSBox::HORIZONTAL:
5182+
direction = "Horizontal";
5183+
break;
5184+
case odb::dbSBox::VERTICAL:
5185+
direction = "Vertical";
5186+
break;
5187+
case odb::dbSBox::OCTILINEAR:
5188+
direction = "Octilinear";
5189+
break;
5190+
}
5191+
props.push_back({"Direction", direction});
5192+
5193+
return props;
5194+
}
5195+
5196+
//////////////////////////////////////////////////
5197+
51115198
DbMasterEdgeTypeDescriptor::DbMasterEdgeTypeDescriptor(odb::dbDatabase* db)
51125199
: BaseDbDescriptor<odb::dbMasterEdgeType>(db)
51135200
{
@@ -5326,4 +5413,166 @@ Descriptor::Properties DbCellEdgeSpacingDescriptor::getDBProperties(
53265413
return props;
53275414
}
53285415

5416+
//////////////////////////////////////////////////
5417+
5418+
DbWireDescriptor::DbWireDescriptor(odb::dbDatabase* db)
5419+
: BaseDbDescriptor<odb::dbWire>(db)
5420+
{
5421+
}
5422+
5423+
std::string DbWireDescriptor::getName(const std::any& object) const
5424+
{
5425+
auto* obj = getObject(object);
5426+
return obj->getNet()->getName();
5427+
}
5428+
5429+
std::string DbWireDescriptor::getTypeName() const
5430+
{
5431+
return "Net Wire";
5432+
}
5433+
5434+
bool DbWireDescriptor::getBBox(const std::any& object, odb::Rect& bbox) const
5435+
{
5436+
auto* obj = getObject(object);
5437+
const auto box = obj->getBBox();
5438+
if (box.has_value()) {
5439+
bbox = *box;
5440+
return true;
5441+
}
5442+
return false;
5443+
}
5444+
5445+
void DbWireDescriptor::highlight(const std::any& object, Painter& painter) const
5446+
{
5447+
auto* wire = getObject(object);
5448+
5449+
odb::dbWireShapeItr it;
5450+
it.begin(wire);
5451+
odb::dbShape shape;
5452+
while (it.next(shape)) {
5453+
painter.drawRect(shape.getBox());
5454+
}
5455+
}
5456+
5457+
void DbWireDescriptor::visitAllObjects(
5458+
const std::function<void(const Selected&)>& func) const
5459+
{
5460+
auto* chip = db_->getChip();
5461+
if (chip == nullptr) {
5462+
return;
5463+
}
5464+
auto* block = chip->getBlock();
5465+
if (block == nullptr) {
5466+
return;
5467+
}
5468+
5469+
for (auto* net : block->getNets()) {
5470+
odb::dbWire* wire = net->getWire();
5471+
if (wire != nullptr) {
5472+
func({wire, this});
5473+
}
5474+
}
5475+
}
5476+
5477+
Descriptor::Properties DbWireDescriptor::getDBProperties(
5478+
odb::dbWire* wire) const
5479+
{
5480+
Properties props;
5481+
auto* gui = Gui::get();
5482+
5483+
props.push_back({"Net", gui->makeSelected(wire->getNet())});
5484+
props.push_back({"Is global", wire->isGlobalWire()});
5485+
props.push_back({"Count", wire->count()});
5486+
props.push_back({"Entries", wire->length()});
5487+
props.push_back({"Length", Property::convert_dbu(wire->getLength(), true)});
5488+
5489+
return props;
5490+
}
5491+
5492+
//////////////////////////////////////////////////
5493+
5494+
DbSWireDescriptor::DbSWireDescriptor(odb::dbDatabase* db)
5495+
: BaseDbDescriptor<odb::dbSWire>(db)
5496+
{
5497+
}
5498+
5499+
std::string DbSWireDescriptor::getName(const std::any& object) const
5500+
{
5501+
auto* obj = getObject(object);
5502+
return obj->getNet()->getName();
5503+
}
5504+
5505+
std::string DbSWireDescriptor::getTypeName() const
5506+
{
5507+
return "Net SWire";
5508+
}
5509+
5510+
bool DbSWireDescriptor::getBBox(const std::any& object, odb::Rect& bbox) const
5511+
{
5512+
auto* obj = getObject(object);
5513+
if (obj->getWires().empty()) {
5514+
return false;
5515+
}
5516+
bbox.mergeInit();
5517+
for (auto* box : obj->getWires()) {
5518+
bbox.merge(box->getBox());
5519+
}
5520+
return true;
5521+
}
5522+
5523+
void DbSWireDescriptor::highlight(const std::any& object,
5524+
Painter& painter) const
5525+
{
5526+
auto* wire = getObject(object);
5527+
5528+
auto* sbox_descriptor = Gui::get()->getDescriptor<odb::dbSBox*>();
5529+
5530+
for (auto* box : wire->getWires()) {
5531+
sbox_descriptor->highlight(box, painter);
5532+
}
5533+
}
5534+
5535+
void DbSWireDescriptor::visitAllObjects(
5536+
const std::function<void(const Selected&)>& func) const
5537+
{
5538+
auto* chip = db_->getChip();
5539+
if (chip == nullptr) {
5540+
return;
5541+
}
5542+
auto* block = chip->getBlock();
5543+
if (block == nullptr) {
5544+
return;
5545+
}
5546+
5547+
for (auto* net : block->getNets()) {
5548+
for (auto* swire : net->getSWires()) {
5549+
func({swire, this});
5550+
}
5551+
}
5552+
}
5553+
5554+
Descriptor::Properties DbSWireDescriptor::getDBProperties(
5555+
odb::dbSWire* wire) const
5556+
{
5557+
Properties props;
5558+
auto* gui = Gui::get();
5559+
5560+
props.push_back({"Net", gui->makeSelected(wire->getNet())});
5561+
props.push_back({"Type", wire->getWireType().getString()});
5562+
if (wire->getShield() != nullptr) {
5563+
props.push_back({"Sheild net", gui->makeSelected(wire->getShield())});
5564+
}
5565+
if (wire->getWires().size() > kMaxBoxes) {
5566+
props.push_back({"Boxes", wire->getWires().size()});
5567+
} else {
5568+
SelectionSet boxes;
5569+
for (odb::dbSBox* box : wire->getWires()) {
5570+
boxes.insert(gui->makeSelected(box));
5571+
}
5572+
props.push_back({"Boxes", boxes});
5573+
}
5574+
5575+
return props;
5576+
}
5577+
53295578
} // namespace gui

0 commit comments

Comments
 (0)