From 1efdf708f871f2ff5c3c184abf23c0a873379f73 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Feb 2017 22:34:36 +0100 Subject: spline-widget: only use singular point if below zoom pt Otherwise it got linearly interpolated toward a point that wasn't visible on the spline widget. --- spline-widget/spline.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spline-widget/spline.cpp b/spline-widget/spline.cpp index 02453420..ecfd459a 100644 --- a/spline-widget/spline.cpp +++ b/spline-widget/spline.cpp @@ -169,7 +169,7 @@ int spline::element_count(const QList& points, double max_x) const unsigned sz = points.size(); for (unsigned i = 0; i < sz; i++) { - if (points[i].x() > max_x) + if (!(points[i].x() <= max_x)) return i; } return points.size(); @@ -200,13 +200,16 @@ void spline::update_interp_data() if (sz < 2) { - const double x = points[0].x(); - const double y = points[0].y(); - const int max = clamp(int(x * precision(points)), 0, value_count-1); - for (int k = 0; k <= max; k++) + if (points[0].x() - 1e-2 <= max_x) { - if (k < value_count) - data[unsigned(k)] = float(y * k / max); + const double x = points[0].x(); + const double y = points[0].y(); + const int max = clamp(int(x * precision(points)), 0, value_count-1); + for (int k = 0; k <= max; k++) + { + if (k < value_count) + data[unsigned(k)] = float(y * k / max); + } } } else -- cgit v1.2.3