clang-format and uncomment debug

This commit is contained in:
Sergiusz Bazanski 2018-07-20 13:19:45 +01:00
parent b4b111a053
commit 19f4b68f07
4 changed files with 39 additions and 45 deletions

View File

@ -250,6 +250,7 @@ struct CellInfo : ArchCellInfo
class IdStringDB
{
friend class IdString;
private:
mutable std::unordered_map<std::string, int> *idstring_str_to_idx;
mutable std::vector<const std::string *> *idstring_idx_to_str;
@ -279,9 +280,7 @@ class DeterministicRNG
uint64_t rngstate;
public:
DeterministicRNG() : rngstate(0x3141592653589793)
{
}
DeterministicRNG() : rngstate(0x3141592653589793) {}
uint64_t rng64()
{
@ -340,7 +339,6 @@ class DeterministicRNG
std::sort(a.begin(), a.end());
shuffle(a);
}
};
class BaseCtx : public IdStringDB
@ -362,7 +360,6 @@ class BaseCtx : public IdStringDB
{
mutex.lock();
mutex_owner = pthread_self();
}
void unlock(void)

View File

@ -37,17 +37,17 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
bool Application::notify(QObject *receiver, QEvent *event)
{
bool retVal = true;
//try {
try {
retVal = QApplication::notify(receiver, event);
//} catch (assertion_failure ex) {
// QString msg;
// QTextStream out(&msg);
// out << ex.filename.c_str() << " at " << ex.line << "\n";
// out << ex.msg.c_str();
// QMessageBox::critical(0, "Error", msg);
//} catch (...) {
// QMessageBox::critical(0, "Error", "Fatal error !!!");
//}
} catch (assertion_failure ex) {
QString msg;
QTextStream out(&msg);
out << ex.filename.c_str() << " at " << ex.line << "\n";
out << ex.msg.c_str();
QMessageBox::critical(0, "Error", msg);
} catch (...) {
QMessageBox::critical(0, "Error", "Fatal error !!!");
}
return retVal;
}

View File

@ -241,7 +241,8 @@ void LineShader::draw(const LineShaderData &line, const QColor &color, float thi
}
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
: QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), paintTimer_(this), rendererData_(new FPGAViewWidget::RendererData), rendererArgs_(new FPGAViewWidget::RendererArgs)
: QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), paintTimer_(this),
rendererData_(new FPGAViewWidget::RendererData), rendererArgs_(new FPGAViewWidget::RendererArgs)
{
colors_.background = QColor("#000000");
colors_.grid = QColor("#333");
@ -276,11 +277,11 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
}
connect(&paintTimer_, SIGNAL(timeout()), this, SLOT(update()));
paintTimer_.start(std::chrono::duration<int, std::milli>(1000/20)); // paint GL 20 times per second
paintTimer_.start(std::chrono::duration<int, std::milli>(1000 / 20)); // paint GL 20 times per second
renderRunner_ = std::unique_ptr<PeriodicRunner>(new PeriodicRunner(this, [this] { renderLines(); }));
renderRunner_->start();
renderRunner_->startTimer(std::chrono::duration<int, std::milli>(1000/2)); // render line 2 times per second
renderRunner_->startTimer(std::chrono::duration<int, std::milli>(1000 / 2)); // render line 2 times per second
}
FPGAViewWidget::~FPGAViewWidget() {}
@ -301,7 +302,8 @@ void FPGAViewWidget::initializeGL()
log_error("Could not compile shader.\n");
}
initializeOpenGLFunctions();
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);
}
void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal)
@ -417,9 +419,7 @@ void FPGAViewWidget::paintGL()
rendererDataLock_.unlock();
}
void FPGAViewWidget::pokeRenderer(void) {
renderRunner_->poke();
}
void FPGAViewWidget::pokeRenderer(void) { renderRunner_->poke(); }
void FPGAViewWidget::renderLines(void)
{
@ -439,7 +439,7 @@ void FPGAViewWidget::renderLines(void)
ctx_->frameUiReload = false;
decalsChanged = true;
}
if (ctx_->belUiReload.size() > 0){
if (ctx_->belUiReload.size() > 0) {
ctx_->belUiReload.clear();
decalsChanged = true;
}
@ -525,7 +525,6 @@ void FPGAViewWidget::renderLines(void)
rendererDataLock_.unlock();
}
void FPGAViewWidget::onSelectedArchItem(std::vector<DecalXY> decals)
{
rendererArgsLock_.lock();

View File

@ -28,8 +28,8 @@
#include <QOpenGLVertexArrayObject>
#include <QOpenGLWidget>
#include <QPainter>
#include <QTimer>
#include <QThread>
#include <QTimer>
#include <QWaitCondition>
#include "nextpnr.h"
@ -213,15 +213,16 @@ class LineShader
class PeriodicRunner : public QThread
{
Q_OBJECT
private:
private:
QMutex mutex_;
QWaitCondition condition_;
bool abort_;
std::function<void()> target_;
QTimer timer_;
public:
explicit PeriodicRunner(QObject *parent, std::function<void()> target) :
QThread(parent), abort_(false), target_(target), timer_(this)
public:
explicit PeriodicRunner(QObject *parent, std::function<void()> target)
: QThread(parent), abort_(false), target_(target), timer_(this)
{
connect(&timer_, &QTimer::timeout, this, &PeriodicRunner::poke);
}
@ -243,10 +244,7 @@ public:
}
}
void startTimer(std::chrono::milliseconds value)
{
timer_.start(value);
}
void startTimer(std::chrono::milliseconds value) { timer_.start(value); }
~PeriodicRunner()
{
@ -258,10 +256,7 @@ public:
wait();
}
void poke(void)
{
condition_.wakeOne();
}
void poke(void) { condition_.wakeOne(); }
};
class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
@ -319,7 +314,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
std::unique_ptr<PeriodicRunner> renderRunner_;
struct {
struct
{
QColor background;
QColor grid;
QColor frame;
@ -330,13 +326,15 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
QColor highlight[8];
} colors_;
struct RendererData {
struct RendererData
{
LineShaderData decals[4];
LineShaderData selected;
LineShaderData highlighted[8];
};
struct RendererArgs {
struct RendererArgs
{
std::vector<DecalXY> selectedItems;
std::vector<DecalXY> highlightedItems[8];
bool highlightedOrSelectedChanged;