gui: allow building for ECP5 and on Windows

This commit is contained in:
Sergiusz Bazanski 2018-07-27 13:46:44 +01:00
parent 96608c8d07
commit dc46eea24d
2 changed files with 25 additions and 5 deletions

View File

@ -143,12 +143,32 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
Inner(WireId _wire) : wire(_wire) {} Inner(WireId _wire) : wire(_wire) {}
Inner(PipId _pip) : pip(_pip) {} Inner(PipId _pip) : pip(_pip) {}
Inner(GroupId _group) : group(_group) {} Inner(GroupId _group) : group(_group) {}
Inner() {}
} element; } element;
float x, y; // Decal X and Y float x, y; // Decal X and Y
PickedElement(BelId bel, float x, float y) : type(ElementType::BEL), element(bel), x(x), y(y) {} PickedElement(BelId bel, float x, float y) : type(ElementType::BEL), element(bel), x(x), y(y) {}
PickedElement(WireId wire, float x, float y) : type(ElementType::WIRE), element(wire), x(x), y(y) {} PickedElement(WireId wire, float x, float y) : type(ElementType::WIRE), element(wire), x(x), y(y) {}
PickedElement(PipId pip, float x, float y) : type(ElementType::PIP), element(pip), x(x), y(y) {} PickedElement(PipId pip, float x, float y) : type(ElementType::PIP), element(pip), x(x), y(y) {}
PickedElement(GroupId group, float x, float y) : type(ElementType::GROUP), element(group), x(x), y(y) {} PickedElement(GroupId group, float x, float y) : type(ElementType::GROUP), element(group), x(x), y(y) {}
PickedElement(const PickedElement &other) : type(other.type)
{
switch (type) {
case ElementType::BEL:
element.bel = other.element.bel;
break;
case ElementType::WIRE:
element.wire = other.element.wire;
break;
case ElementType::PIP:
element.pip = other.element.pip;
break;
case ElementType::GROUP:
element.group = other.element.group;
break;
default:
NPNR_ASSERT_FALSE("Invalid ElementType");
}
}
DecalXY decal(Context *ctx) const DecalXY decal(Context *ctx) const
{ {

View File

@ -157,7 +157,7 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
// - any of the 4 children nodes. // - any of the 4 children nodes.
enum Quadrant enum Quadrant
{ {
THIS = -1, THIS_NODE = -1,
NW = 0, NW = 0,
NE = 1, NE = 1,
SW = 2, SW = 2,
@ -171,7 +171,7 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
Quadrant quadrant(const BoundingBox &b) const Quadrant quadrant(const BoundingBox &b) const
{ {
if (children_ == nullptr) { if (children_ == nullptr) {
return THIS; return THIS_NODE;
} }
bool west0 = b.x0_ < splitx_; bool west0 = b.x0_ < splitx_;
@ -187,7 +187,7 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
return SW; return SW;
if (!west0 && !west1 && !north0 && !north1) if (!west0 && !west1 && !north0 && !north1)
return SE; return SE;
return THIS; return THIS_NODE;
} }
// Checks whether this node should split. // Checks whether this node should split.
@ -252,7 +252,7 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
// Put the element either recursively into a child if it fits // Put the element either recursively into a child if it fits
// entirely or keep it for ourselves if not. // entirely or keep it for ourselves if not.
auto quad = quadrant(k); auto quad = quadrant(k);
if (quad == THIS) { if (quad == THIS_NODE) {
elems_.push_back(BoundElement(k, std::move(v))); elems_.push_back(BoundElement(k, std::move(v)));
} else { } else {
return children_[quad].insert(k, std::move(v)); return children_[quad].insert(k, std::move(v));
@ -286,7 +286,7 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
auto it = elems_.begin(); auto it = elems_.begin();
while (it != elems_.end()) { while (it != elems_.end()) {
auto quad = quadrant(it->bb_); auto quad = quadrant(it->bb_);
if (quad != THIS) { if (quad != THIS_NODE) {
// Move to one of the children. // Move to one of the children.
if (!children_[quad].insert(it->bb_, std::move(it->elem_))) if (!children_[quad].insert(it->bb_, std::move(it->elem_)))
return false; return false;