display properties for nets and cells and simplify types
This commit is contained in:
parent
6b904aefd3
commit
d119206ffd
@ -32,7 +32,9 @@ enum class ElementType
|
|||||||
NONE,
|
NONE,
|
||||||
BEL,
|
BEL,
|
||||||
WIRE,
|
WIRE,
|
||||||
PIP
|
PIP,
|
||||||
|
NET,
|
||||||
|
CELL
|
||||||
};
|
};
|
||||||
|
|
||||||
class ElementTreeItem : public QTreeWidgetItem
|
class ElementTreeItem : public QTreeWidgetItem
|
||||||
@ -47,11 +49,11 @@ class ElementTreeItem : public QTreeWidgetItem
|
|||||||
ElementType type;
|
ElementType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BelTreeItem : public ElementTreeItem
|
class IdStringTreeItem : public ElementTreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BelTreeItem(IdString d, QString str, QTreeWidgetItem *parent) : ElementTreeItem(ElementType::BEL, str, parent) { this->data = d; }
|
IdStringTreeItem(IdString d, ElementType t, QString str, QTreeWidgetItem *parent) : ElementTreeItem(t, str, parent) { this->data = d; }
|
||||||
virtual ~BelTreeItem(){};
|
virtual ~IdStringTreeItem(){};
|
||||||
|
|
||||||
IdString getData() { return this->data; };
|
IdString getData() { return this->data; };
|
||||||
|
|
||||||
@ -59,29 +61,6 @@ class BelTreeItem : public ElementTreeItem
|
|||||||
IdString data;
|
IdString data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WireTreeItem : public ElementTreeItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WireTreeItem(IdString d, QString str, QTreeWidgetItem *parent) : ElementTreeItem(ElementType::WIRE, str, parent) { this->data = d; }
|
|
||||||
virtual ~WireTreeItem(){};
|
|
||||||
|
|
||||||
IdString getData() { return this->data; };
|
|
||||||
|
|
||||||
private:
|
|
||||||
IdString data;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PipTreeItem : public ElementTreeItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PipTreeItem(IdString d, QString str, QTreeWidgetItem *parent) : ElementTreeItem(ElementType::PIP, str, parent) { this->data = d; }
|
|
||||||
virtual ~PipTreeItem(){};
|
|
||||||
|
|
||||||
IdString getData() { return this->data; };
|
|
||||||
|
|
||||||
private:
|
|
||||||
IdString data;
|
|
||||||
};
|
|
||||||
|
|
||||||
DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), nets_root(nullptr), cells_root(nullptr)
|
DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), nets_root(nullptr), cells_root(nullptr)
|
||||||
{
|
{
|
||||||
@ -148,7 +127,7 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
name += items.at(i);
|
name += items.at(i);
|
||||||
if (!bel_items.contains(name)) {
|
if (!bel_items.contains(name)) {
|
||||||
if (i==items.size()-1)
|
if (i==items.size()-1)
|
||||||
bel_items.insert(name,new BelTreeItem(id, items.at(i),parent));
|
bel_items.insert(name,new IdStringTreeItem(id, ElementType::BEL, items.at(i),parent));
|
||||||
else
|
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));
|
||||||
}
|
}
|
||||||
@ -177,7 +156,7 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
name += items.at(i);
|
name += items.at(i);
|
||||||
if (!wire_items.contains(name)) {
|
if (!wire_items.contains(name)) {
|
||||||
if (i==items.size()-1)
|
if (i==items.size()-1)
|
||||||
wire_items.insert(name,new WireTreeItem(id, items.at(i),parent));
|
wire_items.insert(name,new IdStringTreeItem(id, ElementType::WIRE, items.at(i),parent));
|
||||||
else
|
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));
|
||||||
}
|
}
|
||||||
@ -206,7 +185,7 @@ void DesignWidget::newContext(Context *ctx)
|
|||||||
name += items.at(i);
|
name += items.at(i);
|
||||||
if (!pip_items.contains(name)) {
|
if (!pip_items.contains(name)) {
|
||||||
if (i==items.size()-1)
|
if (i==items.size()-1)
|
||||||
pip_items.insert(name,new PipTreeItem(id, items.at(i),parent));
|
pip_items.insert(name,new IdStringTreeItem(id, ElementType::PIP, items.at(i),parent));
|
||||||
else
|
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));
|
||||||
}
|
}
|
||||||
@ -244,7 +223,7 @@ void DesignWidget::updateTree()
|
|||||||
for (auto& item : ctx->nets) {
|
for (auto& item : ctx->nets) {
|
||||||
auto id = item.first;
|
auto id = item.first;
|
||||||
QString name = QString(id.c_str(ctx));
|
QString name = QString(id.c_str(ctx));
|
||||||
nets_items.insert(name,new ElementTreeItem(ElementType::NONE, name, nullptr));
|
nets_items.insert(name, new IdStringTreeItem(id, ElementType::NET, name, nullptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto item : nets_items.toStdMap()) {
|
for (auto item : nets_items.toStdMap()) {
|
||||||
@ -260,7 +239,7 @@ void DesignWidget::updateTree()
|
|||||||
for (auto& item : ctx->cells) {
|
for (auto& item : ctx->cells) {
|
||||||
auto id = item.first;
|
auto id = item.first;
|
||||||
QString name = QString(id.c_str(ctx));
|
QString name = QString(id.c_str(ctx));
|
||||||
cells_items.insert(name,new ElementTreeItem(ElementType::NONE, 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()) {
|
||||||
@ -300,7 +279,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
|||||||
|
|
||||||
clearProperties();
|
clearProperties();
|
||||||
if (type == ElementType::BEL) {
|
if (type == ElementType::BEL) {
|
||||||
IdString c = static_cast<BelTreeItem *>(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 = variantManager->addProperty(QVariant::String, QString("Name"));
|
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
||||||
@ -312,14 +291,27 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
|
|||||||
addProperty(typeItem, QString("Type"));
|
addProperty(typeItem, QString("Type"));
|
||||||
|
|
||||||
} else if (type == ElementType::WIRE) {
|
} else if (type == ElementType::WIRE) {
|
||||||
IdString c = static_cast<WireTreeItem *>(item)->getData();
|
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||||
|
|
||||||
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
||||||
topItem->setValue(QString(c.c_str(ctx)));
|
topItem->setValue(QString(c.c_str(ctx)));
|
||||||
addProperty(topItem, QString("Name"));
|
addProperty(topItem, QString("Name"));
|
||||||
|
|
||||||
} else if (type == ElementType::PIP) {
|
} else if (type == ElementType::PIP) {
|
||||||
IdString c = static_cast<PipTreeItem *>(item)->getData();
|
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||||
|
|
||||||
|
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
||||||
|
topItem->setValue(QString(c.c_str(ctx)));
|
||||||
|
addProperty(topItem, QString("Name"));
|
||||||
|
} else if (type == ElementType::NET) {
|
||||||
|
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||||
|
|
||||||
|
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
||||||
|
topItem->setValue(QString(c.c_str(ctx)));
|
||||||
|
addProperty(topItem, QString("Name"));
|
||||||
|
|
||||||
|
} else if (type == ElementType::CELL) {
|
||||||
|
IdString c = static_cast<IdStringTreeItem *>(item)->getData();
|
||||||
|
|
||||||
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
|
||||||
topItem->setValue(QString(c.c_str(ctx)));
|
topItem->setValue(QString(c.c_str(ctx)));
|
||||||
|
Loading…
Reference in New Issue
Block a user