From 8d1996cae99ff80a2d9390b94db54217ed1d8726 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 14 Jul 2018 19:44:37 +0200 Subject: display selected object from tree --- gui/basewindow.cc | 1 + gui/basewindow.h | 1 + gui/designwidget.cc | 15 +++++++++++++-- gui/designwidget.h | 1 + gui/fpgaviewwidget.cc | 20 +++++++++++++++++++- gui/fpgaviewwidget.h | 7 ++++++- 6 files changed, 41 insertions(+), 4 deletions(-) (limited to 'gui') diff --git a/gui/basewindow.cc b/gui/basewindow.cc index b9c1de5e..0c7632ee 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -81,6 +81,7 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr context, QWidget *parent centralTabWidget->addTab(fpgaView, "Graphics"); connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *))); + connect(designview, SIGNAL(selected(std::vector)), fpgaView, SLOT(onSelectedArchItem(std::vector))); splitter_v->addWidget(centralTabWidget); splitter_v->addWidget(tabWidget); diff --git a/gui/basewindow.h b/gui/basewindow.h index ebbe66f0..4d3d80a1 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -31,6 +31,7 @@ #include Q_DECLARE_METATYPE(std::string) +Q_DECLARE_METATYPE(NEXTPNR_NAMESPACE_PREFIX DecalXY) NEXTPNR_NAMESPACE_BEGIN diff --git a/gui/designwidget.cc b/gui/designwidget.cc index ba2c76f5..a6ebba5e 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -336,10 +336,15 @@ void DesignWidget::onItemSelectionChanged() auto &&proxy = ctx->rproxy(); + std::vector decals; + clearProperties(); if (type == ElementType::BEL) { IdString c = static_cast(clickItem)->getData(); BelId bel = proxy.getBelByName(c); + + decals.push_back(ctx->getBelDecal(bel)); + Q_EMIT selected(decals); QtProperty *topItem = groupManager->addProperty("Bel"); addProperty(topItem, "Bel"); @@ -368,6 +373,9 @@ void DesignWidget::onItemSelectionChanged() IdString c = static_cast(clickItem)->getData(); WireId wire = proxy.getWireByName(c); + decals.push_back(ctx->getWireDecal(wire)); + Q_EMIT selected(decals); + QtProperty *topItem = groupManager->addProperty("Wire"); addProperty(topItem, "Wire"); @@ -421,7 +429,7 @@ void DesignWidget::onItemSelectionChanged() portItem->setValue(pinname); dhItem->addSubProperty(portItem); } - +/* QtProperty *pipsDownItem = groupManager->addProperty("Pips Downhill"); topItem->addSubProperty(pipsDownItem); for (const auto &item : ctx->getPipsDownhill(wire)) { @@ -437,11 +445,14 @@ void DesignWidget::onItemSelectionChanged() pipItem->setValue(ctx->getPipName(item).c_str(ctx)); pipsUpItem->addSubProperty(pipItem); } - +*/ } else if (type == ElementType::PIP) { IdString c = static_cast(clickItem)->getData(); PipId pip = proxy.getPipByName(c); + decals.push_back(ctx->getPipDecal(pip)); + Q_EMIT selected(decals); + QtProperty *topItem = groupManager->addProperty("Pip"); addProperty(topItem, "Pip"); diff --git a/gui/designwidget.h b/gui/designwidget.h index 843fbb72..618c7bbf 100644 --- a/gui/designwidget.h +++ b/gui/designwidget.h @@ -43,6 +43,7 @@ class DesignWidget : public QWidget Q_SIGNALS: void info(std::string text); + void selected(std::vector decal); private Q_SLOTS: void prepareMenu(const QPoint &pos); diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 21ce5b67..f8fefd97 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -241,7 +241,7 @@ void LineShader::draw(const LineShaderData &line, const QColor &color, const flo vao_.release(); } -FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr) +FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), selectedItemsChanged(false) { backgroundColor_ = QColor("#000000"); gridColor_ = QColor("#333"); @@ -249,6 +249,7 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineSha gHiddenColor_ = QColor("#606060"); gInactiveColor_ = QColor("#303030"); gActiveColor_ = QColor("#f0f0f0"); + gSelectedColor_ = QColor("#ff6600"); frameColor_ = QColor("#0066ba"); auto fmt = format(); @@ -364,15 +365,32 @@ void FPGAViewWidget::paintGL() // Draw Frame Graphics. drawDecal(proxy, shaders_, ctx_->getFrameDecal()); } + + if (selectedItemsChanged) + { + selectedItemsChanged = false; + selectedShader_.clear(); + for (auto decal : selectedItems_) { + drawDecal(proxy, selectedShader_, decal); + } + } } lineShader_.draw(shaders_[0], gFrameColor_, thick11Px, matrix); lineShader_.draw(shaders_[1], gHiddenColor_, thick11Px, matrix); lineShader_.draw(shaders_[2], gInactiveColor_, thick11Px, matrix); lineShader_.draw(shaders_[3], gActiveColor_, thick11Px, matrix); + lineShader_.draw(selectedShader_, gSelectedColor_, thick11Px, matrix); //lineShader_.draw(frame, matrix); } +void FPGAViewWidget::onSelectedArchItem(std::vector decals) +{ + selectedItems_ = decals; + selectedItemsChanged = true; + update(); +} + void FPGAViewWidget::resizeGL(int width, int height) {} void FPGAViewWidget::mousePressEvent(QMouseEvent *event) { lastPos_ = event->pos(); } diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 3652e82e..0a9599c9 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -213,6 +213,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions Q_PROPERTY(QColor gHiddenColor MEMBER gHiddenColor_ DESIGNABLE true) Q_PROPERTY(QColor gInactiveColor MEMBER gInactiveColor_ DESIGNABLE true) Q_PROPERTY(QColor gActiveColor MEMBER gActiveColor_ DESIGNABLE true) + Q_PROPERTY(QColor gSelectedColor MEMBER gSelectedColor_ DESIGNABLE true) Q_PROPERTY(QColor frameColor MEMBER frameColor_ DESIGNABLE true) public: @@ -309,7 +310,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions public Q_SLOTS: void newContext(Context *ctx); - + void onSelectedArchItem(std::vector decals); private: QPoint lastPos_; LineShader lineShader_; @@ -332,9 +333,13 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions QColor gHiddenColor_; QColor gInactiveColor_; QColor gActiveColor_; + QColor gSelectedColor_; QColor frameColor_; LineShaderData shaders_[4]; + LineShaderData selectedShader_; + std::vector selectedItems_; + bool selectedItemsChanged; }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3