aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-07-26 17:33:19 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-07-26 17:33:19 +0100
commitba5395d89fea3a0a646d9bf3df643dac8c8bdec4 (patch)
tree50d40994547ea1f4d1a22d3c0833250508cb16e7 /gui
parent25bf147d1a8ec7122ab3da5572019ae0d13f3a06 (diff)
downloadnextpnr-ba5395d89fea3a0a646d9bf3df643dac8c8bdec4.tar.gz
nextpnr-ba5395d89fea3a0a646d9bf3df643dac8c8bdec4.tar.bz2
nextpnr-ba5395d89fea3a0a646d9bf3df643dac8c8bdec4.zip
gui: refactor FPGAViewWidget even more slightly
Diffstat (limited to 'gui')
-rw-r--r--gui/fpgaviewwidget.cc16
-rw-r--r--gui/fpgaviewwidget.h40
2 files changed, 28 insertions, 28 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 2211c93b..d87c26a3 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -242,9 +242,11 @@ void LineShader::draw(const LineShaderData &line, const QColor &color, float thi
vao_.release();
}
-FPGAViewWidget::FPGAViewWidget(QWidget *parent)
- : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), paintTimer_(this),
- rendererData_(new FPGAViewWidget::RendererData), rendererArgs_(new FPGAViewWidget::RendererArgs)
+FPGAViewWidget::FPGAViewWidget(QWidget *parent) :
+ QOpenGLWidget(parent), ctx_(nullptr), paintTimer_(this),
+ lineShader_(this), zoom_(500.0f),
+ rendererData_(new FPGAViewWidget::RendererData),
+ rendererArgs_(new FPGAViewWidget::RendererArgs)
{
colors_.background = QColor("#000000");
colors_.grid = QColor("#333");
@@ -562,7 +564,7 @@ void FPGAViewWidget::onHighlightGroupChanged(std::vector<DecalXY> decals, int gr
void FPGAViewWidget::resizeGL(int width, int height) {}
-void FPGAViewWidget::mousePressEvent(QMouseEvent *event) { lastPos_ = event->pos(); }
+void FPGAViewWidget::mousePressEvent(QMouseEvent *event) { lastDragPos_ = event->pos(); }
// Invert the projection matrix to calculate screen/mouse to world/grid
// coordinates.
@@ -578,9 +580,9 @@ QVector4D FPGAViewWidget::mouseToWorldCoordinates(int x, int y)
void FPGAViewWidget::mouseMoveEvent(QMouseEvent *event)
{
- const int dx = event->x() - lastPos_.x();
- const int dy = event->y() - lastPos_.y();
- lastPos_ = event->pos();
+ const int dx = event->x() - lastDragPos_.x();
+ const int dy = event->y() - lastDragPos_.y();
+ lastDragPos_ = event->pos();
auto world = mouseToWorldCoordinates(dx, dy);
viewMove_.translate(world.x(), -world.y());
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index 69e947cf..6505c555 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -267,16 +267,17 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
FPGAViewWidget(QWidget *parent = 0);
~FPGAViewWidget();
- QSize minimumSizeHint() const override;
- QSize sizeHint() const override;
-
protected:
+ // Qt callbacks.
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
void resizeGL(int width, int height) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+ QSize minimumSizeHint() const override;
+ QSize sizeHint() const override;
+
public Q_SLOTS:
void newContext(Context *ctx);
@@ -289,30 +290,20 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void zoomOutbound();
private:
- void drawGraphicElement(LineShaderData &out, const GraphicElement &el, float x, float y);
- void drawArchDecal(LineShaderData out[GraphicElement::STYLE_MAX], const DecalXY &decal);
- void drawDecal(LineShaderData &out, const DecalXY &decal);
- void renderLines(void);
- void zoom(int level);
-
- QPoint lastPos_;
- LineShader lineShader_;
- QMatrix4x4 viewMove_;
- float zoom_;
- QMatrix4x4 getProjection(void);
- QVector4D mouseToWorldCoordinates(int x, int y);
-
const float zoomNear_ = 1.0f; // do not zoom closer than this
const float zoomFar_ = 10000.0f; // do not zoom further than this
-
const float zoomLvl1_ = 100.0f;
const float zoomLvl2_ = 50.0f;
Context *ctx_;
QTimer paintTimer_;
-
std::unique_ptr<PeriodicRunner> renderRunner_;
+ QPoint lastDragPos_;
+ LineShader lineShader_;
+ QMatrix4x4 viewMove_;
+ float zoom_;
+
struct
{
QColor background;
@@ -331,6 +322,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
LineShaderData gfxSelected;
LineShaderData gfxHighlighted[8];
};
+ std::unique_ptr<RendererData> rendererData_;
+ QMutex rendererDataLock_;
struct RendererArgs
{
@@ -338,11 +331,16 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
std::vector<DecalXY> highlightedDecals[8];
bool highlightedOrSelectedChanged;
};
-
- std::unique_ptr<RendererData> rendererData_;
- QMutex rendererDataLock_;
std::unique_ptr<RendererArgs> rendererArgs_;
QMutex rendererArgsLock_;
+
+ void zoom(int level);
+ void renderLines(void);
+ void drawGraphicElement(LineShaderData &out, const GraphicElement &el, float x, float y);
+ void drawDecal(LineShaderData &out, const DecalXY &decal);
+ void drawArchDecal(LineShaderData out[GraphicElement::STYLE_MAX], const DecalXY &decal);
+ QVector4D mouseToWorldCoordinates(int x, int y);
+ QMatrix4x4 getProjection(void);
};
NEXTPNR_NAMESPACE_END