Add options to enable/disable displayed elements

This commit is contained in:
Miodrag Milanovic 2019-12-20 15:25:10 +01:00
parent a05954249a
commit d399346de0
9 changed files with 105 additions and 16 deletions

View File

@ -24,5 +24,9 @@
<file>resources/open_json.png</file>
<file>resources/save_json.png</file>
<file>resources/py.png</file>
<file>resources/bel.png</file>
<file>resources/wire.png</file>
<file>resources/pip.png</file>
<file>resources/group.png</file>
</qresource>
</RCC>

View File

@ -225,6 +225,38 @@ void BaseMainWindow::createMenusAndBars()
actionZoomOutbound->setIcon(QIcon(":/icons/resources/shape_square.png"));
connect(actionZoomOutbound, &QAction::triggered, fpgaView, &FPGAViewWidget::zoomOutbound);
actionDisplayBel = new QAction("Enable/Disable Bels", this);
actionDisplayBel->setIcon(QIcon(":/icons/resources/bel.png"));
actionDisplayBel->setCheckable(true);
actionDisplayBel->setChecked(true);
connect(actionDisplayBel, &QAction::triggered, this, &BaseMainWindow::enableDisableDecals);
actionDisplayWire = new QAction("Enable/Disable Wires", this);
actionDisplayWire->setIcon(QIcon(":/icons/resources/wire.png"));
actionDisplayWire->setCheckable(true);
actionDisplayWire->setChecked(true);
connect(actionDisplayWire, &QAction::triggered, this, &BaseMainWindow::enableDisableDecals);
actionDisplayPip = new QAction("Enable/Disable Pips", this);
actionDisplayPip->setIcon(QIcon(":/icons/resources/pip.png"));
actionDisplayPip->setCheckable(true);
#ifdef ARCH_ECP5
actionDisplayPip->setChecked(false);
#else
actionDisplayPip->setChecked(true);
#endif
connect(actionDisplayPip, &QAction::triggered, this, &BaseMainWindow::enableDisableDecals);
actionDisplayGroups = new QAction("Enable/Disable Groups", this);
actionDisplayGroups->setIcon(QIcon(":/icons/resources/group.png"));
actionDisplayGroups->setCheckable(true);
actionDisplayGroups->setChecked(true);
connect(actionDisplayGroups, &QAction::triggered, this, &BaseMainWindow::enableDisableDecals);
// set initial state
fpgaView->enableDisableDecals(actionDisplayBel->isChecked(), actionDisplayWire->isChecked(),
actionDisplayPip->isChecked(), actionDisplayGroups->isChecked());
// Add main menu
menuBar = new QMenuBar();
menuBar->setGeometry(QRect(0, 0, 1024, 27));
@ -281,6 +313,11 @@ void BaseMainWindow::createMenusAndBars()
deviceViewToolBar->addAction(actionZoomOut);
deviceViewToolBar->addAction(actionZoomSelected);
deviceViewToolBar->addAction(actionZoomOutbound);
deviceViewToolBar->addSeparator();
deviceViewToolBar->addAction(actionDisplayBel);
deviceViewToolBar->addAction(actionDisplayWire);
deviceViewToolBar->addAction(actionDisplayPip);
deviceViewToolBar->addAction(actionDisplayGroups);
// Add status bar with progress bar
statusBar = new QStatusBar();
@ -293,6 +330,13 @@ void BaseMainWindow::createMenusAndBars()
setStatusBar(statusBar);
}
void BaseMainWindow::enableDisableDecals()
{
fpgaView->enableDisableDecals(actionDisplayBel->isChecked(), actionDisplayWire->isChecked(),
actionDisplayPip->isChecked(), actionDisplayGroups->isChecked());
ctx->refreshUi();
}
void BaseMainWindow::open_json()
{
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));

View File

