clangformat

This commit is contained in:
Miodrag Milanovic 2018-10-21 13:19:44 +02:00
parent f43ee265e8
commit d08fe2109d
6 changed files with 74 additions and 56 deletions

View File

@ -51,8 +51,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr)
tabWidget = new QTabWidget(); tabWidget = new QTabWidget();
// Add tree view // Add tree view
for(int i=0;i<6;i++) for (int i = 0; i < 6; i++) {
{
treeView[i] = new TreeView(); treeView[i] = new TreeView();
treeModel[i] = new TreeModel::Model(); treeModel[i] = new TreeModel::Model();
treeView[i]->setModel(treeModel[i]); treeView[i]->setModel(treeModel[i]);
@ -96,7 +95,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr)
history_index = 0; history_index = 0;
auto h = history.at(history_index); auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect); 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(); updateButtons();
}); });
@ -108,7 +108,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr)
history_index--; history_index--;
auto h = history.at(history_index); auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect); 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(); updateButtons();
}); });
@ -120,7 +121,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr)
history_index++; history_index++;
auto h = history.at(history_index); auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect); 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(); updateButtons();
}); });
@ -132,7 +134,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr)
history_index = int(history.size() - 1); history_index = int(history.size() - 1);
auto h = history.at(history_index); auto h = history.at(history_index);
selectionModel[h.first]->setCurrentIndex(h.second, QItemSelectionModel::ClearAndSelect); 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(); updateButtons();
}); });
@ -143,8 +146,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr)
history_index = -1; history_index = -1;
history.clear(); history.clear();
int num = tabWidget->currentIndex(); int num = tabWidget->currentIndex();
if (selectionModel[num]->selectedIndexes().size()> 0) if (selectionModel[num]->selectedIndexes().size() > 0) {
{
QModelIndex index = selectionModel[num]->selectedIndexes().at(0); QModelIndex index = selectionModel[num]->selectedIndexes().at(0);
if (index.isValid()) { if (index.isValid()) {
ElementType type = treeModel[num]->nodeFromIndex(index)->type(); 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->treeWidget(), &QTreeWidget::itemDoubleClicked, this, &DesignWidget::onItemDoubleClicked);
connect(propertyEditor, &QtTreePropertyBrowser::hoverPropertyChanged, this, &DesignWidget::onHoverPropertyChanged); connect(propertyEditor, &QtTreePropertyBrowser::hoverPropertyChanged, this, &DesignWidget::onHoverPropertyChanged);
for(int num=0;num<6;num++) { for (int num = 0; num < 6; num++) {
connect(treeView[num], &TreeView::customContextMenuRequested, [this,num](const QPoint &pos) { prepareMenuTree(num, pos); }); connect(treeView[num], &TreeView::customContextMenuRequested,
connect(treeView[num], &TreeView::doubleClicked, [this](const QModelIndex &index) { onDoubleClicked(index); } ); [this, num](const QPoint &pos) { prepareMenuTree(num, pos); });
connect(treeView[num], &TreeView::hoverIndexChanged, [this,num](QModelIndex index) { onHoverIndexChanged(num, index); } ); 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(); 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_index = -1;
history_ignore = false; history_ignore = false;
@ -241,7 +248,7 @@ void DesignWidget::addToHistory(int tab, QModelIndex item)
int count = int(history.size()); int count = int(history.size());
for (int i = count - 1; i > history_index; i--) for (int i = count - 1; i > history_index; i--)
history.pop_back(); history.pop_back();
history.push_back(std::make_pair(tab,item)); history.push_back(std::make_pair(tab, item));
history_index++; history_index++;
} }
history_ignore = false; 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_ui(ctx->ui_mutex);
std::lock_guard<std::mutex> lock(ctx->mutex); std::lock_guard<std::mutex> lock(ctx->mutex);
{ {
std::map<std::pair<int, int>, std::vector<BelId>> belMap; std::map<std::pair<int, int>, std::vector<BelId>> belMap;
for (auto bel : ctx->getBels()) { 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); belMap[std::pair<int, int>(loc.x, loc.y)].push_back(bel);
} }
auto belGetter = [](Context *ctx, BelId id) { return ctx->getBelName(id); }; auto belGetter = [](Context *ctx, BelId id) { return ctx->getBelName(id); };
getTreeByElementType(ElementType::BEL)->loadData(std::unique_ptr<TreeModel::ElementXYRoot<BelId>>( getTreeByElementType(ElementType::BEL)
new TreeModel::ElementXYRoot<BelId>(ctx, belMap, belGetter, 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; std::map<std::pair<int, int>, std::vector<WireId>> wireMap;
for (int i = 0; i < ctx->chip_info->num_wires; i++) { 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); wireMap[std::pair<int, int>(wire->x, wire->y)].push_back(wireid);
} }
auto wireGetter = [](Context *ctx, WireId id) { return ctx->getWireName(id); }; auto wireGetter = [](Context *ctx, WireId id) { return ctx->getWireName(id); };
getTreeByElementType(ElementType::WIRE)->loadData(std::unique_ptr<TreeModel::ElementXYRoot<WireId>>( getTreeByElementType(ElementType::WIRE)
new TreeModel::ElementXYRoot<WireId>(ctx, wireMap, wireGetter, 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); pipMap[std::pair<int, int>(pip->x, pip->y)].push_back(pipid);
} }
auto pipGetter = [](Context *ctx, PipId id) { return ctx->getPipName(id); }; auto pipGetter = [](Context *ctx, PipId id) { return ctx->getPipName(id); };
getTreeByElementType(ElementType::PIP)->loadData(std::unique_ptr<TreeModel::ElementXYRoot<PipId>>( getTreeByElementType(ElementType::PIP)
new TreeModel::ElementXYRoot<PipId>(ctx, pipMap, pipGetter, ElementType::PIP))); ->loadData(std::unique_ptr<TreeModel::ElementXYRoot<PipId>>(
new TreeModel::ElementXYRoot<PipId>(ctx, pipMap, pipGetter, ElementType::PIP)));
} }
#endif #endif
getTreeByElementType(ElementType::CELL)->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::CELL))); getTreeByElementType(ElementType::CELL)
getTreeByElementType(ElementType::NET)->loadData(std::unique_ptr<TreeModel::IdStringList>(new TreeModel::IdStringList(ElementType::NET))); ->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(); updateTree();
} }
@ -458,9 +470,10 @@ void DesignWidget::onClickedBel(BelId bel, bool keep)
Q_EMIT selected(getDecals(ElementType::BEL, ctx->getBelName(bel)), 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), 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) 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); 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), 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) 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); 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), 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 &) void DesignWidget::onSelectionChanged(int num, const QItemSelection &, const QItemSelection &)
@ -782,7 +797,7 @@ std::vector<DecalXY> DesignWidget::getDecals(ElementType type, IdString value)
} }
} }
} break; } break;
case ElementType::CELL: { case ElementType::CELL: {
CellInfo *cell = ctx->cells.at(value).get(); CellInfo *cell = ctx->cells.at(value).get();
if (cell->bel != BelId()) { if (cell->bel != BelId()) {
decals.push_back(ctx->getBelDecal(cell->bel)); 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())); auto it = getTreeByElementType(type)->nodeForId(ctx->id(selectedProperty->valueText().toStdString()));
if (it) { if (it) {
int num = getIndexByElementType(type); int num = getIndexByElementType(type);
if (tabWidget->currentIndex()!=num) tabWidget->setCurrentIndex(num); if (tabWidget->currentIndex() != num)
selectionModel[num]->setCurrentIndex(getTreeByElementType(type)->indexFromNode(*it), QItemSelectionModel::ClearAndSelect); tabWidget->setCurrentIndex(num);
selectionModel[num]->setCurrentIndex(getTreeByElementType(type)->indexFromNode(*it),
QItemSelectionModel::ClearAndSelect);
} }
} }
@ -937,7 +954,8 @@ void DesignWidget::onSearchInserted()
currentIndexTab = tabWidget->currentIndex(); currentIndexTab = tabWidget->currentIndex();
} }
if (currentSearchIndexes.size() > 0 && currentIndex < currentSearchIndexes.size()) 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) void DesignWidget::onHoverIndexChanged(int num, QModelIndex index)

