summaryrefslogtreecommitdiffhomepage
path: root/spline-widget/spline.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-02-13 22:34:36 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-02-13 22:34:36 +0100
commit1efdf708f871f2ff5c3c184abf23c0a873379f73 (patch)
tree5cd1d10343cec239d1b0060d4ef86e6d694437c6 /spline-widget/spline.cpp
parent87d2b5992d400239240709adc6503e500ea7e058 (diff)
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.
Diffstat (limited to 'spline-widget/spline.cpp')
-rw-r--r--spline-widget/spline.cpp17
1 files 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<QPointF>& 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