@ -56,6 +56,7 @@ class BaseMainWindow : public QMainWindow
protected:
void createMenusAndBars();
void disableActions();
void enableDisableDecals();
virtual void onDisableActions(){};
virtual void onUpdateActions(){};
@ -122,6 +123,11 @@ class BaseMainWindow : public QMainWindow
QAction *actionPlay;
QAction *actionPause;
QAction *actionStop;
QAction *actionDisplayBel;
QAction *actionDisplayWire;
QAction *actionDisplayPip;
QAction *actionDisplayGroups;
};
NEXTPNR_NAMESPACE_END

View File

@ -66,6 +66,11 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
renderRunner_->start();
renderRunner_->startTimer(1000 / 2); // render lines 2 times per second
setMouseTracking(true);
displayBel_ = false;
displayWire_ = false;
displayPip_ = false;
displayGroup_ = false;
}
FPGAViewWidget::~FPGAViewWidget() {}
@ -333,6 +338,14 @@ void FPGAViewWidget::paintGL()
void FPGAViewWidget::pokeRenderer(void) { renderRunner_->poke(); }
void FPGAViewWidget::enableDisableDecals(bool bels, bool wires, bool pips, bool groups)
{
displayBel_ = bels;
displayWire_ = wires;
displayPip_ = pips;
displayGroup_ = groups;
}
void FPGAViewWidget::renderLines(void)
{
if (ctx_ == nullptr)
@ -379,17 +392,25 @@ void FPGAViewWidget::renderLines(void)
// Local copy of decals, taken as fast as possible to not block the P&R.
if (decalsChanged) {
for (auto bel : ctx_->getBels()) {
belDecals.push_back({ctx_->getBelDecal(bel), bel});
if (displayBel_) {
for (auto bel : ctx_->getBels()) {
belDecals.push_back({ctx_->getBelDecal(bel), bel});
}
}
for (auto wire : ctx_->getWires()) {
wireDecals.push_back({ctx_->getWireDecal(wire), wire});
if (displayWire_) {
for (auto wire : ctx_->getWires()) {
wireDecals.push_back({ctx_->getWireDecal(wire), wire});
}
}
for (auto pip : ctx_->getPips()) {
pipDecals.push_back({ctx_->getPipDecal(pip), pip});
if (displayPip_) {
for (auto pip : ctx_->getPips()) {
pipDecals.push_back({ctx_->getPipDecal(pip), pip});
}
}
for (auto group : ctx_->getGroups()) {
groupDecals.push_back({ctx_->getGroupDecal(group), group});
if (displayGroup_) {
for (auto group : ctx_->getGroups()) {
groupDecals.push_back({ctx_->getGroupDecal(group), group});
}
}
}
}
@ -430,20 +451,28 @@ void FPGAViewWidget::renderLines(void)
data->bbGlobal.clear();
// Draw Bels.
for (auto const &decal : belDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
if (displayBel_) {
for (auto const &decal : belDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
}
}
// Draw Wires.
for (auto const &decal : wireDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
if (displayWire_) {
for (auto const &decal : wireDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
}
}
// Draw Pips.
for (auto const &decal : pipDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
if (displayPip_) {
for (auto const &decal : pipDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
}
}
// Draw Groups.
for (auto const &decal : groupDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
if (displayGroup_) {
for (auto const &decal : groupDecals) {
renderArchDecal(data->gfxByStyle, data->bbGlobal, decal.first);
}
}
// Bounding box should be calculated by now.

View File

@ -119,6 +119,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void zoomOut();
void zoomSelected();
void zoomOutbound();
void enableDisableDecals(bool bels, bool wires, bool pips, bool groups);
Q_SIGNALS:
void clickedBel(BelId bel, bool add);
@ -227,6 +228,11 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
QMatrix4x4 viewMove_;
float zoom_;
bool displayBel_;
bool displayWire_;
bool displayPip_;
bool displayGroup_;
struct
{
QColor background;

BIN
gui/resources/bel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

BIN
gui/resources/group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

BIN
gui/resources/pip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

BIN
gui/resources/wire.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B