all nets and cells info visible in properties

This commit is contained in:
Miodrag Milanovic 2018-07-06 19:05:05 +02:00
parent ec96e47bf0
commit cc901d67f5

View File

@ -69,7 +69,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net
// Add tree view // Add tree view
treeWidget->setColumnCount(1); treeWidget->setColumnCount(1);
treeWidget->setHeaderLabel(QString("Items")); treeWidget->setHeaderLabel("Items");
treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
// Add property view // Add property view
@ -111,7 +111,7 @@ void DesignWidget::newContext(Context *ctx)
// Add bels to tree // Add bels to tree
QTreeWidgetItem *bel_root = new QTreeWidgetItem(treeWidget); QTreeWidgetItem *bel_root = new QTreeWidgetItem(treeWidget);
QMap<QString, QTreeWidgetItem *> bel_items; QMap<QString, QTreeWidgetItem *> bel_items;
bel_root->setText(0, QString("Bels")); bel_root->setText(0, "Bels");
treeWidget->insertTopLevelItem(0, bel_root); treeWidget->insertTopLevelItem(0, bel_root);
if (ctx) { if (ctx) {
for (auto bel : ctx->getBels()) { for (auto bel : ctx->getBels()) {
@ -140,7 +140,7 @@ void DesignWidget::newContext(Context *ctx)
// Add wires to tree // Add wires to tree
QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget); QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget);
QMap<QString, QTreeWidgetItem *> wire_items; QMap<QString, QTreeWidgetItem *> wire_items;
wire_root->setText(0, QString("Wires")); wire_root->setText(0, "Wires");
treeWidget->insertTopLevelItem(0, wire_root); treeWidget->insertTopLevelItem(0, wire_root);
if (ctx) { if (ctx) {
for (auto wire : ctx->getWires()) { for (auto wire : ctx->getWires()) {
@ -169,7 +169,7 @@ void DesignWidget::newContext(Context *ctx)
// Add pips to tree // Add pips to tree
QTreeWidgetItem *pip_root = new QTreeWidgetItem(treeWidget); QTreeWidgetItem *pip_root = new QTreeWidgetItem(treeWidget);
QMap<QString, QTreeWidgetItem *> pip_items; QMap<QString, QTreeWidgetItem *> pip_items;
pip_root->setText(0, QString("Pips")); pip_root->setText(0, "Pips");
treeWidget->insertTopLevelItem(0, pip_root); treeWidget->insertTopLevelItem(0, pip_root);
if (ctx) { if (ctx) {
for (auto pip : ctx->getPips()) { for (auto pip : ctx->getPips()) {
@ -197,12 +197,12 @@ void DesignWidget::newContext(Context *ctx)
// Add nets to tree // Add nets to tree
nets_root = new QTreeWidgetItem(treeWidget); nets_root = new QTreeWidgetItem(treeWidget);
nets_root->setText(0, QString("Nets")); nets_root->setText(0, "Nets");
treeWidget->insertTopLevelItem(0, nets_root); treeWidget->insertTopLevelItem(0, nets_root);
// Add cells to tree // Add cells to tree
cells_root = new QTreeWidgetItem(treeWidget); cells_root = new QTreeWidgetItem(treeWidget);
cells_root->setText(0, QString("Cells")); cells_root->setText(0, "Cells");
treeWidget->insertTopLevelItem(0, cells_root); treeWidget->insertTopLevelItem(0, cells_root);
} }
@ -216,7 +216,7 @@ void DesignWidget::updateTree()
// Add nets to tree // Add nets to tree
nets_root = new QTreeWidgetItem(treeWidget); nets_root = new QTreeWidgetItem(treeWidget);
QMap<QString, QTreeWidgetItem *> nets_items; QMap<QString, QTreeWidgetItem *> nets_items;
nets_root->setText(0, QString("Nets")); nets_root->setText(0, "Nets");
treeWidget->insertTopLevelItem(0, nets_root); treeWidget->insertTopLevelItem(0, nets_root);
if (ctx) { if (ctx) {
for (auto& item : ctx->nets) { for (auto& item : ctx->nets) {
@ -232,7 +232,7 @@ void DesignWidget::updateTree()
// Add cells to tree // Add cells to tree
cells_root = new QTreeWidgetItem(treeWidget); cells_root = new QTreeWidgetItem(treeWidget);
QMap<QString, QTreeWidgetItem *> cells_items; QMap<QString, QTreeWidgetItem *> cells_items;
cells_root->setText(0, QString("Cells")); cells_root->setText(0, "Cells");
treeWidget->insertTopLevelItem(0, cells_root); treeWidget->insertTopLevelItem(0, cells_root);
if (ctx) { if (ctx) {
for (auto& item : ctx->cells) { for (auto& item : ctx->cells) {
@ -279,103 +279,218 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
clearProperties(); clearProperties();
if (type == ElementType::BEL) { if (type == ElementType::BEL) {
IdString c = static_cast<IdStringTreeItem *>(item)->getData(); IdString c = static_cast<IdStringTreeItem *>(item)->getData();
BelType type = ctx->getBelType(ctx->getBelByName(c)); BelType type = ctx->getBelType(ctx->getBelByName(c));
QtVariantProperty *topItem = readOnlyManager->addProperty(QVariant::String, QString("Name"));
topItem->setValue(QString(c.c_str(ctx)));
addProperty(topItem, QString("Name"));
QtVariantProperty *typeItem = readOnlyManager->addProperty(QVariant::String, QString("Type")); QtProperty *topItem = groupManager->addProperty("Bel");
typeItem->setValue(QString(ctx->belTypeToId(type).c_str(ctx))); addProperty(topItem, "Bel");
addProperty(typeItem, QString("Type"));
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
nameItem->setValue(c.c_str(ctx));
topItem->addSubProperty(nameItem);
QtVariantProperty *typeItem = readOnlyManager->addProperty(QVariant::String, "Type");
typeItem->setValue(ctx->belTypeToId(type).c_str(ctx));
topItem->addSubProperty(typeItem);
} else if (type == ElementType::WIRE) { } else if (type == ElementType::WIRE) {
IdString c = static_cast<IdStringTreeItem *>(item)->getData(); IdString c = static_cast<IdStringTreeItem *>(item)->getData();
QtVariantProperty *topItem = readOnlyManager->addProperty(QVariant::String, QString("Name")); QtProperty *topItem = groupManager->addProperty("Wire");
topItem->setValue(QString(c.c_str(ctx))); addProperty(topItem, "Wire");
addProperty(topItem, QString("Name"));
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
nameItem->setValue(c.c_str(ctx));
topItem->addSubProperty(nameItem);
} else if (type == ElementType::PIP) { } else if (type == ElementType::PIP) {
IdString c = static_cast<IdStringTreeItem *>(item)->getData(); IdString c = static_cast<IdStringTreeItem *>(item)->getData();
QtVariantProperty *topItem = readOnlyManager->addProperty(QVariant::String, QString("Name")); QtProperty *topItem = groupManager->addProperty("Pip");
topItem->setValue(QString(c.c_str(ctx))); addProperty(topItem, "Pip");
addProperty(topItem, QString("Name"));
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
nameItem->setValue(c.c_str(ctx));
topItem->addSubProperty(nameItem);
} else if (type == ElementType::NET) { } else if (type == ElementType::NET) {
IdString c = static_cast<IdStringTreeItem *>(item)->getData(); IdString c = static_cast<IdStringTreeItem *>(item)->getData();
NetInfo *net = ctx->nets.at(c).get(); NetInfo *net = ctx->nets.at(c).get();
QtVariantProperty *topItem = readOnlyManager->addProperty(QVariant::String, QString("Name")); QtProperty *topItem = groupManager->addProperty("Net");
topItem->setValue(QString(net->name.c_str(ctx))); addProperty(topItem, "Net");
addProperty(topItem, QString("Name"));
QtVariantProperty *portItem = readOnlyManager->addProperty(QVariant::String, QString("Port")); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
portItem->setValue(QString(net->driver.port.c_str(ctx))); nameItem->setValue(net->name.c_str(ctx));
addProperty(portItem, QString("Port")); topItem->addSubProperty(nameItem);
QtProperty *driverItem = groupManager->addProperty("Driver");
topItem->addSubProperty(driverItem);
QtVariantProperty *portItem = readOnlyManager->addProperty(QVariant::String, "Port");
portItem->setValue(net->driver.port.c_str(ctx));
driverItem->addSubProperty(portItem);
QtVariantProperty *budgetItem = readOnlyManager->addProperty(QVariant::Double, QString("Budget")); QtVariantProperty *budgetItem = readOnlyManager->addProperty(QVariant::Double, "Budget");
budgetItem->setValue(net->driver.budget); budgetItem->setValue(net->driver.budget);
addProperty(budgetItem, QString("Budget")); driverItem->addSubProperty(budgetItem);
if (net->driver.cell) { if (net->driver.cell) {
CellInfo *cell = net->driver.cell; CellInfo *cell = net->driver.cell;
QtProperty *cellItem = groupManager->addProperty(QString("Cell"));
addProperty(cellItem, QString("Cell")); QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell");
cellNameItem->setValue(cell->name.c_str(ctx));
driverItem->addSubProperty(cellNameItem);
}
QtProperty *usersItem = groupManager->addProperty("Users");
topItem->addSubProperty(usersItem);
for(auto &item : net->users)
{
QtProperty *portItem = groupManager->addProperty(item.port.c_str(ctx));
usersItem->addSubProperty(portItem);
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, QString("Name")); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Port");
cellNameItem->setValue(QString(cell->name.c_str(ctx))); nameItem->setValue(item.port.c_str(ctx));
cellItem->addSubProperty(cellNameItem); portItem->addSubProperty(nameItem);
QtVariantProperty *cellTypeItem = readOnlyManager->addProperty(QVariant::String, QString("Type")); QtVariantProperty *budgetItem = readOnlyManager->addProperty(QVariant::Double, "Budget");
cellTypeItem->setValue(QString(cell->type.c_str(ctx))); budgetItem->setValue(item.budget);
cellItem->addSubProperty(cellTypeItem); portItem->addSubProperty(budgetItem);
QtProperty *cellPortsItem = groupManager->addProperty(QString("Ports")); QtVariantProperty *userItem = readOnlyManager->addProperty(QVariant::String, "Cell");
cellItem->addSubProperty(cellPortsItem); if (item.cell)
for(auto &item : cell->ports) userItem->setValue(item.cell->name.c_str(ctx));
{ else
PortInfo p = item.second; userItem->setValue("");
portItem->addSubProperty(userItem);
QtProperty *portInfoItem = groupManager->addProperty(QString(p.name.c_str(ctx))); }
QtVariantProperty *portInfoNameItem = readOnlyManager->addProperty(QVariant::String, QString("Name")); QtProperty *attrsItem = groupManager->addProperty("Attributes");
portInfoNameItem->setValue(QString(p.name.c_str(ctx))); topItem->addSubProperty(attrsItem);
portInfoItem->addSubProperty(portInfoNameItem); for(auto &item : net->attrs)
{
QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx));
attrItem->setValue(item.second.c_str());
attrsItem->addSubProperty(attrItem);
}
QtVariantProperty *portInfoTypeItem = readOnlyManager->addProperty(QVariant::Int, QString("Type")); QtProperty *wiresItem = groupManager->addProperty("Wires");
portInfoTypeItem->setValue(int(p.type)); topItem->addSubProperty(wiresItem);
portInfoItem->addSubProperty(portInfoTypeItem); for(auto &item : net->wires)
{
auto name = ctx->getWireName(item.first).c_str(ctx);
cellPortsItem->addSubProperty(portInfoItem); QtProperty *wireItem = groupManager->addProperty(name);
}
QtProperty *cellAttrItem = groupManager->addProperty(QString("Attributes")); QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
cellItem->addSubProperty(cellAttrItem); nameItem->setValue(name);
for(auto &item : cell->attrs) wireItem->addSubProperty(nameItem);
{
QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, QString(item.first.c_str(ctx))); QtVariantProperty *pipItem = readOnlyManager->addProperty(QVariant::String, "Pip");
attrItem->setValue(QString(item.second.c_str()));
cellAttrItem->addSubProperty(attrItem); if (item.second.pip!=PipId())
} pipItem->setValue(ctx->getPipName(item.second.pip).c_str(ctx));
else
pipItem->setValue("");
wireItem->addSubProperty(pipItem);
QtProperty *cellParamsItem = groupManager->addProperty(QString("Parameters")); QtVariantProperty *strengthItem = readOnlyManager->addProperty(QVariant::Int, "Strength");
cellItem->addSubProperty(cellParamsItem); strengthItem->setValue((int)item.second.strength);
for(auto &item : cell->params) wireItem->addSubProperty(strengthItem);
{
QtVariantProperty *paramItem = readOnlyManager->addProperty(QVariant::String, QString(item.first.c_str(ctx))); wiresItem->addSubProperty(wireItem);
paramItem->setValue(QString(item.second.c_str()));
cellParamsItem->addSubProperty(paramItem);
}
} }
} else if (type == ElementType::CELL) { } else if (type == ElementType::CELL) {
IdString c = static_cast<IdStringTreeItem *>(item)->getData(); IdString c = static_cast<IdStringTreeItem *>(item)->getData();
CellInfo *cell = ctx->cells.at(c).get();
QtProperty *topItem = groupManager->addProperty("Cell");
addProperty(topItem, "Cell");
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Name");
cellNameItem->setValue(cell->name.c_str(ctx));
topItem->addSubProperty(cellNameItem);
QtVariantProperty *cellTypeItem = readOnlyManager->addProperty(QVariant::String, "Type");
cellTypeItem->setValue(cell->type.c_str(ctx));
topItem->addSubProperty(cellTypeItem);
QtVariantProperty *cellBelItem = readOnlyManager->addProperty(QVariant::String, "Bel");
if (cell->bel!=BelId())
cellBelItem->setValue(ctx->getBelName(cell->bel).c_str(ctx));
else
cellBelItem->setValue("");
topItem->addSubProperty(cellBelItem);
QtVariantProperty *cellBelStrItem = readOnlyManager->addProperty(QVariant::Int, "Bel strength");
cellBelStrItem->setValue(int(cell->belStrength));
topItem->addSubProperty(cellBelStrItem);
QtProperty *cellPortsItem = groupManager->addProperty("Ports");
topItem->addSubProperty(cellPortsItem);
for(auto &item : cell->ports)
{
PortInfo p = item.second;
QtProperty *portInfoItem = groupManager->addProperty(p.name.c_str(ctx));
QtVariantProperty *portInfoNameItem = readOnlyManager->addProperty(QVariant::String, "Name");
portInfoNameItem->setValue(p.name.c_str(ctx));
portInfoItem->addSubProperty(portInfoNameItem);
QtVariantProperty *portInfoTypeItem = readOnlyManager->addProperty(QVariant::Int, "Type");
portInfoTypeItem->setValue(int(p.type));
portInfoItem->addSubProperty(portInfoTypeItem);
QtVariantProperty *portInfoNetItem = readOnlyManager->addProperty(QVariant::String, "Net");
if (p.net)
portInfoNetItem->setValue(p.net->name.c_str(ctx));
else
portInfoNetItem->setValue("");
portInfoItem->addSubProperty(portInfoNetItem);
cellPortsItem->addSubProperty(portInfoItem);
}
QtProperty *cellAttrItem = groupManager->addProperty("Attributes");
topItem->addSubProperty(cellAttrItem);
for(auto &item : cell->attrs)
{
QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx));
attrItem->setValue(item.second.c_str());
cellAttrItem->addSubProperty(attrItem);
}
QtProperty *cellParamsItem = groupManager->addProperty("Parameters");
topItem->addSubProperty(cellParamsItem);
for(auto &item : cell->params)
{
QtVariantProperty *paramItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx));
paramItem->setValue(item.second.c_str());
cellParamsItem->addSubProperty(paramItem);
}
QtProperty *cellPinsItem = groupManager->addProperty("Pins");
topItem->addSubProperty(cellPinsItem);
for(auto &item : cell->pins)
{
std::string cell_port = item.first.c_str(ctx);
std::string bel_pin = item.second.c_str(ctx);
QtProperty *pinGroupItem = groupManager->addProperty((cell_port + " -> " + bel_pin).c_str());
QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Cell");
cellItem->setValue(cell_port.c_str());
pinGroupItem->addSubProperty(cellItem);
QtVariantProperty *belItem = readOnlyManager->addProperty(QVariant::String, "Bel");
belItem->setValue(bel_pin.c_str());
pinGroupItem->addSubProperty(belItem);
cellPinsItem->addSubProperty(pinGroupItem);
}
QtVariantProperty *topItem = readOnlyManager->addProperty(QVariant::String, QString("Name"));
topItem->setValue(QString(c.c_str(ctx)));
addProperty(topItem, QString("Name"));
} }
} }