Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for manipulating DRR position using the arrow keys #294

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Documentation/shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| `Ctrl + L` | Smooth tangents between keyframes |
| `Left` | Select previous DOF. |
| `Right` | Select next DOF. |
| `Up` | Increment selected DOF. |
| `Down` | Decrement selected DOF. |
6 changes: 6 additions & 0 deletions autoscoper/src/ui/AdvancedOptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AutoscoperMainWindow*>(parent());
mainwindow->updateStepSize(d);
}

void AdvancedOptionsDialog::setDefPaths(QString root_path,
QString filter_folder,
QString filter_name,
Expand Down
1 change: 1 addition & 0 deletions autoscoper/src/ui/AdvancedOptionsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
57 changes: 57 additions & 0 deletions autoscoper/src/ui/AutoscoperMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,10 @@ void AutoscoperMainWindow::loadFilterSettings(int camera, QString filename)

std::vector<double> AutoscoperMainWindow::getPose(unsigned int volume, unsigned int frame)
{
if (frame == -1) {
frame = tracker->trial()->frame;
}

std::vector<double> pose(6, 0);
pose[0] = (*tracker->trial()->getXCurve(volume))(frame);
pose[1] = (*tracker->trial()->getYCurve(volume))(frame);
Expand All @@ -846,10 +850,16 @@ std::vector<double> AutoscoperMainWindow::getPose(unsigned int volume, unsigned

void AutoscoperMainWindow::setPose(std::vector<double> 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();
NicerNewerCar marked this conversation as resolved.
Show resolved Hide resolved
redrawGL();
}

void AutoscoperMainWindow::setBackground(double threshold)
Expand Down Expand Up @@ -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<double> 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<double> curPose = getPose(-1, -1);
int currentDOF = this->timeline_widget->getCurrentDOF();
curPose[currentDOF] = curPose[currentDOF] - stepVal;
setPose(curPose, -1, -1);
}

// Shortcuts
void AutoscoperMainWindow::setupShortcuts()
{
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions autoscoper/src/ui/AutoscoperMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -220,6 +222,9 @@ class AutoscoperMainWindow : public QMainWindow
std::vector<unsigned int> 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:
Expand Down Expand Up @@ -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
58 changes: 57 additions & 1 deletion autoscoper/src/ui/TimelineDockWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "ui/TimelineDockWidget.h"
#include "ui/AutoscoperMainWindow.h"

#include "TimelineDockWidget.h"
#include "Tracker.hpp"

#include <QOpenGLContext>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -442,4 +498,4 @@ void TimelineDockWidget::update_graph_min_max(int frame)
position_graph->min_value -= 1.0;
position_graph->max_value += 1.0;
}
}
}
12 changes: 12 additions & 0 deletions autoscoper/src/ui/TimelineDockWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#define TIMELINEDOCKWIDGET_H

#include <QDockWidget>

#include "AutoscoperMainWindow.h"
#include "KeyCurve.hpp"

struct GraphData
Expand Down Expand Up @@ -100,6 +102,12 @@ class TimelineDockWidget : public QDockWidget

std::vector<std::pair<IKeyCurve*, IKeyCurve::iterator>>* 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);
Expand All @@ -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();
Expand Down
Loading
Loading