View File

@ -113,7 +113,7 @@ class DesignWidget : public QWidget
QMap<QtProperty *, QString> propertyToId; QMap<QtProperty *, QString> propertyToId;
QMap<QString, QtProperty *> idToProperty; QMap<QString, QtProperty *> idToProperty;
std::vector<std::pair<int,QModelIndex>> history; std::vector<std::pair<int, QModelIndex>> history;
int history_index; int history_index;
bool history_ignore; bool history_ignore;

View File

@ -115,10 +115,10 @@ void FPGAViewWidget::initializeGL()
QMutexLocker locker(&rendererDataLock_); QMutexLocker locker(&rendererDataLock_);
// Render grid. // Render grid.
auto grid = LineShaderData(); 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); 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); PolyLine(0.0f, i, 1.0f * ctx_->getGridDimX(), i).build(grid);
} }
grid.last_render = 1; grid.last_render = 1;

View File

@ -127,7 +127,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
private: private:
const float zoomNear_ = 0.1f; // do not zoom closer than this 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 zoomLvl1_ = 1.0f;
const float zoomLvl2_ = 5.0f; const float zoomLvl2_ = 5.0f;

View File

@ -266,20 +266,20 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
splitx_ = (bound_.x1_ - bound_.x0_) / 2 + bound_.x0_; splitx_ = (bound_.x1_ - bound_.x0_) / 2 + bound_.x0_;
splity_ = (bound_.y1_ - bound_.y0_) / 2 + bound_.y0_; splity_ = (bound_.y1_ - bound_.y0_) / 2 + bound_.y0_;
// Create the new children. // Create the new children.
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_), /* NW */ QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, bound_.y0_, splitx_, splity_),
depth_ + 1, max_elems_), depth_ + 1, max_elems_),
/* NE */ /* NE */
QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, bound_.y0_, bound_.x1_, splity_), QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, bound_.y0_, bound_.x1_, splity_),
depth_ + 1, max_elems_), depth_ + 1, max_elems_),
/* SW */ /* SW */
QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, splity_, splitx_, bound_.y1_), QuadTreeNode<CoordinateT, ElementT>(BoundingBox(bound_.x0_, splity_, splitx_, bound_.y1_),
depth_ + 1, max_elems_), depth_ + 1, max_elems_),
/* SE */ /* SE */
QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, splity_, bound_.x1_, bound_.y1_), QuadTreeNode<CoordinateT, ElementT>(BoundingBox(splitx_, splity_, bound_.x1_, bound_.y1_),
depth_ + 1, max_elems_), 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();

View File

@ -103,8 +103,8 @@ class Item
virtual void fetchMore() {} virtual void fetchMore() {}
virtual boost::optional<Item *> getById(IdString id) { return boost::none; } virtual boost::optional<Item *> getById(IdString id) { return boost::none; }
virtual void search(QList<Item *> &results, QString text, int limit) { } virtual void search(QList<Item *> &results, QString text, int limit) {}
virtual void updateElements(Context *ctx, std::vector<IdString> elements) { } virtual void updateElements(Context *ctx, std::vector<IdString> elements) {}
virtual ~Item() virtual ~Item()
{ {