diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/designwidget.cc | 26 | ||||
-rw-r--r-- | gui/fpgaviewwidget.cc | 142 | ||||
-rw-r--r-- | gui/fpgaviewwidget.h | 77 |
3 files changed, 110 insertions, 135 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc index a6ebba5e..edf9f1ec 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -334,14 +334,12 @@ void DesignWidget::onItemSelectionChanged() return;
}
- 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);
+ BelId bel = ctx->getBelByName(c);
decals.push_back(ctx->getBelDecal(bel));
Q_EMIT selected(decals);
@@ -358,20 +356,20 @@ void DesignWidget::onItemSelectionChanged() topItem->addSubProperty(typeItem);
QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available");
- availItem->setValue(proxy.checkBelAvail(bel));
+ availItem->setValue(ctx->checkBelAvail(bel));
topItem->addSubProperty(availItem);
QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Cell");
- cellItem->setValue(proxy.getBoundBelCell(bel).c_str(ctx));
+ cellItem->setValue(ctx->getBoundBelCell(bel).c_str(ctx));
topItem->addSubProperty(cellItem);
QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Cell");
- conflictItem->setValue(proxy.getConflictingBelCell(bel).c_str(ctx));
+ conflictItem->setValue(ctx->getConflictingBelCell(bel).c_str(ctx));
topItem->addSubProperty(conflictItem);
} else if (type == ElementType::WIRE) {
IdString c = static_cast<IdStringTreeItem *>(clickItem)->getData();
- WireId wire = proxy.getWireByName(c);
+ WireId wire = ctx->getWireByName(c);
decals.push_back(ctx->getWireDecal(wire));
Q_EMIT selected(decals);
@@ -384,15 +382,15 @@ void DesignWidget::onItemSelectionChanged() topItem->addSubProperty(nameItem);
QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available");
- availItem->setValue(proxy.checkWireAvail(wire));
+ availItem->setValue(ctx->checkWireAvail(wire));
topItem->addSubProperty(availItem);
QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net");
- cellItem->setValue(proxy.getBoundWireNet(wire).c_str(ctx));
+ cellItem->setValue(ctx->getBoundWireNet(wire).c_str(ctx));
topItem->addSubProperty(cellItem);
QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net");
- conflictItem->setValue(proxy.getConflictingWireNet(wire).c_str(ctx));
+ conflictItem->setValue(ctx->getConflictingWireNet(wire).c_str(ctx));
topItem->addSubProperty(conflictItem);
BelPin uphill = ctx->getBelPinUphill(wire);
@@ -448,7 +446,7 @@ void DesignWidget::onItemSelectionChanged() */
} else if (type == ElementType::PIP) {
IdString c = static_cast<IdStringTreeItem *>(clickItem)->getData();
- PipId pip = proxy.getPipByName(c);
+ PipId pip = ctx->getPipByName(c);
decals.push_back(ctx->getPipDecal(pip));
Q_EMIT selected(decals);
@@ -461,15 +459,15 @@ void DesignWidget::onItemSelectionChanged() topItem->addSubProperty(nameItem);
QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available");
- availItem->setValue(proxy.checkPipAvail(pip));
+ availItem->setValue(ctx->checkPipAvail(pip));
topItem->addSubProperty(availItem);
QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net");
- cellItem->setValue(proxy.getBoundPipNet(pip).c_str(ctx));
+ cellItem->setValue(ctx->getBoundPipNet(pip).c_str(ctx));
topItem->addSubProperty(cellItem);
QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net");
- conflictItem->setValue(proxy.getConflictingPipNet(pip).c_str(ctx));
+ conflictItem->setValue(ctx->getConflictingPipNet(pip).c_str(ctx));
topItem->addSubProperty(conflictItem);
QtVariantProperty *srcWireItem = readOnlyManager->addProperty(QVariant::String, "Src Wire");
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index f8fefd97..1d0e8b57 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -23,7 +23,6 @@ #include <QApplication> #include <QCoreApplication> #include <QMouseEvent> -#include <QTimer> #include <QWidget> #include "fpgaviewwidget.h" @@ -196,7 +195,7 @@ bool LineShader::compile(void) return true; } -void LineShader::draw(const LineShaderData &line, const QColor &color, const float thickness, const QMatrix4x4 &projection) +void LineShader::draw(const LineShaderData &line, const QColor &color, float thickness, const QMatrix4x4 &projection) { auto gl = QOpenGLContext::currentContext()->functions(); vao_.bind(); @@ -266,10 +265,6 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineSha if (fmt.minorVersion() < 1) { printf("Could not get OpenGL 3.1 context - trying anyway...\n "); } - - QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(update())); - timer->start(5000); } FPGAViewWidget::~FPGAViewWidget() {} @@ -293,6 +288,73 @@ void FPGAViewWidget::initializeGL() glClearColor(backgroundColor_.red() / 255, backgroundColor_.green() / 255, backgroundColor_.blue() / 255, 0.0); } +void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal) +{ + const float scale = 1.0; + float offsetX = 0.0, offsetY = 0.0; + + for (auto &el : ctx_->getDecalGraphics(decal.decal)) { + offsetX = decal.x; + offsetY = decal.y; + + if (el.type == GraphicElement::G_BOX) { + auto line = PolyLine(true); + line.point(offsetX + scale * el.x1, offsetY + scale * el.y1); + line.point(offsetX + scale * el.x2, offsetY + scale * el.y1); + line.point(offsetX + scale * el.x2, offsetY + scale * el.y2); + line.point(offsetX + scale * el.x1, offsetY + scale * el.y2); + line.build(out); + } + + if (el.type == GraphicElement::G_LINE) { + PolyLine(offsetX + scale * el.x1, offsetY + scale * el.y1, offsetX + scale * el.x2, offsetY + scale * el.y2) + .build(out); + } + } +} + +void FPGAViewWidget::drawDecal(LineShaderData out[], const DecalXY &decal) +{ + const float scale = 1.0; + float offsetX = 0.0, offsetY = 0.0; + + for (auto &el : ctx_->getDecalGraphics(decal.decal)) { + offsetX = decal.x; + offsetY = decal.y; + + if (el.type == GraphicElement::G_BOX) { + auto line = PolyLine(true); + line.point(offsetX + scale * el.x1, offsetY + scale * el.y1); + line.point(offsetX + scale * el.x2, offsetY + scale * el.y1); + line.point(offsetX + scale * el.x2, offsetY + scale * el.y2); + line.point(offsetX + scale * el.x1, offsetY + scale * el.y2); + switch (el.style) { + case GraphicElement::G_FRAME: + case GraphicElement::G_INACTIVE: + case GraphicElement::G_ACTIVE: + line.build(out[el.style]); + break; + default: + break; + } + } + + if (el.type == GraphicElement::G_LINE) { + auto line = PolyLine(offsetX + scale * el.x1, offsetY + scale * el.y1, offsetX + scale * el.x2, + offsetY + scale * el.y2); + switch (el.style) { + case GraphicElement::G_FRAME: + case GraphicElement::G_INACTIVE: + case GraphicElement::G_ACTIVE: + line.build(out[el.style]); + break; + default: + break; + } + } + } +} + QMatrix4x4 FPGAViewWidget::getProjection(void) { QMatrix4x4 matrix; @@ -326,44 +388,27 @@ void FPGAViewWidget::paintGL() } lineShader_.draw(grid, gridColor_, thick1Px, matrix); + LineShaderData shaders[4] = {[GraphicElement::G_FRAME] = LineShaderData(), + [GraphicElement::G_HIDDEN] = LineShaderData(), + [GraphicElement::G_INACTIVE] = LineShaderData(), + [GraphicElement::G_ACTIVE] = LineShaderData()}; + if (ctx_) { - auto &&proxy = ctx_->rwproxy(); - auto updates = proxy.getUIUpdatesRequired(); - - // Collapse all updates to a full redraw. - // TODO(q3k) fix this. - - bool redraw = (updates.allUIReload - || !updates.belUIReload.empty() - || !updates.wireUIReload.empty() - || !updates.pipUIReload.empty() - || !updates.groupUIReload.empty() - || updates.frameUIReload); - - if (redraw) { - shaders_[0].clear(); - shaders_[1].clear(); - shaders_[2].clear(); - shaders_[3].clear(); - - // Draw Bels. - for (auto bel : ctx_->getBels()) { - drawDecal(proxy, shaders_, ctx_->getBelDecal(bel)); - } - // Draw Wires. - for (auto wire : ctx_->getWires()) { - drawDecal(proxy, shaders_, ctx_->getWireDecal(wire)); - } - // Draw Pips. - for (auto pip : ctx_->getPips()) { - drawDecal(proxy, shaders_, ctx_->getPipDecal(pip)); - } - // Draw Groups. - for (auto group : ctx_->getGroups()) { - drawDecal(proxy, shaders_, ctx_->getGroupDecal(group)); - } - // Draw Frame Graphics. - drawDecal(proxy, shaders_, ctx_->getFrameDecal()); + // Draw Bels. + for (auto bel : ctx_->getBels()) { + drawDecal(shaders, ctx_->getBelDecal(bel)); + } + // Draw Wires. + for (auto wire : ctx_->getWires()) { + drawDecal(shaders, ctx_->getWireDecal(wire)); + } + // Draw Pips. + for (auto pip : ctx_->getPips()) { + drawDecal(shaders, ctx_->getPipDecal(pip)); + } + // Draw Groups. + for (auto group : ctx_->getGroups()) { + drawDecal(shaders, ctx_->getGroupDecal(group)); } if (selectedItemsChanged) @@ -371,17 +416,16 @@ void FPGAViewWidget::paintGL() selectedItemsChanged = false; selectedShader_.clear(); for (auto decal : selectedItems_) { - drawDecal(proxy, selectedShader_, decal); + drawDecal(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(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) diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 0a9599c9..dd86277e 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -51,6 +51,8 @@ struct LineShaderData std::vector<GLfloat> miters; std::vector<GLuint> indices; + LineShaderData(void) {} + void clear(void) { vertices.clear(); @@ -201,7 +203,7 @@ class LineShader bool compile(void); // Render a LineShaderData with a given M/V/P transformation. - void draw(const LineShaderData &data, const QColor &color, const float thickness, const QMatrix4x4 &projection); + void draw(const LineShaderData &data, const QColor &color, float thickness, const QMatrix4x4 &projection); }; class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions @@ -238,76 +240,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; - - template <typename T> - void drawDecal(const T &proxy, LineShaderData &out, const DecalXY &decal) - { - const float scale = 1.0; - float offsetX = 0.0, offsetY = 0.0; - - for (auto &el : proxy.getDecalGraphics(decal.decal)) { - offsetX = decal.x; - offsetY = decal.y; - - if (el.type == GraphicElement::G_BOX) { - auto line = PolyLine(true); - line.point(offsetX + scale * el.x1, offsetY + scale * el.y1); - line.point(offsetX + scale * el.x2, offsetY + scale * el.y1); - line.point(offsetX + scale * el.x2, offsetY + scale * el.y2); - line.point(offsetX + scale * el.x1, offsetY + scale * el.y2); - line.build(out); - } - - if (el.type == GraphicElement::G_LINE) { - PolyLine(offsetX + scale * el.x1, offsetY + scale * el.y1, offsetX + scale * el.x2, offsetY + scale * el.y2) - .build(out); - } - } - } - - template <typename T> - void drawDecal(const T &proxy, LineShaderData out[], const DecalXY &decal) - { - const float scale = 1.0; - float offsetX = 0.0, offsetY = 0.0; - - for (auto &el : proxy.getDecalGraphics(decal.decal)) { - offsetX = decal.x; - offsetY = decal.y; - - if (el.type == GraphicElement::G_BOX) { - auto line = PolyLine(true); - line.point(offsetX + scale * el.x1, offsetY + scale * el.y1); - line.point(offsetX + scale * el.x2, offsetY + scale * el.y1); - line.point(offsetX + scale * el.x2, offsetY + scale * el.y2); - line.point(offsetX + scale * el.x1, offsetY + scale * el.y2); - switch (el.style) { - case GraphicElement::G_FRAME: - case GraphicElement::G_INACTIVE: - case GraphicElement::G_ACTIVE: - line.build(out[el.style]); - break; - default: - break; - } - } - - if (el.type == GraphicElement::G_LINE) { - auto line = PolyLine(offsetX + scale * el.x1, offsetY + scale * el.y1, offsetX + scale * el.x2, - offsetY + scale * el.y2); - switch (el.style) { - case GraphicElement::G_FRAME: - case GraphicElement::G_INACTIVE: - case GraphicElement::G_ACTIVE: - line.build(out[el.style]); - break; - default: - break; - } - } - } - } - + void drawDecal(LineShaderData &data, const DecalXY &decal); + void drawDecal(LineShaderData out[], const DecalXY &decal); public Q_SLOTS: void newContext(Context *ctx); void onSelectedArchItem(std::vector<DecalXY> decals); @@ -336,7 +270,6 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions QColor gSelectedColor_; QColor frameColor_; - LineShaderData shaders_[4]; LineShaderData selectedShader_; std::vector<DecalXY> selectedItems_; bool selectedItemsChanged; |