summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gui/curve-config.cpp6
-rw-r--r--spline-widget/qfunctionconfigurator.cpp13
-rw-r--r--spline-widget/qfunctionconfigurator.h3
3 files changed, 19 insertions, 3 deletions
diff --git a/gui/curve-config.cpp b/gui/curve-config.cpp
index 2e9065b4..7cd78580 100644
--- a/gui/curve-config.cpp
+++ b/gui/curve-config.cpp
@@ -54,6 +54,12 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) :
qfc.setEnabled(qfcs[i].checkbox->isChecked());
qfc.force_redraw();
}
+
+ if (qfcs[i].axis >= 3)
+ qfcs[i].qfc->set_snap(2, 5);
+ else
+ qfcs[i].qfc->set_snap(1, 5);
+
qfcs[i].qfc->setConfig(conf, name);
}
}
diff --git a/spline-widget/qfunctionconfigurator.cpp b/spline-widget/qfunctionconfigurator.cpp
index 5d910826..112b5457 100644
--- a/spline-widget/qfunctionconfigurator.cpp
+++ b/spline-widget/qfunctionconfigurator.cpp
@@ -21,7 +21,9 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) :
QWidget(parent),
_config(nullptr),
moving_control_point_idx(-1),
- _draw_function(true)
+ _draw_function(true),
+ snap_x(0),
+ snap_y(0)
{
update_range();
setMouseTracking(true);
@@ -412,8 +414,13 @@ QPointF QFunctionConfigurator::pixel_coord_to_point(const QPointF& point)
if (!_config)
return QPointF(-1, -1);
- double x = (point.x() - pixel_bounds.x()) / c.x();
- double y = (pixel_bounds.height() - point.y() + pixel_bounds.y()) / c.y();
+ int x = (point.x() - pixel_bounds.x()) / c.x();
+ int y = (pixel_bounds.height() - point.y() + pixel_bounds.y()) / c.y();
+
+ if (snap_x > 0)
+ x -= x % snap_x;
+ if (snap_y > 0)
+ y -= y % snap_y;
if (x < 0)
x = 0;
diff --git a/spline-widget/qfunctionconfigurator.h b/spline-widget/qfunctionconfigurator.h
index 4a9cb5f1..d4ba904a 100644
--- a/spline-widget/qfunctionconfigurator.h
+++ b/spline-widget/qfunctionconfigurator.h
@@ -39,6 +39,8 @@ public:
_background = QPixmap();
update();
}
+ void set_snap(int x, int y) { snap_x = x; snap_y = y; }
+ void get_snap(int& x, int& y) const { x = snap_x; y = snap_y; }
protected slots:
void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
@@ -72,4 +74,5 @@ private:
QPixmap _background;
QPixmap _function;
bool _draw_function;
+ int snap_x, snap_y;
};