display selected object from tree
This commit is contained in:
parent
f339f796a1
commit
8d1996cae9
@ -81,6 +81,7 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
|
||||
centralTabWidget->addTab(fpgaView, "Graphics");
|
||||
|
||||
connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *)));
|
||||
connect(designview, SIGNAL(selected(std::vector<DecalXY>)), fpgaView, SLOT(onSelectedArchItem(std::vector<DecalXY>)));
|
||||
|
||||
splitter_v->addWidget(centralTabWidget);
|
||||
splitter_v->addWidget(tabWidget);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QToolBar>
|
||||
|
||||
Q_DECLARE_METATYPE(std::string)
|
||||
Q_DECLARE_METATYPE(NEXTPNR_NAMESPACE_PREFIX DecalXY)
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -336,10 +336,15 @@ void DesignWidget::onItemSelectionChanged()
|
||||
|
||||
auto &&proxy = ctx->rproxy();
|
||||
|
||||
std::vector<DecalXY> decals;
|
||||
|
||||
clearProperties();
|
||||
if (type == ElementType::BEL) {
|
||||
IdString c = static_cast<IdStringTreeItem *>(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<IdStringTreeItem *>(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<IdStringTreeItem *>(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");
|
||||
|
||||
|
@ -43,6 +43,7 @@ class DesignWidget : public QWidget
|
||||
|
||||
Q_SIGNALS:
|
||||
void info(std::string text);
|
||||
void selected(std::vector<DecalXY> decal);
|
||||
|
||||
private Q_SLOTS:
|
||||
void prepareMenu(const QPoint &pos);
|
||||
|
@ -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<DecalXY> decals)
|
||||
{
|
||||
selectedItems_ = decals;
|
||||
selectedItemsChanged = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void FPGAViewWidget::resizeGL(int width, int height) {}
|
||||
|
||||
void FPGAViewWidget::mousePressEvent(QMouseEvent *event) { lastPos_ = event->pos(); }
|
||||
|
@ -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<DecalXY> 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<DecalXY> selectedItems_;
|
||||
bool selectedItemsChanged;
|
||||
};
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
Loading…
Reference in New Issue
Block a user