aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/fpgaviewwidget.cc16
-rw-r--r--gui/fpgaviewwidget.h2
2 files changed, 15 insertions, 3 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index db4179e4..58df0586 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -1,13 +1,24 @@
#include "fpgaviewwidget.h"
+#include <QApplication>
#include <QCoreApplication>
#include <QMouseEvent>
+#include <QWidget>
#include <math.h>
#include "mainwindow.h"
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
: QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0)
{
- design = qobject_cast<MainWindow*>(parentWidget()->parentWidget()->parentWidget()->parentWidget())->getDesign();
+ design = qobject_cast<MainWindow *>(getMainWindow())->getDesign();
+}
+
+QMainWindow *FPGAViewWidget::getMainWindow()
+{
+ QWidgetList widgets = qApp->topLevelWidgets();
+ for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i)
+ if ((*i)->objectName() == "MainWindow")
+ return (QMainWindow *)(*i);
+ return NULL;
}
FPGAViewWidget::~FPGAViewWidget() {}
@@ -64,11 +75,10 @@ void FPGAViewWidget::drawElement(const GraphicElement &el)
glVertex3f((offset + scale * el.x2), (offset + scale * el.y2), 0.0f);
glVertex3f((offset + scale * el.x1), (offset + scale * el.y2), 0.0f);
-
+
glVertex3f((offset + scale * el.x1), (offset + scale * el.y2), 0.0f);
glVertex3f((offset + scale * el.x1), (offset + scale * el.y1), 0.0f);
glEnd();
-
}
if (el.type == GraphicElement::G_LINE) {
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index 1eb98065..c54a745e 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -1,6 +1,7 @@
#ifndef MAPGLWIDGET_H
#define MAPGLWIDGET_H
+#include <QMainWindow>
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#include <QPainter>
@@ -33,6 +34,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
void drawElement(const GraphicElement &el);
+ QMainWindow *getMainWindow();
private:
int m_windowWidth;