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

Method updateDataExtremes

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

* @brief Refreshes the finite Y extremes that drive the area fill's bipolarity from * real data. A sign-clamped configured range short-circuits the per-frame scan; * otherwise the current samples are swept. Returns true when the bipolar or * all-negative verdict flips, so the caller refreshes the baseline binding. */

Source from the content-addressed store, hash-verified

738 * all-negative verdict flips, so the caller refreshes the baseline binding.
739 */
740bool Widgets::Plot::updateDataExtremes(const DataModel::Dataset& dataset)
741{
742 const bool wasBipolar = dataBipolar();
743 const bool wasAllNegative = m_dataMaxY <= 0.0;
744
745 if (signClampedRange(dataset)) {
746 m_dataMinY = qMin(dataset.pltMin, dataset.pltMax);
747 m_dataMaxY = qMax(dataset.pltMin, dataset.pltMax);
748 return wasBipolar != dataBipolar() || wasAllNegative != (m_dataMaxY <= 0.0);
749 }
750
751 double dataMin = std::numeric_limits<double>::max();
752 double dataMax = std::numeric_limits<double>::lowest();
753 for (auto i = 0; i < m_data.size(); ++i) {
754 const double value = m_data[i].y();
755 if (std::isfinite(value)) {
756 dataMin = qMin(dataMin, value);
757 dataMax = qMax(dataMax, value);
758 }
759 }
760
761 if (dataMin > dataMax) {
762 m_dataMinY = 0.0;
763 m_dataMaxY = 0.0;
764 } else {
765 m_dataMinY = dataMin;
766 m_dataMaxY = dataMax;
767 }
768
769 return wasBipolar != dataBipolar() || wasAllNegative != (m_dataMaxY <= 0.0);
770}
771
772/**
773 * @brief Computes the minimum and maximum values for a given axis of the plot.

Callers

nothing calls this directly

Calls 3

signClampedRangeFunction · 0.85
isfiniteFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected