aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2018-11-16 13:25:51 +0000
committerDavid Shah <dave@ds0.me>2018-11-16 13:25:51 +0000
commit9c52afcf5fabd888ec7d89e506ebe00c5a1a3640 (patch)
tree1235428896dcae4bbd8daf6be34a21a7510e2d8c /gui
parent20aa0a0eedbce02f50e134772dcd2b4a5be830e4 (diff)
downloadnextpnr-9c52afcf5fabd888ec7d89e506ebe00c5a1a3640.tar.gz
nextpnr-9c52afcf5fabd888ec7d89e506ebe00c5a1a3640.tar.bz2
nextpnr-9c52afcf5fabd888ec7d89e506ebe00c5a1a3640.zip
clangformat
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'gui')
-rw-r--r--gui/designwidget.cc36
-rw-r--r--gui/ecp5/mainwindow.cc6
-rw-r--r--gui/fpgaviewwidget.cc94
-rw-r--r--gui/lineshader.cc7
-rw-r--r--gui/lineshader.h12
-rw-r--r--gui/quadtree.h28
6 files changed, 86 insertions, 97 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index 9895cad1..235dd2cb 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -291,15 +291,16 @@ void DesignWidget::newContext(Context *ctx)
{
TreeModel::ElementXYRoot<BelId>::ElementMap belMap;
- for (const auto& bel : ctx->getBels()) {
+ for (const auto &bel : ctx->getBels()) {
auto loc = ctx->getBelLocation(bel);
belMap[std::pair<int, int>(loc.x, loc.y)].push_back(bel);
}
auto belGetter = [](Context *ctx, BelId id) { return ctx->getBelName(id); };
getTreeByElementType(ElementType::BEL)
- ->loadData(ctx, std::unique_ptr<TreeModel::ElementXYRoot<BelId>>(
- new TreeModel::ElementXYRoot<BelId>(ctx, belMap, belGetter, ElementType::BEL)));
+ ->loadData(ctx,
+ std::unique_ptr<TreeModel::ElementXYRoot<BelId>>(
+ new TreeModel::ElementXYRoot<BelId>(ctx, belMap, belGetter, ElementType::BEL)));
}
{
@@ -313,33 +314,37 @@ void DesignWidget::newContext(Context *ctx)
}
#endif
#ifdef ARCH_ECP5
- for (const auto& wire : ctx->getWires()) {
+ for (const auto &wire : ctx->getWires()) {
wireMap[std::pair<int, int>(wire.location.x, wire.location.y)].push_back(wire);
}
#endif
auto wireGetter = [](Context *ctx, WireId id) { return ctx->getWireName(id); };
getTreeByElementType(ElementType::WIRE)
- ->loadData(ctx, std::unique_ptr<TreeModel::ElementXYRoot<WireId>>(
- new TreeModel::ElementXYRoot<WireId>(ctx, wireMap, wireGetter, ElementType::WIRE)));
+ ->loadData(ctx,
+ std::unique_ptr<TreeModel::ElementXYRoot<WireId>>(new TreeModel::ElementXYRoot<WireId>(
+ ctx, wireMap, wireGetter, ElementType::WIRE)));
}
{
TreeModel::ElementXYRoot<PipId>::ElementMap pipMap;
- for (const auto& pip : ctx->getPips()) {
+ for (const auto &pip : ctx->getPips()) {
auto loc = ctx->getPipLocation(pip);
pipMap[std::pair<int, int>(loc.x, loc.y)].push_back(pip);
}
auto pipGetter = [](Context *ctx, PipId id) { return ctx->getPipName(id); };
getTreeByElementType(ElementType::PIP)
- ->loadData(ctx, std::unique_ptr<TreeModel::ElementXYRoot<PipId>>(
- new TreeModel::ElementXYRoot<PipId>(ctx, pipMap, pipGetter, ElementType::PIP)));
+ ->loadData(ctx,
+ std::unique_ptr<TreeModel::ElementXYRoot<PipId>>(
+ new TreeModel::ElementXYRoot<PipId>(ctx, pipMap, pipGetter, ElementType::PIP)));
}
getTreeByElementType(ElementType::CELL)
- ->loadData(ctx, std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::CELL)));
+ ->loadData(ctx,
+ std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::CELL)));
getTreeByElementType(ElementType::NET)
- ->loadData(ctx, std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::NET)));
+ ->loadData(ctx,
+ std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::NET)));
}
updateTree();
}
@@ -567,18 +572,18 @@ void DesignWidget::onSelectionChanged(int num, const QItemSelection &, const QIt
std::move(d.begin(), d.end(), std::back_inserter(decals));
}
}
-
+
// Keep other tree seleciton only if Control is pressed
if (num_selected > 1 && QApplication::keyboardModifiers().testFlag(Qt::ControlModifier) == true) {
Q_EMIT selected(decals, false);
return;
}
-
+
// For deselect and multiple select just send all
if (selectionModel[num]->selectedIndexes().size() != 1) {
Q_EMIT selected(decals, false);
return;
- }
+ }
QModelIndex index = selectionModel[num]->selectedIndexes().at(0);
if (!index.isValid())
@@ -591,7 +596,8 @@ void DesignWidget::onSelectionChanged(int num, const QItemSelection &, const QIt
// Clear other tab selections
for (int i = 0; i <= getIndexByElementType(ElementType::GROUP); i++)
- if (i!=num) selectionModel[i]->clearSelection();
+ if (i != num)
+ selectionModel[i]->clearSelection();
addToHistory(num, index);
diff --git a/gui/ecp5/mainwindow.cc b/gui/ecp5/mainwindow.cc
index fe2f9e57..c6c7bc97 100644
--- a/gui/ecp5/mainwindow.cc
+++ b/gui/ecp5/mainwindow.cc
@@ -18,9 +18,9 @@
*/
#include "mainwindow.h"
+#include <fstream>
#include "bitstream.h"
#include "log.h"
-#include <fstream>
#include <QFileDialog>
#include <QInputDialog>
@@ -150,7 +150,7 @@ void MainWindow::open_lpf()
{
QString fileName = QFileDialog::getOpenFileName(this, QString("Open LPF"), QString(), QString("*.lpf"));
if (!fileName.isEmpty()) {
- std::ifstream in(fileName.toStdString());
+ std::ifstream in(fileName.toStdString());
if (ctx->applyLPF(fileName.toStdString(), in)) {
log("Loading LPF successful.\n");
actionPack->setEnabled(true);
@@ -158,7 +158,7 @@ void MainWindow::open_lpf()
} else {
actionLoadLPF->setEnabled(true);
log("Loading LPF failed.\n");
- }
+ }
}
}
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index b771d6a4..3fba6bff 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -113,8 +113,8 @@ void FPGAViewWidget::initializeGL()
}
initializeOpenGLFunctions();
QtImGui::initialize(this);
- glClearColor(colors_.background.red() / 255, colors_.background.green() / 255,
- colors_.background.blue() / 255, 0.0);
+ glClearColor(colors_.background.red() / 255, colors_.background.green() / 255, colors_.background.blue() / 255,
+ 0.0);
}
float FPGAViewWidget::PickedElement::distance(Context *ctx, float wx, float wy) const
@@ -314,36 +314,27 @@ void FPGAViewWidget::paintGL()
}
// Render the grid.
- lineShader_.draw(GraphicElement::STYLE_GRID, colors_.grid, thick1Px,
- matrix);
+ lineShader_.draw(GraphicElement::STYLE_GRID, colors_.grid, thick1Px, matrix);
// Render Arch graphics.
- lineShader_.draw(GraphicElement::STYLE_FRAME, colors_.frame, thick11Px,
- matrix);
- lineShader_.draw(GraphicElement::STYLE_HIDDEN, colors_.hidden, thick11Px,
- matrix);
- lineShader_.draw(GraphicElement::STYLE_INACTIVE, colors_.inactive,
- thick11Px, matrix);
- lineShader_.draw(GraphicElement::STYLE_ACTIVE, colors_.active, thick11Px,
- matrix);
+ lineShader_.draw(GraphicElement::STYLE_FRAME, colors_.frame, thick11Px, matrix);
+ lineShader_.draw(GraphicElement::STYLE_HIDDEN, colors_.hidden, thick11Px, matrix);
+ lineShader_.draw(GraphicElement::STYLE_INACTIVE, colors_.inactive, thick11Px, matrix);
+ lineShader_.draw(GraphicElement::STYLE_ACTIVE, colors_.active, thick11Px, matrix);
// Draw highlighted items.
for (int i = 0; i < 8; i++) {
- GraphicElement::style_t style = (GraphicElement::style_t)(
- GraphicElement::STYLE_HIGHLIGHTED0 + i);
+ GraphicElement::style_t style = (GraphicElement::style_t)(GraphicElement::STYLE_HIGHLIGHTED0 + i);
lineShader_.draw(style, colors_.highlight[i], thick11Px, matrix);
}
- lineShader_.draw(GraphicElement::STYLE_SELECTED, colors_.selected,
- thick11Px, matrix);
- lineShader_.draw(GraphicElement::STYLE_HOVER, colors_.hovered,
- thick2Px, matrix);
+ lineShader_.draw(GraphicElement::STYLE_SELECTED, colors_.selected, thick11Px, matrix);
+ lineShader_.draw(GraphicElement::STYLE_HOVER, colors_.hovered, thick2Px, matrix);
// Render ImGui
QtImGui::newFrame();
QMutexLocker lock(&rendererArgsLock_);
- if (!(rendererArgs_->hoveredDecal == DecalXY()) && rendererArgs_->hintText.size() > 0)
- {
+ if (!(rendererArgs_->hoveredDecal == DecalXY()) && rendererArgs_->hintText.size() > 0) {
ImGui::SetNextWindowPos(ImVec2(rendererArgs_->x, rendererArgs_->y));
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
@@ -351,7 +342,7 @@ void FPGAViewWidget::paintGL()
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
- ImGui::Render();
+ ImGui::Render();
}
void FPGAViewWidget::pokeRenderer(void) { renderRunner_->poke(); }
@@ -444,10 +435,10 @@ void FPGAViewWidget::renderLines(void)
int last_render[GraphicElement::STYLE_HIGHLIGHTED0];
{
QMutexLocker locker(&rendererDataLock_);
- for(int i =0; i<GraphicElement::STYLE_HIGHLIGHTED0; i++)
+ for (int i = 0; i < GraphicElement::STYLE_HIGHLIGHTED0; i++)
last_render[i] = rendererData_->gfxByStyle[(enum GraphicElement::style_t)i].last_render;
}
-
+
auto data = std::unique_ptr<FPGAViewWidget::RendererData>(new FPGAViewWidget::RendererData);
// Reset bounding box.
data->bbGlobal.clear();
@@ -514,13 +505,12 @@ void FPGAViewWidget::renderLines(void)
for (int i = 0; i < 8; i++)
data->gfxHighlighted[i] = rendererData_->gfxHighlighted[i];
}
- for(int i =0; i<GraphicElement::STYLE_HIGHLIGHTED0; i++)
+ for (int i = 0; i < GraphicElement::STYLE_HIGHLIGHTED0; i++)
data->gfxByStyle[(enum GraphicElement::style_t)i].last_render = ++last_render[i];
rendererData_ = std::move(data);
}
}
- if (gridChanged)
- {
+ if (gridChanged) {
QMutexLocker locker(&rendererDataLock_);
rendererData_->gfxGrid.clear();
// Render grid.
@@ -529,7 +519,7 @@ void FPGAViewWidget::renderLines(void)
}
for (float i = 0.0f; i < 1.0f * ctx_->getGridDimY() + 1; i += 1.0f) {
PolyLine(0.0f, i, 1.0f * ctx_->getGridDimX(), i).build(rendererData_->gfxGrid);
- }
+ }
rendererData_->gfxGrid.last_render++;
}
if (highlightedOrSelectedChanged) {
@@ -537,7 +527,7 @@ void FPGAViewWidget::renderLines(void)
// Whether the currently being hovered decal is also selected.
bool hoveringSelected = false;
- // Render selected.
+ // Render selected.
rendererData_->bbSelected.clear();
rendererData_->gfxSelected.clear();
for (auto &decal : selectedDecals) {
@@ -565,11 +555,11 @@ void FPGAViewWidget::renderLines(void)
}
{
- QMutexLocker lock(&rendererArgsLock_);
+ QMutexLocker lock(&rendererArgsLock_);
if (rendererArgs_->zoomOutbound) {
zoomOutbound();
- rendererArgs_->zoomOutbound = false;
+ rendererArgs_->zoomOutbound = false;
}
}
}
@@ -651,7 +641,8 @@ boost::optional<FPGAViewWidget::PickedElement> FPGAViewWidget::pickElement(float
void FPGAViewWidget::mousePressEvent(QMouseEvent *event)
{
ImGuiIO &io = ImGui::GetIO();
- if (io.WantCaptureMouse) return;
+ if (io.WantCaptureMouse)
+ return;
if (event->buttons() & Qt::RightButton || event->buttons() & Qt::MidButton) {
lastDragPos_ = event->pos();
@@ -687,7 +678,8 @@ void FPGAViewWidget::mousePressEvent(QMouseEvent *event)
void FPGAViewWidget::mouseMoveEvent(QMouseEvent *event)
{
ImGuiIO &io = ImGui::GetIO();
- if (io.WantCaptureMouse) return;
+ if (io.WantCaptureMouse)
+ return;
if (event->buttons() & Qt::RightButton || event->buttons() & Qt::MidButton) {
const int dx = event->x() - lastDragPos_.x();
@@ -724,22 +716,23 @@ void FPGAViewWidget::mouseMoveEvent(QMouseEvent *event)
if (closest.type == ElementType::BEL) {
rendererArgs_->hintText = std::string("BEL\n") + ctx_->getBelName(closest.bel).c_str(ctx_);
CellInfo *cell = ctx_->getBoundBelCell(closest.bel);
- if (cell!=nullptr)
- rendererArgs_->hintText += std::string("\nCELL\n") +ctx_->nameOf(cell);
+ if (cell != nullptr)
+ rendererArgs_->hintText += std::string("\nCELL\n") + ctx_->nameOf(cell);
} else if (closest.type == ElementType::WIRE) {
rendererArgs_->hintText = std::string("WIRE\n") + ctx_->getWireName(closest.wire).c_str(ctx_);
NetInfo *net = ctx_->getBoundWireNet(closest.wire);
- if (net!=nullptr)
- rendererArgs_->hintText += std::string("\nNET\n") +ctx_->nameOf(net);
+ if (net != nullptr)
+ rendererArgs_->hintText += std::string("\nNET\n") + ctx_->nameOf(net);
} else if (closest.type == ElementType::PIP) {
rendererArgs_->hintText = std::string("PIP\n") + ctx_->getPipName(closest.pip).c_str(ctx_);
NetInfo *net = ctx_->getBoundPipNet(closest.pip);
- if (net!=nullptr)
- rendererArgs_->hintText += std::string("\nNET\n") +ctx_->nameOf(net);
+ if (net != nullptr)
+ rendererArgs_->hintText += std::string("\nNET\n") + ctx_->nameOf(net);
} else if (closest.type == ElementType::GROUP) {
rendererArgs_->hintText = std::string("GROUP\n") + ctx_->getGroupName(closest.group).c_str(ctx_);
- } else rendererArgs_->hintText = "";
-
+ } else
+ rendererArgs_->hintText = "";
+
pokeRenderer();
}
update();
@@ -789,8 +782,9 @@ QVector4D FPGAViewWidget::mouseToWorldDimensions(float x, float y)
void FPGAViewWidget::wheelEvent(QWheelEvent *event)
{
ImGuiIO &io = ImGui::GetIO();
- if (io.WantCaptureMouse) return;
-
+ if (io.WantCaptureMouse)
+ return;
+
QPoint degree = event->angleDelta() / 8;
if (!degree.isNull())
@@ -875,23 +869,17 @@ void FPGAViewWidget::update_vbos()
{
lineShader_.update_vbos(GraphicElement::STYLE_GRID, rendererData_->gfxGrid);
- for (int style = GraphicElement::STYLE_FRAME; style
- < GraphicElement::STYLE_HIGHLIGHTED0;
- style++) {
- lineShader_.update_vbos((enum GraphicElement::style_t)(style),
- rendererData_->gfxByStyle[style]);
+ for (int style = GraphicElement::STYLE_FRAME; style < GraphicElement::STYLE_HIGHLIGHTED0; style++) {
+ lineShader_.update_vbos((enum GraphicElement::style_t)(style), rendererData_->gfxByStyle[style]);
}
for (int i = 0; i < 8; i++) {
- GraphicElement::style_t style = (GraphicElement::style_t)(
- GraphicElement::STYLE_HIGHLIGHTED0 + i);
+ GraphicElement::style_t style = (GraphicElement::style_t)(GraphicElement::STYLE_HIGHLIGHTED0 + i);
lineShader_.update_vbos(style, rendererData_->gfxHighlighted[i]);
}
- lineShader_.update_vbos(GraphicElement::STYLE_SELECTED,
- rendererData_->gfxSelected);
- lineShader_.update_vbos(GraphicElement::STYLE_HOVER,
- rendererData_->gfxHovered);
+ lineShader_.update_vbos(GraphicElement::STYLE_SELECTED, rendererData_->gfxSelected);
+ lineShader_.update_vbos(GraphicElement::STYLE_HOVER, rendererData_->gfxHovered);
}
NEXTPNR_NAMESPACE_END
diff --git a/gui/lineshader.cc b/gui/lineshader.cc
index fc726df5..eded1689 100644
--- a/gui/lineshader.cc
+++ b/gui/lineshader.cc
@@ -206,8 +206,7 @@ bool LineShader::compile(void)
return true;
}
-void LineShader::update_vbos(enum GraphicElement::style_t style,
- const LineShaderData &line)
+void LineShader::update_vbos(enum GraphicElement::style_t style, const LineShaderData &line)
{
if (buffers_[style].last_vbo_update == line.last_render)
return;
@@ -230,8 +229,8 @@ void LineShader::update_vbos(enum GraphicElement::style_t style,
buffers_[style].index.allocate(&line.indices[0], sizeof(GLuint) * line.indices.size());
}
-void LineShader::draw(enum GraphicElement::style_t style, const QColor &color,
- float thickness, const QMatrix4x4 &projection)
+void LineShader::draw(enum GraphicElement::style_t style, const QColor &color, float thickness,
+ const QMatrix4x4 &projection)
{
auto gl = QOpenGLContext::currentContext()->functions();
if (buffers_[style].indices == 0)
diff --git a/gui/lineshader.h b/gui/lineshader.h
index eb0f9e09..98042051 100644
--- a/gui/lineshader.h
+++ b/gui/lineshader.h
@@ -20,12 +20,12 @@
#ifndef LINESHADER_H
#define LINESHADER_H
-#include <array>
#include <QOpenGLBuffer>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLWidget>
+#include <array>
#include "log.h"
#include "nextpnr.h"
@@ -169,9 +169,7 @@ class LineShader
} uniforms_;
public:
- LineShader(QObject *parent) : parent_(parent), program_(nullptr)
- {
- }
+ LineShader(QObject *parent) : parent_(parent), program_(nullptr) {}
static constexpr const char *vertexShaderSource_ =
"#version 110\n"
@@ -194,12 +192,10 @@ class LineShader
// Must be called on initialization.
bool compile(void);
- void update_vbos(enum GraphicElement::style_t style,
- const LineShaderData &line);
+ void update_vbos(enum GraphicElement::style_t style, const LineShaderData &line);
// Render a LineShaderData with a given M/V/P transformation.
- void draw(enum GraphicElement::style_t style, const QColor &color,
- float thickness, const QMatrix4x4 &projection);
+ void draw(enum GraphicElement::style_t style, const QColor &color, float thickness, const QMatrix4x4 &projection);
};
NEXTPNR_NAMESPACE_END
diff --git a/gui/quadtree.h b/gui/quadtree.h
index 9fcddf73..a6c38a85 100644
--- a/gui/quadtree.h
+++ b/gui/quadtree.h
@@ -266,20 +266,20 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
splitx_ = (bound_.x1_ - bound_.x0_) / 2 + bound_.x0_;
splity_ = (bound_.y1_ - bound_.y0_) / 2 + bound_.y0_;
// Create the new children.
- children_ = decltype(children_)(new QuadTreeNode<CoordinateT, ElementT>[4]{
- // Note: not using [NW] = QuadTreeNode because that seems to
- // crash g++ 7.3.0.
- /* NW */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, bound_.y0_, splitx_, splity_),
- depth_ + 1, max_elems_),
- /* NE */
- 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_),
+ children_ = decltype(children_)(new QuadTreeNode<CoordinateT, ElementT>[4] {
+ // Note: not using [NW] = QuadTreeNode because that seems to
+ // crash g++ 7.3.0.
+ /* NW */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, bound_.y0_, splitx_, splity_),
+ depth_ + 1, max_elems_),
+ /* NE */
+ 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.
auto it = elems_.begin();