summaryrefslogtreecommitdiffhomepage
path: root/spline/spline-widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-08-01 10:43:25 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-08-01 10:45:13 +0200
commitd8ad3ee99ba8cfdfeee8376237df55653883a765 (patch)
tree06d3331eb236bcbd3c3a5ff0fbc0628db0041744 /spline/spline-widget.cpp
parent8fbcdf775660a0cc1857e8bedee7ac2351292aa6 (diff)
spline: ensure cubic spline drawn up to max value
Diffstat (limited to 'spline/spline-widget.cpp')
-rw-r--r--spline/spline-widget.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 0dfac0e9..f56522bd 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -204,18 +204,22 @@ void spline_widget::drawFunction()
: QPointF{max_x_pixel, val.y()};
};
- for (double k = 0; k < maxx; k += step*3) // NOLINT
- {
- const auto next_1 = config->get_value_no_save(k + step*1);
- const auto next_2 = config->get_value_no_save(k + step*2);
- const auto next_3 = config->get_value_no_save(k + step*3);
+ const auto fn = [&] (double k) {
+ const auto next_1 = config->get_value_no_save(k + step*1);
+ const auto next_2 = config->get_value_no_save(k + step*2);
+ const auto next_3 = config->get_value_no_save(k + step*3);
- QPointF b(clamp(point_to_pixel({k + step*1, next_1}))),
- c(clamp(point_to_pixel({k + step*2, next_2}))),
- d(clamp(point_to_pixel({k + step*3, next_3})));
+ QPointF b(clamp(point_to_pixel({k + step*1, next_1}))),
+ c(clamp(point_to_pixel({k + step*2, next_2}))),
+ d(clamp(point_to_pixel({k + step*3, next_3})));
- path.cubicTo(b, c, d);
- }
+ path.cubicTo(b, c, d);
+ };
+
+ for (double k = 0; k < maxx; k += step*3) // NOLINT
+ fn(k);
+
+ fn(maxx);
painter.drawPath(path);
#else