diff options
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | Main.qml | 2 | ||||
| -rw-r--r-- | QmlCustomPlot.cpp | 6 | ||||
| -rw-r--r-- | main.cpp | 49 |
4 files changed, 51 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2923a7b..8d68a93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,3 +54,5 @@ install(TARGETS appeurydice LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + +add_compile_options(-Ofast -fno-unroll-loops -Wall) @@ -542,6 +542,8 @@ ApplicationWindow { QmlCustomPlot { id: qmlPlot + objectName: "qmlCustomPlot" + Label { anchors { top: parent.top diff --git a/QmlCustomPlot.cpp b/QmlCustomPlot.cpp index ef30b3f..bba287e 100644 --- a/QmlCustomPlot.cpp +++ b/QmlCustomPlot.cpp @@ -127,7 +127,8 @@ void QmlCustomPlot::setLines(const QVector<QLineF> lines) // const QColor color(Qt::green); // QRgb green = QRandomGenerator::generate(); // QRgb blue = QRandomGenerator::generate(); - const QColor color { QRgb { QRandomGenerator::global()->generate() } }; + QColor color { QRgb { QRandomGenerator::global()->generate() } }; + color.setAlpha(100); const QPen linePen(color, 4); QCPItemLine * l; @@ -145,7 +146,8 @@ void QmlCustomPlot::setLines(const QVector<QLineF> lines) l = m_lineItems[i]; } - const QPointF offset(0, 2); + // const QPointF offset(0, 2); + const QPointF offset(0, 0); const auto & lineToSet = lines.at(i); l->start->setCoords(lineToSet.p1() + offset); @@ -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); |
