Skip to content

Commit

Permalink
ENH: Add disaply to UI to show number of active tracking sets
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar authored and jcfr committed Aug 19, 2024
1 parent 6cb0a19 commit 81cf758
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 2 deletions.
3 changes: 3 additions & 0 deletions autoscoper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(autoscoper_FORMS_HEADERS
src/ui/TimelineDockWidget.h
src/ui/ImportExportTrackingOptionsDialog.h
src/ui/TrackingOptionsDialog.h
src/ui/TrackingSetDockWidget.h
src/ui/AdvancedOptionsDialog.h
src/ui/FilterTreeWidgetParameter.h
src/ui/GLWidget.h
Expand Down Expand Up @@ -50,6 +51,7 @@ set(autoscoper_FORMS_SOURCES
src/ui/TimelineDockWidget.cpp
src/ui/ImportExportTrackingOptionsDialog.cpp
src/ui/TrackingOptionsDialog.cpp
src/ui/TrackingSetDockWidget.cpp
src/ui/AdvancedOptionsDialog.cpp
src/ui/AboutAutoscoper.cpp
src/ui/FilterTreeWidgetParameter.cpp
Expand All @@ -75,6 +77,7 @@ set(autoscoper_FORMS
src/ui/ui-files/TimelineDockWidget.ui
src/ui/ui-files/ImportExportTrackingOptionsDialog.ui
src/ui/ui-files/TrackingOptionsDialog.ui
src/ui/ui-files/TrackingSetDockWidget.ui
src/ui/ui-files/AdvancedOptionsDialog.ui
src/ui/ui-files/OpenCLPlatformSelectDialog.ui
src/ui/ui-files/CameraBox.ui
Expand Down
17 changes: 16 additions & 1 deletion autoscoper/src/ui/AutoscoperMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@
#include "ui/CameraViewWidget.h"
#include "ui/TimelineDockWidget.h"
#include "ui/TrackingOptionsDialog.h"
#include "ui/TrackingSetDockWidget.h"
#include "ui/AdvancedOptionsDialog.h"

#include "ui/GLTracker.h"
#include "ui/ImportExportTrackingOptionsDialog.h"
#include "ui_ImportExportTrackingOptionsDialog.h"
#include "ui_TrackingOptionsDialog.h"
#include "ui_TrackingSetDockWidget.h"
#include "ui/AboutAutoscoper.h"
#include "ui/OpenCLPlatformSelectDialog.h"
#include "Manip3D.hpp"
Expand Down Expand Up @@ -127,6 +129,11 @@ AutoscoperMainWindow::AutoscoperMainWindow(bool skipGpuDevice, QWidget* parent)
// Create filter widget and put it on the left
filters_widget = new FilterDockWidget(this);
this->addDockWidget(Qt::LeftDockWidgetArea, filters_widget);
this->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);

// Create the tracking set widget
tracking_set_widget = new TrackingSetDockWidget(this);
this->addDockWidget(Qt::LeftDockWidgetArea, tracking_set_widget);

// Create volume idwget and put it on the bottom-left
volumes_widget = new VolumeDockWidget(this);
Expand Down Expand Up @@ -180,6 +187,7 @@ AutoscoperMainWindow::~AutoscoperMainWindow()
delete ui;

delete filters_widget;
delete tracking_set_widget;
delete volumes_widget;
delete worldview;
delete tracker;
Expand Down Expand Up @@ -598,6 +606,11 @@ void AutoscoperMainWindow::setupUI()
}
// Setup the default view

// Add tracking sets - Needs to happen after textures get binded
for (unsigned int i = 0; i < tracker->trial()->numberOfCurveSets(); i++) {
tracking_set_widget->addTrackingSet(tracker->trial()->volumes.size());
}

// Update the number of frames
timeline_widget->setFramesRange(0, tracker->trial()->num_frames - 1);
reset_graph();
Expand Down Expand Up @@ -2100,8 +2113,10 @@ void AutoscoperMainWindow::on_toolButtonPreviousCurveSet_clicked()

void AutoscoperMainWindow::on_toolButtonAddNewCurveSet_clicked()
{
if (tracker)
if (tracker) {
tracker->trial()->addCurveSet();
tracking_set_widget->addTrackingSet(tracker->trial()->volumes.size());
}
redrawGL();
frame_changed();
}
Expand Down
2 changes: 2 additions & 0 deletions autoscoper/src/ui/AutoscoperMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class TimelineDockWidget;
class VolumeDockWidget;
class AboutAutoscoper;
class TrackingOptionsDialog;
class TrackingSetDockWidget;
class AdvancedOptionsDialog;
class WorldViewWindow;
class QOpenGLContext;
Expand Down Expand Up @@ -169,6 +170,7 @@ class AutoscoperMainWindow : public QMainWindow
TimelineDockWidget* timeline_widget;
VolumeDockWidget* volumes_widget;
TrackingOptionsDialog* tracking_dialog;
TrackingSetDockWidget* tracking_set_widget;
AdvancedOptionsDialog* advanced_dialog;
AboutAutoscoper* about_autoscoper;

Expand Down
47 changes: 47 additions & 0 deletions autoscoper/src/ui/TrackingSetDockWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifdef _MSC_VER
# define _CRT_SECURE_NO_WARNINGS
#endif

#include "ui_TrackingSetDockWidget.h"
#include "ui/TrackingSetDockWidget.h"
#include "ui/AutoscoperMainWindow.h"

#include "Tracker.hpp"
#include "Trial.hpp"

TrackingSetDockWidget::TrackingSetDockWidget(QWidget* parent)
: QDockWidget(parent)
, dock(new Ui::TrackingSetDockWidget)
{
dock->setupUi(this);
mainwindow = dynamic_cast<AutoscoperMainWindow*>(parent);
}

TrackingSetDockWidget::~TrackingSetDockWidget()
{
delete dock;
}

void TrackingSetDockWidget::addTrackingSet(const int& num_volumes)
{
this->tracking_sets.push_back("Tracking set " + std::to_string(dock->listWidget->count()));
QListWidgetItem* item = new QListWidgetItem();
int currentSet = this->mainwindow->getTracker()->trial()->numberOfCurveSets() - 1;
item->setText(QString::fromStdString(this->tracking_sets[currentSet]));
dock->listWidget->addItem(item);
dock->listWidget->setCurrentItem(item);
}

void TrackingSetDockWidget::setCurrentSet(const int& idx)
{
dock->listWidget->setCurrentRow(idx);
}

void TrackingSetDockWidget::on_listWidget_currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous)
{
if (current != NULL) {
mainwindow->getTracker()->trial()->setCurrentCurveSet(dock->listWidget->row(current));
mainwindow->redrawGL();
mainwindow->frame_changed();
}
}
40 changes: 40 additions & 0 deletions autoscoper/src/ui/TrackingSetDockWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef TRACKINGSETDOCKWIDGET_H
#define TRACKINGSETDOCKWIDGET_H

