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

Method processDatasetIntoWidgetMaps

app/src/UI/Dashboard.cpp:1620–1662  ·  view source on GitHub ↗

* @brief Registers a dataset's index and per-widget-key mappings. */

Source from the content-addressed store, hash-verified

1618 * @brief Registers a dataset's index and per-widget-key mappings.
1619 */
1620void UI::Dashboard::processDatasetIntoWidgetMaps(const DataModel::Dataset& datasetIn,
1621 DataModel::Group& ledPanel)
1622{
1623 Q_ASSERT(datasetIn.index >= 0);
1624 Q_ASSERT(datasetIn.uniqueId >= 0);
1625
1626 DataModel::Dataset dataset = datasetIn;
1627 if (DSP::almostEqual(dataset.wgtMin, dataset.wgtMax)) {
1628 dataset.wgtMin = dataset.pltMin;
1629 dataset.wgtMax = dataset.pltMax;
1630 }
1631
1632 if (DSP::almostEqual(dataset.fftMin, dataset.fftMax)) {
1633 dataset.fftMin = dataset.pltMin;
1634 dataset.fftMax = dataset.pltMax;
1635 }
1636
1637 if (!m_datasets.contains(dataset.uniqueId)) {
1638 m_datasets.insert(dataset.uniqueId, dataset);
1639 } else {
1640 auto prev = m_datasets.value(dataset.uniqueId);
1641 double newMin = qMin(prev.pltMin, dataset.pltMin);
1642 double newMax = qMax(prev.pltMax, dataset.pltMax);
1643
1644 auto d = dataset;
1645 d.pltMin = newMin;
1646 d.pltMax = newMax;
1647 m_datasets.insert(dataset.uniqueId, d);
1648 }
1649
1650 if (dataset.hideOnDashboard)
1651 return;
1652
1653 auto keys = SerialStudio::getDashboardWidgets(dataset);
1654 for (const auto& widgetKey : std::as_const(keys)) {
1655 if (widgetKey == SerialStudio::DashboardLED) {
1656 ledPanel.datasets.push_back(dataset);
1657 continue;
1658 }
1659 if (widgetKey != SerialStudio::DashboardNoWidget)
1660 m_widgetDatasets[widgetKey].append(dataset);
1661 }
1662}
1663
1664/**
1665 * @brief Merges every cached per-source frame into one layout frame. The reconfigure path must

Callers

nothing calls this directly

Calls 4

almostEqualFunction · 0.85
containsMethod · 0.45
valueMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected