diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-10-21 13:19:44 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-10-27 12:02:01 +0200 |
commit | d08fe2109dcb7e037d4321f9804a5c0aeca3b87b (patch) | |
tree | 938720d86a6fd054cd14e39d56cd33958ddee3bd /gui | |
parent | f43ee265e8d303d7b41b9b79036c3c2ba433877b (diff) | |
download | nextpnr-d08fe2109dcb7e037d4321f9804a5c0aeca3b87b.tar.gz nextpnr-d08fe2109dcb7e037d4321f9804a5c0aeca3b87b.tar.bz2 nextpnr-d08fe2109dcb7e037d4321f9804a5c0aeca3b87b.zip |
clangformat
Diffstat (limited to 'gui')
-rw-r--r-- | gui/designwidget.cc | 90 | ||||
-rw-r--r-- | gui/designwidget.h | 2 | ||||
-rw-r--r-- | gui/fpgaviewwidget.cc | 4 | ||||
-rw-r--r-- | gui/fpgaviewwidget.h | 2 | ||||
-rw-r--r-- | gui/quadtree.h | 28 | ||||
-rw-r--r-- | gui/treemodel.h | 4 |
6 files changed, 74 insertions, 56 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 310fcdd6..e6baf090 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -51,8 +51,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) tabWidget = new QTabWidget();
// Add tree view
- for(int i=0;i<6;i++)
- {
+ for (int i = 0; i < 6; i++) {
treeView[i] = new TreeView();
treeModel[i] = new TreeModel::Model();
treeView[i]->setModel(treeModel[i]);
@@ -96,7 +95,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) history_index = 0;
auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect);
- if (tabWidget->currentIndex()!=h.first) tabWidget->setCurrentIndex(h.first);
+ if (tabWidget->currentIndex() != h.first)
+ tabWidget->setCurrentIndex(h.first);
updateButtons();
});
@@ -108,7 +108,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) history_index--;
auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect);
- if (tabWidget->currentIndex()!=h.first) tabWidget->setCurrentIndex(h.first);
+ if (tabWidget->currentIndex() != h.first)
+ tabWidget->setCurrentIndex(h.first);
updateButtons();
});
@@ -120,7 +121,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) history_index++;
auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect);
- if (tabWidget->currentIndex()!=h.first) tabWidget->setCurrentIndex(h.first);
+ if (tabWidget->currentIndex() != h.first)
+ tabWidget->setCurrentIndex(h.first);
updateButtons();
});
@@ -132,7 +134,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) history_index = int(history.size() - 1);
auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect);
- if (tabWidget->currentIndex()!=h.first) tabWidget->setCurrentIndex(h.first);
+ if (tabWidget->currentIndex() != h.first)
+ tabWidget->setCurrentIndex(h.first);
updateButtons();
});
@@ -143,8 +146,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) history_index = -1;
history.clear();
int num = tabWidget->currentIndex();
- if (selectionModel[num]->selectedIndexes().size()> 0)
- {
+ if (selectionModel[num]->selectedIndexes().size() > 0) {
QModelIndex index = selectionModel[num]->selectedIndexes().at(0);
if (index.isValid()) {
ElementType type = treeModel[num]->nodeFromIndex(index)->type();
@@ -203,14 +205,19 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr) connect(propertyEditor->treeWidget(), &QTreeWidget::itemDoubleClicked, this, &DesignWidget::onItemDoubleClicked);
connect(propertyEditor, &QtTreePropertyBrowser::hoverPropertyChanged, this, &DesignWidget::onHoverPropertyChanged);
- for(int num=0;num<6;num++) {
- connect(treeView[num], &TreeView::customContextMenuRequested, [this,num](const QPoint &pos) { prepareMenuTree(num, pos); });
- connect(treeView[num], &TreeView::doubleClicked, [this](const QModelIndex &index) { onDoubleClicked(index); } );
- connect(treeView[num], &TreeView::hoverIndexChanged, [this,num](QModelIndex index) { onHoverIndexChanged(num, index); } );
+ for (int num = 0; num < 6; num++) {
+ connect(treeView[num], &TreeView::customContextMenuRequested,
+ [this, num](const QPoint &pos) { prepareMenuTree(num, pos); });
+ connect(treeView[num], &TreeView::doubleClicked, [this](const QModelIndex &index) { onDoubleClicked(index); });
+ connect(treeView[num], &TreeView::hoverIndexChanged,
+ [this, num](QModelIndex index) { onHoverIndexChanged(num, index); });
selectionModel[num] = treeView[num]->selectionModel();
- connect(selectionModel[num], &QItemSelectionModel::selectionChanged, [this,num](const QItemSelection &selected, const QItemSelection &deselected) { onSelectionChanged(num, selected, deselected); });
+ connect(selectionModel[num], &QItemSelectionModel::selectionChanged,
+ [this, num](const QItemSelection &selected, const QItemSelection &deselected) {
+ onSelectionChanged(num, selected, deselected);
+ });
}
-
+
history_index = -1;
history_ignore = false;
@@ -241,7 +248,7 @@ void DesignWidget::addToHistory(int tab, QModelIndex item) int count = int(history.size());
for (int i = count - 1; i > history_index; i--)
history.pop_back();
- history.push_back(std::make_pair(tab,item));
+ history.push_back(std::make_pair(tab, item));
history_index++;
}
history_ignore = false;
@@ -264,7 +271,7 @@ void DesignWidget::newContext(Context *ctx) {
std::lock_guard<std::mutex> lock_ui(ctx->ui_mutex);
std::lock_guard<std::mutex> lock(ctx->mutex);
-
+
{
std::map<std::pair<int, int>, std::vector<BelId>> belMap;
for (auto bel : ctx->getBels()) {
@@ -272,12 +279,13 @@ void DesignWidget::newContext(Context *ctx) 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(std::unique_ptr<TreeModel::ElementXYRoot<BelId>>(
- new TreeModel::ElementXYRoot<BelId>(ctx, belMap, belGetter, ElementType::BEL)));
+
+ getTreeByElementType(ElementType::BEL)
+ ->loadData(std::unique_ptr<TreeModel::ElementXYRoot<BelId>>(
+ new TreeModel::ElementXYRoot<BelId>(ctx, belMap, belGetter, ElementType::BEL)));
}
-#ifdef ARCH_ICE40
+#ifdef ARCH_ICE40
{
std::map<std::pair<int, int>, std::vector<WireId>> wireMap;
for (int i = 0; i < ctx->chip_info->num_wires; i++) {
@@ -287,8 +295,9 @@ void DesignWidget::newContext(Context *ctx) wireMap[std::pair<int, int>(wire->x, wire->y)].push_back(wireid);
}
auto wireGetter = [](Context *ctx, WireId id) { return ctx->getWireName(id); };
- getTreeByElementType(ElementType::WIRE)->loadData(std::unique_ptr<TreeModel::ElementXYRoot<WireId>>(
- new TreeModel::ElementXYRoot<WireId>(ctx, wireMap, wireGetter, ElementType::WIRE)));
+ getTreeByElementType(ElementType::WIRE)
+ ->loadData(std::unique_ptr<TreeModel::ElementXYRoot<WireId>>(
+ new TreeModel::ElementXYRoot<WireId>(ctx, wireMap, wireGetter, ElementType::WIRE)));
}
{
@@ -300,12 +309,15 @@ void DesignWidget::newContext(Context *ctx) pipMap[std::pair<int, int>(pip->x, pip->y)].push_back(pipid);
}
auto pipGetter = [](Context *ctx, PipId id) { return ctx->getPipName(id); };
- getTreeByElementType(ElementType::PIP)->loadData(std::unique_ptr<TreeModel::ElementXYRoot<PipId>>(
- new TreeModel::ElementXYRoot<PipId>(ctx, pipMap, pipGetter, ElementType::PIP)));
+ getTreeByElementType(ElementType::PIP)
+ ->loadData(std::unique_ptr<TreeModel::ElementXYRoot<PipId>>(
+ new TreeModel::ElementXYRoot<PipId>(ctx, pipMap, pipGetter, ElementType::PIP)));
}
#endif
- getTreeByElementType(ElementType::CELL)->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::CELL)));
- getTreeByElementType(ElementType::NET)->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::NET)));
+ getTreeByElementType(ElementType::CELL)
+ ->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::CELL)));
+ getTreeByElementType(ElementType::NET)
+ ->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::NET)));
}
updateTree();
}
@@ -458,9 +470,10 @@ void DesignWidget::onClickedBel(BelId bel, bool keep) Q_EMIT selected(getDecals(ElementType::BEL, ctx->getBelName(bel)), keep);
}
- if (tabWidget->currentIndex()!=0) tabWidget->setCurrentIndex(0);
+ if (tabWidget->currentIndex() != 0)
+ tabWidget->setCurrentIndex(0);
selectionModel[0]->setCurrentIndex(getTreeByElementType(ElementType::BEL)->indexFromNode(*item),
- keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
+ keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
}
void DesignWidget::onClickedWire(WireId wire, bool keep)
@@ -476,9 +489,10 @@ void DesignWidget::onClickedWire(WireId wire, bool keep) Q_EMIT selected(getDecals(ElementType::WIRE, ctx->getWireName(wire)), keep);
}
- if (tabWidget->currentIndex()!=1) tabWidget->setCurrentIndex(1);
+ if (tabWidget->currentIndex() != 1)
+ tabWidget->setCurrentIndex(1);
selectionModel[1]->setCurrentIndex(getTreeByElementType(ElementType::WIRE)->indexFromNode(*item),
- keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
+ keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
}
void DesignWidget::onClickedPip(PipId pip, bool keep)
@@ -494,9 +508,10 @@ void DesignWidget::onClickedPip(PipId pip, bool keep) Q_EMIT selected(getDecals(ElementType::PIP, ctx->getPipName(pip)), keep);
}
- if (tabWidget->currentIndex()!=2) tabWidget->setCurrentIndex(2);
+ if (tabWidget->currentIndex() != 2)
+ tabWidget->setCurrentIndex(2);
selectionModel[2]->setCurrentIndex(getTreeByElementType(ElementType::PIP)->indexFromNode(*item),
- keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
+ keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
}
void DesignWidget::onSelectionChanged(int num, const QItemSelection &, const QItemSelection &)
@@ -782,7 +797,7 @@ std::vector<DecalXY> DesignWidget::getDecals(ElementType type, IdString value) }
}
} break;
- case ElementType::CELL: {
+ case ElementType::CELL: {
CellInfo *cell = ctx->cells.at(value).get();
if (cell->bel != BelId()) {
decals.push_back(ctx->getBelDecal(cell->bel));
@@ -914,8 +929,10 @@ void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column) auto it = getTreeByElementType(type)->nodeForId(ctx->id(selectedProperty->valueText().toStdString()));
if (it) {
int num = getIndexByElementType(type);
- if (tabWidget->currentIndex()!=num) tabWidget->setCurrentIndex(num);
- selectionModel[num]->setCurrentIndex(getTreeByElementType(type)->indexFromNode(*it), QItemSelectionModel::ClearAndSelect);
+ if (tabWidget->currentIndex() != num)
+ tabWidget->setCurrentIndex(num);
+ selectionModel[num]->setCurrentIndex(getTreeByElementType(type)->indexFromNode(*it),
+ QItemSelectionModel::ClearAndSelect);
}
}
@@ -937,7 +954,8 @@ void DesignWidget::onSearchInserted() currentIndexTab = tabWidget->currentIndex();
}
if (currentSearchIndexes.size() > 0 && currentIndex < currentSearchIndexes.size())
- selectionModel[tabWidget->currentIndex()]->setCurrentIndex(currentSearchIndexes.at(currentIndex), QItemSelectionModel::ClearAndSelect);
+ selectionModel[tabWidget->currentIndex()]->setCurrentIndex(currentSearchIndexes.at(currentIndex),
+ QItemSelectionModel::ClearAndSelect);
}
void DesignWidget::onHoverIndexChanged(int num, QModelIndex index)
diff --git a/gui/designwidget.h b/gui/designwidget.h index 1859ed12..f27eced2 100644 --- a/gui/designwidget.h +++ b/gui/designwidget.h @@ -113,7 +113,7 @@ class DesignWidget : public QWidget QMap<QtProperty *, QString> propertyToId;
QMap<QString, QtProperty *> idToProperty;
- std::vector<std::pair<int,QModelIndex>> history;
+ std::vector<std::pair<int, QModelIndex>> history;
int history_index;
bool history_ignore;
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 0f900d9e..22c748a7 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -115,10 +115,10 @@ void FPGAViewWidget::initializeGL() QMutexLocker locker(&rendererDataLock_); // Render grid. auto grid = LineShaderData(); - for (float i = 0.0f; i < 1.0f * ctx_->getGridDimX()+1; i += 1.0f) { + for (float i = 0.0f; i < 1.0f * ctx_->getGridDimX() + 1; i += 1.0f) { PolyLine(i, 0.0f, i, 1.0f * ctx_->getGridDimY()).build(grid); } - for (float i = 0.0f; i < 1.0f * ctx_->getGridDimY()+1; i += 1.0f) { + for (float i = 0.0f; i < 1.0f * ctx_->getGridDimY() + 1; i += 1.0f) { PolyLine(0.0f, i, 1.0f * ctx_->getGridDimX(), i).build(grid); } grid.last_render = 1; diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index e76e6f32..de272ab9 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -127,7 +127,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions private: const float zoomNear_ = 0.1f; // do not zoom closer than this - float zoomFar_ = 10.0f; // do not zoom further than this + float zoomFar_ = 10.0f; // do not zoom further than this const float zoomLvl1_ = 1.0f; const float zoomLvl2_ = 5.0f; diff --git a/gui/quadtree.h b/gui/quadtree.h index a6c38a85..9fcddf73 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(); diff --git a/gui/treemodel.h b/gui/treemodel.h index 5238ed7f..dbbf1025 100644 --- a/gui/treemodel.h +++ b/gui/treemodel.h @@ -103,8 +103,8 @@ class Item virtual void fetchMore() {} virtual boost::optional<Item *> getById(IdString id) { return boost::none; } - virtual void search(QList<Item *> &results, QString text, int limit) { } - virtual void updateElements(Context *ctx, std::vector<IdString> elements) { } + virtual void search(QList<Item *> &results, QString text, int limit) {} + virtual void updateElements(Context *ctx, std::vector<IdString> elements) {} virtual ~Item() { |