#include <QDockWidget>

// forward declarations
namespace Ui {
class TrackingSetDockWidget;
}

class AutoscoperMainWindow;
class QListWidgetItem;

class TrackingSetDockWidget : public QDockWidget
{

Q_OBJECT

public:
explicit TrackingSetDockWidget(QWidget* parent = 0);
~TrackingSetDockWidget();

AutoscoperMainWindow* getMainWindow() { return mainwindow; };

void addTrackingSet(const int& num_volumes);
void setCurrentSet(const int& idx);

private:
Ui::TrackingSetDockWidget* dock;

AutoscoperMainWindow* mainwindow;

std::vector<std::string> tracking_sets;

protected:
public slots:
void on_listWidget_currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous);
};

#endif // TRACKINGSETDOCKWIDGET_H
32 changes: 32 additions & 0 deletions autoscoper/src/ui/ui-files/TrackingSetDockWidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TrackingSetDockWidget</class>
<widget class="QDockWidget" name="TrackingSetDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>115</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>91</width>
<height>50</height>
</size>
</property>
<property name="windowTitle">
<string>Tracking Sets</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
13 changes: 13 additions & 0 deletions libautoscoper/src/Trial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,19 @@ KeyCurve<Quatf>* Trial::getQuatCurve(int volumeID)
}
}

size_t Trial::numberOfCurveSets()
{
return volumestransform.begin()->numberOfCurveSets();
}

void Trial::setCurrentCurveSet(const int& idx)
{
// Set the active curve to idx for all volumes
for (std::vector<VolumeTransform>::iterator itr = volumestransform.begin(); itr != volumestransform.end(); ++itr) {
itr->setCurrentCurveSet(idx);
}
}

void Trial::addCurveSet()
{
// Add a new blank curve set to all volumes, also switches the active curve to the new set
Expand Down
2 changes: 2 additions & 0 deletions libautoscoper/src/Trial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class Trial
KeyCurve<float>* getZCurve(int volumeID);
KeyCurve<Quatf>* getQuatCurve(int volumeID);

size_t numberOfCurveSets();
void setCurrentCurveSet(const int& idx);
void addCurveSet();
void setCurrentCurveSetToNext();
void setCurrentCurveSetToPrevious();
Expand Down
12 changes: 11 additions & 1 deletion libautoscoper/src/VolumeTransform.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@

#include "VolumeTransform.hpp"

#include <istream>
namespace xromm {

void VolumeTransform::setCurrentCurveSet(const int& idx)
{
if (idx < 0 || idx >= numberOfCurveSets()) {
std::cerr << "[WARNING] Failed to set curveSet " << idx << " is either below 0 or above " << numberOfCurveSets()
<< std::endl;
return;
}
currentCurveSet = idx;
}

void VolumeTransform::addCurveSet()
{
KeyCurve<float>* x_curve = new KeyCurve<float>(KeyCurve<float>::X_CURVE);
Expand Down
1 change: 1 addition & 0 deletions libautoscoper/src/VolumeTransform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class VolumeTransform
KeyCurve<Quatf>* getQuatCurve() { return quat_curves[currentCurveSet]; }

size_t numberOfCurveSets() const { return x_curves.size(); }
void setCurrentCurveSet(const int& idx);
void addCurveSet();
void setCurrentCurveSetToNext();
void setCurrentCurveSetToPrevious();
Expand Down

0 comments on commit 81cf758

Please sign in to comment.