diff options
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
@@ -5,7 +5,9 @@ #include <QQmlContext> #include <QTimer> #include <QtConcurrent/QtConcurrentRun> + #include "QmlCustomPlot.h" + #include <iostream> // #include <execution> @@ -46,7 +48,9 @@ int main( QVector<qreal> prev_y_profile; - for (int x = -640; x < 640; ++x) { + constexpr int img_width = 704; + for (int x = -img_width / 2; x < img_width / 2; ++x) + { double y = double(QRandomGenerator::global()->bounded(0, 80000)) / 100.; x_pixels << x; @@ -90,8 +94,8 @@ int main( manager, &QNetworkAccessManager::finished, [&](QNetworkReply *reply) { // qDebug() << "replyFinished"; if (reply->error()) { - qDebug() << "replyFinished:" << reply->errorString(); - qDebug() << "url was:" << reply->request().url(); + // qDebug() << "replyFinished:" << reply->errorString(); + // qDebug() << "url was:" << reply->request().url(); reply->deleteLater(); return; @@ -201,43 +205,27 @@ int main( prev_y_profile = y_pixels; } else if (reply->url().toString().endsWith("profile")) { - // qDebug() << "got profile"; auto json = QJsonDocument::fromJson(reply->readAll()).object(); auto jsonProfile = json["profile"].toObject(); auto jsonPointsMm = jsonProfile["pointsMm"].toArray(); - QList<qreal> x_profile(size_t(1280), 0.); - QList<qreal> y_profile(size_t(1280), 0.); - - static bool done{false}; - - if (!done) { - qDebug() << "got profile result:"; - qDebug() << jsonProfile; - } + QList<qreal> x_profile(size_t(img_width), 0.); + QList<qreal> y_profile(size_t(img_width), 0.); for (int i = 0; i < jsonPointsMm.count(); ++i) { - // qDebug() << jsonPointsMm.at(i); - // continue; const auto x = jsonPointsMm.at(i).toArray()[0].toDouble(); const auto z = jsonPointsMm.at(i).toArray()[1].toDouble(); if (qFuzzyIsNull(z) || std::isnan(z)) { - x_profile[i] = 0; + // x_profile[i] = 0; y_profile[i] = 0; continue; } x_profile[i] = x; y_profile[i] = z; - - if (!done) { - qDebug() << '\t' << x_profile[i] << y_profile[i]; - } } - done = true; - profileGraph->setData(x_profile, y_profile); // pixelsGraph->setData(x_profile, y_profile); |
