summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--spline/spline-widget.cpp25
-rw-r--r--spline/spline.cpp2
2 files changed, 12 insertions, 15 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 90a8a68a..fef03e82 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -403,30 +403,27 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e)
if (i >= 0 && i < sz)
{
- const int point_pixel_closeness_limit = get_closeness_limit();
+ const int point_closeness_limit = get_closeness_limit();
bool overlap = false;
- const QPoint pix = progn(
- // takes snap into account
- const QPointF pix_ = point_to_pixel(pixel_coord_to_point(e->pos()));
- return QPoint(int(pix_.x()), int(pix_.y()));
- );
+ const QPointF pix_ = point_to_pixel(pixel_coord_to_point(e->pos()));
+ const QPoint pix(int(pix_.x()), int(pix_.y()));
QPointF new_pt = pixel_coord_to_point(e->pos());
if (i + 1 < points.size())
{
- const QPointF other_pix = point_to_pixel(points[i+1]);
- overlap |= other_pix.x() - pix.x() < point_pixel_closeness_limit;
+ overlap |= points[i+1].x() - new_pt.x() < point_closeness_limit;
}
- if (i != 0)
+ if (i > 0)
{
- const QPointF other_pix = point_to_pixel(points[i-1]);
- overlap |= pix.x() - other_pix.x() < point_pixel_closeness_limit;
+ overlap |= new_pt.x() - points[i-1].x() < point_closeness_limit;
}
- if (!overlap)
- _config->move_point(i, new_pt);
+ if (overlap)
+ new_pt = QPointF(points[i].x(), new_pt.y());
+
+ _config->move_point(i, new_pt);
_draw_function = true;
setCursor(Qt::ClosedHandCursor);
@@ -490,7 +487,7 @@ void spline_widget::reload_spline()
int spline_widget::get_closeness_limit()
{
- return std::max(iround(snap_x * c.x()), 1);
+ return std::fmax(snap_x, 1);
}
void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 0f606173..195d68d6 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -317,7 +317,7 @@ void spline::move_point(int idx, QPointF pt)
{
points[idx] = pt;
// we don't allow points to be reordered, but sort due to possible caller logic error
- std::stable_sort(points.begin(), points.end(), sort_fn);
+ //std::stable_sort(points.begin(), points.end(), sort_fn);
s->points = points;
validp = false;
}