aboutsummaryrefslogtreecommitdiffstats
path: root/gui/fpgaviewwidget.cc
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-26 15:58:35 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-26 15:58:35 +0200
commit95de0a36b43776ffd07993ff7d2be994981aa8fb (patch)
treef40c72cd0a4aaa0df13a9ef7401d7dc73a235ce7 /gui/fpgaviewwidget.cc
parent21d5a04501e411b8c1391606c1eafba5d4789c41 (diff)
parent0bd73c19778c9bdbc8e6d85c120715e239a9bc0d (diff)
downloadnextpnr-95de0a36b43776ffd07993ff7d2be994981aa8fb.tar.gz
nextpnr-95de0a36b43776ffd07993ff7d2be994981aa8fb.tar.bz2
nextpnr-95de0a36b43776ffd07993ff7d2be994981aa8fb.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
Diffstat (limited to 'gui/fpgaviewwidget.cc')
-rw-r--r--gui/fpgaviewwidget.cc32
1 files changed, 17 insertions, 15 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 34e1a761..a2691401 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -241,9 +241,8 @@ void LineShader::draw(const LineShaderData &line, const QMatrix4x4 &projection)
}
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
- : QOpenGLWidget(parent), moveX_(0), moveY_(0), zoom_(10.0f), lineShader_(this)
+ : QOpenGLWidget(parent), moveX_(0), moveY_(0), zoom_(10.0f), lineShader_(this), ctx_(nullptr)
{
- ctx_ = qobject_cast<BaseMainWindow *>(getMainWindow())->getContext();
auto fmt = format();
fmt.setMajorVersion(3);
fmt.setMinorVersion(1);
@@ -260,17 +259,14 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
}
}
-QMainWindow *FPGAViewWidget::getMainWindow()
+FPGAViewWidget::~FPGAViewWidget() {}
+
+void FPGAViewWidget::newContext(Context *ctx)
{
- QWidgetList widgets = qApp->topLevelWidgets();
- for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i)
- if ((*i)->objectName() == "BaseMainWindow")
- return (QMainWindow *)(*i);
- return NULL;
+ ctx_ = ctx;
+ update();
}
-FPGAViewWidget::~FPGAViewWidget() {}
-
QSize FPGAViewWidget::minimumSizeHint() const { return QSize(640, 480); }
QSize FPGAViewWidget::sizeHint() const { return QSize(640, 480); }
@@ -359,16 +355,22 @@ void FPGAViewWidget::paintGL()
// Draw Bels.
auto bels = LineShaderData(0.02f, QColor("#b000ba"));
- for (auto bel : ctx_->getBels()) {
- for (auto &el : ctx_->getBelGraphics(bel))
- drawElement(bels, el);
+ if (ctx_)
+ {
+ for (auto bel : ctx_->getBels()) {
+ for (auto &el : ctx_->getBelGraphics(bel))
+ drawElement(bels, el);
+ }
}
lineShader_.draw(bels, matrix);
// Draw Frame Graphics.
auto frames = LineShaderData(0.02f, QColor("#0066ba"));
- for (auto &el : ctx_->getFrameGraphics()) {
- drawElement(frames, el);
+ if (ctx_)
+ {
+ for (auto &el : ctx_->getFrameGraphics()) {
+ drawElement(frames, el);
+ }
}
lineShader_.draw(frames, matrix);
}