* @brief Selects the padding strategy for a [min, max] pair before rounding. */
| 832 | * @brief Selects the padding strategy for a [min, max] pair before rounding. |
| 833 | */ |
| 834 | void 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 | } |
nothing calls this directly
no test coverage detected