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

Method configureGpsSeries

app/src/UI/Dashboard.cpp:2209–2263  ·  view source on GitHub ↗

* @brief Initializes the GPS series structure for all GPS widgets. * Two passes are deliberate: the push table stores raw pointers into m_gpsValues, * and those addresses are stable only after that vector stops growing, so all * series are allocated first and the pushes resolved in a second pass. */

Source from the content-addressed store, hash-verified

2207 * series are allocated first and the pushes resolved in a second pass.
2208 */
2209void UI::Dashboard::configureGpsSeries()
2210{
2211 m_gpsValues.clear();
2212 m_gpsValues.squeeze();
2213 m_gpsPushes.clear();
2214 m_gpsPushes.shrink_to_fit();
2215
2216 const int gpsCount = widgetCount(SerialStudio::DashboardGPS);
2217 for (int i = 0; i < gpsCount; ++i) {
2218 DSP::GpsSeries series;
2219 const auto& group = getGroupWidget(SerialStudio::DashboardGPS, i);
2220 const QMap<QString, DSP::FixedQueue<double>*> fieldMap = {
2221 {"lat", &series.latitudes},
2222 {"lon", &series.longitudes},
2223 {"alt", &series.altitudes}
2224 };
2225
2226 for (size_t j = 0; j < group.datasets.size(); ++j) {
2227 const auto& dataset = group.datasets[j];
2228 if (fieldMap.contains(dataset.widget)) {
2229 auto* vector = fieldMap[dataset.widget];
2230 vector->resize(points() + 1);
2231 vector->fill(std::nan(""));
2232 }
2233 }
2234
2235 m_gpsValues.append(series);
2236 }
2237
2238 m_gpsPushes.reserve(static_cast<std::size_t>(gpsCount));
2239 for (int i = 0; i < gpsCount; ++i) {
2240 const auto& group = getGroupWidget(SerialStudio::DashboardGPS, i);
2241
2242 GpsPush push;
2243 push.sourceId = group.sourceId;
2244 push.series = &m_gpsValues[i];
2245 push.lat = {&kNoGpsFix, &kNeverNumeric};
2246 push.lon = {&kNoGpsFix, &kNeverNumeric};
2247 push.alt = {&kNoGpsFix, &kNeverNumeric};
2248
2249 for (const auto& dataset : group.datasets) {
2250 const GpsPush::Field field{&dataset.numericValue, &dataset.isNumeric};
2251 if (dataset.widget == QStringLiteral("lat"))
2252 push.lat = field;
2253
2254 if (dataset.widget == QStringLiteral("lon"))
2255 push.lon = field;
2256
2257 if (dataset.widget == QStringLiteral("alt"))
2258 push.alt = field;
2259 }
2260
2261 m_gpsPushes.push_back(push);
2262 }
2263}
2264
2265/**
2266 * @brief Configures the FFT series data structure for the dashboard.

Callers

nothing calls this directly

Calls 6

clearMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45
resizeMethod · 0.45
fillMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected