From 64d39b835539a1cc045698d3a98e960dfd9799ba Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Wed, 2 Apr 2025 12:55:17 +0200 Subject: [PATCH] client plot --- client/simulator_base.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/client/simulator_base.cpp b/client/simulator_base.cpp index 336b61a..a67dfc5 100644 --- a/client/simulator_base.cpp +++ b/client/simulator_base.cpp @@ -535,11 +535,35 @@ void Simulator_base::process_ui_plot(json &uiItem) } QString text = QString::fromStdString(uiItem["text"]); + QString x_label = QString::fromStdString(uiItem["x_label"]); + QString y_label = QString::fromStdString(uiItem["y_label"]); + std::vector x_vals = (std::vector)uiItem.at("x_vals"); + std::vector y_vals = (std::vector)uiItem.at("x_vals"); if (text != plot->title().text()) { plot->setTitle(text); } + + if (x_label != plot->axisTitle(QwtAxis::XBottom).text()) + { + plot->setAxisTitle(QwtAxis::XBottom, x_label); + } + + if (y_label != plot->axisTitle(QwtAxis::YLeft).text()) + { + plot->setAxisTitle(QwtAxis::YLeft, y_label); + } + + plot->curve()->setRawSamples( + x_vals.data(), + y_vals.data(), + x_vals.capacity() + ); + plot->setAxisScale( QwtAxis::XBottom, + x_vals[x_vals.capacity() - 1], x_vals[0] ); + // plot_time[0], plot_time[api.get_plot_size() - 1] ); + plot->replot(); } void Simulator_base::process_ui_can(json &uiItem)