clang format and some cleanup
This commit is contained in:
parent
cc901d67f5
commit
7a741b66a1
@ -40,7 +40,10 @@ enum class ElementType
|
||||
class ElementTreeItem : public QTreeWidgetItem
|
||||
{
|
||||
public:
|
||||
ElementTreeItem(ElementType t, QString str, QTreeWidgetItem *parent) : QTreeWidgetItem(parent, QStringList(str)), type(t) {}
|
||||
ElementTreeItem(ElementType t, QString str, QTreeWidgetItem *parent)
|
||||
: QTreeWidgetItem(parent, QStringList(str)), type(t)
|
||||
{
|
||||
}
|
||||
virtual ~ElementTreeItem(){};
|
||||
|
||||
ElementType getType() { return type; };
|
||||
@ -52,7 +55,10 @@ class ElementTreeItem : public QTreeWidgetItem
|
||||
class IdStringTreeItem : public ElementTreeItem
|
||||
{
|
||||
public:
|
||||
IdStringTreeItem(IdString d, ElementType t, QString str, QTreeWidgetItem *parent) : ElementTreeItem(t, str, parent) { this->data = d; }
|
||||
IdStringTreeItem(IdString d, ElementType t, QString str, QTreeWidgetItem *parent) : ElementTreeItem(t, str, parent)
|
||||
{
|
||||
this->data = d;
|
||||
}
|
||||
virtual ~IdStringTreeItem(){};
|
||||
|
||||
IdString getData() { return this->data; };
|
||||
@ -61,7 +67,6 @@ class IdStringTreeItem : public ElementTreeItem
|
||||
IdString data;
|
||||
};
|
||||
|
||||
|
||||
DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), nets_root(nullptr), cells_root(nullptr)
|
||||
{
|
||||
|
||||
@ -99,9 +104,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net
|
||||
connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), SLOT(onItemClicked(QTreeWidgetItem *, int)));
|
||||
}
|
||||
|
||||
DesignWidget::~DesignWidget()
|
||||
{
|
||||
}
|
||||
DesignWidget::~DesignWidget() {}
|
||||
|
||||
void DesignWidget::newContext(Context *ctx)
|
||||
{
|
||||
@ -112,28 +115,28 @@ void DesignWidget::newContext(Context *ctx)
|
||||
QTreeWidgetItem *bel_root = new QTreeWidgetItem(treeWidget);
|
||||
QMap<QString, QTreeWidgetItem *> bel_items;
|
||||
bel_root->setText(0, "Bels");
|
||||
treeWidget->insertTopLevelItem(0, bel_root);
|
||||
treeWidget->insertTopLevelItem(0, bel_root);
|
||||
if (ctx) {
|
||||
for (auto bel : ctx->getBels()) {
|
||||
auto id = ctx->getBelName(bel);
|
||||
QStringList items = QString(id.c_str(ctx)).split("/");
|
||||
QString name;
|
||||
QTreeWidgetItem *parent = nullptr;
|
||||
for(int i=0;i<items.size();i++)
|
||||
{
|
||||
if (!name.isEmpty()) name += "/";
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (!name.isEmpty())
|
||||
name += "/";
|
||||
name += items.at(i);
|
||||
if (!bel_items.contains(name)) {
|
||||
if (i==items.size()-1)
|
||||
bel_items.insert(name,new IdStringTreeItem(id, ElementType::BEL, items.at(i),parent));
|
||||
if (i == items.size() - 1)
|
||||
bel_items.insert(name, new IdStringTreeItem(id, ElementType::BEL, items.at(i), parent));
|
||||
else
|
||||
bel_items.insert(name,new ElementTreeItem(ElementType::NONE, items.at(i),parent));
|
||||
}
|
||||
bel_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
|
||||
}
|
||||
parent = bel_items[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto bel : bel_items.toStdMap()) {
|
||||
for (auto bel : bel_items.toStdMap()) {
|
||||
bel_root->addChild(bel.second);
|
||||
}
|
||||
|
||||
@ -141,28 +144,28 @@ void DesignWidget::newContext(Context *ctx)
|
||||
QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget);
|
||||
QMap<QString, QTreeWidgetItem *> wire_items;
|
||||
wire_root->setText(0, "Wires");
|
||||
treeWidget->insertTopLevelItem(0, wire_root);
|
||||
treeWidget->insertTopLevelItem(0, wire_root);
|
||||
if (ctx) {
|
||||
for (auto wire : ctx->getWires()) {
|
||||
auto id = ctx->getWireName(wire);
|
||||
QStringList items = QString(id.c_str(ctx)).split("/");
|
||||
QString name;
|
||||
QTreeWidgetItem *parent = nullptr;
|
||||
for(int i=0;i<items.size();i++)
|
||||
{
|
||||
if (!name.isEmpty()) name += "/";
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (!name.isEmpty())
|
||||
name += "/";
|
||||
name += items.at(i);
|
||||
if (!wire_items.contains(name)) {
|
||||
if (i==items.size()-1)
|
||||
wire_items.insert(name,new IdStringTreeItem(id, ElementType::WIRE, items.at(i),parent));
|
||||
if (i == items.size() - 1)
|
||||
wire_items.insert(name, new IdStringTreeItem(id, ElementType::WIRE, items.at(i), parent));
|
||||
else
|
||||
wire_items.insert(name,new ElementTreeItem(ElementType::NONE, items.at(i),parent));
|
||||
}
|
||||
wire_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
|
||||
}
|
||||
parent = wire_items[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto wire : wire_items.toStdMap()) {
|
||||
for (auto wire : wire_items.toStdMap()) {
|
||||
wire_root->addChild(wire.second);
|
||||
}
|
||||
|
||||
@ -177,34 +180,33 @@ void DesignWidget::newContext(Context *ctx)
|
||||
QStringList items = QString(id.c_str(ctx)).split("/");
|
||||
QString name;
|
||||
QTreeWidgetItem *parent = nullptr;
|
||||
for(int i=0;i<items.size();i++)
|
||||
{
|
||||
if (!name.isEmpty()) name += "/";
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (!name.isEmpty())
|
||||
name += "/";
|
||||
name += items.at(i);
|
||||
if (!pip_items.contains(name)) {
|
||||
if (i==items.size()-1)
|
||||
pip_items.insert(name,new IdStringTreeItem(id, ElementType::PIP, items.at(i),parent));
|
||||
if (i == items.size() - 1)
|
||||
pip_items.insert(name, new IdStringTreeItem(id, ElementType::PIP, items.at(i), parent));
|
||||
else
|
||||
pip_items.insert(name,new ElementTreeItem(ElementType::NONE, items.at(i),parent));
|
||||
}
|
||||
pip_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent));
|
||||
}
|
||||
parent = pip_items[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto pip : pip_items.toStdMap()) {
|
||||
for (auto pip : pip_items.toStdMap()) {
|
||||
pip_root->addChild(pip.second);
|
||||
}
|
||||
|
||||
// Add nets to tree
|
||||
nets_root = new QTreeWidgetItem(treeWidget);
|
||||
nets_root->setText(0, "Nets");
|
||||
treeWidget->insertTopLevelItem(0, nets_root);
|
||||
treeWidget->insertTopLevelItem(0, nets_root);
|
||||
|
||||
// Add cells to tree
|
||||
cells_root = new QTreeWidgetItem(treeWidget);
|
||||
cells_root->setText(0, "Cells");
|
||||
treeWidget->insertTopLevelItem(0, cells_root);
|
||||
|
||||
treeWidget->insertTopLevelItem(0, cells_root);
|
||||
}
|
||||
|
||||
void DesignWidget::updateTree()
|
||||
@ -217,34 +219,33 @@ void DesignWidget::updateTree()
|
||||
nets_root = new QTreeWidgetItem(treeWidget);
|
||||
QMap<QString, QTreeWidgetItem *> nets_items;
|
||||
nets_root->setText(0, "Nets");
|
||||
treeWidget->insertTopLevelItem(0, nets_root);
|
||||
treeWidget->insertTopLevelItem(0, nets_root);
|
||||
if (ctx) {
|
||||
for (auto& item : ctx->nets) {
|
||||
for (auto &item : ctx->nets) {
|
||||
auto id = item.first;
|
||||
QString name = QString(id.c_str(ctx));
|
||||
nets_items.insert(name, new IdStringTreeItem(id, ElementType::NET, name, nullptr));
|
||||
}
|
||||
}
|
||||
for (auto item : nets_items.toStdMap()) {
|
||||
for (auto item : nets_items.toStdMap()) {
|
||||
nets_root->addChild(item.second);
|
||||
}
|
||||
}
|
||||
|
||||
// Add cells to tree
|
||||
cells_root = new QTreeWidgetItem(treeWidget);
|
||||
QMap<QString, QTreeWidgetItem *> cells_items;
|
||||
cells_root->setText(0, "Cells");
|
||||
treeWidget->insertTopLevelItem(0, cells_root);
|
||||
treeWidget->insertTopLevelItem(0, cells_root);
|
||||
if (ctx) {
|
||||
for (auto& item : ctx->cells) {
|
||||
for (auto &item : ctx->cells) {
|
||||
auto id = item.first;
|
||||
QString name = QString(id.c_str(ctx));
|
||||
cells_items.insert(name,new IdStringTreeItem(id, ElementType::CELL,name, nullptr));
|
||||
cells_items.insert(name, new IdStringTreeItem(id, ElementType::CELL, name, nullptr));
|
||||
}
|
||||
}
|
||||
for (auto item : cells_items.toStdMap()) {
|
||||
for (auto item : cells_items.toStdMap()) {
|
||||
cells_root->addChild(item.second);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DesignWidget::addProperty(QtProperty *property, const QString &id)
|
||||
@ -270,12 +271,11 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
if (!item->parent())
|
||||
return;
|
||||
|
||||
|
||||
ElementType type = static_cast<ElementTreeItem *>(item)->getType();
|
||||
if (type == ElementType::NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
clearProperties();
|
||||
if (type == ElementType::BEL) {
|
||||
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||
@ -295,7 +295,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
} else if (type == ElementType::WIRE) {
|
||||
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||
|
||||
QtProperty *topItem = groupManager->addProperty("Wire");
|
||||
QtProperty *topItem = groupManager->addProperty("Wire");
|
||||
addProperty(topItem, "Wire");
|
||||
|
||||
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
|
||||
@ -305,7 +305,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
} else if (type == ElementType::PIP) {
|
||||
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||
|
||||
QtProperty *topItem = groupManager->addProperty("Pip");
|
||||
QtProperty *topItem = groupManager->addProperty("Pip");
|
||||
addProperty(topItem, "Pip");
|
||||
|
||||
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
|
||||
@ -316,36 +316,35 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||
NetInfo *net = ctx->nets.at(c).get();
|
||||
|
||||
QtProperty *topItem = groupManager->addProperty("Net");
|
||||
QtProperty *topItem = groupManager->addProperty("Net");
|
||||
addProperty(topItem, "Net");
|
||||
|
||||
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
|
||||
nameItem->setValue(net->name.c_str(ctx));
|
||||
topItem->addSubProperty(nameItem);
|
||||
|
||||
QtProperty *driverItem = groupManager->addProperty("Driver");
|
||||
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, "Budget");
|
||||
budgetItem->setValue(net->driver.budget);
|
||||
driverItem->addSubProperty(budgetItem);
|
||||
|
||||
if (net->driver.cell) {
|
||||
CellInfo *cell = net->driver.cell;
|
||||
|
||||
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell");
|
||||
cellNameItem->setValue(cell->name.c_str(ctx));
|
||||
driverItem->addSubProperty(cellNameItem);
|
||||
}
|
||||
QtProperty *usersItem = groupManager->addProperty("Users");
|
||||
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell");
|
||||
if (net->driver.cell)
|
||||
cellNameItem->setValue(net->driver.cell->name.c_str(ctx));
|
||||
else
|
||||
cellNameItem->setValue("");
|
||||
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));
|
||||
for (auto &item : net->users) {
|
||||
QtProperty *portItem = groupManager->addProperty(item.port.c_str(ctx));
|
||||
usersItem->addSubProperty(portItem);
|
||||
|
||||
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Port");
|
||||
@ -364,30 +363,28 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
portItem->addSubProperty(userItem);
|
||||
}
|
||||
|
||||
QtProperty *attrsItem = groupManager->addProperty("Attributes");
|
||||
QtProperty *attrsItem = groupManager->addProperty("Attributes");
|
||||
topItem->addSubProperty(attrsItem);
|
||||
for(auto &item : net->attrs)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
QtProperty *wiresItem = groupManager->addProperty("Wires");
|
||||
QtProperty *wiresItem = groupManager->addProperty("Wires");
|
||||
topItem->addSubProperty(wiresItem);
|
||||
for(auto &item : net->wires)
|
||||
{
|
||||
for (auto &item : net->wires) {
|
||||
auto name = ctx->getWireName(item.first).c_str(ctx);
|
||||
|
||||
QtProperty *wireItem = groupManager->addProperty(name);
|
||||
QtProperty *wireItem = groupManager->addProperty(name);
|
||||
|
||||
QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name");
|
||||
nameItem->setValue(name);
|
||||
wireItem->addSubProperty(nameItem);
|
||||
|
||||
|
||||
QtVariantProperty *pipItem = readOnlyManager->addProperty(QVariant::String, "Pip");
|
||||
|
||||
if (item.second.pip!=PipId())
|
||||
|
||||
if (item.second.pip != PipId())
|
||||
pipItem->setValue(ctx->getPipName(item.second.pip).c_str(ctx));
|
||||
else
|
||||
pipItem->setValue("");
|
||||
@ -397,14 +394,14 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
strengthItem->setValue((int)item.second.strength);
|
||||
wireItem->addSubProperty(strengthItem);
|
||||
|
||||
wiresItem->addSubProperty(wireItem);
|
||||
wiresItem->addSubProperty(wireItem);
|
||||
}
|
||||
|
||||
} else if (type == ElementType::CELL) {
|
||||
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||
CellInfo *cell = ctx->cells.at(c).get();
|
||||
|
||||
QtProperty *topItem = groupManager->addProperty("Cell");
|
||||
QtProperty *topItem = groupManager->addProperty("Cell");
|
||||
addProperty(topItem, "Cell");
|
||||
|
||||
QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Name");
|
||||
@ -414,9 +411,9 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
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())
|
||||
if (cell->bel != BelId())
|
||||
cellBelItem->setValue(ctx->getBelName(cell->bel).c_str(ctx));
|
||||
else
|
||||
cellBelItem->setValue("");
|
||||
@ -428,10 +425,9 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
|
||||
QtProperty *cellPortsItem = groupManager->addProperty("Ports");
|
||||
topItem->addSubProperty(cellPortsItem);
|
||||
for(auto &item : cell->ports)
|
||||
{
|
||||
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");
|
||||
@ -445,7 +441,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
QtVariantProperty *portInfoNetItem = readOnlyManager->addProperty(QVariant::String, "Net");
|
||||
if (p.net)
|
||||
portInfoNetItem->setValue(p.net->name.c_str(ctx));
|
||||
else
|
||||
else
|
||||
portInfoNetItem->setValue("");
|
||||
portInfoItem->addSubProperty(portInfoNetItem);
|
||||
|
||||
@ -454,8 +450,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
|
||||
QtProperty *cellAttrItem = groupManager->addProperty("Attributes");
|
||||
topItem->addSubProperty(cellAttrItem);
|
||||
for(auto &item : cell->attrs)
|
||||
{
|
||||
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);
|
||||
@ -463,18 +458,15 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
|
||||
QtProperty *cellParamsItem = groupManager->addProperty("Parameters");
|
||||
topItem->addSubProperty(cellParamsItem);
|
||||
for(auto &item : cell->params)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (auto &item : cell->pins) {
|
||||
std::string cell_port = item.first.c_str(ctx);
|
||||
std::string bel_pin = item.second.c_str(ctx);
|
||||
|
||||
@ -489,8 +481,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
||||
pinGroupItem->addSubProperty(belItem);
|
||||
|
||||
cellPinsItem->addSubProperty(pinGroupItem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include "nextpnr.h"
|
||||
#include "qtgroupboxpropertybrowser.h"
|
||||
#include "qtpropertymanager.h"
|
||||
#include "qttreepropertybrowser.h"
|
||||
#include "qtvariantproperty.h"
|
||||
#include "qtgroupboxpropertybrowser.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -249,7 +249,7 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
|
||||
setFormat(fmt);
|
||||
|
||||
fmt = format();
|
||||
//printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), fmt.minorVersion());
|
||||
// printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), fmt.minorVersion());
|
||||
if (fmt.majorVersion() < 3) {
|
||||
printf("Could not get OpenGL 3.0 context. Aborting.\n");
|
||||
log_abort();
|
||||
|
@ -34,8 +34,7 @@ NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
// Vertex2DPOD is a structure of X, Y coordinates that can be passed to OpenGL
|
||||
// directly.
|
||||
NPNR_PACKED_STRUCT(struct Vertex2DPOD
|
||||
{
|
||||
NPNR_PACKED_STRUCT(struct Vertex2DPOD {
|
||||
GLfloat x;
|
||||
GLfloat y;
|
||||
|
||||
@ -44,8 +43,7 @@ NPNR_PACKED_STRUCT(struct Vertex2DPOD
|
||||
|
||||
// Vertex2DPOD is a structure of R, G, B, A values that can be passed to OpenGL
|
||||
// directly.
|
||||
NPNR_PACKED_STRUCT(struct ColorPOD
|
||||
{
|
||||
NPNR_PACKED_STRUCT(struct ColorPOD {
|
||||
GLfloat r;
|
||||
GLfloat g;
|
||||
GLfloat b;
|
||||
|
Loading…
Reference in New Issue
Block a user