From 6b904aefd36192dd94bef727634c287845ef5062 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 5 Jul 2018 20:06:12 +0200 Subject: Display nets and cells as well --- gui/basewindow.cc | 1 + gui/basewindow.h | 1 + gui/designwidget.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++- gui/designwidget.h | 3 +++ gui/ice40/mainwindow.cc | 4 ++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 5d2e21cc..2463027a 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -69,6 +69,7 @@ BaseMainWindow::BaseMainWindow(QWidget *parent) : QMainWindow(parent), ctx(nullp splitter_h->addWidget(designview); connect(this, SIGNAL(contextChanged(Context *)), designview, SLOT(newContext(Context *))); + connect(this, SIGNAL(updateTreeView()), designview, SLOT(updateTree())); connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string))); diff --git a/gui/basewindow.h b/gui/basewindow.h index 6180e795..5c06fa6e 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -55,6 +55,7 @@ class BaseMainWindow : public QMainWindow Q_SIGNALS: void contextChanged(Context *ctx); + void updateTreeView(); protected: Context *ctx; diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 4656be02..48a05ed4 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -83,7 +83,7 @@ class PipTreeItem : public ElementTreeItem IdString data; }; -DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) +DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), nets_root(nullptr), cells_root(nullptr) { treeWidget = new QTreeWidget(); @@ -217,6 +217,56 @@ void DesignWidget::newContext(Context *ctx) for (auto pip : pip_items.toStdMap()) { pip_root->addChild(pip.second); } + + // Add nets to tree + nets_root = new QTreeWidgetItem(treeWidget); + nets_root->setText(0, QString("Nets")); + treeWidget->insertTopLevelItem(0, nets_root); + + // Add cells to tree + cells_root = new QTreeWidgetItem(treeWidget); + cells_root->setText(0, QString("Cells")); + treeWidget->insertTopLevelItem(0, cells_root); + +} + +void DesignWidget::updateTree() +{ + delete nets_root; + delete cells_root; + + // Add nets to tree + nets_root = new QTreeWidgetItem(treeWidget); + QMap nets_items; + nets_root->setText(0, QString("Nets")); + treeWidget->insertTopLevelItem(0, nets_root); + if (ctx) { + for (auto& item : ctx->nets) { + auto id = item.first; + QString name = QString(id.c_str(ctx)); + nets_items.insert(name,new ElementTreeItem(ElementType::NONE, name, nullptr)); + } + } + for (auto item : nets_items.toStdMap()) { + nets_root->addChild(item.second); + } + + // Add cells to tree + cells_root = new QTreeWidgetItem(treeWidget); + QMap cells_items; + cells_root->setText(0, QString("Cells")); + treeWidget->insertTopLevelItem(0, cells_root); + if (ctx) { + for (auto& item : ctx->cells) { + auto id = item.first; + QString name = QString(id.c_str(ctx)); + cells_items.insert(name,new ElementTreeItem(ElementType::NONE, name, nullptr)); + } + } + for (auto item : cells_items.toStdMap()) { + cells_root->addChild(item.second); + } + } void DesignWidget::addProperty(QtVariantProperty *property, const QString &id) diff --git a/gui/designwidget.h b/gui/designwidget.h index e3fbb19e..8e4be062 100644 --- a/gui/designwidget.h +++ b/gui/designwidget.h @@ -49,6 +49,7 @@ class DesignWidget : public QWidget void selectObject(); public Q_SLOTS: void newContext(Context *ctx); + void updateTree(); private: Context *ctx; @@ -62,6 +63,8 @@ class DesignWidget : public QWidget QMap propertyToId; QMap idToProperty; + QTreeWidgetItem *nets_root; + QTreeWidgetItem *cells_root; }; NEXTPNR_NAMESPACE_END diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index c89b5d2d..6cc8bc38 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -272,6 +272,7 @@ void MainWindow::loadfile_finished(bool status) log("Loading design successful.\n"); actionLoadPCF->setEnabled(true); actionPack->setEnabled(true); + Q_EMIT updateTreeView(); } else { log("Loading design failed.\n"); } @@ -303,6 +304,7 @@ void MainWindow::pack_finished(bool status) disableActions(); if (status) { log("Packing design successful.\n"); + Q_EMIT updateTreeView(); actionPlace->setEnabled(true); actionAssignBudget->setEnabled(true); } else { @@ -326,6 +328,7 @@ void MainWindow::place_finished(bool status) disableActions(); if (status) { log("Placing design successful.\n"); + Q_EMIT updateTreeView(); actionRoute->setEnabled(true); } else { log("Placing design failed.\n"); @@ -336,6 +339,7 @@ void MainWindow::route_finished(bool status) disableActions(); if (status) { log("Routing design successful.\n"); + Q_EMIT updateTreeView(); actionSaveAsc->setEnabled(true); } else log("Routing design failed.\n"); -- cgit v1.2.3