summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp42
1 files changed, 16 insertions, 26 deletions
diff --git a/main.cpp b/main.cpp
index 8a3633b..06668a8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3,10 +3,10 @@
#include <QNetworkReply>
#include <QQmlApplicationEngine>
#include <QQmlContext>
-#include <QtConcurrent/QtConcurrentRun>
#include <QTimer>
-#include <iostream>
+#include <QtConcurrent/QtConcurrentRun>
#include "QmlCustomPlot.h"
+#include <iostream>
// #include <execution>
@@ -29,8 +29,7 @@ int main(int argc, char *argv[])
QVector<qreal> y_profile;
QVector<qreal> prev_y_profile;
- for(int x = -640; x < 640; ++x)
- {
+ for (int x = -640; x < 640; ++x) {
double y = double(QRandomGenerator::global()->bounded(0, 80000)) / 100.;
x_profile << x;
@@ -50,10 +49,7 @@ int main(int argc, char *argv[])
QTimer pixelsAutoRestartTimer(&app);
pixelsAutoRestartTimer.setInterval(500);
pixelsAutoRestartTimer.setSingleShot(false);
- QObject::connect(&pixelsAutoRestartTimer, &QTimer::timeout,
- [&](){
- manager->get(request);
- });
+ QObject::connect(&pixelsAutoRestartTimer, &QTimer::timeout, [&]() { manager->get(request); });
QObject::connect(manager, &QNetworkAccessManager::finished, [&](QNetworkReply *reply) {
// qDebug() << "replyFinished";
@@ -64,8 +60,7 @@ int main(int argc, char *argv[])
return;
}
- auto json = QJsonDocument::fromJson(reply->readAll())
- .object();
+ auto json = QJsonDocument::fromJson(reply->readAll()).object();
auto jsonPixels = json["pixels"].toArray();
auto encoderPosition = json["encoderPosition"].toInteger();
auto measurementCounter = json["measurementCounter"].toInteger();
@@ -78,11 +73,11 @@ int main(int argc, char *argv[])
}
QVector<qreal> y_diff(y_profile.count());
- qreal max_diff { 0. };
- qreal min_diff { 1000000. };
+ qreal max_diff{0.};
+ qreal min_diff{1000000.};
size_t max_diff_idx = 0;
size_t min_diff_idx = 0;
- qreal avg_diff { 0. };
+ qreal avg_diff{0.};
for (size_t i = 0; i < y_profile.count(); ++i) {
y_diff[i] = y_profile.at(i) - prev_y_profile.at(i);
@@ -141,27 +136,22 @@ int main(int argc, char *argv[])
jsonLines.cbegin(),
jsonLines.cend(),
lines.begin(),
- [](const auto& jsonLine) -> QLineF {
+ [](const auto &jsonLine) -> QLineF {
const auto jsonPoints = jsonLine.toArray();
const auto jsonPoint0 = jsonPoints.at(0).toArray();
const auto jsonPoint1 = jsonPoints.at(1).toArray();
- return {
- { jsonPoint0.at(0).toDouble(), jsonPoint0.at(1).toDouble() },
- { jsonPoint1.at(0).toDouble(), jsonPoint1.at(1).toDouble() }
- };
- }
- );
+ return {{jsonPoint0.at(0).toDouble(), jsonPoint0.at(1).toDouble()},
+ {jsonPoint1.at(0).toDouble(), jsonPoint1.at(1).toDouble()}};
+ });
// lines.append({{6,780},{38,787}});
- auto qmlCustomPlot = engine.rootObjects().first()->findChild<QmlCustomPlot*>("qmlCustomPlot");
+ auto qmlCustomPlot = engine.rootObjects().first()->findChild<QmlCustomPlot *>(
+ "qmlCustomPlot");
- if (!qmlCustomPlot)
- {
+ if (!qmlCustomPlot) {
qWarning() << "no qmlCustomPlot";
- }
- else
- {
+ } else {
// qDebug() << "set lines. count is" << lines.count();
qmlCustomPlot->setLines(lines);
}