From 665a9d29bc986e5ad0daa7609e0c2e2ff438960c Mon Sep 17 00:00:00 2001 From: Anthony Lombardi Date: Thu, 22 Aug 2024 15:04:11 -0400 Subject: [PATCH] ENH: Add short to align pivot with global axes --- autoscoper/src/ui/AutoscoperMainWindow.cpp | 24 ++++++++++++++++++++++ autoscoper/src/ui/AutoscoperMainWindow.h | 1 + 2 files changed, 25 insertions(+) diff --git a/autoscoper/src/ui/AutoscoperMainWindow.cpp b/autoscoper/src/ui/AutoscoperMainWindow.cpp index af19bdff..a3faabd6 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.cpp +++ b/autoscoper/src/ui/AutoscoperMainWindow.cpp @@ -2463,6 +2463,28 @@ void AutoscoperMainWindow::key_p_pressed() redrawGL(); } + +void AutoscoperMainWindow::key_o_pressed() +{ + // Get the current position of the manipulator and the volume. + Mat4d cur_manip_pos = getManipulator(-1)->transform(); + Vec3f cur_manip_t = Vec3f(cur_manip_pos(0, 3), cur_manip_pos(1, 3), cur_manip_pos(2, 3)); + CoordFrame* vol_mat = tracker->trial()->getVolumeMatrix(-1); + + // Update the rotation of the volume mat to preserve the orientation of the volume + *vol_mat = CoordFrame::from_matrix(trans(cur_manip_pos)) * *vol_mat; + // Ensure we are compenstating for the manipulator so we don't alter the world coordinate calculations + vol_mat->set_translation(Vec3f(vol_mat->translation()) - cur_manip_t); + + // Reset the rotation of the manipulator + Mat4d new_manip_pos = Mat4d::eye(); + new_manip_pos(0, 3) = cur_manip_t.x; + new_manip_pos(1, 3) = cur_manip_t.y; + new_manip_pos(2, 3) = cur_manip_t.z; + getManipulator(-1)->set_transform(new_manip_pos); + + redrawGL(); +} void AutoscoperMainWindow::key_c_pressed() { on_actionInsert_Key_triggered(true); // Insert the current frame and then run the tracking @@ -2544,6 +2566,8 @@ void AutoscoperMainWindow::setupShortcuts() new QShortcut(QKeySequence(Qt::Key_K), this, SLOT(key_k_pressed())); // P - Snap pivot back to the center of the volume new QShortcut(QKeySequence(Qt::Key_P), this, SLOT(key_p_pressed())); + // O - Align pivot back to global axes + new QShortcut(QKeySequence(Qt::Key_O), this, SLOT(key_o_pressed())); // C - Track current frame new QShortcut(QKeySequence(Qt::Key_C), this, SLOT(key_c_pressed())); // + - Increase pivot size diff --git a/autoscoper/src/ui/AutoscoperMainWindow.h b/autoscoper/src/ui/AutoscoperMainWindow.h index 776b9f93..107676e2 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.h +++ b/autoscoper/src/ui/AutoscoperMainWindow.h @@ -335,6 +335,7 @@ public slots: void key_k_pressed(); // void key_r_pressed(); void key_p_pressed(); + void key_o_pressed(); void key_c_pressed(); void key_plus_pressed(); void key_equal_pressed();