MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / updateData

Method updateData

app/src/UI/Widgets/Plot.cpp:517–576  ·  view source on GitHub ↗

* @brief Updates the plot data from the Dashboard. */

Source from the content-addressed store, hash-verified

515 * @brief Updates the plot data from the Dashboard.
516 */
517void Widgets::Plot::updateData()
518{
519 static thread_local DSP::DownsampleWorkspace ws;
520
521 if (!isEnabled())
522 return;
523
524 if (!VALIDATE_WIDGET(SerialStudio::DashboardPlot, m_index))
525 return;
526
527 if (m_timeAxis && m_sweepEnabled) {
528 double xLo = m_minX;
529 double xHi = m_maxX;
530 clampToVisibleX(xLo, xHi);
531 const auto& ring = UI::Dashboard::instance().plotSweep(m_index).display(0);
532 (void)DSP::downsampleWindowAbsolute(
533 ring.time, ring.value, xLo, xHi, m_dataW, m_dataH, m_data, &ws);
534 return;
535 }
536
537 if (m_timeAxis) {
538 double xLo = m_minX;
539 double xHi = m_maxX;
540 clampToVisibleX(xLo, xHi);
541 const auto& ring = UI::Dashboard::instance().plotTimeRing(m_index);
542 (void)DSP::downsampleTimeWindow(ring.time, ring.value, xLo, xHi, m_dataW, m_dataH, m_data, &ws);
543 return;
544 }
545
546 const auto& plotData = UI::Dashboard::instance().plotData(m_index);
547
548 if (m_monotonicData) {
549 (void)DSP::downsampleMonotonic(plotData, m_dataW, m_dataH, m_data, &ws);
550 return;
551 }
552
553 const auto& X = *plotData.x;
554 const auto& Y = *plotData.y;
555
556 const qsizetype count = std::min(X.size(), Y.size());
557 if (m_data.size() != count)
558 m_data.resize(count);
559
560 if (X.capacity() == 0 || Y.capacity() == 0)
561 return;
562
563 QPointF* out = m_data.data();
564 const auto* xData = X.raw();
565 const auto* yData = Y.raw();
566 const std::size_t xMask = X.storageMask();
567 const std::size_t yMask = Y.storageMask();
568 std::size_t xIdx = X.frontIndex();
569 std::size_t yIdx = Y.frontIndex();
570 for (qsizetype i = 0; i < count; ++i) {
571 out[i].setX(xData[xIdx]);
572 out[i].setY(yData[yIdx]);
573 xIdx = (xIdx + 1) & xMask;
574 yIdx = (yIdx + 1) & yMask;

Callers

nothing calls this directly

Calls 11

VALIDATE_WIDGETFunction · 0.85
downsampleWindowAbsoluteFunction · 0.85
downsampleTimeWindowFunction · 0.85
downsampleMonotonicFunction · 0.85
rawMethod · 0.80
storageMaskMethod · 0.80
frontIndexMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
capacityMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected