diff options
-rw-r--r-- | gui/mapping-dialog.cpp | 44 | ||||
-rw-r--r-- | spline/spline-widget.cpp | 11 | ||||
-rw-r--r-- | spline/spline-widget.hpp | 16 |
3 files changed, 45 insertions, 26 deletions
diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp index 7aa42b13..d4f8a1d4 100644 --- a/gui/mapping-dialog.cpp +++ b/gui/mapping-dialog.cpp @@ -125,21 +125,49 @@ void mapping_dialog::load() const int idx = qfcs[i].axis; - auto update_snap = [idx, &conf, &qfc](int value) { - //qfc.reload_spline(); - qfc.set_x_step(value + 1e-2 >= 90 ? 10 : 5); + using c = axis_opts::max_clamp; - if (idx >= 3) - qfc.set_snap(.5, 1); + auto update_xstep = [idx, &conf, &qfc](int clamp_x) { + int value; + + if (clamp_x <= c::r20) + value = 1; + else if (clamp_x <= c::r30) + value = 5; else - qfc.set_snap(.5, 1); + value = 10; + + qfc.set_x_step(value); + }; + + auto update_ystep = [idx, &conf, &qfc](int clamp_y) { + int value; + switch (clamp_y) + { + default: + case c::o_r180: + value = 15; break; + case c::o_r90: + value = 10; break; + case c::o_t75: + value = 5; break; + } + qfc.set_y_step(value); }; - connect(&axis.opts.clamp_x_, base_value::value_changed<int>(), &qfc, update_snap); + if (idx >= Yaw) + qfc.set_snap(.5, 1); + else + qfc.set_snap(.5, 1); + + connect(&axis.opts.clamp_x_, base_value::value_changed<int>(), &qfc, update_xstep); + connect(&axis.opts.clamp_y_, base_value::value_changed<int>(), &qfc, update_ystep); // force signal to avoid duplicating the slot's logic qfc.setConfig(&conf); - update_snap(axis.opts.clamp_x_.to<int>()); + + update_xstep(axis.opts.clamp_x_); + update_ystep(axis.opts.clamp_y_); widgets[i % 6][altp ? 1 : 0] = &qfc; } diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp index 9a0ae08e..960ba3aa 100644 --- a/spline/spline-widget.cpp +++ b/spline/spline-widget.cpp @@ -25,16 +25,7 @@ #include <cmath> #include <algorithm> -spline_widget::spline_widget(QWidget *parent) : - QWidget(parent), - _config(nullptr), - snap_x(0), - snap_y(0), - _x_step(10), - _y_step(10), - moving_control_point_idx(-1), - _draw_function(true), - _preview_only(false) +spline_widget::spline_widget(QWidget *parent) : QWidget(parent) { setMouseTracking(true); setFocusPolicy(Qt::ClickFocus); diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp index be80f2bc..12d21970 100644 --- a/spline/spline-widget.hpp +++ b/spline/spline-widget.hpp @@ -49,8 +49,8 @@ public: void set_preview_only(bool val); bool is_preview_only() const; - double x_step() { return _x_step; } - double y_step() { return _y_step; } + double x_step() const { return _x_step; } + double y_step() const { return _y_step; } void set_x_step(double val) { _x_step = std::fmax(1., val); } void set_y_step(double val) { _y_step = std::fmax(1., val); } @@ -85,7 +85,7 @@ private: QPoint point_to_pixel(const QPointF& point); QPointF c; - base_spline* _config; + base_spline* _config = nullptr; QPixmap _background; QPixmap _function; @@ -97,10 +97,10 @@ private: QMetaObject::Connection connection; - double snap_x, snap_y; - double _x_step, _y_step; - int moving_control_point_idx; - bool _draw_function, _preview_only; + double snap_x = 0, snap_y = 0; + double _x_step = 10, _y_step = 10; + int moving_control_point_idx = -1; + bool _draw_function = true, _preview_only = false; - static constexpr int point_size = 4; + static constexpr inline int point_size = 4; }; |