Skip to content

Commit

Permalink
ENH: Support loading and swapping between multiple tracking files
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar committed Aug 7, 2024
1 parent 8fe9748 commit c0a502d
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 66 deletions.
37 changes: 37 additions & 0 deletions autoscoper/src/ui/AutoscoperMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
/// \author Benjamin Knorlein, Andy Loomis

#include "ui/AutoscoperMainWindow.h"
#include "AutoscoperMainWindow.h"
#include "ui_AutoscoperMainWindow.h"
#include <QGridLayout>
#include "ui/FilterDockWidget.h"
Expand Down Expand Up @@ -2078,6 +2079,30 @@ void AutoscoperMainWindow::on_toolButtonTrackCurrent_clicked()
tracking_dialog->retrack();
}*/

void AutoscoperMainWindow::on_toolButtonPreviousCurveSet_clicked()
{
if (tracker)
tracker->trial()->decrementActiveCurve();
redrawGL();
frame_changed();
}

void AutoscoperMainWindow::on_toolButtonAddNewCurveSet_clicked()
{
if (tracker)
tracker->trial()->addBlankCurveSet();
redrawGL();
frame_changed();
}

void AutoscoperMainWindow::on_toolButtonNextCurveSet_clicked()
{
if (tracker)
tracker->trial()->incrementActiveCurve();
redrawGL();
frame_changed();
}

void AutoscoperMainWindow::on_actionExport_NCC_as_csv_triggered(bool checked)
{
QString filename = get_filename(true, "*.ncc");
Expand Down Expand Up @@ -2374,6 +2399,14 @@ void AutoscoperMainWindow::key_t_pressed()
{
ui->toolButtonTrack->click();
}
void AutoscoperMainWindow::key_j_pressed()
{
ui->toolButtonPreviousCurveSet->click();
}
void AutoscoperMainWindow::key_k_pressed()
{
ui->toolButtonNextCurveSet->click();
}
/*void AutoscoperMainWindow::key_p_pressed(){
ui->toolButtonRetrack->click();
} */
Expand Down Expand Up @@ -2412,6 +2445,10 @@ void AutoscoperMainWindow::setupShortcuts()
new QShortcut(QKeySequence(Qt::Key_H), this, SLOT(key_h_pressed()));
// T - Opens the tracking dialog
new QShortcut(QKeySequence(Qt::Key_T), this, SLOT(key_t_pressed()));
// J - Goes to the previous tracking set if there is one
new QShortcut(QKeySequence(Qt::Key_J), this, SLOT(key_j_pressed()));
// K - Goes to the next tracking set if there is one
new QShortcut(QKeySequence(Qt::Key_K), this, SLOT(key_k_pressed()));
// P - Retrack - not enabled
// new QShortcut(QKeySequence(Qt::Key_P), this, SLOT(key_p_pressed()));
// C - Track current frame
Expand Down
6 changes: 6 additions & 0 deletions autoscoper/src/ui/AutoscoperMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,18 @@ public slots:
void on_toolButtonTrackCurrent_clicked();
// void on_toolButtonRetrack_clicked();

void on_toolButtonPreviousCurveSet_clicked();
void on_toolButtonAddNewCurveSet_clicked();
void on_toolButtonNextCurveSet_clicked();

// Shortcuts
void key_w_pressed();
void key_e_pressed();
void key_d_pressed();
void key_h_pressed();
void key_t_pressed();
void key_j_pressed();
void key_k_pressed();
// void key_r_pressed();
// void key_p_pressed();
void key_c_pressed();
Expand Down
49 changes: 46 additions & 3 deletions autoscoper/src/ui/ui-files/AutoscoperMainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<width>1283</width>
<height>632</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -384,6 +384,49 @@ Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonPreviousCurveSet">
<property name="text">
<string>Previous
Tracking
Set (J)</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonAddNewCurveSet">
<property name="text">
<string>Add New
Tracking
Set</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonNextCurveSet">
<property name="text">
<string>Next
Tracking
Set (K)</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand All @@ -410,7 +453,7 @@ Dialog</string>
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>1283</width>
<height>25</height>
</rect>
</property>
Expand Down
1 change: 0 additions & 1 deletion libautoscoper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ set(libautoscoper_SOURCES
src/CoordFrame.cpp
src/DownhillSimplex.cpp
src/PSO.cpp
src/KeyCurve.cpp
src/TiffImage.cpp
src/Tracker.cpp
src/Trial.cpp
Expand Down
40 changes: 0 additions & 40 deletions libautoscoper/src/KeyCurve.cpp

This file was deleted.

40 changes: 32 additions & 8 deletions libautoscoper/src/Trial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ KeyCurve<float>* Trial::getXCurve(int volumeID)
return NULL;

if (volumeID < volumestransform.size() && volumeID >= 0) {
return &volumestransform[volumeID].x_curve;
return volumestransform[volumeID].getXCurve();
} else {
return &volumestransform[current_volume].x_curve;
return volumestransform[current_volume].getXCurve();
}
}

Expand All @@ -441,9 +441,9 @@ KeyCurve<float>* Trial::getYCurve(int volumeID)
return NULL;

if (volumeID < volumestransform.size() && volumeID >= 0) {
return &volumestransform[volumeID].y_curve;
return volumestransform[volumeID].getYCurve();
} else {
return &volumestransform[current_volume].y_curve;
return volumestransform[current_volume].getYCurve();
}
}

Expand All @@ -453,9 +453,9 @@ KeyCurve<float>* Trial::getZCurve(int volumeID)
return NULL;

