! * helper function for checkXRange() and checkYRange() */
| 3665 | * helper function for checkXRange() and checkYRange() |
| 3666 | */ |
| 3667 | Range<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 |