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

Method applyDerivedYBounds

app/src/UI/Widgets/MultiPlot.cpp:793–828  ·  view source on GitHub ↗

* @brief Selects the padding strategy for the current m_minY/m_maxY pair. */

Source from the content-addressed store, hash-verified

791 * @brief Selects the padding strategy for the current m_minY/m_maxY pair.
792 */
793void Widgets::MultiPlot::applyDerivedYBounds()
794{
795 if (!std::isfinite(m_minY) || !std::isfinite(m_maxY)) {
796 m_minY = 0;
797 m_maxY = 1;
798 return;
799 }
800
801 if (DSP::almostEqual(m_minY, m_maxY) && DSP::isZero(m_minY)) {
802 m_minY = -1;
803 m_maxY = 1;
804 return;
805 }
806
807 if (DSP::almostEqual(m_minY, m_maxY)) {
808 const double absValue = qAbs(m_minY);
809 m_minY = m_minY - absValue * 0.1;
810 m_maxY = m_maxY + absValue * 0.1;
811 return;
812 }
813
814 const double midY = (m_minY + m_maxY) * 0.5;
815 const double halfRange = (m_maxY - m_minY) * 0.5;
816
817 double paddedRange = halfRange * 1.1;
818 if (DSP::isZero(paddedRange))
819 paddedRange = 1;
820
821 m_minY = std::floor(midY - paddedRange);
822 m_maxY = std::ceil(midY + paddedRange);
823
824 if (DSP::almostEqual(m_minY, m_maxY)) {
825 m_minY -= 1;
826 m_maxY += 1;
827 }
828}
829
830//--------------------------------------------------------------------------------------------------
831// Curve management

Callers

nothing calls this directly

Calls 5

isfiniteFunction · 0.85
almostEqualFunction · 0.85
isZeroFunction · 0.85
floorFunction · 0.85
ceilFunction · 0.85

Tested by

no test coverage detected