diff options
| author | Nikita Kostovsky <luntik2012@gmail.com> | 2024-12-09 13:20:46 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <luntik2012@gmail.com> | 2024-12-09 13:20:46 +0100 |
| commit | d624e965f24067b125fcfae217e612c072cdc441 (patch) | |
| tree | 1ec7036cb39a622e89aaa83edc2ee6cb090878da | |
| parent | 80f2cf91af7706e56c871dfc9b826a5412869386 (diff) | |
add .clang-config
| -rw-r--r-- | .clang-format | 15 | ||||
| -rw-r--r-- | main.cpp | 42 |
2 files changed, 31 insertions, 26 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..56838cf --- /dev/null +++ b/.clang-format @@ -0,0 +1,15 @@ +AccessModifierOffset: -4 +AlignAfterOpenBracket: BlockIndent +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +BasedOnStyle: Microsoft +BinPackParameters: false +BinPackArguments: false +BreakConstructorInitializers: BeforeComma +ColumnLimit: 80 +InsertNewlineAtEOF: true +IndentWidth: 4 +SpacesBeforeTrailingComments: 2 +UseTab: Never +LineEnding: LF +PointerAlignment: Left @@ -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); } |
