aboutsummaryrefslogtreecommitdiffstats
path: root/gui/fpgaviewwidget.h
diff options
context:
space:
mode:
Diffstat (limited to 'gui/fpgaviewwidget.h')
-rw-r--r--gui/fpgaviewwidget.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index 260ebf05..a360eea7 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -33,6 +33,7 @@
#include <QWaitCondition>
#include "nextpnr.h"
+#include "quadtree.h"
#include "lineshader.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -116,6 +117,9 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void zoomSelected();
void zoomOutbound();
+ Q_SIGNALS:
+ void clickedBel(BelId bel);
+
private:
const float zoomNear_ = 1.0f; // do not zoom closer than this
const float zoomFar_ = 10000.0f; // do not zoom further than this
@@ -126,6 +130,21 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
QTimer paintTimer_;
std::unique_ptr<PeriodicRunner> renderRunner_;
+ using QuadTreeBels = QuadTree<float, BelId>;
+
+ template <typename T>
+ void commitToQuadtree(T *tree, const DecalXY &decal, BelId bel)
+ {
+ float offsetX = decal.x;
+ float offsetY = decal.y;
+
+ for (auto &el : ctx_->getDecalGraphics(decal.decal)) {
+ if (el.type == GraphicElement::TYPE_BOX) {
+ tree->insert(typename T::BoundingBox(offsetX + el.x1, offsetY + el.y1, offsetX + el.x2, offsetY + el.y2), bel);
+ }
+ }
+ }
+
QPoint lastDragPos_;
LineShader lineShader_;
QMatrix4x4 viewMove_;
@@ -148,6 +167,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
LineShaderData gfxByStyle[GraphicElement::STYLE_MAX];
LineShaderData gfxSelected;
LineShaderData gfxHighlighted[8];
+ std::unique_ptr<QuadTreeBels> qtBels;
};
std::unique_ptr<RendererData> rendererData_;
QMutex rendererDataLock_;
@@ -167,6 +187,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void drawDecal(LineShaderData &out, const DecalXY &decal);
void drawArchDecal(LineShaderData out[GraphicElement::STYLE_MAX], const DecalXY &decal);
QVector4D mouseToWorldCoordinates(int x, int y);
+ QVector4D mouseToWorldDimensions(int x, int y);
QMatrix4x4 getProjection(void);
};