From a3b890b9b4d8bc14c662cd0b3a3362e784b35593 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Oct 2016 08:31:04 +0200 Subject: spline-widget: use round, not trunc when converting pixel to val --- spline-widget/spline-widget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'spline-widget') diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp index 975f26e5..e68ff4a6 100644 --- a/spline-widget/spline-widget.cpp +++ b/spline-widget/spline-widget.cpp @@ -543,14 +543,16 @@ QPointF spline_widget::pixel_coord_to_point(const QPoint& point) if (snap_x > 0) { + x += snap_x / 2.; x -= std::fmod(x, snap_x); - const volatile int x_ = int(x * c); + const volatile int x_ = iround(x * c); x = x_ / double(c); } if (snap_y > 0) { + y += snap_y / 2.; y -= std::fmod(y, snap_y); - const volatile int y_ = int(y * c); + const volatile int y_ = iround(y * c); y = y_ / double(c); } -- cgit v1.2.3