* @brief Updates the range of the X-axis values. */
| 638 | * @brief Updates the range of the X-axis values. |
| 639 | */ |
| 640 | void 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. |
nothing calls this directly
no test coverage detected