MCPcopy Create free account
hub / github.com/KDE/labplot / checkRange

Method checkRange

src/backend/worksheet/plots/cartesian/CartesianPlot.cpp:3667–3693  ·  view source on GitHub ↗

! * helper function for checkXRange() and checkYRange() */

Source from the content-addressed store, hash-verified

3665 * helper function for checkXRange() and checkYRange()
3666 */
3667Range<double> CartesianPlotPrivate::checkRange(const Range<double>& range) {
3668 double start = range.start(), end = range.end();
3669 const auto scale = range.scale();
3670 if (scale == RangeT::Scale::Linear || (start > 0 && end > 0)) // nothing to do
3671 return range;
3672 if (start >= 0 && end >= 0 && scale == RangeT::Scale::Sqrt) // nothing to do
3673 return range;
3674 // TODO: check if start == end?
3675
3676 double min = 0.01, max = 1.;
3677
3678 if (scale == RangeT::Scale::Sqrt) {
3679 if (start < 0)
3680 start = 0.;
3681 } else if (start <= 0)
3682 start = min;
3683 if (scale == RangeT::Scale::Sqrt) {
3684 if (end < 0)
3685 end = max;
3686 } else if (end <= 0)
3687 end = max;
3688
3689 auto newRange = range;
3690 newRange.setStart(start);
3691 newRange.setEnd(end);
3692 return newRange;
3693}
3694
3695/*!
3696 * check for negative values in the range when non-linear scalings are used

Callers 3

setRangeMethod · 0.80
setRangeScaleMethod · 0.80
calculateDataRangeMethod · 0.80

Calls 8

toStdStringMethod · 0.80
setMinMethod · 0.80
setMaxMethod · 0.80
startMethod · 0.45
endMethod · 0.45
scaleMethod · 0.45
setStartMethod · 0.45
setEndMethod · 0.45

Tested by

no test coverage detected