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

Method updateRange

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

* @brief Updates the range of the X-axis values. */

Source from the content-addressed store, hash-verified

638 * @brief Updates the range of the X-axis values.
639 */
640void Widgets::Plot::updateRange()
641{
642 if (!VALIDATE_WIDGET(SerialStudio::DashboardPlot, m_index)) {
643 Q_EMIT rangeChanged();
644 return;
645 }
646
647 if (m_timeAxis) {
648 const double range = UI::Dashboard::instance().plotTimeRange();
649 const double timebase = m_timebaseMs * 0.001;
650 const double window = (timebase > 0 && timebase < range) ? timebase : range;
651 m_minX = m_sweepEnabled ? 0 : -range;
652 m_maxX = m_sweepEnabled ? window : 0;
653 Q_EMIT rangeChanged();
654 return;
655 }
656
657 const auto& yD = GET_DATASET(SerialStudio::DashboardPlot, m_index);
658 if (yD.xAxisId >= 0) {
659 const auto& datasets = UI::Dashboard::instance().datasets();
660 auto it = datasets.find(yD.xAxisId);
661 if (it != datasets.end()) {
662 m_minX = it->pltMin;
663 m_maxX = it->pltMax;
664 }
665 }
666
667 else {
668 m_minX = 0;
669 m_maxX = UI::Dashboard::instance().points();
670 }
671
672 Q_EMIT rangeChanged();
673}
674
675/**
676 * @brief Calculates the auto-scale range for both X and Y axes of the plot.

Callers

nothing calls this directly

Calls 4

VALIDATE_WIDGETFunction · 0.85
findMethod · 0.80
plotTimeRangeMethod · 0.45
pointsMethod · 0.45

Tested by

no test coverage detected