gui: clang-format
This commit is contained in:
parent
0eb40da749
commit
5a7fe84a04
@ -31,11 +31,9 @@
|
|||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
FPGAViewWidget::FPGAViewWidget(QWidget *parent) :
|
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
|
||||||
QOpenGLWidget(parent), ctx_(nullptr), paintTimer_(this),
|
: QOpenGLWidget(parent), ctx_(nullptr), paintTimer_(this), lineShader_(this), zoom_(10.0f),
|
||||||
lineShader_(this), zoom_(10.0f),
|
rendererArgs_(new FPGAViewWidget::RendererArgs), rendererData_(new FPGAViewWidget::RendererData)
|
||||||
rendererArgs_(new FPGAViewWidget::RendererArgs),
|
|
||||||
rendererData_(new FPGAViewWidget::RendererData)
|
|
||||||
{
|
{
|
||||||
colors_.background = QColor("#000000");
|
colors_.background = QColor("#000000");
|
||||||
colors_.grid = QColor("#333");
|
colors_.grid = QColor("#333");
|
||||||
@ -126,10 +124,10 @@ float FPGAViewWidget::PickedElement::distance(Context *ctx, float wx, float wy)
|
|||||||
|
|
||||||
// Go over its' GraphicElements, and calculate the distance to them.
|
// Go over its' GraphicElements, and calculate the distance to them.
|
||||||
std::vector<float> distances;
|
std::vector<float> distances;
|
||||||
std::transform(graphics.begin(), graphics.end(), std::back_inserter(distances), [&](const GraphicElement &ge) -> float {
|
std::transform(graphics.begin(), graphics.end(), std::back_inserter(distances),
|
||||||
|
[&](const GraphicElement &ge) -> float {
|
||||||
switch (ge.type) {
|
switch (ge.type) {
|
||||||
case GraphicElement::TYPE_BOX:
|
case GraphicElement::TYPE_BOX: {
|
||||||
{
|
|
||||||
// If outside the box, return unit distance to closest border.
|
// If outside the box, return unit distance to closest border.
|
||||||
float outside_x = -1, outside_y = -1;
|
float outside_x = -1, outside_y = -1;
|
||||||
if (dx < ge.x1 || dx > ge.x2) {
|
if (dx < ge.x1 || dx > ge.x2) {
|
||||||
@ -145,8 +143,7 @@ float FPGAViewWidget::PickedElement::distance(Context *ctx, float wx, float wy)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case GraphicElement::TYPE_LINE:
|
case GraphicElement::TYPE_LINE:
|
||||||
case GraphicElement::TYPE_ARROW:
|
case GraphicElement::TYPE_ARROW: {
|
||||||
{
|
|
||||||
// Return somewhat primitively calculated distance to segment.
|
// Return somewhat primitively calculated distance to segment.
|
||||||
// TODO(q3k): consider coming up with a better algorithm
|
// TODO(q3k): consider coming up with a better algorithm
|
||||||
QVector2D w(wx, wy);
|
QVector2D w(wx, wy);
|
||||||
@ -165,13 +162,16 @@ float FPGAViewWidget::PickedElement::distance(Context *ctx, float wx, float wy)
|
|||||||
// Find smallest non -1 distance.
|
// Find smallest non -1 distance.
|
||||||
// Find closest element.
|
// Find closest element.
|
||||||
return *std::min_element(distances.begin(), distances.end(), [&](float a, float b) {
|
return *std::min_element(distances.begin(), distances.end(), [&](float a, float b) {
|
||||||
if (a == -1) return false;
|
if (a == -1)
|
||||||
if (b == -1) return true;
|
return false;
|
||||||
|
if (b == -1)
|
||||||
|
return true;
|
||||||
return a < b;
|
return a < b;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FPGAViewWidget::renderGraphicElement(RendererData *data, LineShaderData &out, const GraphicElement &el, float x, float y)
|
void FPGAViewWidget::renderGraphicElement(RendererData *data, LineShaderData &out, const GraphicElement &el, float x,
|
||||||
|
float y)
|
||||||
{
|
{
|
||||||
if (el.type == GraphicElement::TYPE_BOX) {
|
if (el.type == GraphicElement::TYPE_BOX) {
|
||||||
auto line = PolyLine(true);
|
auto line = PolyLine(true);
|
||||||
@ -301,7 +301,8 @@ void FPGAViewWidget::paintGL()
|
|||||||
// Render Arch graphics.
|
// Render Arch graphics.
|
||||||
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_FRAME], colors_.frame, thick11Px, matrix);
|
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_FRAME], colors_.frame, thick11Px, matrix);
|
||||||
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_HIDDEN], colors_.hidden, thick11Px, matrix);
|
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_HIDDEN], colors_.hidden, thick11Px, matrix);
|
||||||
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_INACTIVE], colors_.inactive, thick11Px, matrix);
|
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_INACTIVE], colors_.inactive, thick11Px,
|
||||||
|
matrix);
|
||||||
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_ACTIVE], colors_.active, thick11Px, matrix);
|
lineShader_.draw(rendererData_->gfxByStyle[GraphicElement::STYLE_ACTIVE], colors_.active, thick11Px, matrix);
|
||||||
|
|
||||||
// Draw highlighted items.
|
// Draw highlighted items.
|
||||||
@ -410,7 +411,6 @@ void FPGAViewWidget::renderLines(void)
|
|||||||
flags = rendererArgs_->flags;
|
flags = rendererArgs_->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Render decals if necessary.
|
// Render decals if necessary.
|
||||||
if (decalsChanged) {
|
if (decalsChanged) {
|
||||||
auto data = std::unique_ptr<FPGAViewWidget::RendererData>(new FPGAViewWidget::RendererData);
|
auto data = std::unique_ptr<FPGAViewWidget::RendererData>(new FPGAViewWidget::RendererData);
|
||||||
@ -549,15 +549,16 @@ boost::optional<FPGAViewWidget::PickedElement> FPGAViewWidget::pickElement(float
|
|||||||
// Calculate distances to all elements picked.
|
// Calculate distances to all elements picked.
|
||||||
using ElemDist = std::pair<const PickedElement *, float>;
|
using ElemDist = std::pair<const PickedElement *, float>;
|
||||||
std::vector<ElemDist> distances;
|
std::vector<ElemDist> distances;
|
||||||
std::transform(elems.begin(), elems.end(), std::back_inserter(distances),
|
std::transform(elems.begin(), elems.end(), std::back_inserter(distances), [&](const PickedElement &e) -> ElemDist {
|
||||||
[&](const PickedElement &e) -> ElemDist {
|
|
||||||
return std::make_pair(&e, e.distance(ctx_, worldx, worldy));
|
return std::make_pair(&e, e.distance(ctx_, worldx, worldy));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find closest non -1 element.
|
// Find closest non -1 element.
|
||||||
auto closest = std::min_element(distances.begin(), distances.end(), [&](const ElemDist &a, const ElemDist &b) {
|
auto closest = std::min_element(distances.begin(), distances.end(), [&](const ElemDist &a, const ElemDist &b) {
|
||||||
if (a.second == -1) return false;
|
if (a.second == -1)
|
||||||
if (b.second == -1) return true;
|
return false;
|
||||||
|
if (b.second == -1)
|
||||||
|
return true;
|
||||||
return a.second < b.second;
|
return a.second < b.second;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -619,7 +620,6 @@ void FPGAViewWidget::mouseMoveEvent(QMouseEvent *event)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Invert the projection matrix to calculate screen/mouse to world/grid
|
// Invert the projection matrix to calculate screen/mouse to world/grid
|
||||||
// coordinates.
|
// coordinates.
|
||||||
QVector4D FPGAViewWidget::mouseToWorldCoordinates(int x, int y)
|
QVector4D FPGAViewWidget::mouseToWorldCoordinates(int x, int y)
|
||||||
@ -677,7 +677,6 @@ void FPGAViewWidget::zoom(int level)
|
|||||||
zoom_ -= level / 100.0;
|
zoom_ -= level / 100.0;
|
||||||
} else {
|
} else {
|
||||||
zoom_ -= level / 10.0;
|
zoom_ -= level / 10.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoom_ < zoomNear_)
|
if (zoom_ < zoomNear_)
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#ifndef MAPGLWIDGET_H
|
#ifndef MAPGLWIDGET_H
|
||||||
#define MAPGLWIDGET_H
|
#define MAPGLWIDGET_H
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QOpenGLBuffer>
|
#include <QOpenGLBuffer>
|
||||||
@ -32,11 +31,12 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
|
#include "designwidget.h"
|
||||||
|
#include "lineshader.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include "quadtree.h"
|
#include "quadtree.h"
|
||||||
#include "lineshader.h"
|
|
||||||
#include "designwidget.h"
|
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -108,7 +108,6 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|||||||
QSize minimumSizeHint() const override;
|
QSize minimumSizeHint() const override;
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
void onSelectedArchItem(std::vector<DecalXY> decals);
|
void onSelectedArchItem(std::vector<DecalXY> decals);
|
||||||
@ -129,9 +128,11 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|||||||
const float zoomLvl1_ = 1.0f;
|
const float zoomLvl1_ = 1.0f;
|
||||||
const float zoomLvl2_ = 5.0f;
|
const float zoomLvl2_ = 5.0f;
|
||||||
|
|
||||||
struct PickedElement {
|
struct PickedElement
|
||||||
|
{
|
||||||
ElementType type;
|
ElementType type;
|
||||||
union Inner {
|
union Inner
|
||||||
|
{
|
||||||
BelId bel;
|
BelId bel;
|
||||||
WireId wire;
|
WireId wire;
|
||||||
PipId pip;
|
PipId pip;
|
||||||
@ -202,17 +203,14 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|||||||
{
|
{
|
||||||
bool zoomOutbound;
|
bool zoomOutbound;
|
||||||
|
|
||||||
PassthroughFlags() :
|
PassthroughFlags() : zoomOutbound(false) {}
|
||||||
zoomOutbound(false) {}
|
PassthroughFlags &operator=(const PassthroughFlags &other) noexcept
|
||||||
PassthroughFlags &operator=(const PassthroughFlags &other) noexcept {
|
{
|
||||||
zoomOutbound = other.zoomOutbound;
|
zoomOutbound = other.zoomOutbound;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear() { zoomOutbound = false; }
|
||||||
{
|
|
||||||
zoomOutbound = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RendererArgs
|
struct RendererArgs
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
#include "lineshader.h"
|
#include "lineshader.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -26,14 +26,16 @@
|
|||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
// A node of a QuadTree. Internal.
|
// A node of a QuadTree. Internal.
|
||||||
template <typename CoordinateT, typename ElementT>
|
template <typename CoordinateT, typename ElementT> class QuadTreeNode
|
||||||
class QuadTreeNode
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class BoundingBox {
|
class BoundingBox
|
||||||
|
{
|
||||||
friend class QuadTreeNode;
|
friend class QuadTreeNode;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CoordinateT x0_, x1_, y0_, y1_;
|
CoordinateT x0_, x1_, y0_, y1_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Standard constructor for a given (x0,y0), (x1,y1) bounding box
|
// Standard constructor for a given (x0,y0), (x1,y1) bounding box
|
||||||
//
|
//
|
||||||
@ -41,11 +43,11 @@ class QuadTreeNode
|
|||||||
// @param y0 y coordinate of top-left corner of box
|
// @param y0 y coordinate of top-left corner of box
|
||||||
// @param x1 x coordinate of bottom-right corner of box
|
// @param x1 x coordinate of bottom-right corner of box
|
||||||
// @param y1 y coordinate of bottom-right corner of box
|
// @param y1 y coordinate of bottom-right corner of box
|
||||||
BoundingBox(CoordinateT x0, CoordinateT y0, CoordinateT x1, CoordinateT y1) :
|
BoundingBox(CoordinateT x0, CoordinateT y0, CoordinateT x1, CoordinateT y1) : x0_(x0), x1_(x1), y0_(y0), y1_(y1)
|
||||||
x0_(x0), x1_(x1), y0_(y0), y1_(y1) {}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
BoundingBox(const BoundingBox &other) :
|
BoundingBox(const BoundingBox &other) : x0_(other.x0_), x1_(other.x1_), y0_(other.y0_), y1_(other.y1_) {}
|
||||||
x0_(other.x0_), x1_(other.x1_), y0_(other.y0_), y1_(other.y1_) {}
|
|
||||||
|
|
||||||
// Whether a bounding box contains a given points.
|
// Whether a bounding box contains a given points.
|
||||||
// A point is defined to be in a bounding box when it's not lesser than
|
// A point is defined to be in a bounding box when it's not lesser than
|
||||||
@ -74,14 +76,16 @@ class QuadTreeNode
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// A pair of Element and BoundingBox that contains it.
|
// A pair of Element and BoundingBox that contains it.
|
||||||
class BoundElement {
|
class BoundElement
|
||||||
|
{
|
||||||
friend class QuadTreeNode;
|
friend class QuadTreeNode;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BoundingBox bb_;
|
BoundingBox bb_;
|
||||||
ElementT elem_;
|
ElementT elem_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoundElement(BoundingBox bb, ElementT elem) :
|
BoundElement(BoundingBox bb, ElementT elem) : bb_(bb), elem_(elem) {}
|
||||||
bb_(bb), elem_(elem) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// The bounding box that this node describes.
|
// The bounding box that this node describes.
|
||||||
@ -124,7 +128,8 @@ class QuadTreeNode
|
|||||||
// Used to describe one of 5 possible places an element can exist:
|
// Used to describe one of 5 possible places an element can exist:
|
||||||
// - the node itself (THIS)
|
// - the node itself (THIS)
|
||||||
// - any of the 4 children nodes.
|
// - any of the 4 children nodes.
|
||||||
enum Quadrant {
|
enum Quadrant
|
||||||
|
{
|
||||||
THIS = -1,
|
THIS = -1,
|
||||||
NW = 0,
|
NW = 0,
|
||||||
NE = 1,
|
NE = 1,
|
||||||
@ -175,22 +180,18 @@ class QuadTreeNode
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Standard constructor for node.
|
// Standard constructor for node.
|
||||||
// @param b BoundingBox this node covers.
|
// @param b BoundingBox this node covers.
|
||||||
// @param depth depth at which this node is in the tree
|
// @param depth depth at which this node is in the tree
|
||||||
// @max_elems how many elements should this node contain before it splits
|
// @max_elems how many elements should this node contain before it splits
|
||||||
QuadTreeNode(BoundingBox b, int depth, size_t max_elems = 4) :
|
QuadTreeNode(BoundingBox b, int depth, size_t max_elems = 4) : bound_(b), max_elems_(max_elems), depth_(depth) {}
|
||||||
bound_(b), max_elems_(max_elems), depth_(depth)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
// Disallow copies.
|
// Disallow copies.
|
||||||
QuadTreeNode(const QuadTreeNode &other) = delete;
|
QuadTreeNode(const QuadTreeNode &other) = delete;
|
||||||
QuadTreeNode &operator=(const QuadTreeNode &other) = delete;
|
QuadTreeNode &operator=(const QuadTreeNode &other) = delete;
|
||||||
// Allow moves.
|
// Allow moves.
|
||||||
QuadTreeNode(QuadTreeNode &&other) :
|
QuadTreeNode(QuadTreeNode &&other)
|
||||||
bound_(other.bound_), max_elems_(other.max_elems_), children_(std::move(other.children_)),
|
: bound_(other.bound_), max_elems_(other.max_elems_), children_(std::move(other.children_)),
|
||||||
splitx_(other.splitx_), splity_(other.splity_), elems_(std::move(other.elems_)), depth_(other.depth_)
|
splitx_(other.splitx_), splity_(other.splity_), elems_(std::move(other.elems_)), depth_(other.depth_)
|
||||||
{
|
{
|
||||||
other.children_ = nullptr;
|
other.children_ = nullptr;
|
||||||
@ -242,10 +243,17 @@ class QuadTreeNode
|
|||||||
children_ = decltype(children_)(new QuadTreeNode<CoordinateT, ElementT>[4] {
|
children_ = decltype(children_)(new QuadTreeNode<CoordinateT, ElementT>[4] {
|
||||||
// Note: not using [NW] = QuadTreeNode because that seems to
|
// Note: not using [NW] = QuadTreeNode because that seems to
|
||||||
// crash g++ 7.3.0.
|
// crash g++ 7.3.0.
|
||||||
/* NW */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, bound_.y0_, splitx_, splity_), depth_+1, max_elems_),
|
/* NW */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, bound_.y0_, splitx_, splity_),
|
||||||
/* NE */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, bound_.y0_, bound_.x1_, splity_), depth_+1, max_elems_),
|
depth_ + 1, max_elems_),
|
||||||
/* SW */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, splity_, splitx_, bound_.y1_), depth_+1, max_elems_),
|
/* NE */
|
||||||
/* SE */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, splity_, bound_.x1_, bound_.y1_), depth_+1, max_elems_),
|
QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, bound_.y0_, bound_.x1_, splity_),
|
||||||
|
depth_ + 1, max_elems_),
|
||||||
|
/* SW */
|
||||||
|
QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, splity_, splitx_, bound_.y1_),
|
||||||
|
depth_ + 1, max_elems_),
|
||||||
|
/* SE */
|
||||||
|
QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, splity_, bound_.x1_, bound_.y1_),
|
||||||
|
depth_ + 1, max_elems_),
|
||||||
});
|
});
|
||||||
// Move all elements to where they belong.
|
// Move all elements to where they belong.
|
||||||
auto it = elems_.begin();
|
auto it = elems_.begin();
|
||||||
@ -271,15 +279,18 @@ class QuadTreeNode
|
|||||||
// Dump a human-readable representation of the tree to stdout.
|
// Dump a human-readable representation of the tree to stdout.
|
||||||
void dump(int level) const
|
void dump(int level) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < level; i++) printf(" ");
|
for (int i = 0; i < level; i++)
|
||||||
|
printf(" ");
|
||||||
printf("loc: % 3d % 3d % 3d % 3d\n", bound_.x0_, bound_.y0_, bound_.x1_, bound_.y1_);
|
printf("loc: % 3d % 3d % 3d % 3d\n", bound_.x0_, bound_.y0_, bound_.x1_, bound_.y1_);
|
||||||
if (elems_.size() != 0) {
|
if (elems_.size() != 0) {
|
||||||
for (int i = 0; i < level; i++) printf(" ");
|
for (int i = 0; i < level; i++)
|
||||||
|
printf(" ");
|
||||||
printf("elems: %zu\n", elems_.size());
|
printf("elems: %zu\n", elems_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (children_ != nullptr) {
|
if (children_ != nullptr) {
|
||||||
for (int i = 0; i < level; i++) printf(" ");
|
for (int i = 0; i < level; i++)
|
||||||
|
printf(" ");
|
||||||
printf("children:\n");
|
printf("children:\n");
|
||||||
children_[NW].dump(level + 1);
|
children_[NW].dump(level + 1);
|
||||||
children_[NE].dump(level + 1);
|
children_[NE].dump(level + 1);
|
||||||
@ -331,8 +342,7 @@ class QuadTreeNode
|
|||||||
//
|
//
|
||||||
// @param CoodinateT scalar type of the coordinate system - int, float, ...
|
// @param CoodinateT scalar type of the coordinate system - int, float, ...
|
||||||
// @param ElementT type of the contained element. Must be movable or copiable.
|
// @param ElementT type of the contained element. Must be movable or copiable.
|
||||||
template <typename CoordinateT, typename ElementT>
|
template <typename CoordinateT, typename ElementT> class QuadTree
|
||||||
class QuadTree
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Root of the tree.
|
// Root of the tree.
|
||||||
@ -348,10 +358,7 @@ class QuadTree
|
|||||||
//
|
//
|
||||||
// @param b Bounding box of the entire tree - all comitted elements must
|
// @param b Bounding box of the entire tree - all comitted elements must
|
||||||
// fit within in.
|
// fit within in.
|
||||||
QuadTree(BoundingBox b) :
|
QuadTree(BoundingBox b) : root_(b, 0) {}
|
||||||
root_(b, 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inserts a new value at a given bounding box.e
|
// Inserts a new value at a given bounding box.e
|
||||||
// BoundingBoxes are not deduplicated - if two are pushed with the same
|
// BoundingBoxes are not deduplicated - if two are pushed with the same
|
||||||
@ -367,17 +374,11 @@ class QuadTree
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dump a human-readable representation of the tree to stdout.
|
// Dump a human-readable representation of the tree to stdout.
|
||||||
void dump() const
|
void dump() const { root_.dump(0); }
|
||||||
{
|
|
||||||
root_.dump(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return count of BoundingBoxes/Elements contained.
|
// Return count of BoundingBoxes/Elements contained.
|
||||||
// @returns count of elements contained.
|
// @returns count of elements contained.
|
||||||
size_t size() const
|
size_t size() const { return root_.size(); }
|
||||||
{
|
|
||||||
return root_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve elements whose bounding boxes cover the given coordinates.
|
// Retrieve elements whose bounding boxes cover the given coordinates.
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user