if (volumeID < volumestransform.size() && volumeID >= 0) {
return &volumestransform[volumeID].z_curve;
return volumestransform[volumeID].getZCurve();
} else {
return &volumestransform[current_volume].z_curve;
return volumestransform[current_volume].getZCurve();
}
}

Expand All @@ -465,9 +465,33 @@ KeyCurve<Quatf>* Trial::getQuatCurve(int volumeID)
return NULL;

if (volumeID < volumestransform.size() && volumeID >= 0) {
return &volumestransform[volumeID].quat_curve;
return volumestransform[volumeID].getQuatCurve();
} else {
return &volumestransform[current_volume].quat_curve;
return volumestransform[current_volume].getQuatCurve();
}
}

void Trial::addBlankCurveSet()
{
// Add a new blank curve set to all volumes, also switches the active curve to the new set
for (std::vector<VolumeTransform>::iterator itr = volumestransform.begin(); itr != volumestransform.end(); ++itr) {
itr->addBlankCurveSet();
}
}

void Trial::incrementActiveCurve()
{
// Switch to the next active curve for all volumes
for (std::vector<VolumeTransform>::iterator itr = volumestransform.begin(); itr != volumestransform.end(); ++itr) {
itr->incrementActiveCurve();
}
}

void Trial::decrementActiveCurve()
{
// Go to the previous curve for all volumes
for (std::vector<VolumeTransform>::iterator itr = volumestransform.begin(); itr != volumestransform.end(); ++itr) {
itr->decrementActiveCurve();
}
}

Expand Down
4 changes: 4 additions & 0 deletions libautoscoper/src/Trial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class Trial
KeyCurve<float>* getZCurve(int volumeID);
KeyCurve<Quatf>* getQuatCurve(int volumeID);

void addBlankCurveSet();
void incrementActiveCurve();
void decrementActiveCurve();

CoordFrame* getVolumeMatrix(int volumeID); // Pivot

private:
Expand Down
48 changes: 41 additions & 7 deletions libautoscoper/src/VolumeTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,47 @@
#include "VolumeTransform.hpp"

namespace xromm {
VolumeTransform::VolumeTransform()

void VolumeTransform::addBlankCurveSet()
{
KeyCurve<float>* x_curve = new KeyCurve<float>(KeyCurve<float>::X_CURVE);
KeyCurve<float>* y_curve = new KeyCurve<float>(KeyCurve<float>::Y_CURVE);
KeyCurve<float>* z_curve = new KeyCurve<float>(KeyCurve<float>::Z_CURVE);
KeyCurve<Quatf>* quat_curve = new KeyCurve<Quatf>(KeyCurve<Quatf>::QUAT_CURVE);

x_curves.push_back(x_curve);
y_curves.push_back(y_curve);
z_curves.push_back(z_curve);
quat_curves.push_back(quat_curve);

numCurves++;
activeCurve = numCurves - 1;
}

void VolumeTransform::incrementActiveCurve()
{
x_curve.type = KeyCurve<float>::X_CURVE;
y_curve.type = KeyCurve<float>::Y_CURVE;
z_curve.type = KeyCurve<float>::Z_CURVE;
quat_curve.type = KeyCurve<Quatf>::QUAT_CURVE;
// Increment the activeCurve, unless it goes above the numCurves, then wrap it back to 0
activeCurve++;
if (activeCurve >= numCurves) {
activeCurve = 0;
}
}

VolumeTransform::~VolumeTransform() {}
} // namespace xromm
void VolumeTransform::decrementActiveCurve()
{
// Decrement the activeCurve unless it's at 0, then wrap it to the highest index
if (activeCurve == 0) {
activeCurve = numCurves - 1;
} else {
activeCurve--;
}
}

VolumeTransform::~VolumeTransform()
{
x_curves.clear();
y_curves.clear();
z_curves.clear();
quat_curves.clear();
}
} // namespace xromm
25 changes: 18 additions & 7 deletions libautoscoper/src/VolumeTransform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
#ifndef XROMM_VOLUME_TRANSFORM_HPP
#define XROMM_VOLUME_TRANSFORM_HPP

#include "CoordFrame.hpp"
#include <vector>

#include "KeyCurve.hpp"
#include "CoordFrame.hpp"
namespace xromm {

// The trial class contains all of the state information for an autoscoper run.
Expand All @@ -57,16 +56,28 @@ class VolumeTransform
{
public:
// Loads a trial file
VolumeTransform();
VolumeTransform() { addBlankCurveSet(); }
~VolumeTransform();

KeyCurve<float> x_curve;
KeyCurve<float> y_curve;
KeyCurve<float> z_curve;
KeyCurve<Quatf> quat_curve;
KeyCurve<float>* getXCurve() { return x_curves[activeCurve]; }
KeyCurve<float>* getYCurve() { return y_curves[activeCurve]; }
KeyCurve<float>* getZCurve() { return z_curves[activeCurve]; }
KeyCurve<Quatf>* getQuatCurve() { return quat_curves[activeCurve]; }

void addBlankCurveSet();
void incrementActiveCurve();
void decrementActiveCurve();

// CoordFrame volumeTrans; //FromWorldToVolume
CoordFrame volumeMatrix; // FromWorldToPivot

private:
unsigned int activeCurve;
unsigned int numCurves = 0;
std::vector<KeyCurve<float>*> x_curves;
std::vector<KeyCurve<float>*> y_curves;
std::vector<KeyCurve<float>*> z_curves;
std::vector<KeyCurve<Quatf>*> quat_curves;
};
} // namespace xromm

Expand Down

0 comments on commit c0a502d

Please sign in to comment.