diff options
| author | Nikita Kostovsky <luntik2012@gmail.com> | 2024-12-02 19:42:40 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <luntik2012@gmail.com> | 2024-12-02 19:42:40 +0100 |
| commit | 8f383df0c295e1049bcf2211869e0b069fb3890e (patch) | |
| tree | e55f09abca9aaed78bd413e1acd35f8aa611ba83 /main.cpp | |
| parent | 05a8166fa1ada3b386a4e0cce30c60f396587476 (diff) | |
draw lines
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 49 |
1 files changed, 43 insertions, 6 deletions
@@ -5,14 +5,10 @@ #include <QQmlContext> #include <QtConcurrent/QtConcurrentRun> #include <QTimer> - +#include <iostream> #include "QmlCustomPlot.h" -template <typename T> -T& median3(const T& a, const T& b, const T& c) { - using namespace std; - return max(min(a,b), min(max(a,b),c)); -} +// #include <execution> int main(int argc, char *argv[]) { @@ -132,6 +128,47 @@ int main(int argc, char *argv[]) graph->setData(x_profile, y_profile); + auto jsonLines = json["lines"].toArray(); + + QList<QLineF> lines(jsonLines.count()); + + // FIXME: validate + // WARNING + // AHTUNG + // DANGER + std::transform( + // std::execution::par_unseq + jsonLines.cbegin(), + jsonLines.cend(), + lines.begin(), + [](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() } + }; + } + ); + + // lines.append({{6,780},{38,787}}); + + auto qmlCustomPlot = engine.rootObjects().first()->findChild<QmlCustomPlot*>("qmlCustomPlot"); + + if (!qmlCustomPlot) + { + qWarning() << "no qmlCustomPlot"; + } + else + { + qDebug() << "set lines. count is" << lines.count(); + qmlCustomPlot->setLines(lines); + } + + // 6 780 + // 38 787 + engine.rootContext()->setContextProperty("max_diff", max_diff); engine.rootContext()->setContextProperty("max_diff_idx", int(max_diff_idx)); engine.rootContext()->setContextProperty("min_diff", min_diff); |
