From bfaa79b997032769cf6b2b68f275260f618dbf58 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 13:26:21 +0100 Subject: settings framework for rift --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 81 +++-------------------------- 1 file changed, 7 insertions(+), 74 deletions(-) (limited to 'ftnoir_tracker_rift/ftnoir_tracker_rift.cpp') diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index da44ea0c..e10db0bf 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -8,14 +8,6 @@ using namespace OVR; Rift_Tracker::Rift_Tracker() { - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; -#if 0 - bEnableX = true; - bEnableY = true; - bEnableZ = true; -#endif should_quit = false; pManager = NULL; pSensor = NULL; @@ -38,10 +30,6 @@ Rift_Tracker::~Rift_Tracker() void Rift_Tracker::StartTracker(QFrame*) { - loadSettings(); - // - // Startup the Oculus SDK device handling, use the first Rift sensor we find. - // System::Init(Log::ConfigureDefaultLog(LogMask_All)); pManager = DeviceManager::Create(); if (pManager != NULL) @@ -81,80 +69,25 @@ void Rift_Tracker::GetHeadPoseData(double *data) newHeadPose[Pitch] = pitch; newHeadPose[Roll] = roll; newHeadPose[Yaw] = yaw; - if (useYawSpring) + if (s.useYawSpring) { - newHeadPose[Yaw] = old_yaw*persistence + (yaw-old_yaw); - if(newHeadPose[Yaw]>deadzone)newHeadPose[Yaw]-= constant_drift; - if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; + newHeadPose[Yaw] = old_yaw*s.persistence + (yaw-old_yaw); + if(newHeadPose[Yaw]>s.deadzone)newHeadPose[Yaw]-= s.constant_drift; + if(newHeadPose[Yaw]<-s.deadzone)newHeadPose[Yaw]+= s.constant_drift; old_yaw=yaw; } -#if 0 - newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; - newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; - newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - - if (bEnableX) { - data[TX] = newHeadPose[TX]; - } - if (bEnableY) { - data[TY] = newHeadPose[TY]; - } - if (bEnableY) { - data[TZ] = newHeadPose[TZ]; - } -#endif - if (bEnableYaw) { + if (s.bEnableYaw) { data[Yaw] = newHeadPose[Yaw] * 57.295781f; } - if (bEnablePitch) { + if (s.bEnablePitch) { data[Pitch] = newHeadPose[Pitch] * 57.295781f; } - if (bEnableRoll) { + if (s.bEnableRoll) { data[Roll] = newHeadPose[Roll] * 57.295781f; } } } - -// -// Load the current Settings from the currently 'active' INI-file. -// -void Rift_Tracker::loadSettings() { - - qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Rift" ); - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); -#if 0 - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); -#endif - useYawSpring = iniFile.value("yaw-spring", false).toBool(); - constant_drift = iniFile.value("constant-drift", 0.000005).toDouble(); - persistence = iniFile.value("persistence", 0.99999).toDouble(); - deadzone = iniFile.value("deadzone", 0.02).toDouble(); - iniFile.endGroup (); -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTracker - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTracker@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { return new Rift_Tracker; -- cgit v1.2.3 From d1e0537f704ea67483ccbdf7461e636490aba0cf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:41:16 +0100 Subject: meta: get rid of Initialize(), now RAII --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 4 - ftnoir_filter_accela/ftnoir_filter_accela.h | 4 +- .../ftnoir_filter_accela_dialog.cpp | 4 - ftnoir_filter_base/ftnoir_filter_base.h | 3 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 4 - ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 5 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 21 -- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 9 +- ftnoir_filter_kalman/kalman.cpp | 4 +- ftnoir_protocol_base/ftnoir_protocol_base.h | 3 - ftnoir_protocol_fg/ftnoir_protocol_fg.h | 7 - ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 24 -- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 3 - .../ftnoir_protocol_fsuipc_dialog.cpp | 29 -- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 3 - ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 30 -- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 3 - ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 24 -- .../ftnoir_protocol_libevdev.h | 4 - .../ftnoir_protocol_libevdev_dialog.cpp | 15 - ftnoir_protocol_sc/ftnoir_protocol_sc.h | 3 - ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 30 -- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 4 - .../ftnoir_protocol_vjoy_dialog.cpp | 15 - ftnoir_protocol_wine/ftnoir_protocol_wine.h | 3 - ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 309 +++++---------------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 55 ++-- ftnoir_tracker_base/ftnoir_tracker_base.h | 3 +- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 34 --- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 7 - .../ftnoir_tracker_hat_dialog.cpp | 18 -- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 4 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 5 - ftnoir_tracker_ht/ftnoir_tracker_ht.h | 1 - ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 1 - .../ftnoir_tracker_hydra_dialog.cpp | 9 - ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 6 +- .../ftnoir_tracker_joystick_dialog.cpp | 18 -- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 - ftnoir_tracker_rift/ftnoir_tracker_rift.h | 1 - ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 9 - ftnoir_tracker_udp/ftnoir_tracker_udp.h | 3 - ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 23 -- 43 files changed, 118 insertions(+), 648 deletions(-) (limited to 'ftnoir_tracker_rift/ftnoir_tracker_rift.cpp') diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h index 18283837..1d30e7e5 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h @@ -20,10 +20,6 @@ class TrackerDll : public ITrackerDll #endif { - // ITrackerDll interface -#ifndef OPENTRACK_API - void Initialize() {} -#endif void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 2b93f550..1aaa039f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -37,7 +37,7 @@ class FTNoIR_Filter : public IFilter public: FTNoIR_Filter(); void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); - void Initialize() { + void reset() { first_run = true; } void receiveSettings() { @@ -64,7 +64,7 @@ class FilterControls: public QWidget, public IFilterDialog Q_OBJECT public: FilterControls(); - void Initialize(QWidget *); + void reset(QWidget *); void registerFilter(IFilter* filter); void unregisterFilter(); private: diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index cc759bcb..6d1ad384 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -20,10 +20,6 @@ FilterControls::FilterControls() : tie_setting(s.expt, ui.expt); } -void FilterControls::Initialize(QWidget *) { - show(); -} - void FilterControls::registerFilter(IFilter* filter) { accela_filter = (FTNoIR_Filter*) filter; diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 800e5deb..fbb0441d 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -14,7 +14,7 @@ struct IFilter { virtual ~IFilter() = 0; virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; - virtual void Initialize() = 0; + virtual void reset() = 0; }; inline IFilter::~IFilter() { } @@ -22,7 +22,6 @@ inline IFilter::~IFilter() { } struct IFilterDialog { virtual ~IFilterDialog() {} - virtual void Initialize(QWidget *parent) = 0; virtual void registerFilter(IFilter* tracker) = 0; virtual void unregisterFilter() = 0; }; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 5f66be96..77596b71 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -44,10 +44,6 @@ FTNoIR_Filter::FTNoIR_Filter() loadSettings(); // Load the Settings } -FTNoIR_Filter::~FTNoIR_Filter() -{ -} - void FTNoIR_Filter::receiveSettings(double smin, double smax, double sexpt) { QMutexLocker foo(&mutex); diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 86e4b65c..7c98b2cb 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -41,8 +41,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - virtual ~FTNoIR_Filter(); - void Initialize() {} + void reset() {} void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position); @@ -73,9 +72,7 @@ class FilterControls: public QWidget, public IFilterDialog Q_OBJECT public: explicit FilterControls(); - virtual ~FilterControls(); void showEvent (QShowEvent *); - void Initialize(QWidget *parent); void registerFilter(IFilter* flt); void unregisterFilter(); diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index c304eb0a..eb414340 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -59,27 +59,6 @@ FilterControls::FilterControls() : loadSettings(); } -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent) { - // - // - // - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void FilterControls::registerFilter(IFilter* flt) { pFilter = (FTNoIR_Filter*) flt; diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index da6df2b1..9e0d817d 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -28,7 +28,7 @@ public: FTNoIR_Filter(); ~FTNoIR_Filter() virt_override { } - void Initialize() virt_override; + void reset() virt_override; void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) virt_override; cv::KalmanFilter kalman; @@ -68,16 +68,9 @@ public: connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); } - ~FilterControls() {} void showEvent ( QShowEvent * ) virt_override { show(); } - - void Initialize(QWidget *) virt_override { - show(); - raise(); - } - bool settingsDirty; Ui::KalmanUICFilterControls ui; virtual void registerFilter(IFilter*) virt_override {} diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index 629cfcc8..743eb3d4 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -31,12 +31,12 @@ void kalman_save_settings(FilterControls&) { FTNoIR_Filter::FTNoIR_Filter() { kalman_load_settings(*this); - Initialize(); + reset(); } // the following was written by Donovan Baarda // https://sourceforge.net/p/facetracknoir/discussion/1150909/thread/418615e1/?limit=25#af75/084b -void FTNoIR_Filter::Initialize() { +void FTNoIR_Filter::reset() { const double accel_variance = 1e-3; const double noise_variance = 5e2; kalman.init(12, 6, 0, CV_64F); diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index e4ca1977..d2f85ec0 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -50,9 +50,6 @@ inline IProtocol::~IProtocol() { } struct IProtocolDialog { virtual ~IProtocolDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void showEvent ( QShowEvent * event ) = 0; - virtual void registerProtocol(IProtocol *protocol) = 0; virtual void unRegisterProtocol() = 0; }; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 9a4f304c..0a255d84 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -35,11 +35,8 @@ #include #include #include -#include #include "facetracknoir/global-settings.h" -#define FT_PROGRAMID "FT_ProgramID" - class FTNoIR_Protocol : public IProtocol { public: @@ -65,10 +62,6 @@ class FGControls: public QWidget, public IProtocolDialog public: explicit FGControls(); - virtual ~FGControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); void registerProtocol(IProtocol *protocol) { theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index 45123540..cb11ace6 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -63,25 +63,6 @@ QWidget() loadSettings(); } -// -// Destructor for server-dialog -// -FGControls::~FGControls() { - qDebug() << "~FGControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FGControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - // // OK clicked on server-dialog // @@ -90,11 +71,6 @@ void FGControls::doOK() { this->close(); } -// override show event -void FGControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - // // Cancel clicked on server-dialog // diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 87c6a3a4..9f5e3b6f 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -83,9 +83,6 @@ class FSUIPCControls: public QWidget, public IProtocolDialog public: explicit FSUIPCControls(); - virtual ~FSUIPCControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); void registerProtocol(IProtocol *protocol) { theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol } diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 985915b4..b2f28ba1 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -48,41 +48,12 @@ QWidget() loadSettings(); } -// -// Destructor for server-dialog -// -FSUIPCControls::~FSUIPCControls() { - qDebug() << "~FSUIPCControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FSUIPCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// void FSUIPCControls::doOK() { save(); this->close(); } -// override show event -void FSUIPCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} -// -// Cancel clicked on server-dialog -// void FSUIPCControls::doCancel() { // // Ask if changed Settings should be saved diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index e13d260f..56316ec4 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -93,9 +93,6 @@ class FTControls: public QWidget, public IProtocolDialog public: explicit FTControls(); - virtual ~FTControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); void registerProtocol(IProtocol *protocol) { theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index df13a6dc..0b29db6e 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -75,41 +75,11 @@ QWidget() } -// -// Destructor for server-dialog -// -FTControls::~FTControls() { - qDebug() << "~FTControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FTControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// void FTControls::doOK() { save(); this->close(); } -// override show event -void FTControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void FTControls::doCancel() { // // Ask if changed Settings should be saved diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 9aee73ac..acccc9e7 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -64,9 +64,6 @@ class FTNControls: public QWidget, public IProtocolDialog public: explicit FTNControls(); - virtual ~FTNControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *parent); void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index 3b4e851c..72c30051 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -56,25 +56,6 @@ QWidget() loadSettings(); } -// -// Destructor for server-dialog -// -FTNControls::~FTNControls() { - qDebug() << "~FTNControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FTNControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - // // OK clicked on server-dialog // @@ -83,11 +64,6 @@ void FTNControls::doOK() { this->close(); } -// override show event -void FTNControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - // // Cancel clicked on server-dialog // diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index aabd3e51..5df59919 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -41,10 +41,6 @@ class LibevdevControls: public QWidget, public IProtocolDialog public: explicit LibevdevControls(); - virtual ~LibevdevControls(); - void showEvent ( QShowEvent *) {} - - void Initialize(QWidget *); void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp index 6665a3d2..bb54c354 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp @@ -8,21 +8,6 @@ LibevdevControls::LibevdevControls() : QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); } -LibevdevControls::~LibevdevControls() { -} - -// -// Initialize tracker-client-dialog -// -void LibevdevControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void LibevdevControls::doOK() { save(); this->close(); diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index e17cabb5..7917c532 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -131,9 +131,6 @@ class SCControls: public QWidget, public IProtocolDialog public: explicit SCControls(); - virtual ~SCControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); void registerProtocol(IProtocol *protocol) { theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index fb822145..eb15ca69 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -49,41 +49,11 @@ QWidget() loadSettings(); } -// -// Destructor for server-dialog -// -SCControls::~SCControls() { - qDebug() << "~SCControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void SCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// void SCControls::doOK() { save(); this->close(); } -// override show event -void SCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void SCControls::doCancel() { // // Ask if changed Settings should be saved diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index c4db29e4..873b4e3c 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -60,10 +60,6 @@ class VJoyControls: public QWidget, public IProtocolDialog public: explicit VJoyControls(); - virtual ~VJoyControls(); - void showEvent ( QShowEvent *) {} - - void Initialize(QWidget *); void registerProtocol(IProtocol *l) {} void unRegisterProtocol() {} diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp index 0009553b..febb7b18 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp @@ -8,21 +8,6 @@ VJoyControls::VJoyControls() : QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); } -VJoyControls::~VJoyControls() { -} - -// -// Initialize tracker-client-dialog -// -void VJoyControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void VJoyControls::doOK() { save(); this->close(); diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index d7276b8e..e84dbd69 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -70,10 +70,7 @@ class FTControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - FTControls(); - void showEvent ( QShowEvent * ) {show();} - void Initialize(QWidget *) {show();} void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 9408de02..a0a11ed2 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -99,47 +99,8 @@ static resolution_tuple resolution_choices[] = { { 0, 0 } }; -void Tracker::load_settings() +Tracker::Tracker() : stop(false), layout(nullptr), videoWidget(nullptr) { - QMutexLocker foo(&mtx); - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "aruco-Tracker" ); - fov = iniFile.value("fov", 56).toFloat(); - force_fps = iniFile.value("fps", 0).toInt(); - camera_index = iniFile.value("camera-index", -1).toInt(); - int res = iniFile.value("resolution", 0).toInt(); - if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) - res = 0; - resolution_tuple r = resolution_choices[res]; - force_width = r.width; - force_height = r.height; - enableRX = iniFile.value("enable-rx", true).toBool(); - enableRY = iniFile.value("enable-ry", true).toBool(); - enableRZ = iniFile.value("enable-rz", true).toBool(); - enableTX = iniFile.value("enable-tx", true).toBool(); - enableTY = iniFile.value("enable-ty", true).toBool(); - enableTZ = iniFile.value("enable-tz", true).toBool(); - - for (int i = 0; i < 3; i++) - { - headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); - } - headpitch = iniFile.value("pitch", 0).toDouble(); - red_only = iniFile.value("red-only", true).toBool(); - - iniFile.endGroup(); -} - -Tracker::Tracker() -{ - layout = nullptr; - stop = false; - videoWidget = NULL; - enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; - load_settings(); } Tracker::~Tracker() @@ -166,7 +127,6 @@ void Tracker::StartTracker(QFrame* videoframe) delete videoframe->layout(); videoframe->setLayout(layout); videoWidget->show(); - load_settings(); start(); for (int i = 0; i < 6; i++) pose[i] = 0; @@ -177,13 +137,35 @@ void Tracker::StartTracker(QFrame* videoframe) void Tracker::run() { - camera = cv::VideoCapture(camera_index); - if (force_width) - camera.set(CV_CAP_PROP_FRAME_WIDTH, force_width); - if (force_height) - camera.set(CV_CAP_PROP_FRAME_HEIGHT, force_height); - if (force_fps) - camera.set(CV_CAP_PROP_FPS, force_fps); + int res = s.resolution; + if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) + res = 0; + resolution_tuple r = resolution_choices[res]; + int fps; + switch (static_cast(s.force_fps)) + { + default: + case 0: + fps = 0; + break; + case 30: + fps = 1; + break; + case 60: + fps = 2; + break; + case 120: + fps = 3; + break; + } + camera = cv::VideoCapture(s.camera_index); + if (r.width) + { + camera.set(CV_CAP_PROP_FRAME_WIDTH, r.width); + camera.set(CV_CAP_PROP_FRAME_HEIGHT, r.height); + } + if (fps) + camera.set(CV_CAP_PROP_FPS, fps); aruco::MarkerDetector detector; detector.setDesiredSpeed(3); @@ -206,7 +188,7 @@ void Tracker::run() auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); - int fps = 0; + int cur_fps = 0; int last_fps = 0; cv::Point2f last_centroid; @@ -216,7 +198,7 @@ void Tracker::run() continue; auto tm = cv::getTickCount(); color_.copyTo(color); - if (red_only) + if (s.red_only) { cv::Mat channel[3]; cv::split(color, channel); @@ -227,8 +209,8 @@ void Tracker::run() const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); - const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); - const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); + const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180); + const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; @@ -275,12 +257,12 @@ void Tracker::run() if ((long) (time / freq) != (long) (last_time / freq)) { - last_fps = fps; - fps = 0; + last_fps = cur_fps; + cur_fps = 0; last_time = time; } - fps++; + cur_fps++; char buf[128]; @@ -296,18 +278,18 @@ void Tracker::run() const float size = 7; cv::Mat obj_points(4,3,CV_32FC1); - obj_points.at(1,0)=-size + headpos[0]; - obj_points.at(1,1)=-size + headpos[1]; - obj_points.at(1,2)=0 + headpos[2]; - obj_points.at(2,0)=size + headpos[0]; - obj_points.at(2,1)=-size + headpos[1]; - obj_points.at(2,2)=0 + headpos[2]; - obj_points.at(3,0)=size + headpos[0]; - obj_points.at(3,1)=size + headpos[1]; - obj_points.at(3,2)=0 + headpos[2]; - obj_points.at(0,0)=-size + headpos[0]; - obj_points.at(0,1)=size + headpos[1]; - obj_points.at(0,2)=0 + headpos[2]; + obj_points.at(1,0)=-size + s.headpos_x; + obj_points.at(1,1)=-size + s.headpos_y; + obj_points.at(1,2)=0 + s.headpos_z; + obj_points.at(2,0)=size + s.headpos_x; + obj_points.at(2,1)=-size + s.headpos_y; + obj_points.at(2,2)=0 + s.headpos_z; + obj_points.at(3,0)=size + s.headpos_x; + obj_points.at(3,1)=size + s.headpos_y; + obj_points.at(3,2)=0 + s.headpos_z; + obj_points.at(0,0)=-size + s.headpos_x; + obj_points.at(0,1)=size + s.headpos_y; + obj_points.at(0,2)=0 + s.headpos_z; last_roi = cv::Rect(65535, 65535, 0, 0); @@ -341,22 +323,12 @@ void Tracker::run() cv::Rodrigues(rvec, rotation_matrix); { - const double beta = headpitch * HT_PI / 180; - double pitch[] = { - 1, 0, 0, - 0, cos(beta), -sin(beta), - 0, sin(beta), cos(beta) - }; - cv::Mat rot(3, 3, CV_64F, pitch); - cv::Mat tvec2 = rot * tvec; - rotation_matrix = rot * rotation_matrix; - cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) - pose[i] = tvec2.at(i); + pose[i] = tvec.at(i); pose[Yaw] = euler[1]; pose[Pitch] = -euler[0]; @@ -389,17 +361,17 @@ void Tracker::GetHeadPoseData(double *data) { QMutexLocker lck(&mtx); - if (enableRX) + if (s.eyaw) data[Yaw] = pose[Yaw]; - if (enableRY) + if (s.epitch) data[Pitch] = pose[Pitch]; - if (enableRZ) + if (s.eroll) data[Roll] = pose[Roll]; - if (enableTX) + if (s.ex) data[TX] = pose[TX]; - if (enableTY) + if (s.ey) data[TY] = pose[TY]; - if (enableTZ) + if (s.ez) data[TZ] = pose[TZ]; } @@ -468,178 +440,49 @@ TrackerControls::TrackerControls() tracker = nullptr; ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); - connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cx, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.cy, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.cz, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - //connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - //connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); - //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); + tie_setting(s.camera_index, ui.cameraName); + tie_setting(s.force_fps, ui.cameraFPS); + tie_setting(s.fov, ui.cameraFOV); + tie_setting(s.eyaw, ui.rx); + tie_setting(s.epitch, ui.ry); + tie_setting(s.eroll, ui.rz); + tie_setting(s.ex, ui.tx); + tie_setting(s.ey, ui.ty); + tie_setting(s.ez, ui.tz); + tie_setting(s.headpos_x, ui.cx); + tie_setting(s.headpos_y, ui.cy); + tie_setting(s.headpos_z, ui.cz); + tie_setting(s.red_only, ui.red_only); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - loadSettings(); - settingsDirty = false; -} - -TrackerControls::~TrackerControls() -{ -} - -void TrackerControls::showEvent(QShowEvent *) -{ -} - -void TrackerControls::Initialize(QWidget*) -{ - loadSettings(); - show(); -} - -void TrackerControls::loadSettings() -{ - ui.cameraName->clear(); - QList names = get_camera_names(); - names.prepend("Any available"); - ui.cameraName->addItems(names); - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - iniFile.beginGroup( "aruco-Tracker" ); - ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1); - ui.cameraFOV->setValue(iniFile.value("fov", 56).toFloat()); - int fps; - switch (iniFile.value("fps", 0).toInt()) - { - default: - case 0: - fps = 0; - break; - case 30: - fps = 1; - break; - case 60: - fps = 2; - break; - case 120: - fps = 3; - break; - } - ui.cameraFPS->setCurrentIndex(fps); - ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - - QDoubleSpinBox* headpos[] = { - ui.cx, - ui.cy, - ui.cz - }; - - for (int i = 0; i < 3; i++) - { - headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble()); - } - - ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); - ui.red_only->setChecked(iniFile.value("red-only", true).toBool()); - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::save() -{ - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "aruco-Tracker" ); - iniFile.setValue("fov", ui.cameraFOV->value()); - int fps; - switch (ui.cameraFPS->currentIndex()) - { - case 0: - default: - fps = 0; - break; - case 1: - fps = 30; - break; - case 2: - fps = 60; - break; - case 3: - fps = 120; - break; - } - iniFile.setValue("fps", fps); - iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); - iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("resolution", ui.resolution->currentIndex()); - iniFile.setValue("pitch", ui.pitch_deg->value()); - - QDoubleSpinBox* headpos[] = { - ui.cx, - ui.cy, - ui.cz - }; - - for (int i = 0; i < 3; i++) - { - iniFile.setValue(QString("headpos-%1").arg(i), headpos[i]->value()); - } - iniFile.setValue("red-only", ui.red_only->isChecked()); - iniFile.endGroup(); - settingsDirty = false; - if (tracker) - tracker->load_settings(); + ui.cameraName->addItems(get_camera_names()); } void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } void TrackerControls::doCancel() { - if (settingsDirty) { + if (s.b->modifiedp()) { int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, - QMessageBox::Discard ); + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); switch (ret) { case QMessageBox::Save: - save(); + s.b->save(); this->close(); break; case QMessageBox::Discard: + s.b->revert(); this->close(); break; case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; + break; } } else { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 545ad5d0..23598f4d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -18,6 +18,33 @@ #include #include #include +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value fov, headpos_x, headpos_y, headpos_z; + value camera_index, force_fps, resolution; + value red_only; + value eyaw, epitch, eroll, ex, ey, ez; + settings() : + b(bundle("aruco-tracker")), + fov(b, "field-of-view", 56), + headpos_x(b, "headpos-x", 0), + headpos_y(b, "headpos-y", 0), + headpos_z(b, "headpos-z", 0), + camera_index(b, "camera-index", 0), + force_fps(b, "force-fps", 0), + resolution(b, "force-resolution", 0), + red_only(b, "red-only", false), + eyaw(b, "enable-y", true), + epitch(b, "enable-p", true), + eroll(b, "enable-r", true), + ex(b, "enable-x", true), + ey(b, "enable-y", true), + ez(b, "enable-z", true) + {} +}; class Tracker : protected QThread, public ITracker { @@ -27,22 +54,16 @@ public: virtual ~Tracker(); void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); - bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; void run(); - void load_settings(); private: QMutex mtx; - ArucoVideoWidget* videoWidget; - QHBoxLayout* layout; volatile bool stop; - float fov; - int camera_index; - int force_fps, force_width, force_height; + QHBoxLayout* layout; + ArucoVideoWidget* videoWidget; + settings s; double pose[6]; cv::Mat frame; - double headpos[3], headpitch; cv::VideoCapture camera; - volatile bool red_only; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -50,32 +71,20 @@ class TrackerControls : public QWidget, public ITrackerDialog { Q_OBJECT public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent (QShowEvent *); - - void Initialize(QWidget *); + TrackerControls(); void registerTracker(ITracker * x) { tracker = dynamic_cast(x); } void unRegisterTracker() { tracker = nullptr; } - private: Ui::Form ui; - void loadSettings(); - void save(); - bool settingsDirty; Tracker* tracker; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } - void settingChanged(double) { settingsDirty = true; } }; #endif diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 16f76cf3..b8e16e9d 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -58,8 +58,7 @@ inline ITracker::~ITracker() { } struct ITrackerDialog { virtual ~ITrackerDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void registerTracker(ITracker *tracker) = 0; + virtual void registerTracker(ITracker *tracker) = 0; virtual void unRegisterTracker() = 0; }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index 3547dd6b..6fef2db0 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -403,7 +403,6 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) CptError=0; return; } -#ifdef OPENTRACK_API data[frame_cnt] = (long) HAT.Code; struct Fun { @@ -446,39 +445,6 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) if (settings.InvertZ) data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]* -1.0f; else data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]; } -#else - data->frame_number = (long) HAT.Code; - - if (bEnableYaw) { - if (bInvertYaw ) data->yaw = (double) HAT.Rot[iYawAxe] * -1.0f; - else data->yaw = (double) HAT.Rot[iYawAxe]; - } - - if (bEnablePitch) { - if (bInvertPitch)data->pitch = (double) HAT.Rot[iPitchAxe] * -1.0f; - else data->pitch = (double) HAT.Rot[iPitchAxe]; - } - - if (bEnableRoll) { - if (bInvertRoll) data->roll = (double) HAT.Rot[iRollAxe] * -1.0f; - else data->roll = (double) HAT.Rot[iRollAxe]; - } - - if (bEnableX) { - if (bInvertX) data->x = (double) HAT.Trans[iXAxe]* -1.0f; - else data->x = (double) HAT.Trans[iXAxe]; - } - - if (bEnableY) { - if (bInvertY) data->y = (double) HAT.Trans[iYAxe]* -1.0f; - else data->y = (double) HAT.Trans[iYAxe]; - } - - if (bEnableZ) { - if (bInvertZ) data->z = (double) HAT.Trans[iZAxe]* -1.0f; - else data->z = (double) HAT.Trans[iZAxe]; - } -#endif } void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index a4243c38..57ead58d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -27,15 +27,8 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); -#ifdef OPENTRACK_API virtual void StartTracker(QFrame*); virtual void GetHeadPoseData(double* data); -#else - void Initialize( QFrame *videoframe ); - virtual void StartTracker(HWND parent_window); - virtual void StopTracker(bool exit); - virtual bool GetHeadPoseData(THeadPoseData *data); -#endif void applysettings(const TrackerSettings& settings); void notifyCenter(); bool notifyZeroed(); diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp index 0ef723c9..2ef75b89 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -146,24 +146,6 @@ TrackerControls::TrackerControls() : theTracker(NULL), timer(this) connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); } -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - - // // Center asked to ARDUINO // diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h index 82c69e0d..fe16e5e8 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -21,8 +21,6 @@ class TrackerControls: public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - virtual ~TrackerControls(); - void Initialize(QWidget *parent) virt_override; void registerTracker(ITracker *tracker) virt_override; void unRegisterTracker() virt_override; private: @@ -30,7 +28,7 @@ private: FTNoIR_Tracker *theTracker; QTime last_time; -public slots: +public slots: void WriteMsgInfo(const QByteArray &MsgInfo); protected slots: diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index e154557e..1773b018 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -275,11 +275,6 @@ TrackerControls::TrackerControls() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); } -void TrackerControls::Initialize(QWidget*) -{ - show(); -} - void TrackerControls::doOK() { s.b->save(); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index f45e54f9..b3c89136 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -62,7 +62,6 @@ class TrackerControls : public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - void Initialize(QWidget *); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 16629c3a..8d91dfbb 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -45,7 +45,6 @@ class TrackerControls: public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} private: diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index e92180a3..4a2deb9f 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -18,15 +18,6 @@ QWidget() tie_setting(s.bEnableZ, ui.chkEnableZ); } -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerControls::doOK() { s.b->save(); this->close(); diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 9c856d85..67291e6f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -62,11 +62,7 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - ~TrackerControls(); - void showEvent (QShowEvent *); - - void Initialize(QWidget *parent); + TrackerControls(); void registerTracker(ITracker *foo) { tracker = dynamic_cast(foo); } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index af3613d9..42ca8689 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -50,29 +50,11 @@ fin: loadSettings(); } -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { -} - -void TrackerControls::Initialize(QWidget *parent) { - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerControls::doOK() { save(); this->close(); } -void TrackerControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - void TrackerControls::doCancel() { if (settingsDirty) { int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index e10db0bf..b548db71 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -26,8 +26,6 @@ Rift_Tracker::~Rift_Tracker() System::Destroy(); } - - void Rift_Tracker::StartTracker(QFrame*) { System::Init(Log::ConfigureDefaultLog(LogMask_All)); diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 80bf6ffa..b1f96bf2 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -55,7 +55,6 @@ class TrackerControls: public QWidget, public ITrackerDialog public: explicit TrackerControls(); - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 5487da92..763ddd11 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -20,15 +20,6 @@ QWidget() tie_setting(s.useYawSpring, ui.yawSpring); } -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerControls::doOK() { s.b->save(); this->close(); diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index c7e9decf..7157f064 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -49,9 +49,6 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent (QShowEvent *); - - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index e17d5c32..707abf37 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -60,34 +60,11 @@ TrackerControls::~TrackerControls() { qDebug() << "~TrackerControls() says: started"; } -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// void TrackerControls::doOK() { save(); this->close(); } -// override show event -void TrackerControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void TrackerControls::doCancel() { // // Ask if changed Settings should be saved -- cgit v1.2.3