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

Method applyAxisPadding

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

* @brief Selects the padding strategy for a [min, max] pair before rounding. */

Source from the content-addressed store, hash-verified

832 * @brief Selects the padding strategy for a [min, max] pair before rounding.
833 */
834void Widgets::Plot::applyAxisPadding(double& min, double& max, const bool addPadding)
835{
836 if (!std::isfinite(min) || !std::isfinite(max)) {
837 min = 0;
838 max = 1;
839 return;
840 }
841
842 if (DSP::almostEqual(min, max) && DSP::isZero(min)) {
843 min = -1;
844 max = 1;
845 return;
846 }
847
848 if (DSP::almostEqual(min, max)) {
849 const double absValue = qAbs(min);
850 min = min - absValue * 0.1;
851 max = max + absValue * 0.1;
852 return;
853 }
854
855 if (addPadding) {
856 double range = max - min;
857 min -= range * 0.1;
858 max += range * 0.1;
859 }
860}

Callers

nothing calls this directly

Calls 3

isfiniteFunction · 0.85
almostEqualFunction · 0.85
isZeroFunction · 0.85

Tested by

no test coverage detected