Ensure that we only moved shared X/Y plot arrays once

This commit is contained in:
Alex Spataru 2024-11-29 12:38:17 -05:00
parent 4824ab1cb4
commit cb3547abbb

View File

@ -722,25 +722,29 @@ void UI::Dashboard::updatePlots()
} }
// Append latest values to linear plots data // Append latest values to linear plots data
QSet<int> xAxesMoved;
QSet<int> yAxesMoved;
for (int i = 0; i < widgetCount(SerialStudio::DashboardPlot); ++i) for (int i = 0; i < widgetCount(SerialStudio::DashboardPlot); ++i)
{ {
// Shift Y-axis points
const auto &yDataset = getDatasetWidget(SerialStudio::DashboardPlot, i); const auto &yDataset = getDatasetWidget(SerialStudio::DashboardPlot, i);
if (m_datasets.contains(yDataset.xAxisId())) if (!yAxesMoved.contains(yDataset.index()))
{ {
const auto &xDataset = m_datasets[yDataset.xAxisId()]; yAxesMoved.insert(yDataset.index());
auto *xData = m_xAxisData[xDataset.index()].data();
auto *yData = m_yAxisData[yDataset.index()].data(); auto *yData = m_yAxisData[yDataset.index()].data();
auto xCount = m_xAxisData[xDataset.index()].count();
auto yCount = m_yAxisData[yDataset.index()].count(); auto yCount = m_yAxisData[yDataset.index()].count();
SIMD::shift<qreal>(xData, xCount, xDataset.value().toDouble());
SIMD::shift<qreal>(yData, yCount, yDataset.value().toDouble()); SIMD::shift<qreal>(yData, yCount, yDataset.value().toDouble());
} }
else // Shift X-axis points
const auto xAxisId = yDataset.xAxisId();
if (m_datasets.contains(xAxisId) && !xAxesMoved.contains(xAxisId))
{ {
auto *data = m_yAxisData[yDataset.index()].data(); xAxesMoved.insert(xAxisId);
auto count = m_yAxisData[yDataset.index()].count(); const auto &xDataset = m_datasets[xAxisId];
SIMD::shift<qreal>(data, count, yDataset.value().toDouble()); auto *xData = m_xAxisData[xAxisId].data();
auto xCount = m_xAxisData[xAxisId].count();
SIMD::shift<qreal>(xData, xCount, xDataset.value().toDouble());
} }
} }