* @brief Calculates the auto-scale range for both X and Y axes of the plot. */
| 676 | * @brief Calculates the auto-scale range for both X and Y axes of the plot. |
| 677 | */ |
| 678 | void Widgets::Plot::calculateAutoScaleRange() |
| 679 | { |
| 680 | if (!VALIDATE_WIDGET(SerialStudio::DashboardPlot, m_index)) |
| 681 | return; |
| 682 | |
| 683 | bool xChanged = false; |
| 684 | bool yChanged = false; |
| 685 | |
| 686 | const auto& dy = GET_DATASET(SerialStudio::DashboardPlot, m_index); |
| 687 | yChanged = computeMinMaxValues(m_minY, m_maxY, dy, true, [](const QPointF& p) { return p.y(); }); |
| 688 | yChanged |= updateDataExtremes(dy); |
| 689 | |
| 690 | #ifdef BUILD_COMMERCIAL |
| 691 | if (const auto& tk2 = Licensing::CommercialToken::current(); |
| 692 | !m_timeAxis && tk2.isValid() && SS_LICENSE_GUARD() |
| 693 | && tk2.featureTier() >= Licensing::FeatureTier::Trial) { |
| 694 | if (UI::Dashboard::instance().datasets().contains(dy.xAxisId)) { |
| 695 | const auto& dx = UI::Dashboard::instance().datasets()[dy.xAxisId]; |
| 696 | xChanged = |
| 697 | computeMinMaxValues(m_minX, m_maxX, dx, false, [](const QPointF& p) { return p.x(); }); |
| 698 | } |
| 699 | } |
| 700 | #else |
| 701 | if (false) { |
| 702 | } |
| 703 | #endif |
| 704 | |
| 705 | else if (!m_timeAxis) { |
| 706 | const auto points = UI::Dashboard::instance().points(); |
| 707 | |
| 708 | if (m_minX != 0 || m_maxX != points) { |
| 709 | m_minX = 0; |
| 710 | m_maxX = points; |
| 711 | xChanged = true; |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | if (xChanged || yChanged) |
| 716 | Q_EMIT rangeChanged(); |
| 717 | } |
| 718 | |
| 719 | /** |
| 720 | * @brief Reports whether a configured plot range hard-clamps the data into one sign, |
nothing calls this directly
no test coverage detected