diff --git a/autoscoper/CMakeLists.txt b/autoscoper/CMakeLists.txt index 42b8ef4d..5f5543d6 100644 --- a/autoscoper/CMakeLists.txt +++ b/autoscoper/CMakeLists.txt @@ -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 @@ -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 @@ -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 diff --git a/autoscoper/src/ui/AutoscoperMainWindow.cpp b/autoscoper/src/ui/AutoscoperMainWindow.cpp index d614f3b6..2371e898 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.cpp +++ b/autoscoper/src/ui/AutoscoperMainWindow.cpp @@ -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" @@ -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); @@ -180,6 +187,7 @@ AutoscoperMainWindow::~AutoscoperMainWindow() delete ui; delete filters_widget; + delete tracking_set_widget; delete volumes_widget; delete worldview; delete tracker; @@ -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(); @@ -2088,8 +2101,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(); } diff --git a/autoscoper/src/ui/AutoscoperMainWindow.h b/autoscoper/src/ui/AutoscoperMainWindow.h index ea095455..00fc3a60 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.h +++ b/autoscoper/src/ui/AutoscoperMainWindow.h @@ -64,6 +64,7 @@ class TimelineDockWidget; class VolumeDockWidget; class AboutAutoscoper; class TrackingOptionsDialog; +class TrackingSetDockWidget; class AdvancedOptionsDialog; class WorldViewWindow; class QOpenGLContext; @@ -167,6 +168,7 @@ class AutoscoperMainWindow : public QMainWindow TimelineDockWidget* timeline_widget; VolumeDockWidget* volumes_widget; TrackingOptionsDialog* tracking_dialog; + TrackingSetDockWidget* tracking_set_widget; AdvancedOptionsDialog* advanced_dialog; AboutAutoscoper* about_autoscoper; diff --git a/autoscoper/src/ui/TrackingSetDockWidget.cpp b/autoscoper/src/ui/TrackingSetDockWidget.cpp new file mode 100644 index 00000000..befe3ea0 --- /dev/null +++ b/autoscoper/src/ui/TrackingSetDockWidget.cpp @@ -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(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(); + } +} diff --git a/autoscoper/src/ui/TrackingSetDockWidget.h b/autoscoper/src/ui/TrackingSetDockWidget.h new file mode 100644 index 00000000..96254d95 --- /dev/null +++ b/autoscoper/src/ui/TrackingSetDockWidget.h @@ -0,0 +1,40 @@ +#ifndef TRACKINGSETDOCKWIDGET_H +#define TRACKINGSETDOCKWIDGET_H + +#include + +// 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 tracking_sets; + +protected: +public slots: + void on_listWidget_currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous); +}; + +#endif // TRACKINGSETDOCKWIDGET_H diff --git a/autoscoper/src/ui/ui-files/TrackingSetDockWidget.ui b/autoscoper/src/ui/ui-files/TrackingSetDockWidget.ui new file mode 100644 index 00000000..c711c314 --- /dev/null +++ b/autoscoper/src/ui/ui-files/TrackingSetDockWidget.ui @@ -0,0 +1,32 @@ + + + TrackingSetDockWidget + + + + 0 + 0 + 250 + 115 + + + + + 91 + 50 + + + + Tracking Sets + + + + + + + + + + + + diff --git a/libautoscoper/src/Trial.cpp b/libautoscoper/src/Trial.cpp index d5ab8503..3ec66b95 100644 --- a/libautoscoper/src/Trial.cpp +++ b/libautoscoper/src/Trial.cpp @@ -471,6 +471,19 @@ KeyCurve* 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::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 diff --git a/libautoscoper/src/Trial.hpp b/libautoscoper/src/Trial.hpp index 17a0b6db..a0d180ff 100644 --- a/libautoscoper/src/Trial.hpp +++ b/libautoscoper/src/Trial.hpp @@ -90,6 +90,8 @@ class Trial KeyCurve* getZCurve(int volumeID); KeyCurve* getQuatCurve(int volumeID); + size_t numberOfCurveSets(); + void setCurrentCurveSet(const int& idx); void addCurveSet(); void setCurrentCurveSetToNext(); void setCurrentCurveSetToPrevious(); diff --git a/libautoscoper/src/VolumeTransform.cpp b/libautoscoper/src/VolumeTransform.cpp index 20e5d93c..2d4c2986 100644 --- a/libautoscoper/src/VolumeTransform.cpp +++ b/libautoscoper/src/VolumeTransform.cpp @@ -1,8 +1,18 @@ #include "VolumeTransform.hpp" - +#include 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* x_curve = new KeyCurve(KeyCurve::X_CURVE); diff --git a/libautoscoper/src/VolumeTransform.hpp b/libautoscoper/src/VolumeTransform.hpp index 4687c125..22dcdd09 100644 --- a/libautoscoper/src/VolumeTransform.hpp +++ b/libautoscoper/src/VolumeTransform.hpp @@ -65,6 +65,7 @@ class VolumeTransform KeyCurve* getQuatCurve() { return quat_curves[currentCurveSet]; } size_t numberOfCurveSets() const { return x_curves.size(); } + void setCurrentCurveSet(const int& idx); void addCurveSet(); void setCurrentCurveSetToNext(); void setCurrentCurveSetToPrevious();