From d624e965f24067b125fcfae217e612c072cdc441 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Mon, 9 Dec 2024 13:20:46 +0100 Subject: add .clang-config --- .clang-format | 15 +++++++++++++++ main.cpp | 42 ++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 .clang-format 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 diff --git a/main.cpp b/main.cpp index 8a3633b..06668a8 100644 --- a/main.cpp +++ b/main.cpp @@ -3,10 +3,10 @@ #include #include #include -#include #include -#include +#include #include "QmlCustomPlot.h" +#include // #include @@ -29,8 +29,7 @@ int main(int argc, char *argv[]) QVector y_profile; QVector 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 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"); + auto qmlCustomPlot = engine.rootObjects().first()->findChild( + "qmlCustomPlot"); - if (!qmlCustomPlot) - { + if (!qmlCustomPlot) { qWarning() << "no qmlCustomPlot"; - } - else - { + } else { // qDebug() << "set lines. count is" << lines.count(); qmlCustomPlot->setLines(lines); } -- cgit v1.2.3-70-g09d2