diff --git a/Documentation/shortcuts.md b/Documentation/shortcuts.md index 3d604031..b6e9bdcf 100644 --- a/Documentation/shortcuts.md +++ b/Documentation/shortcuts.md @@ -40,4 +40,8 @@ These shortcuts only apply to the currently selected volume. See [](./user-inter | `Ctrl + Z` | Undo - back to previous keyframe | | `Ctrl + Y` | Redo - forward to next keyframe | | `Delete` | Delete the current keyframe | -| `Ctrl + L` | Smooth tangents between keyframes | \ No newline at end of file +| `Ctrl + L` | Smooth tangents between keyframes | +| `Left` | Select previous DOF. | +| `Right` | Select next DOF. | +| `Up` | Increment selected DOF. | +| `Down` | Decrement selected DOF. | diff --git a/autoscoper/src/ui/AdvancedOptionsDialog.cpp b/autoscoper/src/ui/AdvancedOptionsDialog.cpp index ce1bd009..de5b9905 100644 --- a/autoscoper/src/ui/AdvancedOptionsDialog.cpp +++ b/autoscoper/src/ui/AdvancedOptionsDialog.cpp @@ -149,6 +149,12 @@ void AdvancedOptionsDialog::on_radioButton_AnotherMethod_clicked(bool checked) // mainwindow->getTracker()->trial()->guess = 1; } +void AdvancedOptionsDialog::on_stepSizeSpinBox_valueChanged(double d) +{ + AutoscoperMainWindow* mainwindow = dynamic_cast(parent()); + mainwindow->updateStepSize(d); +} + void AdvancedOptionsDialog::setDefPaths(QString root_path, QString filter_folder, QString filter_name, diff --git a/autoscoper/src/ui/AdvancedOptionsDialog.h b/autoscoper/src/ui/AdvancedOptionsDialog.h index aaa94971..bfe50a6f 100644 --- a/autoscoper/src/ui/AdvancedOptionsDialog.h +++ b/autoscoper/src/ui/AdvancedOptionsDialog.h @@ -77,6 +77,7 @@ public slots: void on_pushButton_Delete_clicked(bool checked); void on_radioButton_MovingAverage_clicked(bool checked); void on_radioButton_AnotherMethod_clicked(bool checked); + void on_stepSizeSpinBox_valueChanged(double d); void setDefPaths(QString root_path, QString filter_folder, diff --git a/autoscoper/src/ui/AutoscoperMainWindow.cpp b/autoscoper/src/ui/AutoscoperMainWindow.cpp index 36ea6fb3..6b73450d 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.cpp +++ b/autoscoper/src/ui/AutoscoperMainWindow.cpp @@ -833,6 +833,10 @@ void AutoscoperMainWindow::loadFilterSettings(int camera, QString filename) std::vector AutoscoperMainWindow::getPose(unsigned int volume, unsigned int frame) { + if (frame == -1) { + frame = tracker->trial()->frame; + } + std::vector pose(6, 0); pose[0] = (*tracker->trial()->getXCurve(volume))(frame); pose[1] = (*tracker->trial()->getYCurve(volume))(frame); @@ -846,10 +850,16 @@ std::vector AutoscoperMainWindow::getPose(unsigned int volume, unsigned void AutoscoperMainWindow::setPose(std::vector pose, unsigned int volume, unsigned int frame) { + if (frame == -1) { + frame = tracker->trial()->frame; + } + tracker->trial()->getXCurve(volume)->insert(frame, pose[0]); tracker->trial()->getYCurve(volume)->insert(frame, pose[1]); tracker->trial()->getZCurve(volume)->insert(frame, pose[2]); tracker->trial()->getQuatCurve(volume)->insert(frame, Quatf(pose[3], pose[4], pose[5])); + frame_changed(); + redrawGL(); } void AutoscoperMainWindow::setBackground(double threshold) @@ -2399,6 +2409,44 @@ void AutoscoperMainWindow::key_minus_pressed() redrawGL(); } +void AutoscoperMainWindow::key_left_pressed() +{ + // Move to the prev DOF + int updatedDOF = this->timeline_widget->getCurrentDOF(); + updatedDOF--; + if (updatedDOF < 0) { + updatedDOF = TimelineDockWidget::NUMBER_OF_DEGREES_OF_FREEDOM - 1; + } + this->timeline_widget->setCurrentDOF(updatedDOF); +} + +void AutoscoperMainWindow::key_right_pressed() +{ + // Move to the next DOF + int updatedDOF = timeline_widget->getCurrentDOF(); + updatedDOF++; + if (updatedDOF >= TimelineDockWidget::NUMBER_OF_DEGREES_OF_FREEDOM) { + updatedDOF = 0; + } + timeline_widget->setCurrentDOF(updatedDOF); +} + +void AutoscoperMainWindow::key_up_pressed() +{ + std::vector curPose = getPose(-1, -1); + int currentDOF = this->timeline_widget->getCurrentDOF(); + curPose[currentDOF] = curPose[currentDOF] + stepVal; + setPose(curPose, -1, -1); +} + +void AutoscoperMainWindow::key_down_pressed() +{ + std::vector curPose = getPose(-1, -1); + int currentDOF = this->timeline_widget->getCurrentDOF(); + curPose[currentDOF] = curPose[currentDOF] - stepVal; + setPose(curPose, -1, -1); +} + // Shortcuts void AutoscoperMainWindow::setupShortcuts() { @@ -2423,6 +2471,15 @@ void AutoscoperMainWindow::setupShortcuts() // - - Decrease pivot size new QShortcut(QKeySequence(Qt::Key_Minus), this, SLOT(key_minus_pressed())); + // Left Arrow Key - Previous DOF + new QShortcut(QKeySequence(Qt::Key_Left), this, SLOT(key_left_pressed())); + // Right Arrow Key - Next DOF + new QShortcut(QKeySequence(Qt::Key_Right), this, SLOT(key_right_pressed())); + // Up Arrow Key - Increment DOF + new QShortcut(QKeySequence(Qt::Key_Up), this, SLOT(key_up_pressed())); + // Down Arrow Key - Decrement DOF + new QShortcut(QKeySequence(Qt::Key_Down), this, SLOT(key_down_pressed())); + // CTRL+C - Copy keyframe ui->actionCopy->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); // CTRL+V - Paste keyframe diff --git a/autoscoper/src/ui/AutoscoperMainWindow.h b/autoscoper/src/ui/AutoscoperMainWindow.h index 42e2e15e..368ff105 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.h +++ b/autoscoper/src/ui/AutoscoperMainWindow.h @@ -161,6 +161,8 @@ class AutoscoperMainWindow : public QMainWindow // Backup Save void backup_tracking(bool backup_on); + void updateStepSize(double d) { stepVal = d; } + private: Ui::AutoscoperMainWindow* ui; FilterDockWidget* filters_widget; @@ -220,6 +222,9 @@ class AutoscoperMainWindow : public QMainWindow std::vector textures; void reset_graph(); + // Arrow key stepping + double stepVal = 1.0; + /// \brief Log tracking parameter to file /// /// The file is created based on the following pattern: @@ -325,6 +330,11 @@ public slots: void key_plus_pressed(); void key_equal_pressed(); void key_minus_pressed(); + + void key_left_pressed(); + void key_right_pressed(); + void key_up_pressed(); + void key_down_pressed(); }; #endif // UAUTOSCOPERMAINWINDOW_H diff --git a/autoscoper/src/ui/TimelineDockWidget.cpp b/autoscoper/src/ui/TimelineDockWidget.cpp index ce78b363..1cac2271 100644 --- a/autoscoper/src/ui/TimelineDockWidget.cpp +++ b/autoscoper/src/ui/TimelineDockWidget.cpp @@ -47,6 +47,7 @@ #include "ui/TimelineDockWidget.h" #include "ui/AutoscoperMainWindow.h" +#include "TimelineDockWidget.h" #include "Tracker.hpp" #include @@ -292,6 +293,61 @@ void TimelineDockWidget::on_spinBox_LastFrame_valueChanged(int d) } } +void TimelineDockWidget::setCurrentDOF(int dof) +{ + if (dof < 0) { + dof = 0; + } + if (dof >= NUMBER_OF_DEGREES_OF_FREEDOM) { + dof = NUMBER_OF_DEGREES_OF_FREEDOM - 1; + } + if (dof == this->currentDOF) { + return; + } + this->updateBolding(this->currentDOF, false); + this->updateBolding(dof, true); + this->currentDOF = dof; +} + +void TimelineDockWidget::updateBolding(int dof, bool state) +{ + QFont font; + switch (dof) { + case 0: + font = dock->checkBox_X->font(); + font.setBold(state); + dock->checkBox_X->setFont(font); + break; + case 1: + font = dock->checkBox_Y->font(); + font.setBold(state); + dock->checkBox_Y->setFont(font); + break; + case 2: + font = dock->checkBox_Z->font(); + font.setBold(state); + dock->checkBox_Z->setFont(font); + break; + case 3: + font = dock->checkBox_Yaw->font(); + font.setBold(state); + dock->checkBox_Yaw->setFont(font); + break; + case 4: + font = dock->checkBox_Pitch->font(); + font.setBold(state); + dock->checkBox_Pitch->setFont(font); + break; + case 5: + font = dock->checkBox_Roll->font(); + font.setBold(state); + dock->checkBox_Roll->setFont(font); + break; + default: + break; + } +} + void TimelineDockWidget::getValues(double* xyzypr) { xyzypr[0] = dock->doubleSpinBox_X->value(); @@ -442,4 +498,4 @@ void TimelineDockWidget::update_graph_min_max(int frame) position_graph->min_value -= 1.0; position_graph->max_value += 1.0; } -} \ No newline at end of file +} diff --git a/autoscoper/src/ui/TimelineDockWidget.h b/autoscoper/src/ui/TimelineDockWidget.h index 2eeb35e6..ae97255a 100644 --- a/autoscoper/src/ui/TimelineDockWidget.h +++ b/autoscoper/src/ui/TimelineDockWidget.h @@ -43,6 +43,8 @@ #define TIMELINEDOCKWIDGET_H #include + +#include "AutoscoperMainWindow.h" #include "KeyCurve.hpp" struct GraphData @@ -100,6 +102,12 @@ class TimelineDockWidget : public QDockWidget std::vector>* getCopiedNodes() { return &copied_nodes; } + // DOF stepping and selection + void setCurrentDOF(int dof); + int getCurrentDOF() { return this->currentDOF; } + + static const int NUMBER_OF_DEGREES_OF_FREEDOM = 6; + void getValues(double* xyzypr); void setValues(double* xyzypr); void setValuesEnabled(bool enabled); @@ -125,6 +133,10 @@ class TimelineDockWidget : public QDockWidget int play_tag; QTimer* play_timer; + // DOF stepping and selection + int currentDOF = 0; + void updateBolding(int dof, bool state); + protected: public slots: void play_update(); diff --git a/autoscoper/src/ui/ui-files/AdvancedOptionsDialog.ui b/autoscoper/src/ui/ui-files/AdvancedOptionsDialog.ui index 50391652..7aa04127 100644 --- a/autoscoper/src/ui/ui-files/AdvancedOptionsDialog.ui +++ b/autoscoper/src/ui/ui-files/AdvancedOptionsDialog.ui @@ -7,8 +7,8 @@ 0 0 - 477 - 470 + 468 + 568 @@ -41,7 +41,106 @@ 15 - + + + + + 0 + 80 + + + + QGroupBox { + border: 1px solid gray; + border-radius: 9px; + margin-top: 0.5em; +} + +QGroupBox::title { + subcontrol-origin: margin; + left: 10px; + padding: 0 3px 0 3px; +} + + + Range + + + false + + + false + + + + + + + + End Frame + + + + + + + Start Frame + + + + + + + Qt::Vertical + + + + + + + 1000 + + + + + + + 1000 + + + + + + + + 75 + false + true + false + false + + + + Skip Frame + + + + + + + 1 + + + 1000 + + + + + + + + + @@ -291,105 +390,6 @@ QGroupBox::title { - - - - - 0 - 80 - - - - QGroupBox { - border: 1px solid gray; - border-radius: 9px; - margin-top: 0.5em; -} - -QGroupBox::title { - subcontrol-origin: margin; - left: 10px; - padding: 0 3px 0 3px; -} - - - Range - - - false - - - false - - - - - - - - End Frame - - - - - - - Start Frame - - - - - - - Qt::Vertical - - - - - - - 1000 - - - - - - - 1000 - - - - - - - - 75 - false - true - false - false - - - - Skip Frame - - - - - - - 1 - - - 1000 - - - - - - - - @@ -460,6 +460,71 @@ QGroupBox::title { + + + + QGroupBox { + border: 1px solid gray; + border-radius: 9px; + margin-top: 0.5em; +} + +QGroupBox::title { + subcontrol-origin: margin; + left: 10px; + padding: 0 3px 0 3px; +} + + + Step Size + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Step size + + + + + + + 0.010000000000000 + + + 1.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + diff --git a/autoscoper/src/ui/ui-files/TimelineDockWidget.ui b/autoscoper/src/ui/ui-files/TimelineDockWidget.ui index c6f6a321..e564cdaf 100644 --- a/autoscoper/src/ui/ui-files/TimelineDockWidget.ui +++ b/autoscoper/src/ui/ui-files/TimelineDockWidget.ui @@ -6,14 +6,14 @@ 0 0 - 941 + 1088 366 - 941 - 180 + 1088 + 194 @@ -232,6 +232,12 @@ 20 + + + 75 + true + + X (mm)