Skip to content

Commit

Permalink
ENH: Support DRR manipulation with arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar committed Aug 13, 2024
1 parent b74fb20 commit bdcc5f0
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 109 deletions.
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
62 changes: 59 additions & 3 deletions autoscoper/src/ui/AutoscoperMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,19 +833,28 @@ 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);
pose[2] = (*tracker->trial()->getZCurve(volume))(frame);
Quatf q = (*tracker->trial()->getQuatCurve(volume))(frame);
pose[3] = q.z;
pose[4] = q.y;
pose[5] = q.x;
Vec3f euler = q.toEuler();
pose[3] = euler.z;
pose[4] = euler.y;
pose[5] = euler.x;
return pose;
}

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]);
Expand Down Expand Up @@ -2401,6 +2410,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 @@ -2425,6 +2472,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 @@ -39,6 +39,7 @@
/// \file TimelineDockWidget.cpp
/// \author Benjamin Knorlein, Andy Loomis

#include "TimelineDockWidget.h"
#ifdef _MSC_VER
# define _CRT_SECURE_NO_WARNINGS
#endif
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(const int dof, const 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;
}
}
}
11 changes: 11 additions & 0 deletions autoscoper/src/ui/TimelineDockWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#define TIMELINEDOCKWIDGET_H

#include <QDockWidget>
#include "AutoscoperMainWindow.h"
#include "KeyCurve.hpp"

struct GraphData
Expand Down Expand Up @@ -100,6 +101,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 +132,10 @@ class TimelineDockWidget : public QDockWidget
int play_tag;
QTimer* play_timer;

// DOF stepping and selection
int currentDOF = 0;
void updateBolding(const int dof, const bool state);

protected:
public slots:
void play_update();
Expand Down
Loading

0 comments on commit bdcc5f0

Please sign in to comment.