diff options
author | ZipCPU <dgisselq@ieee.org> | 2018-06-07 15:46:21 -0400 |
---|---|---|
committer | ZipCPU <dgisselq@ieee.org> | 2018-06-07 15:46:21 -0400 |
commit | 87775d3c6f56bcaaf47e169822ae97b8370ac44f (patch) | |
tree | 6771accc538332b08aeceb25856cad45db183678 /gui/fpgaviewwidget.cc | |
parent | 4499864024a5b658bf5772ed87e218bcdaedc262 (diff) | |
parent | e7ff22ce901102589173f7a7dc3e4ddbb030655f (diff) | |
download | nextpnr-87775d3c6f56bcaaf47e169822ae97b8370ac44f.tar.gz nextpnr-87775d3c6f56bcaaf47e169822ae97b8370ac44f.tar.bz2 nextpnr-87775d3c6f56bcaaf47e169822ae97b8370ac44f.zip |
Tried to add fixes *and* update clang-format jsonparse.cc
Diffstat (limited to 'gui/fpgaviewwidget.cc')
-rw-r--r-- | gui/fpgaviewwidget.cc | 63 |
1 files changed, 22 insertions, 41 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index bd36b724..84cb4a5f 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -1,57 +1,42 @@ -#include <QMouseEvent> +#include "fpgaviewwidget.h" #include <QCoreApplication> +#include <QMouseEvent> #include <math.h> -#include "fpgaviewwidget.h" FPGAViewWidget::FPGAViewWidget(QWidget *parent) - : QOpenGLWidget(parent), - m_xMove(0),m_yMove(0),m_zDistance(1.0) + : QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0) { - } -FPGAViewWidget::~FPGAViewWidget() -{ -} +FPGAViewWidget::~FPGAViewWidget() {} -QSize FPGAViewWidget::minimumSizeHint() const -{ - return QSize(640, 480); -} +QSize FPGAViewWidget::minimumSizeHint() const { return QSize(640, 480); } -QSize FPGAViewWidget::sizeHint() const -{ - return QSize(640, 480); -} +QSize FPGAViewWidget::sizeHint() const { return QSize(640, 480); } void FPGAViewWidget::setXTranslation(float t_x) { - if(t_x != m_xMove) - { + if (t_x != m_xMove) { m_xMove = t_x; update(); } } - void FPGAViewWidget::setYTranslation(float t_y) { - if(t_y != m_yMove) - { + if (t_y != m_yMove) { m_yMove = t_y; update(); } } - void FPGAViewWidget::setZoom(float t_z) { - if(t_z != m_zDistance) - { + if (t_z != m_zDistance) { m_zDistance -= t_z; - if(m_zDistance < 0.1f) + if (m_zDistance < 0.1f) m_zDistance = 0.1f; - if(m_zDistance > 10.0f) + if (m_zDistance > 10.0f) m_zDistance = 10.0f; update(); @@ -70,21 +55,19 @@ void FPGAViewWidget::paintGL() glLoadIdentity(); glTranslatef(m_xMove, m_yMove, -10.0); - glScalef(m_zDistance,m_zDistance, 0.0f); - + glScalef(m_zDistance, m_zDistance, 0.0f); + // Example grid glColor3f(0.8, 0.8, 0.8); glBegin(GL_LINES); - for(float i = -100; i <= 100; i += 0.1) - { + for (float i = -100; i <= 100; i += 0.1) { glVertex3f((float)i, -100.0f, 0.0f); glVertex3f((float)i, 100.0f, 0.0f); glVertex3f(-100.0f, (float)i, 0.0f); glVertex3f(100.0f, (float)i, 0.0f); } glColor3f(0.5, 0.5, 0.5); - for(int i = -100; i <= 100; i += 1) - { + for (int i = -100; i <= 100; i += 1) { glVertex3f((float)i, -100.0f, 0.0f); glVertex3f((float)i, 100.0f, 0.0f); glVertex3f(-100.0f, (float)i, 0.0f); @@ -101,7 +84,6 @@ void FPGAViewWidget::paintGL() glColor3f(0.0, 0.0, 1.0); glVertex3f(0, 0.5, 0); glEnd(); - } void FPGAViewWidget::resizeGL(int width, int height) @@ -114,7 +96,7 @@ void FPGAViewWidget::resizeGL(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(-1.0* aspect, +1.0* aspect, -1.0, +1.0, 1.0, 15.0); + glOrtho(-1.0 * aspect, +1.0 * aspect, -1.0, +1.0, 1.0, 15.0); glMatrixMode(GL_MODELVIEW); } @@ -130,13 +112,13 @@ void FPGAViewWidget::mouseMoveEvent(QMouseEvent *event) float dx_scale = dx * (1 / (float)640); float dy_scale = -dy * (1 / (float)480); - if (event->buttons() & Qt::LeftButton) - { + if (event->buttons() & Qt::LeftButton) { float xpos = m_xMove + dx_scale; float ypos = m_yMove + dy_scale; - if (m_xMove/m_zDistance <= 100.0 && m_xMove/m_zDistance>= -100.0) setXTranslation(xpos); - if (m_yMove/m_zDistance <= 100.0 && m_yMove/m_zDistance>= -100.0) setYTranslation(ypos); - + if (m_xMove / m_zDistance <= 100.0 && m_xMove / m_zDistance >= -100.0) + setXTranslation(xpos); + if (m_yMove / m_zDistance <= 100.0 && m_yMove / m_zDistance >= -100.0) + setYTranslation(ypos); } m_lastPos = event->pos(); } @@ -145,8 +127,7 @@ void FPGAViewWidget::wheelEvent(QWheelEvent *event) { QPoint degree = event->angleDelta() / 8; - if(!degree.isNull()) - { + if (!degree.isNull()) { QPoint step = degree / 15; setZoom(step.y() * -0.1f); } |