From 9518808799cd34f3cd1497cdac5c163c1cbaf72b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 8 Feb 2024 16:06:47 +0100 Subject: add post-invert, rename invert to pre-invert Requested by: a few people --- gui/options-dialog.cpp | 19 ++-- gui/settings-dialog.ui | 276 ++++++++++++++++++++++++++++++++++--------------- logic/pipeline.cpp | 8 +- spline/axis-opts.cpp | 3 +- spline/axis-opts.hpp | 2 +- 5 files changed, 212 insertions(+), 96 deletions(-) diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index 9cd416ee..76c3313a 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -103,12 +103,19 @@ options_dialog::options_dialog(std::unique_ptr& tracker_dialog_, tie_setting(main.a_pitch.zero, ui.pos_ry); tie_setting(main.a_roll.zero, ui.pos_rz); - tie_setting(main.a_yaw.invert, ui.invert_yaw); - tie_setting(main.a_pitch.invert, ui.invert_pitch); - tie_setting(main.a_roll.invert, ui.invert_roll); - tie_setting(main.a_x.invert, ui.invert_x); - tie_setting(main.a_y.invert, ui.invert_y); - tie_setting(main.a_z.invert, ui.invert_z); + tie_setting(main.a_yaw.invert_pre, ui.invert_yaw_pre); + tie_setting(main.a_pitch.invert_pre, ui.invert_pitch_pre); + tie_setting(main.a_roll.invert_pre, ui.invert_roll_pre); + tie_setting(main.a_x.invert_pre, ui.invert_x_pre); + tie_setting(main.a_y.invert_pre, ui.invert_y_pre); + tie_setting(main.a_z.invert_pre, ui.invert_z_pre); + + tie_setting(main.a_yaw.invert_post, ui.invert_yaw_post); + tie_setting(main.a_pitch.invert_post, ui.invert_pitch_post); + tie_setting(main.a_roll.invert_post, ui.invert_roll_post); + tie_setting(main.a_x.invert_post, ui.invert_x_post); + tie_setting(main.a_y.invert_post, ui.invert_y_post); + tie_setting(main.a_z.invert_post, ui.invert_z_post); tie_setting(main.a_yaw.src, ui.src_yaw); tie_setting(main.a_pitch.src, ui.src_pitch); diff --git a/gui/settings-dialog.ui b/gui/settings-dialog.ui index 45f86ef4..9e2c0042 100644 --- a/gui/settings-dialog.ui +++ b/gui/settings-dialog.ui @@ -984,6 +984,19 @@ 9 + + + + + 254 + 0 + + + + Pitch + + + @@ -1034,8 +1047,8 @@ - - + + 254 @@ -1043,12 +1056,12 @@ - X + Source - - + + 254 @@ -1056,25 +1069,25 @@ - Roll + Pre-invert - - + + - 255 + 254 0 - + X - - + + 255 @@ -1086,21 +1099,8 @@ - - - - - 254 - 0 - - - - Yaw - - - - - + + 255 @@ -1112,21 +1112,8 @@ - - - - - 254 - 0 - - - - Source - - - - - + + 0 @@ -1170,8 +1157,21 @@ - - + + + + + 255 + 0 + + + + + + + + + 255 @@ -1228,8 +1228,8 @@ - - + + 254 @@ -1237,12 +1237,25 @@ - Z + Roll - - + + + + + 254 + 0 + + + + Destination + + + + + 255 @@ -1254,8 +1267,8 @@ - - + + 0 @@ -1304,8 +1317,21 @@ - - + + + + + 254 + 0 + + + + Y + + + + + 0 @@ -1349,21 +1375,21 @@ - - + + - 255 + 254 0 - + Yaw - - + + 254 @@ -1371,12 +1397,38 @@ - Invert + Post-invert - - + + + + + 254 + 0 + + + + Z + + + + + + + + 255 + 0 + + + + + + + + + 0 @@ -1425,42 +1477,81 @@ - - + + - 254 + 255 0 - Destination + - - + + - 254 + 255 0 - Y + - - + + - 254 + 255 0 - Pitch + + + + + + + + + 255 + 0 + + + + + + + + + + + + 255 + 0 + + + + + + + + + + + + 255 + 0 + + + + @@ -1469,23 +1560,30 @@ label_13 label_14 src_yaw - invert_yaw + invert_yaw_pre label_7 src_pitch label_8 - invert_pitch + invert_pitch_pre label_9 src_roll - invert_roll + invert_roll_pre label_10 src_x - invert_x + invert_x_pre label_11 src_y - invert_y + invert_y_pre label_12 src_z - invert_z + invert_z_pre + label_19 + invert_yaw_post + invert_pitch_post + invert_roll_post + invert_x_post + invert_y_post + invert_z_post @@ -2220,17 +2318,23 @@ trayp tray_start src_yaw - invert_yaw + invert_yaw_pre + invert_yaw_post src_pitch - invert_pitch + invert_pitch_pre + invert_pitch_post src_roll - invert_roll + invert_roll_pre + invert_roll_post src_x - invert_x + invert_x_pre + invert_x_post src_y - invert_y + invert_y_pre + invert_y_post src_z - invert_z + invert_z_pre + invert_z_post pos_rx pos_ry pos_rz diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index 2f88c8b1..2e8efe55 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -349,7 +349,7 @@ Pose pipeline::apply_center(const centering_state mode, Pose value) const for (int i = 0; i < 6; i++) // don't invert after reltrans // inverting here doesn't break centering - if (m(i).opts.invert) + if (m(i).opts.invert_pre) value(i) = -value(i); return value; @@ -391,7 +391,7 @@ Pose pipeline::maybe_apply_filter(const Pose& value) const Pose pipeline::apply_zero_pos(Pose value) const { for (int i = 0; i < 6; i++) - value(i) += m(i).opts.zero * (m(i).opts.invert ? -1 : 1); + value(i) += m(i).opts.zero * (m(i).opts.invert_pre ? -1 : 1); return value; } @@ -504,6 +504,10 @@ ok: last_value = value; value = apply_zero_pos(value); + for (int i = 0; i < 6; i++) + if (m(i).opts.invert_post) + value(i) = -value(i); + libs.pProtocol->pose(value, raw); QMutexLocker foo(&mtx); diff --git a/spline/axis-opts.cpp b/spline/axis-opts.cpp index 59b0c15c..ca266136 100644 --- a/spline/axis-opts.cpp +++ b/spline/axis-opts.cpp @@ -31,7 +31,8 @@ axis_opts::axis_opts(QString pfx, Axis idx) : axis_(idx), zero(b_settings_window, n(pfx, "zero-pos"), 0), src(b_settings_window, n(pfx, "source-index"), idx), - invert(b_settings_window, n(pfx, "invert-sign"), false), + invert_post(b_settings_window, n(pfx, "invert-sign-post"), false), + invert_pre(b_settings_window, n(pfx, "invert-sign"), false), altp(b_mapping_window, n(pfx, "alt-axis-sign"), false), clamp_x_(b_mapping_window, n(pfx, "max-value"), get_max_x(idx)), clamp_y_(b_mapping_window, n(pfx, "max-output-value"), get_max_y(idx)) diff --git a/spline/axis-opts.hpp b/spline/axis-opts.hpp index b389f4b9..437a5faa 100644 --- a/spline/axis-opts.hpp +++ b/spline/axis-opts.hpp @@ -55,7 +55,7 @@ public: bundle b_mapping_window{ make_bundle(axis_ == Axis(-1) ? QString() : "opentrack-mappings") }; value zero; value src; - value invert, altp; + value invert_pre, invert_post, altp; value clamp_x_, clamp_y_; double max_clamp_x() const { return std::fabs(clamp_x_.to()); } double max_clamp_y() const { return std::fabs(clamp_y_.to()); } -- cgit v1.2.3