From a7195519a25b715a5786383450a25f0420f7aeb5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:19:24 +0100 Subject: initial ng options impl, untested --- facetracknoir/options.hpp | 200 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 facetracknoir/options.hpp diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp new file mode 100644 index 00000000..7db75941 --- /dev/null +++ b/facetracknoir/options.hpp @@ -0,0 +1,200 @@ +/* Copyright (c) 2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace options { + template + inline T qcruft_to_t(const QVariant& t); + + template<> + inline int qcruft_to_t(const QVariant& t) + { + return t.toInt(); + } + + template<> + inline bool qcruft_to_t(const QVariant& t) + { + return t.toBool(); + } + + template<> + inline double qcruft_to_t(const QVariant& t) + { + return t.toDouble(); + } + + template<> + inline float qcruft_to_t(const QVariant& t) + { + return t.toFloat(); + } + + // snapshot of qsettings group at given time + class group { + private: + QMap map; + QString name; + public: + group(const QString& name, QSettings& s) : name(name) + { + s.beginGroup(name); + for (auto& k : s.childKeys()) + map[k] = s.value(k); + s.endGroup(); + } + static constexpr const char* org = "opentrack"; + void save() { + QSettings s(org); + s.beginGroup(name); + for (auto& k : map.keys()) + s.setValue(k, map[k]); + s.endGroup(); + } + template + T get(const QString& k) { + return qcruft_to_t(map.value(k)); + } + + void put(const QString& s, const QVariant& d) + { + map[s] = d; + } + }; + + class bundle { + private: + const QString group_name; + group saved; + group transient; + bundle(const bundle&) = delete; + bundle& operator=(const bundle&) = delete; + bool modified; + public: + bundle(const QString& group_name, QSettings& s) : + group_name(group_name), + saved(group_name, s), + transient(saved), + modified(false) + { + } + std::shared_ptr make(const QString& name, QSettings& s) { + assert(s.format() == QSettings::IniFormat); + return std::make_shared(name, s); + } + void store(QString& name, QVariant& datum) + { + modified = true; + transient.put(name, datum); + } + template + T get(QString& name) { + transient.get(name); + } + void save() + { + modified = false; + saved = transient; + transient.save(); + } + void revert() + { + modified = false; + transient = saved; + } + }; + + typedef std::shared_ptr pbundle; + + class QCruft : public QObject { + }; + + template + class value : public QCruft { + private: + const QString self_name; + pbundle b; + public: + value(const pbundle& b, const QString& name) : + self_name(name), + b(b) + { + } + operator T() { return b->get(self_name); } + T& operator=(const T& datum) { + b->store(self_name, datum); + emit valueChanged(datum); + return datum; + } + public slots: + void setValue(const T datum) { + this->operator =(datum); + } + signals: + void valueChanged(T datum); + }; + + template + inline void tie(value&, Q*); + + template<> + inline void tie(value& v, QComboBox* cb) + { + QObject::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); + QObject::connect(&v, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + } + + template<> + inline void tie(value& v, QComboBox* cb) + { + QObject::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString))); + QObject::connect(&v, SIGNAL(valueChanged(QString)), &v, SLOT(setValue(QString))); + } + + template<> + inline void tie(value& v, QCheckBox* cb) + { + QObject::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); + QObject::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + } + + template<> + inline void tie(value& v, QDoubleSpinBox* dsb) + { + QObject::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); + QObject::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + } + + template<> + inline void tie(value& v, QSpinBox* sb) + { + QObject::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + QObject::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + } + + template<> + inline void tie(value& v, QSlider* sl) + { + QObject::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + QObject::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + } +} -- cgit v1.2.3 From c2a5e0fcc98fd725c6f978c4fa2e6ba0d2897218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:19:34 +0100 Subject: connect *.hpp to the build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e9ade02..8b36cb27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,7 +180,7 @@ file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.c file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") -file(GLOB opentrack-bin-h "facetracknoir/*.h") +file(GLOB opentrack-bin-h "facetracknoir/*.h" "facetracknoir/*.hpp") file(GLOB opentrack-bin-ui "facetracknoir/*.ui") file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) -- cgit v1.2.3 From 40d5a72739ff9f650e05c3193a60a6bbcd2ea69c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:27:38 +0100 Subject: const correctness --- facetracknoir/options.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 7db75941..ef3437ad 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -101,7 +101,7 @@ namespace options { assert(s.format() == QSettings::IniFormat); return std::make_shared(name, s); } - void store(QString& name, QVariant& datum) + void store(const QString& name, QVariant& datum) { modified = true; transient.put(name, datum); -- cgit v1.2.3 From 598a7ebfb4672ab96a5f0b8693cfab3d954ea6a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:27:50 +0100 Subject: impl default value --- facetracknoir/options.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index ef3437ad..49367831 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -79,6 +79,10 @@ namespace options { { map[s] = d; } + bool contains(const QString& s) + { + return map.contains(s); + } }; class bundle { @@ -106,6 +110,10 @@ namespace options { modified = true; transient.put(name, datum); } + bool contains(const QString& name) + { + return transient.contains(name); + } template T get(QString& name) { transient.get(name); @@ -131,13 +139,18 @@ namespace options { template class value : public QCruft { private: - const QString self_name; + QString self_name; pbundle b; public: - value(const pbundle& b, const QString& name) : + value(const pbundle& b, const QString& name, T def) : self_name(name), b(b) { + if (!b->contains(name)) + { + QVariant cruft(def); + b->store(self_name, cruft); + } } operator T() { return b->get(self_name); } T& operator=(const T& datum) { -- cgit v1.2.3 From 6e16b672ac49db35d1d0365991de01831d29a0dc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 09:55:19 +0100 Subject: M-x valium-mode on Fix Qt's moronicity the hard way --- facetracknoir/options.hpp | 138 ++++++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 55 deletions(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 49367831..16946e88 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -43,28 +43,31 @@ namespace options { return t.toDouble(); } - template<> - inline float qcruft_to_t(const QVariant& t) - { - return t.toFloat(); - } - // snapshot of qsettings group at given time class group { private: QMap map; QString name; public: - group(const QString& name, QSettings& s) : name(name) + group(const QString& name) : name(name) { - s.beginGroup(name); - for (auto& k : s.childKeys()) - map[k] = s.value(k); - s.endGroup(); + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile(currentFile, QSettings::IniFormat); + iniFile.beginGroup(name); + for (auto& k : iniFile.childKeys()) + map[k] = iniFile.value(k); + iniFile.endGroup(); } static constexpr const char* org = "opentrack"; void save() { - QSettings s(org); + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings s(currentFile, QSettings::IniFormat); s.beginGroup(name); for (auto& k : map.keys()) s.setValue(k, map[k]); @@ -85,27 +88,32 @@ namespace options { } }; - class bundle { + class impl_bundle { private: const QString group_name; group saved; group transient; - bundle(const bundle&) = delete; - bundle& operator=(const bundle&) = delete; + impl_bundle(const impl_bundle&) = delete; + impl_bundle& operator=(const impl_bundle&) = delete; bool modified; public: - bundle(const QString& group_name, QSettings& s) : + impl_bundle(const QString& group_name) : group_name(group_name), - saved(group_name, s), + saved(group_name), transient(saved), modified(false) { } - std::shared_ptr make(const QString& name, QSettings& s) { - assert(s.format() == QSettings::IniFormat); - return std::make_shared(name, s); + /* keep in mind doesn't fire signals */ + void reload() { + saved = group(group_name); + transient = saved; } - void store(const QString& name, QVariant& datum) + + std::shared_ptr make(const QString& name) { + return std::make_shared(name); + } + void store(const QString& name, const QVariant& datum) { modified = true; transient.put(name, datum); @@ -116,7 +124,7 @@ namespace options { } template T get(QString& name) { - transient.get(name); + return transient.get(name); } void save() { @@ -129,15 +137,32 @@ namespace options { modified = false; transient = saved; } + + bool modifiedp() const { return modified; } }; - typedef std::shared_ptr pbundle; + typedef std::shared_ptr pbundle; - class QCruft : public QObject { + class base_value : public QObject { + Q_OBJECT + public: + virtual QVariant operator=(const QVariant& datum) = 0; + public slots: +#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } + DEFINE_SLOT(double) + DEFINE_SLOT(int) + DEFINE_SLOT(QString) + DEFINE_SLOT(bool) + signals: +#define DEFINE_SIGNAL(t) void valueChanged(t); + DEFINE_SIGNAL(double) + DEFINE_SIGNAL(int) + DEFINE_SIGNAL(QString) + DEFINE_SIGNAL(bool) }; template - class value : public QCruft { + class value : public base_value { private: QString self_name; pbundle b; @@ -153,61 +178,64 @@ namespace options { } } operator T() { return b->get(self_name); } - T& operator=(const T& datum) { + QVariant operator=(const QVariant& datum) { b->store(self_name, datum); - emit valueChanged(datum); - return datum; - } - public slots: - void setValue(const T datum) { - this->operator =(datum); + switch (datum.type()) + { +#define BRANCH_ON(e, m) case QVariant::e: return valueChanged(datum.m()), datum + BRANCH_ON(Int, toInt); + BRANCH_ON(Double, toDouble); + BRANCH_ON(String, toString); + BRANCH_ON(Bool, toBool); + default: abort(); + } } - signals: - void valueChanged(T datum); }; template - inline void tie(value&, Q*); + inline void tie_setting(value&, Q*); template<> - inline void tie(value& v, QComboBox* cb) + inline void tie_setting(value& v, QComboBox* cb) { - QObject::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); - QObject::connect(&v, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int))); + cb->setCurrentIndex(v); } template<> - inline void tie(value& v, QComboBox* cb) + inline void tie_setting(value& v, QCheckBox* cb) { - QObject::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString))); - QObject::connect(&v, SIGNAL(valueChanged(QString)), &v, SLOT(setValue(QString))); + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + cb->setChecked(v); } template<> - inline void tie(value& v, QCheckBox* cb) + inline void tie_setting(value& v, QDoubleSpinBox* dsb) { - QObject::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); - QObject::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + dsb->setValue(v); } template<> - inline void tie(value& v, QDoubleSpinBox* dsb) + inline void tie_setting(value& v, QSpinBox* sb) { - QObject::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); - QObject::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + sb->setValue(v); } template<> - inline void tie(value& v, QSpinBox* sb) + inline void tie_setting(value& v, QSlider* sl) { - QObject::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - QObject::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + sl->setValue(v); } - template<> - inline void tie(value& v, QSlider* sl) - { - QObject::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - QObject::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + inline pbundle bundle(const QString& group) { + return std::make_shared(group); } } -- cgit v1.2.3 From 90d5ffb413bdaa05bc84ff8403ac0399d9ea117a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 09:55:53 +0100 Subject: use option classes, and remove cruft while we're at it --- .../ftnoir_accela_filtercontrols.ui | 770 ++++++--------------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 61 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 82 +-- .../ftnoir_filter_accela_dialog.cpp | 243 ++----- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 32 - 5 files changed, 305 insertions(+), 883 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index fb6a9565..4ea78c9f 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 347 - 339 + 202 + 241 @@ -21,8 +21,8 @@ - 347 - 268 + 0 + 0 @@ -47,555 +47,246 @@ - - - 6 - - - 4 - + - - - true + + + + 0 + 0 + + + + Rotation + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + QAbstractSpinBox::CorrectToPreviousValue + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + + 0 + 0 + + + + Translation + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + Order #2 + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + QAbstractSpinBox::CorrectToPreviousValue + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + Order #3 + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + QAbstractSpinBox::CorrectToPreviousValue + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + 1.000000000000000 + + + + + - + 0 0 - 0 + 25 0 - - Basic settings + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Deadband + + + + + + + + 0 + 0 + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QFormLayout::ExpandingFieldsGrow - - - - - - 0 - 0 - - - - Rotation - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Translation - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Order #2 - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Order #3 - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; -background:none; - - - Deadband - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 3 - - - 0.000000000000000 - - - 3.000000000000000 - - - 0.050000000000000 - - - 0.000000000000000 - - - - - - - Exponent - - - - - - - - 0 - 0 - - - - 3 - - - 0.050000000000000 - - - 100.000000000000000 - - - 0.050000000000000 - - - - + + 3 + + + 0.000000000000000 + + + 3.000000000000000 + + + 0.050000000000000 + + + 0.000000000000000 + - - + + + + Exponent + + + + + - + 0 0 - - Axis speed - - - - QFormLayout::ExpandingFieldsGrow - - - 20 - - - 0 - - - 5 - - - 0 - - - 10 - - - 2 - - - - - - 0 - 0 - - - - X - - - - - - - - 0 - 0 - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Y - - - - - - - - 0 - 0 - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Z - - - - - - - - 0 - 0 - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Yaw - - - - - - - - 0 - 0 - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Pitch - - - - - - - - 0 - 0 - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Roll - - - - - - - - 0 - 0 - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - + + 3 + + + 0.050000000000000 + + + 100.000000000000000 + + + 0.050000000000000 + - + @@ -640,8 +331,14 @@ background:none; - + + + + 0 + 0 + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -649,21 +346,6 @@ background:none; - - rotation_alpha - translation_alpha - order_2nd - order_3rd - deadzone - expt - doubleSpinBox - doubleSpinBox_2 - doubleSpinBox_3 - doubleSpinBox_4 - doubleSpinBox_5 - doubleSpinBox_6 - buttonBox - diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 1046c268..2e70c1b0 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -10,55 +10,18 @@ #include #include #include "facetracknoir/global-settings.h" - using namespace std; -FTNoIR_Filter::FTNoIR_Filter() -{ - first_run = true; - loadSettings(); -} - -FTNoIR_Filter::~FTNoIR_Filter() -{ - -} - -void FTNoIR_Filter::loadSettings() { - 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) - - iniFile.beginGroup ( "Accela" ); - rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble(); - translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble(); - second_order_alpha = iniFile.value("second-order-alpha", ACCELA_SECOND_ORDER_ALPHA).toDouble(); - third_order_alpha = iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble(); - deadzone = iniFile.value("deadzone", 0.0).toDouble(); - // bigger means less filtering - static const double init_scaling[] = { - 1, // X - 1, // Y - 1, // Z - 1, // Yaw - 1, // Pitch - 1 // Roll - }; - for (int i = 0; i < 6; i++) - { - scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble(); - } - expt = iniFile.value("exponent", 2.0).toDouble(); - - iniFile.endGroup(); -} - -void FTNoIR_Filter::receiveSettings() +FTNoIR_Filter::FTNoIR_Filter() : + first_run(true), + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + deadzone(b, "deadzone", 0), + expt(b, "exponent", 2) { - QMutexLocker foo(&mutex); - - loadSettings(); } static inline double parabola(const double a, const double x, const double dz, const double expt) @@ -135,9 +98,9 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double a2 = a * second_order_alpha; const double a3 = a * third_order_alpha; const double velocity = - parabola(a, vec * scaling[i], deadzone, expt) + - parabola(a2, vec2 * scaling[i], deadzone, expt) + - parabola(a3, vec3 * scaling[i], deadzone, expt); + parabola(a, vec, deadzone, expt) + + parabola(a2, vec2, deadzone, expt) + + parabola(a3, vec3, deadzone, expt); const double result = last_output[0][i] + velocity; const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; new_camera_position[i] = done ? target_camera_position[i] : result; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index d91a5e42..43564bd8 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,31 +1,4 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ #pragma once -#ifndef INCLUDED_FTN_FILTER_H -#define INCLUDED_FTN_FILTER_H - #include "ftnoir_filter_base/ftnoir_filter_base.h" #include "ui_ftnoir_accela_filtercontrols.h" #include "facetracknoir/global-settings.h" @@ -37,28 +10,31 @@ #define ACCELA_SECOND_ORDER_ALPHA 100.0 #define ACCELA_THIRD_ORDER_ALPHA 180.0 -//******************************************************************************************************* -// FaceTrackNoIR Filter class. -//******************************************************************************************************* +#include "facetracknoir/options.hpp" +using namespace options; + class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - virtual ~FTNoIR_Filter(); void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); void Initialize() { first_run = true; } - void receiveSettings(); + void receiveSettings() { + b->reload(); + } + private: QMutex mutex; - void loadSettings(); bool first_run; - double rotation_alpha, translation_alpha; - double second_order_alpha, third_order_alpha; - double scaling[6]; - double deadzone; - double expt; + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + deadzone, + expt; double last_input[6]; double last_output[3][6]; QElapsedTimer timer; @@ -74,43 +50,33 @@ class FilterControls: public QWidget, public IFilterDialog { Q_OBJECT public: - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *parent); + FilterControls(); + void Initialize(QWidget *); void registerFilter(IFilter* filter); void unregisterFilter(); private: Ui::AccelaUICFilterControls ui; - void loadSettings(); + void discard(); void save(); - bool settingsDirty; FTNoIR_Filter* accela_filter; + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + deadzone, + expt; private slots: void doOK(); void doCancel(); - void settingChanged(bool) { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } - void settingChanged(double) { settingsDirty = true; } }; -//******************************************************************************************************* -// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter -//******************************************************************************************************* class FTNoIR_FilterDll : public Metadata { public: - FTNoIR_FilterDll(); - ~FTNoIR_FilterDll(); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); } void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } }; - - -#endif //INCLUDED_FTN_FILTER_H -//END - diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index a14db280..256f35b4 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ #include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include #include @@ -29,60 +5,30 @@ #include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// FilterControls::FilterControls() : - QWidget(), accela_filter(NULL) + accela_filter(NULL), + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + deadzone(b, "deadzone", 0), + expt(b, "exponent", 2) + { ui.setupUi( this ); - - // Load the settings from the current .INI-file - loadSettings(); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) - { - connect(boxen[i], SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - } - - connect(ui.expt, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - - qDebug() << "FilterControls() says: started"; -} -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; + tie_setting(rotation_alpha, ui.rotation_alpha); + tie_setting(translation_alpha, ui.translation_alpha); + tie_setting(second_order_alpha, ui.order_2nd); + tie_setting(third_order_alpha, ui.order_3rd); + tie_setting(deadzone, ui.deadzone); + tie_setting(expt, ui.expt); } -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent) { - loadSettings(); - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } +void FilterControls::Initialize(QWidget *) { show(); } @@ -96,153 +42,50 @@ void FilterControls::unregisterFilter() accela_filter = NULL; } -// -// OK clicked on server-dialog -// void FilterControls::doOK() { save(); this->close(); } -// override show event -void FilterControls::showEvent ( QShowEvent * ) { -} - -// -// Cancel clicked on server-dialog -// void FilterControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FilterControls::loadSettings() { - 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_Filter::loadSettings2 says: iniFile = " << currentFile; - - //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); - - iniFile.beginGroup ( "Accela" ); - ui.rotation_alpha->setValue(iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble()); - ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble()); - ui.order_2nd->setValue(iniFile.value("second-order-alpha", ACCELA_SECOND_ORDER_ALPHA).toDouble()); - ui.order_3rd->setValue(iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble()); - ui.deadzone->setValue(iniFile.value("deadzone", 0).toDouble()); - - // bigger means less filtering - static const double init_scaling[] = { - 1.5, // X - 1.5, // Y - 1, // Z - 0.8, // Yaw - 0.9, // Pitch - 1.25 // Roll - }; - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) + if (!b->modifiedp()) { - boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); + close(); + return; } + int ret = + QMessageBox::question( this, + "Settings have changed", + "Do you want to save the settings?", + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->discard(); + this->close(); + break; + case QMessageBox::Cancel: + default: + break; + } +} - ui.expt->setValue(iniFile.value("exponent", 2.0).toDouble()); - - iniFile.endGroup(); - settingsDirty = false; +void FilterControls::discard() +{ + b->revert(); } -// -// Save the current Settings to the currently 'active' INI-file. -// void FilterControls::save() { - 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_Filter::save() says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Accela" ); - iniFile.setValue("rotation-alpha", ui.rotation_alpha->value()); - iniFile.setValue("translation-alpha", ui.translation_alpha->value()); - iniFile.setValue("deadzone", ui.deadzone->value()); - iniFile.setValue("exponent", ui.expt->value()); - iniFile.setValue("second-order-alpha", ui.order_2nd->value()); - iniFile.setValue("third-order-alpha", ui.order_3rd->value()); - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) - { - iniFile.setValue(QString("axis-%1").arg(QString::number(i)), boxen[i]->value()); - } - iniFile.endGroup(); - } - - settingsDirty = false; - + b->save(); if (accela_filter) accela_filter->receiveSettings(); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog() { return new FilterControls; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp index d4a11028..a024e789 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -1,38 +1,6 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ #include "ftnoir_filter_accela.h" #include "facetracknoir/global-settings.h" -FTNoIR_FilterDll::FTNoIR_FilterDll() { -} - -FTNoIR_FilterDll::~FTNoIR_FilterDll() -{ - -} - extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_FilterDll; -- cgit v1.2.3 From a49a146b1a9bb68b763a09684bdae8cc7dd16d65 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:02:21 +0100 Subject: remove dist coeffs, no one uses them --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 18 +- ftnoir_tracker_ht/ht-trackercontrols.ui | 591 ++++++++++---------------------- 2 files changed, 186 insertions(+), 423 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index f9f03fae..a1fed131 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -131,7 +131,7 @@ static void load_settings(ht_config_t* config, Tracker* tracker) } for (int i = 0; i < 5; i++) - config->dist_coeffs[i] = iniFile.value(QString("dc%1").arg(i), 0).toDouble(); + config->dist_coeffs[i] = 0; iniFile.endGroup(); } @@ -285,8 +285,8 @@ TrackerControls::TrackerControls() connect(ui.tx, SIGNAL(clicked()), this, SLOT(settingChanged())); connect(ui.ty, SIGNAL(clicked()), this, SLOT(settingChanged())); connect(ui.tz, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); loadSettings(); settingsDirty = false; @@ -344,12 +344,6 @@ void TrackerControls::loadSettings() ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - ui.doubleSpinBox->setValue(iniFile.value("dc0").toDouble()); - ui.doubleSpinBox_2->setValue(iniFile.value("dc1").toDouble()); - ui.doubleSpinBox_3->setValue(iniFile.value("dc2").toDouble()); - ui.doubleSpinBox_4->setValue(iniFile.value("dc3").toDouble()); - ui.doubleSpinBox_5->setValue(iniFile.value("dc4").toDouble()); - iniFile.endGroup(); settingsDirty = false; } @@ -389,12 +383,6 @@ void TrackerControls::save() iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); - iniFile.setValue("dc0", ui.doubleSpinBox->value()); - iniFile.setValue("dc1", ui.doubleSpinBox_2->value()); - iniFile.setValue("dc2", ui.doubleSpinBox_3->value()); - iniFile.setValue("dc3", ui.doubleSpinBox_4->value()); - iniFile.setValue("dc4", ui.doubleSpinBox_5->value()); - iniFile.endGroup(); settingsDirty = false; } diff --git a/ftnoir_tracker_ht/ht-trackercontrols.ui b/ftnoir_tracker_ht/ht-trackercontrols.ui index 6153637a..198cca7f 100644 --- a/ftnoir_tracker_ht/ht-trackercontrols.ui +++ b/ftnoir_tracker_ht/ht-trackercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 593 - 280 + 527 + 144 @@ -28,420 +28,195 @@ HT tracker settings - - - - 10 - 10 - 141 - 16 - - - - Horizontal FOV - - - - - - 130 - 10 - 251 - 22 - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 - - - - - - 10 - 40 - 137 - 16 - - - - Frames per second - - - - - - 130 - 40 - 251 - 22 - - - - - Default - + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + + + + Horizontal FOV + + + + + + + Enable axes + + + + + 10 + 20 + 70 + 17 + + + + RX + + + + + + 10 + 40 + 70 + 17 + + + + RY + + + + + + 10 + 60 + 70 + 17 + + + + RZ + + + + + + 60 + 20 + 70 + 17 + + + + TX + + + + + + 60 + 40 + 70 + 17 + + + + TY + + + + + + 60 + 60 + 70 + 17 + + + + TZ + + + - - - 30 - + + + + Frames per second + + - - - 60 - + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + - - - 120 - + + + + Camera name + + - - - - - 10 - 70 - 133 - 16 - - - - Camera name - - - - - - 430 - 250 - 75 - 23 - - - - OK - - - - - - 510 - 250 - 75 - 23 - - - - Cancel - - - - - - 390 - 10 - 101 - 81 - - - - Enable axes - - - - - 10 - 20 - 70 - 17 - - - - RX - - - - - - 10 - 40 - 70 - 17 - - - - RY - - - - - - 10 - 60 - 70 - 17 - - - - RZ - - - - - - 60 - 20 - 70 - 17 - - - - TX - - - - - - 60 - 40 - 70 - 17 - - - - TY - - - - - - 60 - 60 - 70 - 17 - - - - TZ - - - - - - - 130 - 70 - 251 - 22 - - - - - - - 10 - 100 - 128 - 16 - - - - Resolution - - - - - - 130 - 100 - 251 - 22 - - - - - 640x480 - + + - - - 320x240 - + + + + Resolution + + - - - 320x200 - + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + - - - Default (not recommended!) - + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + - - - - - 130 - 130 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 10 - 130 - 111 - 16 - - - - Distortion coefficients - - - - - - 130 - 160 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 190 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 220 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 250 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - + -- cgit v1.2.3 From 2f6b8f8b2b5bdaeed540e8b87dcae0dfe7ba1e70 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:34:42 +0100 Subject: settings framework for ht tracker --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 251 ++++++++++++-------------------- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 24 +-- 2 files changed, 102 insertions(+), 173 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index a1fed131..ab4c5a3e 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -88,23 +88,34 @@ static resolution_tuple resolution_choices[] = { { 0, 0 } }; -static void load_settings(ht_config_t* config, Tracker* tracker) +void Tracker::load_settings(ht_config_t* config) { - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); + int nframes = 0; + switch (static_cast(fps)) + { + default: + case 0: + nframes = 0; + break; + case 1: + nframes = 30; + break; + case 2: + nframes = 60; + break; + case 3: + nframes = 120; + break; + } - iniFile.beginGroup( "HT-Tracker" ); config->classification_delay = 500; - config->field_of_view = iniFile.value("fov", 52).toFloat(); + config->field_of_view = fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; config->max_keypoints = 350; config->keypoint_distance = 3.4; - //config->force_width = 640; - //config->force_height = 480; - config->force_fps = iniFile.value("fps", 0).toInt(); - config->camera_index = iniFile.value("camera-index", -1).toInt(); + config->force_fps = nframes; + config->camera_index = camera_idx - 1; config->ransac_num_iters = 100; config->ransac_max_reprojection_error = 8; config->ransac_max_inlier_error = 8; @@ -112,38 +123,35 @@ static void load_settings(ht_config_t* config, Tracker* tracker) config->ransac_max_mean_error = 6.5; config->debug = 0; config->ransac_min_features = 0.72; - int res = iniFile.value("resolution", 0).toInt(); + int res = resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; config->force_width = r.width; config->force_height = r.height; config->flandmark_delay = 325; - qDebug() << "width" << r.width << "height" << r.height; - if (tracker) - { - tracker->enableRX = iniFile.value("enable-rx", true).toBool(); - tracker->enableRY = iniFile.value("enable-ry", true).toBool(); - tracker->enableRZ = iniFile.value("enable-rz", true).toBool(); - tracker->enableTX = iniFile.value("enable-tx", true).toBool(); - tracker->enableTY = iniFile.value("enable-ty", true).toBool(); - tracker->enableTZ = iniFile.value("enable-tz", true).toBool(); - } - for (int i = 0; i < 5; i++) config->dist_coeffs[i] = 0; - - iniFile.endGroup(); } -Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)) +Tracker::Tracker() : + b(bundle("HT-Tracker")), + enableTX(b, "enable-tx", true), + enableTY(b, "enable-ty", true), + enableTZ(b, "enable-tz", true), + enableRX(b, "enable-rx", true), + enableRY(b, "enable-ry", true), + enableRZ(b, "enable-rz", true), + fov(b, "fov", 56), + fps(b, "fps", 0), + camera_idx(b, "camera-index", 0), + resolution(b, "resolution", 0), + lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), + shm(reinterpret_cast(lck_shm.mem)), + videoWidget(nullptr), + layout(nullptr) { - videoWidget = NULL; - layout = NULL; - enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; - shm = (ht_shm_t*) lck_shm.mem; shm->terminate = 0; - load_settings(&shm->config, this); shm->result.filled = false; } @@ -174,7 +182,7 @@ void Tracker::StartTracker(QFrame* videoframe) videoframe->setLayout(layout); videoWidget->show(); this->layout = layout; - load_settings(&shm->config, this); + load_settings(&shm->config); shm->frame.channels = shm->frame.width = shm->frame.height = 0; shm->pause = shm->terminate = shm->running = false; shm->timer = 0; @@ -272,153 +280,74 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial return new TrackerControls; } -TrackerControls::TrackerControls() +TrackerControls::TrackerControls() : + b(bundle("HT-Tracker")), + enableTX(b, "enable-tx", true), + enableTY(b, "enable-ty", true), + enableTZ(b, "enable-tz", true), + enableRX(b, "enable-rx", true), + enableRY(b, "enable-ry", true), + enableRZ(b, "enable-rz", true), + fov(b, "fov", 56), + fps(b, "fps", 0), + camera_idx(b, "camera-index", 0), + resolution(b, "resolution", 0) { 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(clicked()), this, SLOT(settingChanged())); - connect(ui.ry, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.rz, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.tx, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.ty, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.tz, SIGNAL(clicked()), this, SLOT(settingChanged())); + ui.cameraName->clear(); + QList names = get_camera_names(); + names.prepend("Any available"); + ui.cameraName->addItems(names); + tie_setting(camera_idx, ui.cameraName); + tie_setting(fps, ui.cameraFPS); + tie_setting(fov, ui.cameraFOV); + tie_setting(enableTX, ui.tx); + tie_setting(enableTY, ui.ty); + tie_setting(enableTZ, ui.tz); + tie_setting(enableRX, ui.rx); + tie_setting(enableRY, ui.ry); + tie_setting(enableRZ, ui.rz); + tie_setting(resolution, ui.resolution); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); - 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( "HT-Tracker" ); - ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1); - ui.cameraFOV->setValue(iniFile.value("fov", 52).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()); - - 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( "HT-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.endGroup(); - settingsDirty = false; -} - void TrackerControls::doOK() { - save(); + b->save(); this->close(); } 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 ); - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + if (!b->modifiedp()) + { + close(); + return; + } + int ret = QMessageBox::question ( this, + "Settings have changed", + "Do you want to save the settings?", + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, + QMessageBox::Discard ); + + switch (ret) { + case QMessageBox::Save: + b->save(); + this->close(); + break; + case QMessageBox::Discard: + b->revert(); + this->close(); + break; + default: + case QMessageBox::Cancel: + break; + } } diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 404dbf6e..3140e99c 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -15,6 +15,8 @@ #include "ht_video_widget.h" #include "compat/compat.h" #include +#include "facetracknoir/options.hpp" +using namespace options; class Tracker : public QObject, public ITracker { @@ -24,10 +26,14 @@ public: virtual ~Tracker(); void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); - bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - ht_shm_t* shm; + pbundle b; + value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + value fov; + value fps, camera_idx, resolution; + void load_settings(ht_config_t* config); private: PortableLockedShm lck_shm; + ht_shm_t* shm; QProcess subprocess; HTVideoWidget* videoWidget; QHBoxLayout* layout; @@ -38,27 +44,21 @@ class TrackerControls : public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *); void registerTracker(ITracker *) {} void unRegisterTracker() {} private: Ui::Form ui; - void loadSettings(); - void save(); - bool settingsDirty; + pbundle b; + value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + value fov; + value fps, camera_idx, resolution; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } - void settingChanged(double) { settingsDirty = true; } }; #endif -- cgit v1.2.3 From 9cb243cc74d953283b0a233e47f1d0a4e303ab55 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:39:54 +0100 Subject: remove boring comments --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index ab4c5a3e..333ce28a 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -250,31 +250,16 @@ void TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/ht.png"); } - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new TrackerDll; } -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { return new Tracker; } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) { return new TrackerControls; @@ -310,7 +295,6 @@ TrackerControls::TrackerControls() : tie_setting(resolution, ui.resolution); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); } void TrackerControls::Initialize(QWidget*) @@ -334,8 +318,7 @@ void TrackerControls::doCancel() 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: -- cgit v1.2.3 From eaeb86205a04a2159de3e55fb7105195962249db Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:58:26 +0100 Subject: don't mark as dirty by accident --- facetracknoir/options.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 16946e88..67c0958d 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -43,6 +43,12 @@ namespace options { return t.toDouble(); } + template<> + inline QVariant qcruft_to_t(const QVariant& t) + { + return t; + } + // snapshot of qsettings group at given time class group { private: @@ -115,8 +121,11 @@ namespace options { } void store(const QString& name, const QVariant& datum) { - modified = true; - transient.put(name, datum); + if (!transient.contains(name) || datum != transient.get(name)) + { + modified = true; + transient.put(name, datum); + } } bool contains(const QString& name) { -- cgit v1.2.3 From 2a3b4460da901256a60fc2e4bc90adc14284bbf3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:02:53 +0100 Subject: accela: bundle settings to reduce boilerplate --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 22 ++++--------- ftnoir_filter_accela/ftnoir_filter_accela.h | 37 +++++++++++++--------- .../ftnoir_filter_accela_dialog.cpp | 28 ++++++---------- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 2e70c1b0..1e12e4de 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -12,15 +12,7 @@ #include "facetracknoir/global-settings.h" using namespace std; -FTNoIR_Filter::FTNoIR_Filter() : - first_run(true), - b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - deadzone(b, "deadzone", 0), - expt(b, "exponent", 2) +FTNoIR_Filter::FTNoIR_Filter() : first_run(true) { } @@ -94,13 +86,13 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double vec2 = target_camera_position[i] - last_output[1][i]; const double vec3 = target_camera_position[i] - last_output[2][i]; const int sign = vec < 0 ? -1 : 1; - const double a = i >= 3 ? rotation_alpha : translation_alpha; - const double a2 = a * second_order_alpha; - const double a3 = a * third_order_alpha; + const double a = i >= 3 ? s.rotation_alpha : s.translation_alpha; + const double a2 = a * s.second_order_alpha; + const double a3 = a * s.third_order_alpha; const double velocity = - parabola(a, vec, deadzone, expt) + - parabola(a2, vec2, deadzone, expt) + - parabola(a3, vec3, deadzone, expt); + parabola(a, vec, s.deadzone, s.expt) + + parabola(a2, vec2, s.deadzone, s.expt) + + parabola(a3, vec3, s.deadzone, s.expt); const double result = last_output[0][i] + velocity; const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; new_camera_position[i] = done ? target_camera_position[i] : result; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 43564bd8..2b93f550 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -13,6 +13,25 @@ #include "facetracknoir/options.hpp" using namespace options; +struct settings { + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + deadzone, + expt; + settings() : + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + deadzone(b, "deadzone", 0), + expt(b, "exponent", 2) + {} +}; + class FTNoIR_Filter : public IFilter { public: @@ -22,19 +41,13 @@ public: first_run = true; } void receiveSettings() { - b->reload(); + s.b->reload(); } private: + settings s; QMutex mutex; bool first_run; - pbundle b; - value rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - deadzone, - expt; double last_input[6]; double last_output[3][6]; QElapsedTimer timer; @@ -59,13 +72,7 @@ private: void discard(); void save(); FTNoIR_Filter* accela_filter; - pbundle b; - value rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - deadzone, - expt; + settings s; private slots: void doOK(); void doCancel(); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 256f35b4..cc759bcb 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -6,26 +6,18 @@ #include "facetracknoir/global-settings.h" FilterControls::FilterControls() : - accela_filter(NULL), - b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - deadzone(b, "deadzone", 0), - expt(b, "exponent", 2) - + accela_filter(nullptr) { ui.setupUi( this ); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - tie_setting(rotation_alpha, ui.rotation_alpha); - tie_setting(translation_alpha, ui.translation_alpha); - tie_setting(second_order_alpha, ui.order_2nd); - tie_setting(third_order_alpha, ui.order_3rd); - tie_setting(deadzone, ui.deadzone); - tie_setting(expt, ui.expt); + tie_setting(s.rotation_alpha, ui.rotation_alpha); + tie_setting(s.translation_alpha, ui.translation_alpha); + tie_setting(s.second_order_alpha, ui.order_2nd); + tie_setting(s.third_order_alpha, ui.order_3rd); + tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.expt, ui.expt); } void FilterControls::Initialize(QWidget *) { @@ -48,7 +40,7 @@ void FilterControls::doOK() { } void FilterControls::doCancel() { - if (!b->modifiedp()) + if (!s.b->modifiedp()) { close(); return; @@ -77,11 +69,11 @@ void FilterControls::doCancel() { void FilterControls::discard() { - b->revert(); + s.b->revert(); } void FilterControls::save() { - b->save(); + s.b->save(); if (accela_filter) accela_filter->receiveSettings(); } -- cgit v1.2.3 From 60a8fd51ba9cd77b1944d10cab75e095db7b2815 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:03:00 +0100 Subject: ht: reduce boilerplate --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 72 ++++++++++++--------------------- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 30 ++++++++++---- 2 files changed, 47 insertions(+), 55 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 333ce28a..e154557e 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -91,7 +91,7 @@ static resolution_tuple resolution_choices[] = { void Tracker::load_settings(ht_config_t* config) { int nframes = 0; - switch (static_cast(fps)) + switch (static_cast(s.fps)) { default: case 0: @@ -109,13 +109,13 @@ void Tracker::load_settings(ht_config_t* config) } config->classification_delay = 500; - config->field_of_view = fov; + config->field_of_view = s.fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; config->max_keypoints = 350; config->keypoint_distance = 3.4; config->force_fps = nframes; - config->camera_index = camera_idx - 1; + config->camera_index = s.camera_idx - 1; config->ransac_num_iters = 100; config->ransac_max_reprojection_error = 8; config->ransac_max_inlier_error = 8; @@ -123,7 +123,7 @@ void Tracker::load_settings(ht_config_t* config) config->ransac_max_mean_error = 6.5; config->debug = 0; config->ransac_min_features = 0.72; - int res = resolution; + int res = s.resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; @@ -135,17 +135,6 @@ void Tracker::load_settings(ht_config_t* config) } Tracker::Tracker() : - b(bundle("HT-Tracker")), - enableTX(b, "enable-tx", true), - enableTY(b, "enable-ty", true), - enableTZ(b, "enable-tz", true), - enableRX(b, "enable-rx", true), - enableRY(b, "enable-ry", true), - enableRZ(b, "enable-rz", true), - fov(b, "fov", 56), - fps(b, "fps", 0), - camera_idx(b, "camera-index", 0), - resolution(b, "resolution", 0), lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), shm(reinterpret_cast(lck_shm.mem)), videoWidget(nullptr), @@ -205,19 +194,19 @@ void Tracker::GetHeadPoseData(double *data) shm->frame.width = 0; } if (shm->result.filled) { - if (enableRX) + if (s.enableRX) data[Yaw] = shm->result.rotx; - if (enableRY) { + if (s.enableRY) { data[Pitch] = shm->result.roty; } - if (enableRZ) { + if (s.enableRZ) { data[Roll] = shm->result.rotz; } - if (enableTX) + if (s.enableTX) data[TX] = shm->result.tx; - if (enableTY) + if (s.enableTY) data[TY] = shm->result.ty; - if (enableTZ) + if (s.enableTZ) data[TZ] = shm->result.tz; if (fabs(data[Yaw]) > 60 || fabs(data[Pitch]) > 50 || fabs(data[Roll]) > 40) { @@ -265,34 +254,23 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial return new TrackerControls; } -TrackerControls::TrackerControls() : - b(bundle("HT-Tracker")), - enableTX(b, "enable-tx", true), - enableTY(b, "enable-ty", true), - enableTZ(b, "enable-tz", true), - enableRX(b, "enable-rx", true), - enableRY(b, "enable-ry", true), - enableRZ(b, "enable-rz", true), - fov(b, "fov", 56), - fps(b, "fps", 0), - camera_idx(b, "camera-index", 0), - resolution(b, "resolution", 0) +TrackerControls::TrackerControls() { ui.setupUi(this); ui.cameraName->clear(); QList names = get_camera_names(); names.prepend("Any available"); ui.cameraName->addItems(names); - tie_setting(camera_idx, ui.cameraName); - tie_setting(fps, ui.cameraFPS); - tie_setting(fov, ui.cameraFOV); - tie_setting(enableTX, ui.tx); - tie_setting(enableTY, ui.ty); - tie_setting(enableTZ, ui.tz); - tie_setting(enableRX, ui.rx); - tie_setting(enableRY, ui.ry); - tie_setting(enableRZ, ui.rz); - tie_setting(resolution, ui.resolution); + tie_setting(s.camera_idx, ui.cameraName); + tie_setting(s.fps, ui.cameraFPS); + tie_setting(s.fov, ui.cameraFOV); + tie_setting(s.enableTX, ui.tx); + tie_setting(s.enableTY, ui.ty); + tie_setting(s.enableTZ, ui.tz); + tie_setting(s.enableRX, ui.rx); + tie_setting(s.enableRY, ui.ry); + tie_setting(s.enableRZ, ui.rz); + tie_setting(s.resolution, ui.resolution); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); } @@ -304,13 +282,13 @@ void TrackerControls::Initialize(QWidget*) void TrackerControls::doOK() { - b->save(); + s.b->save(); this->close(); } void TrackerControls::doCancel() { - if (!b->modifiedp()) + if (!s.b->modifiedp()) { close(); return; @@ -322,11 +300,11 @@ void TrackerControls::doCancel() switch (ret) { case QMessageBox::Save: - b->save(); + s.b->save(); this->close(); break; case QMessageBox::Discard: - b->revert(); + s.b->revert(); this->close(); break; default: diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 3140e99c..f45e54f9 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -18,6 +18,26 @@ #include "facetracknoir/options.hpp" using namespace options; +struct settings { + pbundle b; + value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + value fov; + value fps, camera_idx, resolution; + settings() : + b(bundle("HT-Tracker")), + enableTX(b, "enable-tx", true), + enableTY(b, "enable-ty", true), + enableTZ(b, "enable-tz", true), + enableRX(b, "enable-rx", true), + enableRY(b, "enable-ry", true), + enableRZ(b, "enable-rz", true), + fov(b, "fov", 56), + fps(b, "fps", 0), + camera_idx(b, "camera-index", 0), + resolution(b, "resolution", 0) + {} +}; + class Tracker : public QObject, public ITracker { Q_OBJECT @@ -26,12 +46,9 @@ public: virtual ~Tracker(); void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); - pbundle b; - value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - value fov; - value fps, camera_idx, resolution; void load_settings(ht_config_t* config); private: + settings s; PortableLockedShm lck_shm; ht_shm_t* shm; QProcess subprocess; @@ -51,10 +68,7 @@ public: private: Ui::Form ui; - pbundle b; - value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - value fov; - value fps, camera_idx, resolution; + settings s; private slots: void doOK(); -- cgit v1.2.3 From 272e784d6c79e5f43e2514c349f46734fbbd0078 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:15:17 +0100 Subject: hydra: use new settings framework. also decruft --- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 95 +---------- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 57 +++---- .../ftnoir_tracker_hydra_dialog.cpp | 177 ++++----------------- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp | 18 +-- 4 files changed, 61 insertions(+), 286 deletions(-) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 31e3f319..70af2893 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -9,22 +9,9 @@ #endif #include #include -#if 0 -#include -#include -#include -#include -#endif -Hydra_Tracker::Hydra_Tracker() +Hydra_Tracker::Hydra_Tracker() : should_quit(false) { - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; - should_quit = false; for (int i = 0; i < 6; i++) newHeadPose[i] = 0; } @@ -35,48 +22,18 @@ Hydra_Tracker::~Hydra_Tracker() sixenseExit(); } -/* -void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_step step ) { - - QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton); - if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) { - // Ask the controller manager what the next instruction string should be. - std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString(); - QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton); - // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName(); - - } -}*/ - void Hydra_Tracker::StartTracker(QFrame*) { - //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton); - loadSettings(); - - // Init sixense - //QMessageBox::warning(0,"OpenTrack Info", "sixense init",QMessageBox::Ok,QMessageBox::NoButton); sixenseInit(); - //QMessageBox::warning(0,"OpenTrack Info", "sixense init complete, setting controller manager",QMessageBox::Ok,QMessageBox::NoButton); - // Init the controller manager. This makes sure the controllers are present, assigned to left and right hands, and that - // the hemisphere calibration is complete. - //sixenseUtils::getTheControllerManager()->setGameType( sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER ); - //sixenseUtils::getTheControllerManager()->registerSetupCallback( controller_manager_setup_callback ); - //QMessageBox::warning(0,"OpenTrack Info", "controller manager callback registered",QMessageBox::Ok,QMessageBox::NoButton); - return; } - void Hydra_Tracker::GetHeadPoseData(double *data) { sixenseSetActiveBase(0); sixenseAllControllerData acd; sixenseGetAllNewestData( &acd ); - //sixenseUtils::getTheControllerManager()->update( &acd ); - - //sixenseControllerData cd; - //Rotation quat = Rotation(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); - sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);// sixenseMath::Quat(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); + sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat); float ypr[3]; @@ -90,62 +47,26 @@ void Hydra_Tracker::GetHeadPoseData(double *data) newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - if (bEnableX) { + if (s.bEnableX) { data[TX] = newHeadPose[TX]; } - if (bEnableY) { + if (s.bEnableY) { data[TY] = newHeadPose[TY]; } - if (bEnableY) { + if (s.bEnableY) { data[TZ] = newHeadPose[TZ]; } - - 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 Hydra_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 ( "Hydra" ); - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); - - 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 Hydra_Tracker; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 240f0687..16629c3a 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -5,82 +5,63 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value bEnableRoll, bEnablePitch, bEnableYaw, bEnableX, bEnableY, bEnableZ; + settings() : + b(bundle("tracker-hydra")), + bEnableRoll(b, "enable-rz", true), + bEnablePitch(b, "enable-ry", true), + bEnableYaw(b, "enable-rx", true), + bEnableX(b, "enable-tx", true), + bEnableY(b, "enable-ty", true), + bEnableZ(b, "enable-tz", true) + {} +}; + class Hydra_Tracker : public ITracker { public: Hydra_Tracker(); ~Hydra_Tracker(); - void StartTracker(QFrame *) virt_override; void GetHeadPoseData(double *data) virt_override; - void loadSettings(); volatile bool should_quit; protected: void run(); // qthread override run method - private: + settings s; bool isCalibrated; - double newHeadPose[6]; // Structure with new headpose - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - - bool bEnableX; - bool bEnableY; - bool bEnableZ; - QMutex mutex; - virtual int preferredHz() virt_override { return 250; } }; -// Widget that has controls for FTNoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - ~TrackerControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} - private: + settings s; Ui::UIHydraControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } }; -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* class FTNoIR_TrackerDll : public Metadata { public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; }; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index fa674662..e92180a3 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -1,37 +1,6 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ #include "ftnoir_tracker_hydra.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// TrackerControls::TrackerControls() : QWidget() { @@ -41,28 +10,14 @@ QWidget() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -#if 0 - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -#endif - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); + tie_setting(s.bEnableX, ui.chkEnableX); + tie_setting(s.bEnableY, ui.chkEnableY); + tie_setting(s.bEnableZ, ui.chkEnableZ); } -// -// Initialize tracker-client-dialog -// void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(100, 100); @@ -72,108 +27,38 @@ void TrackerControls::Initialize(QWidget *parent) { show(); } -// -// OK clicked on server-dialog -// void TrackerControls::doOK() { - save(); + s.b->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 - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - - -// -// Load the current Settings from the currently 'active' INI-file. -// -void TrackerControls::loadSettings() { - -// qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Hydra" ); - ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); - ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); - ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); - - iniFile.endGroup (); - - settingsDirty = false; + if (!s.b->modifiedp()) + { + close(); + return; + } + int ret = QMessageBox::question (this, + "Settings have changed", + "Do you want to save the settings?", + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + + switch (ret) { + case QMessageBox::Save: + s.b->save(); + this->close(); + break; + case QMessageBox::Discard: + s.b->revert(); + this->close(); + break; + default: + case QMessageBox::Cancel: + // Cancel was clicked + break; + } } -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::save() { - 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) - - iniFile.beginGroup ( "Hydra" ); - iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); - iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); - iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) { return new TrackerControls; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp index db6f658c..a2cc7c01 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp @@ -3,31 +3,19 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "Hydra"; - trackerShortName = "Hydra"; - trackerDescription = "Hydra"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { - *strToBeFilled = trackerFullName; + *strToBeFilled = "Hydra"; } void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = trackerShortName; + *strToBeFilled = "Hydra"; } void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = trackerDescription; + *strToBeFilled = "Hydra"; } void FTNoIR_TrackerDll::getIcon(QIcon *icon) -- cgit v1.2.3 From d93d2a4f373f79e86e855c43815edf26cc455e3d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:29:28 +0100 Subject: support QLineEdit --- facetracknoir/options.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 67c0958d..c9a982bc 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -20,10 +20,11 @@ #include #include #include +#include namespace options { template - inline T qcruft_to_t(const QVariant& t); + inline T qcruft_to_t (const QVariant& t); template<> inline int qcruft_to_t(const QVariant& t) @@ -31,6 +32,12 @@ namespace options { return t.toInt(); } + template<> + inline QString qcruft_to_t(const QVariant& t) + { + return t.toString(); + } + template<> inline bool qcruft_to_t(const QVariant& t) { @@ -244,6 +251,14 @@ namespace options { sl->setValue(v); } + template<> + inline void tie_setting(value& v, QLineEdit* le) + { + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString))); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString))); + le->setText(v); + } + inline pbundle bundle(const QString& group) { return std::make_shared(group); } -- cgit v1.2.3 From 76c48c14b4f5f5b22532016b5963e600fbebb610 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:56:11 +0100 Subject: add option of tying combobox to its text value --- facetracknoir/options.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index c9a982bc..900f06c0 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -183,7 +183,7 @@ namespace options { QString self_name; pbundle b; public: - value(const pbundle& b, const QString& name, T def) : + value(pbundle& b, const QString& name, T def) : self_name(name), b(b) { @@ -219,6 +219,14 @@ namespace options { cb->setCurrentIndex(v); } + template<> + inline void tie_setting(value& v, QComboBox* cb) + { + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString))); + cb->setCurrentText(v); + } + template<> inline void tie_setting(value& v, QCheckBox* cb) { -- cgit v1.2.3 From ae777909d23d7cf34d5b2e48a568c1df9dfb9303 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:56:34 +0100 Subject: hatire: use new settings framework --- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 207 ++++++++++----------- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 44 ----- .../ftnoir_tracker_hat_dialog.cpp | 198 +++++++------------- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 47 +---- .../ftnoir_tracker_hat_settings.cpp | 145 --------------- .../ftnoir_tracker_hat_settings.h | 124 ++++++------ 6 files changed, 240 insertions(+), 525 deletions(-) delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index f902b207..dc4b2879 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -39,7 +39,6 @@ FTNoIR_Tracker::FTNoIR_Tracker() HAT.Trans[1]=0; HAT.Trans[2]=0; - // prepare & reserve QByteArray dataRead.resize(4096); dataRead.clear(); @@ -47,8 +46,6 @@ FTNoIR_Tracker::FTNoIR_Tracker() Begin.append((char) 0xAA); End.append((char) 0x55); End.append((char) 0x55); - - settings.load_ini(); } FTNoIR_Tracker::~FTNoIR_Tracker() @@ -64,20 +61,18 @@ FTNoIR_Tracker::~FTNoIR_Tracker() //send CENTER to Arduino void FTNoIR_Tracker::notifyCenter() { - sendcmd(sCmdCenter); + sendcmd(static_cast(settings.CmdCenter).toLatin1()); } //send ZERO to Arduino bool FTNoIR_Tracker::notifyZeroed() { - sendcmd(sCmdZero); + sendcmd(static_cast(settings.CmdZero).toLatin1()); return true; } - - //send RESET to Arduino void FTNoIR_Tracker::reset() { - sendcmd(sCmdReset); + sendcmd(static_cast(settings.CmdReset).toLatin1()); } @@ -266,39 +261,91 @@ void FTNoIR_Tracker::StopTracker( bool exit ) #else void FTNoIR_Tracker::StartTracker(QFrame*) { + static const int databits_lookup[] = { + 5, + 6, + 7, + 8, + -1 + }; + + struct Local { + static int idx(int max, int value) + { + if (value < 0) + return 0; + if (max > value) + return value; + return max - 1; + } + }; + + static const int parity_lookup[] = { + QSerialPort::NoParity, + QSerialPort::EvenParity, + QSerialPort::OddParity, + QSerialPort::SpaceParity, + QSerialPort::MarkParity, + QSerialPort::UnknownParity + }; + + static const int stopbits_lookup[] = { + QSerialPort::OneStop, + QSerialPort::OneAndHalfStop, + QSerialPort::TwoStop, + QSerialPort::UnknownStopBits + }; + + static const int flowctl_lookup[] = { + QSerialPort::NoFlowControl, + QSerialPort::HardwareControl, + QSerialPort::SoftwareControl, + }; + + static const int baudrate_lookup[] = { + QSerialPort::Baud1200, + QSerialPort::Baud2400, + QSerialPort::Baud4800, + QSerialPort::Baud9600, + QSerialPort::Baud19200, + QSerialPort::Baud38400, + QSerialPort::Baud57600, + QSerialPort::Baud115200, + QSerialPort::UnknownBaud + }; + CptError=0; dataRead.clear(); frame_cnt=0; - - settings.load_ini(); - applysettings(settings); ComPort = new QSerialPort(this); - ComPort->setPortName(sSerialPortName); - if (ComPort->open(QIODevice::ReadWrite ) == true) { + { + ComPort->setPortName(QSerialPortInfo::availablePorts().value(settings.SerialPortName).portName()); + } + if (ComPort->open(QIODevice::ReadWrite ) == true) { connect(ComPort, SIGNAL(readyRead()), this, SLOT(SerialRead())); if ( - ComPort->setBaudRate((QSerialPort::BaudRate)iBaudRate) - && ComPort->setDataBits((QSerialPort::DataBits)iDataBits) - && ComPort->setParity((QSerialPort::Parity)iParity) - && ComPort->setStopBits((QSerialPort::StopBits)iStopBits) - && ComPort->setFlowControl((QSerialPort::FlowControl)iFlowControl) + ComPort->setBaudRate(baudrate_lookup[Local::idx(8, settings.pBaudRate)]) + && ComPort->setDataBits((QSerialPort::DataBits)databits_lookup[Local::idx(4, settings.pDataBits)]) + && ComPort->setParity((QSerialPort::Parity)parity_lookup[Local::idx(5, settings.pParity)]) + && ComPort->setStopBits((QSerialPort::StopBits)stopbits_lookup[Local::idx(3, settings.pStopBits)]) + && ComPort->setFlowControl((QSerialPort::FlowControl)flowctl_lookup[Local::idx(3, settings.pFlowControl)]) && ComPort->clear(QSerialPort::AllDirections) - && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy) - ) { + && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy) + ){ // Wait init arduino sequence - for (int i = 1; i <=iDelayInit; i+=50) { + for (int i = 1; i <=settings.DelayInit; i+=50) { if (ComPort->waitForReadyRead(50)) break; } - sendcmd(sCmdInit); + sendcmd(static_cast(settings.CmdInit).toLatin1()); // Wait init MPU sequence - for (int i = 1; i <=iDelayStart; i+=50) { + for (int i = 1; i <=settings.DelayStart; i+=50) { if (ComPort->waitForReadyRead(50)) break; } // Send START cmd to IMU - sendcmd(sCmdStart); + sendcmd(static_cast(settings.CmdStart).toLatin1()); // Wait start MPU sequence - for (int i = 1; i <=iDelaySeq; i+=50) { + for (int i = 1; i <=settings.DelaySeq; i+=50) { if (ComPort->waitForReadyRead(50)) break; } } else { @@ -329,7 +376,7 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) while (dataRead.length()>=30) { if ((dataRead.startsWith(Begin) && ( dataRead.mid(28,2)==End )) ) { // .Begin==0xAAAA .End==0x5555 QDataStream datastream(dataRead.left(30)); - if (bBigEndian) datastream.setByteOrder(QDataStream::BigEndian ); + if (settings.BigEndian) datastream.setByteOrder(QDataStream::BigEndian ); else datastream.setByteOrder(QDataStream::LittleEndian ); datastream>>ArduinoData; frame_cnt++; @@ -359,34 +406,45 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) #ifdef OPENTRACK_API data[frame_cnt] = (long) HAT.Code; - if (bEnableYaw) { - if (bInvertYaw ) data[Yaw] = (double) HAT.Rot[iYawAxe] * -1.0f; - else data[Yaw] = (double) HAT.Rot[iYawAxe]; + struct Fun { + static int clamp3(int foo) + { + if (foo > 2) + return 2; + if (foo < 0) + return 0; + return foo; + } + }; + + if (settings.EnableYaw) { + if (settings.InvertYaw) data[Yaw] = (double) HAT.Rot[Fun::clamp3(settings.YawAxe)] * -1.0f; + else data[Yaw] = (double) HAT.Rot[Fun::clamp3(settings.YawAxe)]; } - if (bEnablePitch) { - if (bInvertPitch) data[Pitch] = (double) HAT.Rot[iPitchAxe] * -1.0f; - else data[Pitch] = (double) HAT.Rot[iPitchAxe]; + if (settings.EnablePitch) { + if (settings.InvertPitch) data[Pitch] = (double) HAT.Rot[Fun::clamp3(settings.PitchAxe)] * -1.0f; + else data[Pitch] = (double) HAT.Rot[Fun::clamp3(settings.InvertPitch)]; } - if (bEnableRoll) { - if (bInvertRoll) data[Roll] = (double) HAT.Rot[iRollAxe] * -1.0f; - else data[Roll] = (double) HAT.Rot[iRollAxe]; + if (settings.EnableRoll) { + if (settings.InvertRoll) data[Roll] = (double) HAT.Rot[Fun::clamp3(settings.RollAxe)] * -1.0f; + else data[Roll] = (double) HAT.Rot[Fun::clamp3(settings.RollAxe)]; } - if (bEnableX) { - if (bInvertX) data[TX] =(double) HAT.Trans[iXAxe]* -1.0f; - else data[TX] = HAT.Trans[iXAxe]; + if (settings.EnableX) { + if (settings.InvertX) data[TX] =(double) HAT.Trans[Fun::clamp3(settings.XAxe)]* -1.0f; + else data[TX] = HAT.Trans[Fun::clamp3(settings.XAxe)]; } - if (bEnableY) { - if (bInvertY) data[TY] =(double) HAT.Trans[iYAxe]* -1.0f; - else data[TY] = HAT.Trans[iYAxe]; + if (settings.EnableY) { + if (settings.InvertY) data[TY] =(double) HAT.Trans[Fun::clamp3(settings.YAxe)]* -1.0f; + else data[TY] = HAT.Trans[Fun::clamp3(settings.YAxe)]; } - if (bEnableZ) { - if (bInvertZ) data[TZ] = HAT.Trans[iZAxe]* -1.0f; - else data[TZ] = HAT.Trans[iZAxe]; + if (settings.EnableZ) { + 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; @@ -421,72 +479,13 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) else data->z = (double) HAT.Trans[iZAxe]; } #endif - - // For debug - //data->x=dataRead.length(); - //data->y=CptError; } - - -// -// Apply modification Settings -// void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ QMutexLocker lck(&mutex); - sSerialPortName= settings.SerialPortName; - - bEnableRoll = settings.EnableRoll; - bEnablePitch = settings.EnablePitch; - bEnableYaw = settings.EnableYaw; - bEnableX = settings.EnableX; - bEnableY = settings.EnableY; - bEnableZ = settings.EnableZ; - - bInvertRoll = settings.InvertRoll; - bInvertPitch = settings.InvertPitch; - bInvertYaw = settings.InvertYaw; - bInvertX = settings.InvertX; - bInvertY = settings.InvertY; - bInvertZ = settings.InvertZ; - - iRollAxe= settings.RollAxe; - iPitchAxe= settings.PitchAxe; - iYawAxe= settings.YawAxe; - iXAxe= settings.XAxe; - iYAxe= settings.YAxe; - iZAxe= settings.ZAxe; - - iBaudRate=settings.pBaudRate; - iDataBits=settings.pDataBits; - iParity=settings.pParity; - iStopBits=settings.pStopBits; - iFlowControl=settings.pFlowControl; - - sCmdStart= settings.CmdStart.toLatin1(); - sCmdStop= settings.CmdStop.toLatin1(); - sCmdInit= settings.CmdInit.toLatin1(); - sCmdReset= settings.CmdReset.toLatin1(); - sCmdCenter= settings.CmdCenter.toLatin1(); - sCmdZero= settings.CmdZero.toLatin1(); - - iDelayInit=settings.DelayInit; - iDelayStart=settings.DelayStart; - iDelaySeq=settings.DelaySeq; - - bBigEndian=settings.BigEndian; + settings.b->reload(); } - - -//////////////////////////////////////////////////////////////////////////////// -// 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. -//////////////////////////////////////////////////////////////////////////////// #ifdef OPENTRACK_API extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() #else diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index ec1125b9..a4243c38 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -62,51 +62,7 @@ private: int frame_cnt; TrackerSettings settings; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - bool bInvertRoll; - bool bInvertPitch; - bool bInvertYaw; - bool bInvertX; - bool bInvertY; - bool bInvertZ; - - int iRollAxe; - int iPitchAxe; - int iYawAxe; - int iXAxe; - int iYAxe; - int iZAxe; - - QByteArray sCmdStart; - QByteArray sCmdStop; - QByteArray sCmdInit; - QByteArray sCmdReset; - QByteArray sCmdCenter; - QByteArray sCmdZero; - - int iDelayInit; - int iDelayStart; - int iDelaySeq; - - bool bBigEndian; - - QString sSerialPortName; - QSerialPort::BaudRate iBaudRate; - QSerialPort::DataBits iDataBits; - QSerialPort::Parity iParity; - QSerialPort::StopBits iStopBits; - QSerialPort::FlowControl iFlowControl; - int CptError; - - }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp index 14b6ef0d..0ef723c9 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -37,11 +37,10 @@ // // Constructor for server-settings-dialog // -TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this) +TrackerControls::TrackerControls() : theTracker(NULL), timer(this) { ui.setupUi( this ); - settings.load_ini(); ui.label_version->setText(VER_FILEVERSION_STR); @@ -49,21 +48,13 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim ui.cbSerialPort->clear(); foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) { ui.cbSerialPort->addItem(PortInfo.portName()); - } - + } // Stop if no SerialPort dispo if (ui.cbSerialPort->count()<1) { QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible"); } else { - - int indxport =ui.cbSerialPort->findText(settings.SerialPortName,Qt::MatchExactly ); - if (indxport!=-1) { - ui.cbSerialPort->setCurrentIndex(indxport); - } else { - QMessageBox::warning(this,"FaceTrackNoIR Error", "Selected SerialPort modified"); - ui.cbSerialPort-> setCurrentIndex(indxport); - } + ui.cbSerialPort->setCurrentIndex(settings.SerialPortName); } // Serial config ui.QCB_Serial_baudRate->clear(); @@ -72,122 +63,79 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim ui.QCB_Serial_baudRate->addItem(QLatin1String("38400"),QSerialPort::Baud38400); ui.QCB_Serial_baudRate->addItem(QLatin1String("57600"),QSerialPort:: Baud57600); ui.QCB_Serial_baudRate->addItem(QLatin1String("115200"),QSerialPort::Baud115200); - ui.QCB_Serial_baudRate->setCurrentIndex(ui.QCB_Serial_baudRate->findData(settings.pBaudRate)); ui.QCB_Serial_dataBits->clear(); ui.QCB_Serial_dataBits->addItem(QLatin1String("5"), QSerialPort::Data5); ui.QCB_Serial_dataBits->addItem(QLatin1String("6"), QSerialPort::Data6); ui.QCB_Serial_dataBits->addItem(QLatin1String("7"), QSerialPort::Data7); ui.QCB_Serial_dataBits->addItem(QLatin1String("8"), QSerialPort::Data8); - ui.QCB_Serial_dataBits->setCurrentIndex(ui.QCB_Serial_dataBits->findData(settings.pDataBits)); ui.QCB_Serial_parity->clear(); ui.QCB_Serial_parity->addItem(QLatin1String("None"), QSerialPort::NoParity); ui.QCB_Serial_parity->addItem(QLatin1String("Even"), QSerialPort::EvenParity); ui.QCB_Serial_parity->addItem(QLatin1String("Odd"), QSerialPort::OddParity); - ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity); ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity); - ui.QCB_Serial_parity->setCurrentIndex(ui.QCB_Serial_parity->findData(settings.pParity)); + ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity); ui.QCB_Serial_stopBits->clear(); - ui.QCB_Serial_stopBits->addItem(QLatin1String("1"), QSerialPort::OneStop); - ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop); - ui.QCB_Serial_stopBits->addItem(QLatin1String("2"), QSerialPort::TwoStop); - ui.QCB_Serial_stopBits->setCurrentIndex(ui.QCB_Serial_stopBits->findData(settings.pStopBits)); + ui.QCB_Serial_stopBits->addItem(QLatin1String("1")); + ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5")); + ui.QCB_Serial_stopBits->addItem(QLatin1String("2")); ui.QCB_Serial_flowControl->clear(); - ui.QCB_Serial_flowControl->addItem(QLatin1String("None"), QSerialPort::NoFlowControl); - ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl); - ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl); - ui.QCB_Serial_flowControl->setCurrentIndex(ui.QCB_Serial_flowControl->findData(settings.pFlowControl)); - - - ui.chkEnableRoll->setChecked(settings.EnableRoll); - ui.chkEnablePitch->setChecked(settings.EnablePitch); - ui.chkEnableYaw->setChecked(settings.EnableYaw); - ui.chkEnableX->setChecked(settings.EnableX); - ui.chkEnableY->setChecked(settings.EnableY); - ui.chkEnableZ->setChecked(settings.EnableZ); - - ui.chkInvertRoll->setChecked(settings.InvertRoll); - ui.chkInvertPitch->setChecked(settings.InvertPitch); - ui.chkInvertYaw->setChecked(settings.InvertYaw); - ui.chkInvertX->setChecked(settings.InvertX); - ui.chkInvertY->setChecked(settings.InvertY); - ui.chkInvertZ->setChecked(settings.InvertZ); - - - ui.cb_roll->setCurrentIndex(settings.RollAxe); - ui.cb_pitch->setCurrentIndex(settings.PitchAxe); - ui.cb_yaw->setCurrentIndex(settings.YawAxe); - ui.cb_x->setCurrentIndex(settings.XAxe); - ui.cb_y->setCurrentIndex(settings.YAxe); - ui.cb_z->setCurrentIndex(settings.ZAxe); - - ui.le_cmd_start->setText(settings.CmdStart); - ui.le_cmd_stop->setText(settings.CmdStop); - ui.le_cmd_init->setText(settings.CmdInit); - ui.le_cmd_reset->setText(settings.CmdReset); - ui.le_cmd_center->setText(settings.CmdCenter); - ui.le_cmd_zero->setText(settings.CmdZero); - - ui.spb_BeforeInit->setValue(settings.DelayInit); - ui.spb_BeforeStart->setValue(settings.DelayStart); - ui.spb_AfterStart->setValue(settings.DelaySeq); - - ui.cb_Endian->setChecked(settings.BigEndian); - + ui.QCB_Serial_flowControl->addItem(QLatin1String("None")); + ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS")); + ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF")); + + tie_setting(settings.EnableRoll, ui.chkEnableRoll); + tie_setting(settings.EnablePitch, ui.chkEnablePitch); + tie_setting(settings.EnableYaw, ui.chkEnableYaw); + tie_setting(settings.EnableX, ui.chkEnableX); + tie_setting(settings.EnableY, ui.chkEnableY); + tie_setting(settings.EnableZ, ui.chkEnableZ); + + tie_setting(settings.InvertRoll, ui.chkInvertRoll); + tie_setting(settings.InvertPitch, ui.chkInvertPitch); + tie_setting(settings.InvertYaw, ui.chkInvertYaw); + tie_setting(settings.InvertX, ui.chkInvertX); + tie_setting(settings.InvertY, ui.chkInvertY); + tie_setting(settings.InvertZ, ui.chkInvertZ); + + tie_setting(settings.RollAxe, ui.cb_roll); + tie_setting(settings.RollAxe, ui.cb_roll); + tie_setting(settings.RollAxe, ui.cb_roll); + + tie_setting(settings.XAxe, ui.cb_x); + tie_setting(settings.YAxe, ui.cb_y); + tie_setting(settings.ZAxe, ui.cb_z); + + tie_setting(settings.CmdStart, ui.le_cmd_start); + tie_setting(settings.CmdStop, ui.le_cmd_stop); + tie_setting(settings.CmdInit, ui.le_cmd_init); + tie_setting(settings.CmdReset, ui.le_cmd_reset); + tie_setting(settings.CmdCenter, ui.le_cmd_center); + tie_setting(settings.CmdZero, ui.le_cmd_zero); + + tie_setting(settings.DelayInit, ui.spb_BeforeInit); + tie_setting(settings.DelayStart, ui.spb_BeforeStart); + tie_setting(settings.DelaySeq, ui.spb_AfterStart); + + tie_setting(settings.BigEndian, ui.cb_Endian); + + tie_setting(settings.pBaudRate, ui.QCB_Serial_baudRate); + tie_setting(settings.pDataBits, ui.QCB_Serial_dataBits); + tie_setting(settings.pParity, ui.QCB_Serial_parity); + tie_setting(settings.pStopBits, ui.QCB_Serial_stopBits); + tie_setting(settings.pFlowControl, ui.QCB_Serial_flowControl); + + tie_setting(settings.SerialPortName, ui.cbSerialPort); // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave())); - - connect(ui.cbSerialPort, SIGNAL(currentIndexChanged(QString)), this,SLOT(set_mod_port(QString)) ); - - connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); - connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); - connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); - connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); - connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); - connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); - - connect( ui.chkInvertRoll,SIGNAL(toggled(bool)), this,SLOT(set_inv_roll(bool)) ); - connect( ui.chkInvertPitch,SIGNAL(toggled(bool)), this,SLOT(set_inv_pitch(bool)) ); - connect( ui.chkInvertYaw,SIGNAL(toggled(bool)), this,SLOT(set_inv_yaw(bool)) ); - connect( ui.chkInvertX,SIGNAL(toggled(bool)), this,SLOT(set_inv_x(bool)) ); - connect( ui.chkInvertY,SIGNAL(toggled(bool)), this,SLOT(set_inv_y(bool)) ); - connect( ui.chkInvertZ,SIGNAL(toggled(bool)), this,SLOT(set_inv_z(bool)) ); - - connect(ui.cb_roll, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_roll(int))); - connect(ui.cb_pitch, SIGNAL(currentIndexChanged(int)),this,SLOT(set_rot_pitch(int))); - connect(ui.cb_yaw, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_yaw(int))); - connect(ui.cb_x, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_x(int))); - connect(ui.cb_y, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_y(int))); - connect(ui.cb_z, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_z(int))); - - connect(ui.le_cmd_start, SIGNAL(textEdited (QString )), this,SLOT(set_cmd_start(QString))); - connect(ui.le_cmd_stop, SIGNAL(textEdited ( QString )), this,SLOT(set_cmd_stop(QString))); - connect(ui.le_cmd_init, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_init(QString))); - connect(ui.le_cmd_reset, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_reset(QString))); - connect(ui.le_cmd_center, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_center(QString))); - connect(ui.le_cmd_zero, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_zero(QString))); - - connect(ui.spb_BeforeInit, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayInit(int))); - connect(ui.spb_BeforeStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayStart(int))); - connect(ui.spb_AfterStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelaySeq(int))); - - connect( ui.cb_Endian,SIGNAL(toggled(bool)), this,SLOT(set_endian(bool)) ); - - - connect(ui.QCB_Serial_baudRate, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_baud(int)) ); - connect(ui.QCB_Serial_dataBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_dataBits(int)) ); - connect(ui.QCB_Serial_parity, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_parity(int)) ); - connect(ui.QCB_Serial_stopBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_stopBits(int)) ); - connect(ui.QCB_Serial_flowControl, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_flowControl(int)) ); - connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset())); connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter())); connect(ui.btnZero, SIGNAL(clicked()), this, SLOT(doZero())); @@ -196,7 +144,6 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim connect(ui.btn_icone, SIGNAL(clicked()), this, SLOT(doSerialInfo())); connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - } // @@ -217,16 +164,6 @@ void TrackerControls::Initialize(QWidget *parent) { } -// -// Apply online settings to tracker -// -void TrackerControls::settings_changed() -{ - settingsDirty = true; - if (theTracker) theTracker->applysettings(settings); -} - - // // Center asked to ARDUINO // @@ -299,8 +236,9 @@ void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo) void TrackerControls::doSave() { - settingsDirty=false; - settings.save_ini(); + settings.b->save(); + if (theTracker) + theTracker->applysettings(settings); } @@ -308,8 +246,9 @@ void TrackerControls::doSave() { // OK clicked on server-dialog // void TrackerControls::doOK() { - settingsDirty=false; - settings.save_ini(); + settings.b->save(); + if (theTracker) + theTracker->applysettings(settings); this->close(); } @@ -320,14 +259,15 @@ void TrackerControls::doCancel() { // // Ask if changed Settings should be saved // - 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 ); + if (settings.b->modifiedp()) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); switch (ret) { case QMessageBox::Save: - settings.save_ini(); + settings.b->save(); close(); break; case QMessageBox::Discard: + settings.b->revert(); close(); break; case QMessageBox::Cancel: @@ -348,7 +288,7 @@ void TrackerControls::registerTracker(ITracker *tracker) { theTracker = static_cast(tracker); connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray))); - if (isVisible() && settingsDirty) theTracker->applysettings(settings); + if (isVisible() && settings.b->modifiedp()) theTracker->applysettings(settings); ui.cbSerialPort->setEnabled(false); ui.pteINFO->clear(); @@ -367,16 +307,6 @@ void TrackerControls::unRegisterTracker() { ui.lab_vtps->setText(""); } - - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. #ifdef OPENTRACK_API extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) #else diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h index e413ded6..82c69e0d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -25,7 +25,6 @@ public: void Initialize(QWidget *parent) virt_override; void registerTracker(ITracker *tracker) virt_override; void unRegisterTracker() virt_override; - private: Ui::UIHATControls ui; FTNoIR_Tracker *theTracker; @@ -35,49 +34,7 @@ public slots: void WriteMsgInfo(const QByteArray &MsgInfo); protected slots: - void set_mod_port(const QString & val) { settings.SerialPortName =val; settings_changed(); } - void set_ena_roll(bool val) { settings.EnableRoll = val; settings_changed(); } - void set_ena_pitch(bool val) { settings.EnablePitch = val; settings_changed(); } - void set_ena_yaw(bool val) { settings.EnableYaw = val; settings_changed(); } - void set_ena_x(bool val) { settings.EnableX = val; settings_changed(); } - void set_ena_y(bool val) { settings.EnableY = val; settings_changed(); } - void set_ena_z(bool val) { settings.EnableZ = val; settings_changed(); } - - void set_inv_roll(bool val) { settings.InvertRoll = val; settings_changed(); } - void set_inv_pitch(bool val) { settings.InvertPitch = val; settings_changed(); } - void set_inv_yaw(bool val) { settings.InvertYaw = val; settings_changed(); } - void set_inv_x(bool val) { settings.InvertX = val; settings_changed(); } - void set_inv_y(bool val) { settings.InvertY = val; settings_changed(); } - void set_inv_z(bool val) { settings.InvertZ = val; settings_changed(); } - - - void set_rot_roll(int val) { settings.RollAxe = val; settings_changed(); } - void set_rot_pitch(int val) { settings.PitchAxe = val; settings_changed(); } - void set_rot_yaw(int val) { settings.YawAxe = val; settings_changed(); } - void set_acc_x(int val) { settings.XAxe = val; settings_changed(); } - void set_acc_y(int val) { settings.YAxe = val; settings_changed(); } - void set_acc_z(int val) { settings.ZAxe = val; settings_changed(); } - - void set_cmd_start(const QString &val) { settings.CmdStart = val; settings_changed(); } - void set_cmd_stop(const QString &val) { settings.CmdStop = val; settings_changed(); } - void set_cmd_init(const QString &val) { settings.CmdInit = val; settings_changed(); } - void set_cmd_reset(const QString &val) { settings.CmdReset = val; settings_changed(); } - void set_cmd_center(const QString &val) { settings.CmdCenter = val; settings_changed(); } - void set_cmd_zero(const QString &val) { settings.CmdZero = val; settings_changed(); } - - void set_DelayInit(int val) { settings.DelayInit = val; settings_changed(); } - void set_DelayStart(int val) { settings.DelayStart = val; settings_changed(); } - void set_DelaySeq(int val) { settings.DelaySeq = val; settings_changed(); } - - void set_endian(bool val) { settings.BigEndian = val; settings_changed(); } - - void set_mod_baud(int val) { settings.pBaudRate = static_cast(ui.QCB_Serial_baudRate->itemData(val).toInt()) ; settings_changed(); } - void set_mod_dataBits(int val) { settings.pDataBits = static_cast(ui.QCB_Serial_dataBits->itemData(val).toInt()) ; settings_changed(); } - void set_mod_parity(int val) { settings.pParity = static_cast(ui.QCB_Serial_parity->itemData(val).toInt()) ; settings_changed(); } - void set_mod_stopBits(int val) { settings.pStopBits = static_cast(ui.QCB_Serial_stopBits->itemData(val).toInt()); settings_changed(); } - void set_mod_flowControl(int val) { settings.pFlowControl = static_cast(ui.QCB_Serial_flowControl->itemData(val).toInt()) ; settings_changed(); } - - void doOK(); + void doOK(); void doCancel(); void doSave(); void doReset(); @@ -88,8 +45,6 @@ protected slots: void doSerialInfo(); protected: - bool settingsDirty; - void settings_changed(); TrackerSettings settings; QTimer timer; }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp deleted file mode 100644 index 0be912f2..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) * -* Homepage: http://hatire.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include -#include -#include - -#include "ftnoir_tracker_hat_settings.h" - -void TrackerSettings::load_ini() -{ - 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) - - iniFile.beginGroup( "HAT" ); - - SerialPortName=iniFile.value ( "PortName" ).toString(); - - EnableRoll = iniFile.value( "EnableRoll", 1 ).toBool(); - EnablePitch = iniFile.value( "EnablePitch", 1 ).toBool(); - EnableYaw = iniFile.value( "EnableYaw", 1 ).toBool(); - EnableX = iniFile.value( "EnableX", 0 ).toBool(); - EnableY = iniFile.value( "EnableY", 0 ).toBool(); - EnableZ = iniFile.value( "EnableZ", 0 ).toBool(); - - - InvertRoll = iniFile.value( "InvertRoll", 1 ).toBool(); - InvertPitch = iniFile.value( "InvertPitch", 1 ).toBool(); - InvertYaw = iniFile.value( "InvertYaw", 1 ).toBool(); - InvertX = iniFile.value( "InvertX", 0 ).toBool(); - InvertY = iniFile.value( "InvertY", 0 ).toBool(); - InvertZ = iniFile.value( "InvertZ", 0 ).toBool(); - - - RollAxe=iniFile.value("RollAxe",1).toInt(); - PitchAxe=iniFile.value("PitchAxe",2).toInt(); - YawAxe=iniFile.value("YawAxe",0).toInt(); - XAxe=iniFile.value("XAxe",1).toInt(); - YAxe=iniFile.value("YAxe",2).toInt(); - ZAxe=iniFile.value("ZAxe",0).toInt(); - - - CmdStart=iniFile.value ( "CmdStart").toString(); - CmdStop=iniFile.value ( "CmdStop" ).toString(); - CmdInit=iniFile.value ( "CmdInit" ).toString(); - CmdReset=iniFile.value ( "CmdReset" ).toString(); - CmdCenter=iniFile.value ( "CmdCenter" ).toString(); - CmdZero=iniFile.value ( "CmdZero" ).toString(); - - DelayInit=iniFile.value("DelayInit",0).toInt(); - DelayStart=iniFile.value("DelayStart",0).toInt(); - DelaySeq=iniFile.value("DelaySeq",0).toInt(); - - BigEndian=iniFile.value("BigEndian",0).toBool(); - - - pBaudRate=static_cast(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt()); - pDataBits=static_cast(iniFile.value("DataBits",QSerialPort::Data8).toInt()); - pParity=static_cast(iniFile.value("Parity",QSerialPort::NoParity).toInt()); - pStopBits=static_cast(iniFile.value("StopBits",QSerialPort::OneStop).toInt()); - pFlowControl=static_cast(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt()); - - iniFile.endGroup(); -} - - -void TrackerSettings::save_ini() const -{ - - 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) - - iniFile.beginGroup ( "HAT" ); - - iniFile.setValue ( "PortName",SerialPortName ); - - iniFile.setValue( "EnableRoll", EnableRoll ); - iniFile.setValue( "EnablePitch", EnablePitch ); - iniFile.setValue( "EnableYaw", EnableYaw ); - iniFile.setValue( "EnableX", EnableX ); - iniFile.setValue( "EnableY", EnableY ); - iniFile.setValue( "EnableZ", EnableZ ); - - iniFile.setValue( "InvertRoll", InvertRoll ); - iniFile.setValue( "InvertPitch", InvertPitch ); - iniFile.setValue( "InvertYaw", InvertYaw ); - iniFile.setValue( "InvertX", InvertX ); - iniFile.setValue( "InvertY", InvertY ); - iniFile.setValue( "InvertZ", InvertZ ); - - iniFile.setValue ( "RollAxe", RollAxe ); - iniFile.setValue ( "PitchAxe", PitchAxe ); - iniFile.setValue ( "YawAxe",YawAxe ); - iniFile.setValue ( "XAxe", XAxe ); - iniFile.setValue ( "YAxe", YAxe ); - iniFile.setValue ( "ZAxe", ZAxe ); - - iniFile.setValue ( "CmdStart",CmdStart.toLatin1()); - iniFile.setValue ( "CmdStop",CmdStop.toLatin1()); - iniFile.setValue ( "CmdInit",CmdInit.toLatin1()); - iniFile.setValue ( "CmdReset",CmdReset.toLatin1()); - iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() ); - iniFile.setValue ( "CmdZero",CmdZero.toLatin1() ); - - iniFile.setValue ( "DelayInit",DelayInit); - iniFile.setValue ( "DelayStart",DelayStart); - iniFile.setValue ( "DelaySeq",DelaySeq); - - iniFile.setValue("BigEndian",BigEndian); - - iniFile.setValue("BaudRate",pBaudRate); - iniFile.setValue("DataBits",pDataBits); - iniFile.setValue("Parity",pParity); - iniFile.setValue("StopBits",pStopBits); - iniFile.setValue("FlowControl",pFlowControl); - - - iniFile.endGroup(); -} - diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h index 2e84bde8..8739394f 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -5,61 +5,81 @@ * copyright notice and this permission notice appear in all copies. */ -#ifndef FTNOIR_TRACKER_HAT_SETTINGS_H -#define FTNOIR_TRACKER_HAT_SETTINGS_H +#pragma once #include +#include "facetracknoir/options.hpp" +#include +using namespace options; -//----------------------------------------------------------------------------- struct TrackerSettings { - - void load_ini(); - void save_ini() const; - - bool EnableRoll; - bool EnablePitch; - bool EnableYaw; - bool EnableX; - bool EnableY; - bool EnableZ; - - bool InvertRoll; - bool InvertPitch; - bool InvertYaw; - bool InvertX; - bool InvertY; - bool InvertZ; - - - int RollAxe; - int PitchAxe; - int YawAxe; - int XAxe; - int YAxe; - int ZAxe; - - QString CmdStart; - QString CmdStop; - QString CmdInit; - QString CmdReset; - QString CmdCenter; - QString CmdZero; - - int DelayInit; - int DelayStart; - int DelaySeq; - - bool BigEndian; - - QString SerialPortName; - QSerialPort::BaudRate pBaudRate; - QSerialPort::DataBits pDataBits; - QSerialPort::Parity pParity; - QSerialPort::StopBits pStopBits; - QSerialPort::FlowControl pFlowControl; - + pbundle b; + value EnableRoll, + EnablePitch, + EnableYaw, + EnableX, + EnableY, + EnableZ, + InvertRoll, + InvertPitch, + InvertYaw, + InvertX, + InvertY, + InvertZ; + value RollAxe, + PitchAxe, + YawAxe, + XAxe, + YAxe, + ZAxe; + value BigEndian; + value CmdStart, + CmdStop, + CmdInit, + CmdReset, + CmdCenter, + CmdZero; + value SerialPortName, DelayInit, DelayStart, DelaySeq; + // unfortunately, no way to distinguish this and enum type + // hence, string type used -sh + value pBaudRate, pDataBits, pParity, pStopBits, pFlowControl; + TrackerSettings() : + b(bundle("HAT")), + EnableRoll(b, "EnableRoll", true), + EnablePitch(b, "EnablePitch", true), + EnableYaw(b, "EnableYaw", true), + EnableX(b, "EnableX", true), + EnableY(b, "EnableY", true), + EnableZ(b, "EnableZ", true), + InvertRoll(b, "InvertRoll", false), + InvertPitch(b, "InvertPitch", false), + InvertYaw(b, "InvertYaw", false), + InvertX(b, "InvertX", false), + InvertY(b, "InvertY", false), + InvertZ(b, "InvertZ", false), + RollAxe(b, "RollAe", 2), + PitchAxe(b, "PitchAxe", 1), + YawAxe(b, "YawAxe", 0), + XAxe(b, "XAxe", 0), + YAxe(b, "YAxe", 1), + ZAxe(b, "ZAxe", 2), + BigEndian(b, "BigEndian", false), + CmdStart(b, "CmdStart", ""), + CmdStop(b, "CmdStop", ""), + CmdInit(b, "CmdInit", ""), + CmdReset(b, "CmdReset", ""), + CmdCenter(b, "CmdCenter", ""), + CmdZero(b, "CmdZero", ""), + SerialPortName(b, "PortName", 0), + DelayInit(b, "DelayInit", 0), + DelayStart(b, "DelayStart", 0), + DelaySeq(b, "DelaySeq", 0), + pBaudRate(b, "BaudRate", 0), + pDataBits(b, "DataBits", 0), + pParity(b, "Parity", 0), + pStopBits(b, "StopBits", 0), + pFlowControl(b, "FlowControl", 0) + { + } }; - - -#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file -- cgit v1.2.3 From 9bc97c68bdc64bc4d5735a377b41cf0d697a7824 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:56:52 +0100 Subject: resize hatire dialog not to look cramped on Linux --- ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 116 ++++++++++++++-------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui index 4446ca85..8a6bae62 100644 --- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui +++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui @@ -7,7 +7,7 @@ 0 0 307 - 509 + 567 @@ -126,47 +126,47 @@ 4 - - + + - + 0 0 - 65536 + 65535 16777215 - - Serial port + + false + + + QComboBox::AdjustToMinimumContentsLength + + + 0 - - + + - + 0 0 - 65535 + 65536 16777215 - - false - - - QComboBox::AdjustToMinimumContentsLength - - - 0 + + Serial port @@ -1030,45 +1030,6 @@ p, li { white-space: pre-wrap; } About - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;">FTNoIR HAT Plugin<br />by FuraX49</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://hatire.sourceforge.net/"><span style=" font-size:8pt; font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> - - - true - - - - - - - false - - - - - - - :/images/hat_logo.png - - - - - 128 - 128 - - - - true - - - @@ -1123,6 +1084,45 @@ p, li { white-space: pre-wrap; } + + + + false + + + + + + + :/images/hat_logo.png + + + + + 128 + 128 + + + + true + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;">FTNoIR HAT Plugin<br />by FuraX49</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://hatire.sourceforge.net/"><span style=" font-size:8pt; font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> + + + true + + + -- cgit v1.2.3 From a54f8dede2cc679d0ef2fe30369cf3764ad3ab54 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:58:09 +0100 Subject: hatire: don't hardcode stuff in lookup tables --- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index dc4b2879..3547dd6b 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -262,11 +262,11 @@ void FTNoIR_Tracker::StopTracker( bool exit ) void FTNoIR_Tracker::StartTracker(QFrame*) { static const int databits_lookup[] = { - 5, - 6, - 7, - 8, - -1 + QSerialPort::Data5, + QSerialPort::Data6, + QSerialPort::Data7, + QSerialPort::Data8, + QSerialPort::UnknownDataBits }; struct Local { -- cgit v1.2.3 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 ++------------- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 44 ++++---- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 115 +++------------------ 3 files changed, 42 insertions(+), 198 deletions(-) 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; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 3920c6ad..eadf5fa5 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -8,6 +8,25 @@ #include "facetracknoir/global-settings.h" #include "OVR.h" #include +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring; + value constant_drift, persistence, deadzone; + settings() : + b(bundle("Rift")), + bEnableYaw(b, "EnableYaw", true), + bEnablePitch(b, "EnablePitch", true), + bEnableRoll(b, "EnableRoll", true), + useYawSpring(b, "yaw-spring", false), + constant_drift(b, "constant-drift", 0.000005), + persistence(b, "persistence", 0.99999), + deadzone(b, "deadzone", 0.02) + {} +}; + class Rift_Tracker : public ITracker { public: @@ -16,7 +35,6 @@ public: void StartTracker(QFrame *) virt_override; void GetHeadPoseData(double *data) virt_override; - void loadSettings(); virtual int preferredHz() virt_override { return 250; } volatile bool should_quit; protected: @@ -27,16 +45,8 @@ private: OVR::DeviceManager* pManager; OVR::SensorDevice* pSensor; OVR::SensorFusion* pSFusion; - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; -#if 0 - bool bEnableX; - bool bEnableY; - bool bEnableZ; -#endif - bool useYawSpring; - double old_yaw, constant_drift, persistence, deadzone; + settings s; + double old_yaw; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -44,10 +54,7 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - ~TrackerControls(); - void showEvent (QShowEvent *); void Initialize(QWidget *parent); void registerTracker(ITracker *) {} @@ -55,17 +62,10 @@ public: private: Ui::UIRiftControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } }; //******************************************************************************************************* diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 2efefbb3..5d3b30c1 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -17,28 +17,16 @@ QWidget() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -#if 0 - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -#endif - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); + + tie_setting(s.constant_drift, ui.constantDrift); + tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.persistence, ui.persistence); + tie_setting(s.useYawSpring, ui.yawSpring); } -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(100, 100); @@ -52,15 +40,10 @@ void TrackerControls::Initialize(QWidget *parent) { // OK clicked on server-dialog // void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } -// override show event -void TrackerControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - // // Cancel clicked on server-dialog // @@ -68,24 +51,19 @@ void TrackerControls::doCancel() { // // Ask if changed Settings should be saved // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - + 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); 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; } } @@ -94,73 +72,6 @@ void TrackerControls::doCancel() { } } - -// -// Load the current Settings from the currently 'active' INI-file. -// -void TrackerControls::loadSettings() { - -// qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Rift" ); - ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); - ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); - ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); -#if 0 - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); -#endif - ui.yawSpring->setChecked(iniFile.value("yaw-spring", true).toBool()); - ui.deadzone->setValue(iniFile.value("deadzone", 0.02).toDouble()); - ui.constantDrift->setValue(iniFile.value("constant-drift", 0.000005).toDouble()); - ui.persistence->setValue(iniFile.value("persistence", 0.9999).toDouble()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::save() { - 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) - - iniFile.beginGroup ( "Rift" ); - iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); - iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); - iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); -#if 0 - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); -#endif - iniFile.setValue("yaw-spring", ui.yawSpring->isChecked()); - iniFile.setValue("deadzone", ui.deadzone->value()); - iniFile.setValue("constant-drift", ui.constantDrift->value()); - iniFile.setValue("persistence", ui.persistence->value()); - iniFile.endGroup (); - - settingsDirty = false; -} -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) { return new TrackerControls; -- cgit v1.2.3 From 6adbfba397237340a2db9d1b0b4c7726cc5df94c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 13:30:12 +0100 Subject: rift: remove captain obvious comments --- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 4 ---- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 13 ------------- ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp | 9 --------- 3 files changed, 26 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index eadf5fa5..80bf6ffa 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -49,7 +49,6 @@ private: double old_yaw; }; -// Widget that has controls for FTNoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT @@ -68,9 +67,6 @@ private slots: void doCancel(); }; -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* class FTNoIR_TrackerDll : public Metadata { public: diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 5d3b30c1..5487da92 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -1,13 +1,6 @@ #include "ftnoir_tracker_rift.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// TrackerControls::TrackerControls() : QWidget() { @@ -36,17 +29,11 @@ void TrackerControls::Initialize(QWidget *parent) { show(); } -// -// OK clicked on server-dialog -// void TrackerControls::doOK() { s.b->save(); this->close(); } -// -// Cancel clicked on server-dialog -// void TrackerControls::doCancel() { // // Ask if changed Settings should be saved diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp index 3423ba05..2b24411c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp @@ -35,15 +35,6 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/rift_tiny.png"); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_TrackerDll; -- cgit v1.2.3 From b7eb4245fe6dc261a926d31331b2af3fec959401 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 15:40:24 +0100 Subject: pt: use new settings framework, cleanup --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 214 ++++++--------- FTNoIR_Tracker_PT/camera.h | 12 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 155 ++++------- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 36 +-- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 318 +++++++++-------------- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 69 +---- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 156 ----------- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 137 +++++----- 8 files changed, 338 insertions(+), 759 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 9ad4f83c..6cd17e8d 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -9,7 +9,7 @@ 0 0 - 458 + 459 590 @@ -69,11 +69,39 @@ - + + + + + + Time until automatic reset of tracker's internal state when no valid tracking result is found + + + 9999 + + + + + + + ms + + + + + + + + + + + + + Dynamic Pose Resolution @@ -89,30 +117,6 @@ - - - - - - Time the tracker thread sleeps after each processed frame - - - - - - 9999 - - - - - - - ms - - - - - @@ -123,12 +127,15 @@ - - + + - + - Time until automatic reset of tracker's internal state when no valid tracking result is found + Time the tracker thread sleeps after each processed frame + + + 9999 @@ -136,7 +143,7 @@ - + ms @@ -144,43 +151,7 @@ - - - - Whether to update the content of the VideoWidget - - - Show VideoWidget - - - - - - - Qt::Horizontal - - - - 30 - 20 - - - - - - - - Qt::Horizontal - - - - 30 - 20 - - - - - + false @@ -635,40 +606,7 @@ - - - - - false - - - - 130 - 0 - - - - - - - VideoWidget - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - + @@ -848,38 +786,36 @@ - - - - - - - Hysteresis - - - threshold_secondary_slider - - - - - - - Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) - - - 255 - - - 100 - - - Qt::Horizontal - - - - - - + + + + + + Hysteresis + + + threshold_secondary_slider + + + + + + + Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) + + + 255 + + + 100 + + + Qt::Horizontal + + + + + @@ -1777,6 +1713,13 @@ + + + + Apply + + + @@ -1816,11 +1759,8 @@ tabWidget - videowidget_check sleep_spin - dynpose_check reset_spin - reset_button chkEnableRoll chkEnablePitch chkEnableYaw diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h index 78fe8dfb..ea68c387 100644 --- a/FTNoIR_Tracker_PT/camera.h +++ b/FTNoIR_Tracker_PT/camera.h @@ -69,13 +69,13 @@ protected: virtual void _set_fps() = 0; virtual void _set_res() = 0; - bool active; + float dt_valid; + float dt_mean; int desired_index; int active_index; + bool active; CamInfo cam_info; CamInfo cam_desired; - float dt_valid; - float dt_mean; }; @@ -128,9 +128,9 @@ protected: enum RotationType { - CLOCKWISE = -1, - ZERO = 0, - COUNTER_CLOCKWISE = 1 + CLOCKWISE = 0, + ZERO = 1, + COUNTER_CLOCKWISE = 2 }; // ---------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index e3af446f..25a19ee7 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -23,8 +23,7 @@ const float deg2rad = 1.0/rad2deg; //----------------------------------------------------------------------------- Tracker::Tracker() - : frame_count(0), - commands(0), + : commands(0), video_widget(NULL), video_frame(NULL), tracking_valid(false) @@ -38,9 +37,10 @@ Tracker::~Tracker() // terminate tracker thread set_command(ABORT); wait(); - // destroy video widget - show_video_widget = false; - update_show_video_widget(); + s.video_widget = false; + delete video_widget; + video_widget = NULL; + if (video_frame->layout()) delete video_frame->layout(); } void Tracker::set_command(Command command) @@ -86,10 +86,7 @@ void Tracker::run() frame = frame_rotation.rotate_frame(frame); const std::vector& points = point_extractor.extract_points(frame, dt, has_observers()); tracking_valid = point_tracker.track(points, camera.get_info().f, dt); - frame_count++; -#ifdef OPENTRACK_API video_widget->update_image(frame.clone()); -#endif } #ifdef PT_PERF_LOG log_stream<<"dt: "<(settings.cam_roll); - point_extractor.threshold_val = settings.threshold; - point_extractor.threshold_secondary_val = settings.threshold_secondary; - point_extractor.min_size = settings.min_point_size; - point_extractor.max_size = settings.max_point_size; - point_tracker.point_model = boost::shared_ptr(new PointModel(settings.M01, settings.M02)); - point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; - sleep_time = settings.sleep_time; - point_tracker.dt_reset = settings.reset_time / 1000.0; - show_video_widget = settings.video_widget; - update_show_video_widget(); - bEnableRoll = settings.bEnableRoll; - bEnablePitch = settings.bEnablePitch; - bEnableYaw = settings.bEnableYaw; - bEnableX = settings.bEnableX; - bEnableY = settings.bEnableY; - bEnableZ = settings.bEnableZ; - - t_MH = settings.t_MH; - R_GC = Matx33f( cos(deg2rad*settings.cam_yaw), 0, sin(deg2rad*settings.cam_yaw), + camera.set_device_index(s.cam_index); + camera.set_res(s.cam_res_x, s.cam_res_y); + camera.set_fps(s.cam_fps); + camera.set_f(s.cam_f); + frame_rotation.rotation = static_cast(static_cast(s.cam_roll)); + point_extractor.threshold_val = s.threshold; + point_extractor.threshold_secondary_val = s.threshold_secondary; + point_extractor.min_size = s.min_point_size; + point_extractor.max_size = s.max_point_size; + { + cv::Vec3f M01(s.m01_x, s.m01_y, s.m01_z); + cv::Vec3f M02(s.m02_x, s.m02_y, s.m02_z); + point_tracker.point_model = boost::shared_ptr(new PointModel(M01, M02)); + } + point_tracker.dynamic_pose_resolution = s.dyn_pose_res; + point_tracker.dt_reset = s.reset_time / 1000.0; + t_MH = cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z); + R_GC = Matx33f( cos(deg2rad*s.cam_yaw), 0, sin(deg2rad*s.cam_yaw), 0, 1, 0, - -sin(deg2rad*settings.cam_yaw), 0, cos(deg2rad*settings.cam_yaw)); + -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw)); R_GC = R_GC * Matx33f( 1, 0, 0, - 0, cos(deg2rad*settings.cam_pitch), sin(deg2rad*settings.cam_pitch), - 0, -sin(deg2rad*settings.cam_pitch), cos(deg2rad*settings.cam_pitch)); + 0, cos(deg2rad*s.cam_pitch), sin(deg2rad*s.cam_pitch), + 0, -sin(deg2rad*s.cam_pitch), cos(deg2rad*s.cam_pitch)); FrameTrafo X_MH(Matx33f::eye(), t_MH); X_GH_0 = R_GC * X_MH; @@ -169,58 +160,27 @@ bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std:: return true; } -void Tracker::update_show_video_widget() -{ - if (!show_video_widget && video_widget) { - delete video_widget; - video_widget = NULL; - if (video_frame->layout()) delete video_frame->layout(); - } - else if (video_frame && show_video_widget && !video_widget) - { - const int VIDEO_FRAME_WIDTH = 320; - const int VIDEO_FRAME_HEIGHT = 240; - video_widget = new PTVideoWidget(video_frame, this); - QHBoxLayout* video_layout = new QHBoxLayout(); - video_layout->setContentsMargins(0, 0, 0, 0); - video_layout->addWidget(video_widget); - video_frame->setLayout(video_layout); - video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); - } -} - -//----------------------------------------------------------------------------- -// ITracker interface -void Tracker::Initialize(QFrame *video_frame) -{ - qDebug("Tracker::Initialize"); - // setup video frame - this->video_frame = video_frame; - video_frame->setAttribute(Qt::WA_NativeWindow); - video_frame->show(); - update_show_video_widget(); - TrackerSettings settings; - settings.load_ini(); - camera.start(); - apply(settings); - start(); -} - void Tracker::refreshVideo() { if (video_widget) video_widget->update_frame_and_points(); } -#ifdef OPENTRACK_API void Tracker::StartTracker(QFrame *parent_window) -#else -void Tracker::StartTracker(HWND parent_window) -#endif { -#ifdef OPENTRACK_API - Initialize(parent_window); -#endif - reset_command(PAUSE); + this->video_frame = parent_window; + video_frame->setAttribute(Qt::WA_NativeWindow); + video_frame->show(); + apply(s); + video_widget = new PTVideoWidget(video_frame, this); + QHBoxLayout* video_layout = new QHBoxLayout(parent_window); + video_layout->setContentsMargins(0, 0, 0, 0); + video_layout->addWidget(video_widget); + video_frame->setLayout(video_layout); + video_widget->resize(video_frame->width(), video_frame->height()); + start(); + camera.start(); + start(); + reset_command(PAUSE); } #ifndef OPENTRACK_API @@ -247,18 +207,12 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) Matx33f R = X_GH.R * X_GH_0.R.t(); Vec3f t = X_GH.t - X_GH_0.t; -#ifndef OPENTRACK_API - // get translation(s) - if (bEnableX) data->x = t[0] / 10.0; // convert to cm - if (bEnableY) data->y = t[1] / 10.0; - if (bEnableZ) data->z = t[2] / 10.0; -#else // get translation(s) - if (bEnableX) data[TX] = t[0] / 10.0; // convert to cm - if (bEnableY) data[TY] = t[1] / 10.0; - if (bEnableZ) data[TZ] = t[2] / 10.0; -#endif - // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame + if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm + if (s.bEnableY) data[TY] = t[1] / 10.0; + if (s.bEnableZ) data[TZ] = t[2] / 10.0; + + // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame // -z -> x, y -> z, x -> -y Matx33f R_EG( 0, 0,-1, -1, 0, 0, @@ -271,19 +225,10 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) alpha = atan2( R(1,0), R(0,0)); gamma = atan2( R(2,1), R(2,2)); -#ifndef OPENTRACK_API - if (bEnableYaw) data->yaw = rad2deg * alpha; - if (bEnablePitch) data->pitch = - rad2deg * beta; // FTNoIR expects a minus here - if (bEnableRoll) data->roll = rad2deg * gamma; -#else - if (bEnableYaw) data[Yaw] = rad2deg * alpha; - if (bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here - if (bEnableRoll) data[Roll] = rad2deg * gamma; -#endif + if (s.bEnableYaw) data[Yaw] = rad2deg * alpha; + if (s.bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here + if (s.bEnableRoll) data[Roll] = rad2deg * gamma; } -#ifndef OPENTRACK_API - return true; -#endif } //----------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 54edafb2..c7f1dc02 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -39,20 +39,11 @@ class Tracker : public ITracker, QThread, public FrameProvider public: Tracker(); virtual ~Tracker(); - - // --- ITracker interface --- - virtual void Initialize(QFrame *videoframe); -#ifdef OPENTRACK_API virtual void StartTracker(QFrame* parent_window); virtual void GetHeadPoseData(double* data); -#else - virtual void StartTracker(HWND parent_window); - virtual void StopTracker(bool exit); - virtual bool GetHeadPoseData(THeadPoseData *data); -#endif virtual void refreshVideo(); - void apply(const TrackerSettings& settings); + void apply(settings& s); void center(); void reset(); // reset the trackers internal state variables void run(); @@ -74,20 +65,12 @@ protected: }; void set_command(Command command); void reset_command(Command command); - int commands; - - int sleep_time; + int commands; - // --- tracking chain --- -#ifdef OPENTRACK_API CVCamera camera; -#else - VICamera camera; -#endif FrameRotation frame_rotation; PointExtractor point_extractor; PointTracker point_tracker; - bool tracking_valid; FrameTrafo X_GH_0; // for centering cv::Vec3f t_MH; // translation from model frame to head frame @@ -96,22 +79,11 @@ protected: // --- ui --- cv::Mat frame; // the output frame for display - void update_show_video_widget(); - bool show_video_widget; -#ifdef OPENTRACK_API PTVideoWidget* video_widget; -#endif QFrame* video_frame; + bool tracking_valid; - // --- misc --- - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - long frame_count; + settings s; Timer time; }; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index f8afa790..a88e3a07 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -21,8 +21,7 @@ using namespace std; //----------------------------------------------------------------------------- TrackerDialog::TrackerDialog() - : settings_dirty(false), - tracker(NULL), + : tracker(NULL), video_widget_dialog(NULL), timer(this), trans_calib_running(false) @@ -32,191 +31,112 @@ TrackerDialog::TrackerDialog() ui.setupUi( this ); - settings.load_ini(); - dialog_settings.load_ini(); - - // initialize ui values - ui.videowidget_check->setChecked(settings.video_widget); - ui.dynpose_check->setChecked(settings.dyn_pose_res); - ui.sleep_spin->setValue(settings.sleep_time); - ui.reset_spin->setValue(settings.reset_time); - - vector device_names; + vector device_names; get_camera_device_names(device_names); for (vector::iterator iter = device_names.begin(); iter != device_names.end(); ++iter) { ui.camdevice_combo->addItem(iter->c_str()); } - ui.camdevice_combo->setCurrentIndex(settings.cam_index); - - ui.f_dspin->setValue(settings.cam_f); - ui.res_x_spin->setValue(settings.cam_res_x); - ui.res_y_spin->setValue(settings.cam_res_y); - ui.fps_spin->setValue(settings.cam_fps); - - ui.camroll_combo->addItem("-90", -1); - ui.camroll_combo->addItem("0" , 0); - ui.camroll_combo->addItem("90" , 1); - int i = ui.camroll_combo->findData(settings.cam_roll); - ui.camroll_combo->setCurrentIndex(i>=0 ? i : 0); - - ui.campitch_spin->setValue(settings.cam_pitch); - ui.camyaw_spin->setValue(settings.cam_yaw); - ui.threshold_slider->setValue(settings.threshold); - ui.threshold_secondary_slider->setValue(settings.threshold_secondary); - - ui.chkEnableRoll->setChecked(settings.bEnableRoll); - ui.chkEnablePitch->setChecked(settings.bEnablePitch); - ui.chkEnableYaw->setChecked(settings.bEnableYaw); - ui.chkEnableX->setChecked(settings.bEnableX); - ui.chkEnableY->setChecked(settings.bEnableY); - ui.chkEnableZ->setChecked(settings.bEnableZ); - - ui.mindiam_spin->setValue(settings.min_point_size); - ui.maxdiam_spin->setValue(settings.max_point_size); - ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel); - ui.clip_bheight_spin->setValue(dialog_settings.clip_by); - ui.clip_blength_spin->setValue(dialog_settings.clip_bz); - ui.clip_theight_spin->setValue(dialog_settings.clip_ty); - ui.clip_tlength_spin->setValue(dialog_settings.clip_tz); - ui.cap_width_spin->setValue(dialog_settings.cap_x); - ui.cap_height_spin->setValue(dialog_settings.cap_y); - ui.cap_length_spin->setValue(dialog_settings.cap_z); - ui.m1x_spin->setValue(dialog_settings.M01x); - ui.m1y_spin->setValue(dialog_settings.M01y); - ui.m1z_spin->setValue(dialog_settings.M01z); - ui.m2x_spin->setValue(dialog_settings.M02x); - ui.m2y_spin->setValue(dialog_settings.M02y); - ui.m2z_spin->setValue(dialog_settings.M02z); - ui.tx_spin->setValue(settings.t_MH[0]); - ui.ty_spin->setValue(settings.t_MH[1]); - ui.tz_spin->setValue(settings.t_MH[2]); - - // connect Qt signals and slots - connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) ); - connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(bool)) ); - connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) ); - connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) ); - connect( ui.camdevice_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_index(int)) ); - connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) ); - connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) ); - connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) ); - connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) ); - connect( ui.camroll_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_roll(int)) ); - connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); - connect( ui.camyaw_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_yaw(int)) ); - connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); - connect( ui.threshold_secondary_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold_secondary(int)) ); - - connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); - connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); - connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); - connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); - connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); - connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); - - connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) ); - connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) ); - connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) ); - connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) ); - connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) ); - connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) ); - connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) ); - connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) ); - connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) ); - connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) ); - connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) ); - connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) ); - connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) ); - connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) ); - connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) ); - connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) ); - connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) ); - connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) ); - connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) ); - - connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); - - connect( ui.videowidget_button,SIGNAL(clicked()), this,SLOT(create_video_widget()) ); - - connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); - //connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter())); - - connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); - - connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - timer.start(100); -} -TrackerDialog::~TrackerDialog() -{ - qDebug()<<"TrackerDialog::~TrackerDialog"; -} + ui.camroll_combo->addItem("-90"); + ui.camroll_combo->addItem("0"); + ui.camroll_combo->addItem("90"); -void TrackerDialog::set_cam_roll(int idx) -{ - settings.cam_roll = ui.camroll_combo->itemData(idx).toInt(); - settings_changed(); + tie_setting(s.dyn_pose_res, ui.dynpose_check); + tie_setting(s.sleep_time, ui.sleep_spin); + tie_setting(s.reset_time, ui.reset_spin); + + tie_setting(s.cam_index, ui.camdevice_combo); + tie_setting(s.cam_f, ui.f_dspin); + tie_setting(s.cam_res_x, ui.res_x_spin); + tie_setting(s.cam_res_y, ui.res_y_spin); + tie_setting(s.cam_fps, ui.fps_spin); + tie_setting(s.cam_roll, ui.camroll_combo); + tie_setting(s.cam_pitch, ui.campitch_spin); + tie_setting(s.cam_yaw, ui.camyaw_spin); + + tie_setting(s.threshold_secondary, ui.threshold_secondary_slider); + tie_setting(s.threshold, ui.threshold_slider); + + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); + tie_setting(s.bEnableX, ui.chkEnableX); + tie_setting(s.bEnableY, ui.chkEnableY); + tie_setting(s.bEnableZ, ui.chkEnableZ); + + tie_setting(s.min_point_size, ui.mindiam_spin); + tie_setting(s.max_point_size, ui.maxdiam_spin); + + tie_setting(s.clip_by, ui.clip_bheight_spin); + tie_setting(s.clip_bz, ui.clip_blength_spin); + tie_setting(s.clip_ty, ui.clip_theight_spin); + tie_setting(s.clip_tz, ui.clip_tlength_spin); + + tie_setting(s.cap_x, ui.cap_width_spin); + tie_setting(s.cap_y, ui.cap_height_spin); + tie_setting(s.cap_z, ui.cap_length_spin); + + tie_setting(s.m01_x, ui.m1x_spin); + tie_setting(s.m01_y, ui.m1y_spin); + tie_setting(s.m01_z, ui.m1z_spin); + + tie_setting(s.m02_x, ui.m2x_spin); + tie_setting(s.m02_y, ui.m2y_spin); + tie_setting(s.m02_z, ui.m2z_spin); + + tie_setting(s.t_MH_x, ui.tx_spin); + tie_setting(s.t_MH_y, ui.ty_spin); + tie_setting(s.t_MH_z, ui.tz_spin); + + connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); + connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); + + connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnApply, SIGNAL(clicked()), this, SLOT(doApply())); + + ui.model_tabs->setCurrentIndex(s.active_model_panel); + + connect(ui.model_tabs, SIGNAL(currentChanged(int)), this, SLOT(set_model(int))); + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); + timer.start(100); + + connect(s.b.get(), SIGNAL(bundleChanged()), this, SLOT(do_apply_without_saving())); } void TrackerDialog::set_model_clip() { - settings.M01[0] = 0; - settings.M01[1] = dialog_settings.clip_ty; - settings.M01[2] = -dialog_settings.clip_tz; - settings.M02[0] = 0; - settings.M02[1] = -dialog_settings.clip_by; - settings.M02[2] = -dialog_settings.clip_bz; + s.m01_x = 0; + s.m01_y = static_cast(s.clip_ty); + s.m01_z = -static_cast(s.clip_tz); + s.m02_x = 0; + s.m02_y = -static_cast(s.clip_by); + s.m02_z = -static_cast(s.clip_bz); settings_changed(); } void TrackerDialog::set_model_cap() { - settings.M01[0] = -dialog_settings.cap_x; - settings.M01[1] = -dialog_settings.cap_y; - settings.M01[2] = -dialog_settings.cap_z; - settings.M02[0] = dialog_settings.cap_x; - settings.M02[1] = -dialog_settings.cap_y; - settings.M02[2] = -dialog_settings.cap_z; + s.m01_x = -static_cast(s.cap_x); + s.m01_y = -static_cast(s.cap_y); + s.m01_z = -static_cast(s.cap_z); + s.m02_x = static_cast(s.cap_x); + s.m02_y = -static_cast(s.cap_y); + s.m02_z = -static_cast(s.cap_z); settings_changed(); } void TrackerDialog::set_model_custom() { - settings.M01[0] = dialog_settings.M01x; - settings.M01[1] = dialog_settings.M01y; - settings.M01[2] = dialog_settings.M01z; - settings.M02[0] = dialog_settings.M02x; - settings.M02[1] = dialog_settings.M02y; - settings.M02[2] = dialog_settings.M02z; - settings_changed(); } void TrackerDialog::set_model(int val) { - dialog_settings.active_model_panel = val; - - switch (val) { - - case TrackerDialogSettings::MODEL_CLIP: - set_model_clip(); - break; - - case TrackerDialogSettings::MODEL_CAP: - set_model_cap(); - break; - - case TrackerDialogSettings::MODEL_CUSTOM: - set_model_custom(); - break; - - default: - break; - } + s.active_model_panel = val; } void TrackerDialog::startstop_trans_calib(bool start) @@ -231,7 +151,12 @@ void TrackerDialog::startstop_trans_calib(bool start) { qDebug()<<"TrackerDialog:: Stoppping translation calibration"; trans_calib_running = false; - settings.t_MH = trans_calib.get_estimate(); + { + auto tmp = trans_calib.get_estimate(); + s.t_MH_x = tmp[0]; + s.t_MH_y = tmp[1]; + s.t_MH_z = tmp[2]; + } settings_changed(); } } @@ -244,17 +169,15 @@ void TrackerDialog::trans_calib_step() tracker->get_pose(&X_CM); trans_calib.update(X_CM.R, X_CM.t); cv::Vec3f t_MH = trans_calib.get_estimate(); - //qDebug()<<"TrackerDialog:: Current translation estimate: "<setValue(t_MH[0]); - ui.ty_spin->setValue(t_MH[1]); - ui.tz_spin->setValue(t_MH[2]); + s.t_MH_x = t_MH[0]; + s.t_MH_y = t_MH[1]; + s.t_MH_z = t_MH[2]; } } void TrackerDialog::settings_changed() { - settings_dirty = true; - if (tracker) tracker->apply(settings); + if (tracker) tracker->apply(s); } void TrackerDialog::doCenter() @@ -267,25 +190,52 @@ void TrackerDialog::doReset() if (tracker) tracker->reset(); } +void TrackerDialog::save() +{ + do_apply_without_saving(); + s.b->save(); +} + void TrackerDialog::doOK() { - settings.save_ini(); - dialog_settings.save_ini(); + save(); close(); } +void TrackerDialog::do_apply_without_saving() +{ + switch (s.active_model_panel) { + default: + case 0: + set_model_clip(); + break; + case 1: + set_model_cap(); + break; + case 2: + set_model_custom(); + break; + } + if (tracker) tracker->apply(s); +} + +void TrackerDialog::doApply() +{ + save(); +} + void TrackerDialog::doCancel() { - if (settings_dirty) { + 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 ); switch (ret) { case QMessageBox::Save: - settings.save_ini(); - dialog_settings.save_ini(); + save(); close(); break; case QMessageBox::Discard: + s.b->revert(); close(); break; case QMessageBox::Cancel: @@ -319,8 +269,6 @@ void TrackerDialog::create_video_widget() video_widget_dialog->setAttribute( Qt::WA_DeleteOnClose ); connect( video_widget_dialog, SIGNAL(destroyed(QObject*)), this, SLOT(widget_destroyed(QObject*)) ); video_widget_dialog->show(); - - ui.videowidget_button->setEnabled(false); } void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/) @@ -329,7 +277,6 @@ void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/) if (do_delete) delete video_widget_dialog; video_widget_dialog = NULL; } - if (tracker) ui.videowidget_button->setEnabled(true); } void TrackerDialog::poll_tracker_info() @@ -369,24 +316,12 @@ void TrackerDialog::poll_tracker_info() } } - -//----------------------------------------------------------------------------- -// ITrackerDialog interface -void TrackerDialog::Initialize(QWidget *parent) -{ - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerDialog::registerTracker(ITracker *t) { qDebug()<<"TrackerDialog:: Tracker registered"; tracker = static_cast(t); - if (isVisible() && settings_dirty) tracker->apply(settings); - ui.videowidget_button->setEnabled(true); + if (isVisible() & s.b->modifiedp()) + tracker->apply(s); ui.tcalib_button->setEnabled(true); //ui.center_button->setEnabled(true); ui.reset_button->setEnabled(true); @@ -397,19 +332,12 @@ void TrackerDialog::unRegisterTracker() qDebug()<<"TrackerDialog:: Tracker un-registered"; tracker = NULL; destroy_video_widget(); - ui.videowidget_button->setEnabled(false); ui.tcalib_button->setEnabled(false); //ui.center_button->setEnabled(false); ui.reset_button->setEnabled(false); } -//----------------------------------------------------------------------------- -#ifdef OPENTRACK_API extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) -#else -#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") -FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) -#endif { return new TrackerDialog; } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index de743ad8..0325160d 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -28,71 +28,24 @@ class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDi Q_OBJECT public: TrackerDialog(); - ~TrackerDialog(); - - // ITrackerDialog interface - void Initialize(QWidget *parent); void registerTracker(ITracker *tracker); void unRegisterTracker(); - + void save(); void trans_calib_step(); -protected slots: - // ugly qt stuff - void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); } - void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); } - void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); } - void set_reset_time(int val) { settings.reset_time = val; settings_changed(); } - void set_cam_index(int idx) { settings.cam_index = idx; settings_changed(); } - void set_cam_f(double val) { settings.cam_f = val; settings_changed(); } - void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); } - void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); } - void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); } - void set_cam_roll(int idx); - void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } - void set_cam_yaw(int val) { settings.cam_yaw = val; settings_changed(); } - void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); } - void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); } - void set_threshold(int val) { settings.threshold = val; settings_changed(); } - void set_threshold_secondary(int val) { settings.threshold_secondary = val; settings_changed(); } - void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); } - void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); } - void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); } - void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); } - void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); } - void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); } - - void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_model_clip(); } - void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_model_clip(); } - void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_model_clip(); } - void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_model_clip(); } - void set_cap_width(int val) { dialog_settings.cap_x = val; set_model_cap(); } - void set_cap_height(int val) { dialog_settings.cap_y = val; set_model_cap(); } - void set_cap_length(int val) { dialog_settings.cap_z = val; set_model_cap(); } - void set_m1x(int val) { dialog_settings.M01x = val; set_model_custom(); } - void set_m1y(int val) { dialog_settings.M01y = val; set_model_custom(); } - void set_m1z(int val) { dialog_settings.M01z = val; set_model_custom(); } - void set_m2x(int val) { dialog_settings.M02x = val; set_model_custom(); } - void set_m2y(int val) { dialog_settings.M02y = val; set_model_custom(); } - void set_m2z(int val) { dialog_settings.M02z = val; set_model_custom(); } - void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); } - void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); } - void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); } - void set_model(int model_id); - - void doCenter(); - void doReset(); - +public slots: + void doCenter(); + void doReset(); void doOK(); + void doApply(); void doCancel(); + void do_apply_without_saving(); void startstop_trans_calib(bool start); - void widget_destroyed(QObject* obj); - void create_video_widget(); - void poll_tracker_info(); + void set_model(int idx); protected: void destroy_video_widget(bool do_delete = true); @@ -103,15 +56,11 @@ protected: void settings_changed(); - TrackerSettings settings; - TrackerDialogSettings dialog_settings; - bool settings_dirty; - + settings s; Tracker* tracker; + VideoWidgetDialog* video_widget_dialog; QTimer timer; - VideoWidgetDialog* video_widget_dialog; - TranslationCalibrator trans_calib; bool trans_calib_running; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp deleted file mode 100644 index 50835cb8..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt.h" -#include -#include - -//----------------------------------------------------------------------------- -void TrackerSettings::load_ini() -{ - qDebug("TrackerSettings::load_ini()"); - - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup( "PointTracker" ); - - cam_index = iniFile.value("CameraId", 0).toInt(); - cam_f = iniFile.value("CameraF", 1).toFloat(); - cam_res_x = iniFile.value("CameraResX", 640).toInt(); - cam_res_y = iniFile.value("CameraResY", 480).toInt(); - cam_fps = iniFile.value("CameraFPS", 30).toInt(); - cam_roll = iniFile.value("CameraRoll", 0).toInt(); - cam_pitch = iniFile.value("CameraPitch", 0).toInt(); - cam_yaw = iniFile.value("CameraYaw", 0).toInt(); - threshold = iniFile.value("PointExtractThreshold", 128).toInt(); - threshold_secondary = iniFile.value("PointExtractThresholdSecondary", 128).toInt(); - min_point_size = iniFile.value("PointExtractMinSize", 2).toInt(); - max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt(); - M01[0] = iniFile.value("PointModelM01x", 0).toFloat(); - M01[1] = iniFile.value("PointModelM01y", 40).toFloat(); - M01[2] = iniFile.value("PointModelM01z", -30).toFloat(); - M02[0] = iniFile.value("PointModelM02x", 0).toFloat(); - M02[1] = iniFile.value("PointModelM02y", -70).toFloat(); - M02[2] = iniFile.value("PointModelM02z", -80).toFloat(); - t_MH[0] = iniFile.value("tMHx", 0).toFloat(); - t_MH[1] = iniFile.value("tMHy", 0).toFloat(); - t_MH[2] = iniFile.value("tMHz", 0).toFloat(); - dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool(); - video_widget = iniFile.value("VideoWidget", true).toBool(); - sleep_time = iniFile.value("SleepTime", 10).toInt(); - reset_time = iniFile.value("ResetTime", 1000).toInt(); - - bEnableRoll = iniFile.value("EnableRoll", 1).toBool(); - bEnablePitch = iniFile.value("EnablePitch", 1).toBool(); - bEnableYaw = iniFile.value("EnableYaw", 1).toBool(); - bEnableX = iniFile.value("EnableX", 1).toBool(); - bEnableY = iniFile.value("EnableY", 1).toBool(); - bEnableZ = iniFile.value("EnableZ", 1).toBool(); - - iniFile.endGroup(); -} - -void TrackerSettings::save_ini() const -{ - qDebug("TrackerSettings::save_ini()"); - - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup ( "PointTracker" ); - - iniFile.setValue("CameraId", cam_index); - iniFile.setValue("CameraF", cam_f); - iniFile.setValue("CameraResX", cam_res_x); - iniFile.setValue("CameraResY", cam_res_y); - iniFile.setValue("CameraFPS", cam_fps); - iniFile.setValue("CameraRoll", cam_roll); - iniFile.setValue("CameraPitch", cam_pitch); - iniFile.setValue("CameraYaw", cam_yaw); - iniFile.setValue("PointExtractThreshold", threshold); - iniFile.setValue("PointExtractThresholdSecondary", threshold_secondary); - iniFile.setValue("PointExtractMinSize", min_point_size); - iniFile.setValue("PointExtractMaxSize", max_point_size); - iniFile.setValue("PointModelM01x", M01[0]); - iniFile.setValue("PointModelM01y", M01[1]); - iniFile.setValue("PointModelM01z", M01[2]); - iniFile.setValue("PointModelM02x", M02[0]); - iniFile.setValue("PointModelM02y", M02[1]); - iniFile.setValue("PointModelM02z", M02[2]); - iniFile.setValue("tMHx", t_MH[0]); - iniFile.setValue("tMHy", t_MH[1]); - iniFile.setValue("tMHz", t_MH[2]); - iniFile.setValue("DynamicPoseResolution", dyn_pose_res); - iniFile.setValue("VideoWidget", video_widget); - iniFile.setValue("SleepTime", sleep_time); - iniFile.setValue("ResetTime", reset_time); - - iniFile.setValue( "EnableRoll", bEnableRoll ); - iniFile.setValue( "EnablePitch", bEnablePitch ); - iniFile.setValue( "EnableYaw", bEnableYaw ); - iniFile.setValue( "EnableX", bEnableX ); - iniFile.setValue( "EnableY", bEnableY ); - iniFile.setValue( "EnableZ", bEnableZ ); - - iniFile.endGroup(); -} - -//----------------------------------------------------------------------------- -void TrackerDialogSettings::load_ini() -{ - qDebug("TrackerDialogSettings::load_ini()"); - - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup( "PointTrackerDialog" ); - - active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt(); - M01x = iniFile.value("CustomM01x", 0).toInt(); - M01y = iniFile.value("CustomM01y", 40).toInt(); - M01z = iniFile.value("CustomM01z", -30).toInt(); - M02x = iniFile.value("CustomM02x", 0).toInt(); - M02y = iniFile.value("CustomM02y", -70).toInt(); - M02z = iniFile.value("CustomM02z", -80).toInt(); - clip_ty = iniFile.value("ClipTopHeight", 40).toInt(); - clip_tz = iniFile.value("ClipTopLength", 30).toInt(); - clip_by = iniFile.value("ClipBottomHeight", 70).toInt(); - clip_bz = iniFile.value("ClipBottomLength", 80).toInt(); - cap_x = iniFile.value("CapHalfWidth", 40).toInt(); - cap_y = iniFile.value("CapHeight", 60).toInt(); - cap_z = iniFile.value("CapLength", 100).toInt(); -} - -void TrackerDialogSettings::save_ini() const -{ - qDebug("TrackerDialogSettings::save_ini()"); - - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup ( "PointTrackerDialog" ); - - iniFile.setValue("ActiveModelPanel", active_model_panel); - iniFile.setValue("CustomM01x", M01x); - iniFile.setValue("CustomM01y", M01y); - iniFile.setValue("CustomM01z", M01z); - iniFile.setValue("CustomM02x", M02x); - iniFile.setValue("CustomM02y", M02y); - iniFile.setValue("CustomM02z", M02z); - iniFile.setValue("ClipTopHeight", clip_ty); - iniFile.setValue("ClipTopLength", clip_tz); - iniFile.setValue("ClipBottomHeight", clip_by); - iniFile.setValue("ClipBottomLength", clip_bz); - iniFile.setValue("CapHalfWidth", cap_x); - iniFile.setValue("CapHeight", cap_y); - iniFile.setValue("CapLength", cap_z); -} diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 91a7a8d5..8c590db2 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -11,80 +11,81 @@ #include #include "point_tracker.h" +#include "facetracknoir/options.hpp" +using namespace options; -//----------------------------------------------------------------------------- -// Tracker settings and their ini-IO -struct TrackerSettings -{ - // camera - int cam_index; - float cam_f; - int cam_res_x; - int cam_res_y; - int cam_fps; - int cam_roll; - int cam_pitch; - int cam_yaw; - - // point extraction - int threshold; - int threshold_secondary; - - int min_point_size; - int max_point_size; - - // point tracking - cv::Vec3f M01; - cv::Vec3f M02; - bool dyn_pose_res; - - // head to model translation - cv::Vec3f t_MH; - - int sleep_time; // in ms - int reset_time; // in ms - bool video_widget; +struct settings +{ + pbundle b; + value cam_index, + cam_res_x, + cam_res_y, + cam_fps, + cam_roll, + cam_pitch, + cam_yaw, + threshold, + threshold_secondary, + min_point_size, + max_point_size; + value cam_f; - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; + value m01_x, m01_y, m01_z; + value m02_x, m02_y, m02_z; + value dyn_pose_res, video_widget; - void load_ini(); - void save_ini() const; -}; + value t_MH_x, t_MH_y, t_MH_z; + value sleep_time, reset_time; -//----------------------------------------------------------------------------- -// Settings specific to the tracker dialog and their ini-IO -struct TrackerDialogSettings -{ - enum - { - MODEL_CLIP, - MODEL_CAP, - MODEL_CUSTOM - }; - int active_model_panel; + value bEnableYaw, bEnablePitch, bEnableRoll; + value bEnableX, bEnableY, bEnableZ; - int M01x; - int M01y; - int M01z; - int M02x; - int M02y; - int M02z; - int clip_ty; - int clip_tz; - int clip_by; - int clip_bz; - int cap_x; - int cap_y; - int cap_z; + value clip_ty, clip_tz, clip_by, clip_bz; + value active_model_panel, cap_x, cap_y, cap_z; - void load_ini(); - void save_ini() const; + settings() : + b(bundle("tracker-pt")), + cam_index(b, "camera-index", 0), + cam_res_x(b, "camera-res-width", 640), + cam_res_y(b, "camera-res-height", 480), + cam_fps(b, "camera-fps", 30), + cam_roll(b, "camera-roll", 1), + cam_pitch(b, "camera-pitch", 0), + cam_yaw(b, "camera-yaw", 0), + threshold(b, "threshold-primary", 128), + threshold_secondary(b, "threshold-secondary", 128), + min_point_size(b, "min-point-size", 10), + max_point_size(b, "max-point-size", 50), + cam_f(b, "camera-focal-length", 1), + m01_x(b, "m_01-x", 0), + m01_y(b, "m_01-y", 0), + m01_z(b, "m_01-z", 0), + m02_x(b, "m_02-x", 0), + m02_y(b, "m_02-y", 0), + m02_z(b, "m_02-z", 0), + dyn_pose_res(b, "dynamic-pose-resolution", false), + video_widget(b, "video-widget", true), + t_MH_x(b, "model-centroid-x", 0), + t_MH_y(b, "model-centroid-y", 0), + t_MH_z(b, "model-centroid-z", 0), + sleep_time(b, "sleep-time", 0), + reset_time(b, "reset-time", 0), + bEnableYaw(b, "enable-yaw", true), + bEnablePitch(b, "enable-pitch", true), + bEnableRoll(b, "enable-roll", true), + bEnableX(b, "enable-x", true), + bEnableY(b, "enable-y", true), + bEnableZ(b, "enable-z", true), + clip_ty(b, "clip-ty", 0), + clip_tz(b, "clip-tz", 0), + clip_by(b, "clip-by", 0), + clip_bz(b, "clip-bz", 0), + active_model_panel(b, "active-model-panel", 0), + cap_x(b, "cap-x", 0), + cap_y(b, "cap-y", 0), + cap_z(b, "cap-z", 0) + {} }; -#endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file +#endif //FTNOIR_TRACKER_PT_SETTINGS_H -- cgit v1.2.3 From 904add389667ff9d97cde3930a881fae89c3fb50 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:40:02 +0100 Subject: options: fix some bugs --- facetracknoir/options.hpp | 96 +++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 900f06c0..1305bd0a 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -7,11 +7,13 @@ #pragma once -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -21,6 +23,13 @@ #include #include #include +#include + +#ifdef __GNUC__ +# define ov override +#else +# define ov +#endif namespace options { template @@ -101,8 +110,10 @@ namespace options { } }; - class impl_bundle { + class impl_bundle : public QObject { + Q_OBJECT private: + QMutex mtx; const QString group_name; group saved; group transient; @@ -111,6 +122,7 @@ namespace options { bool modified; public: impl_bundle(const QString& group_name) : + mtx(QMutex::Recursive), group_name(group_name), saved(group_name), transient(saved), @@ -119,8 +131,10 @@ namespace options { } /* keep in mind doesn't fire signals */ void reload() { + QMutexLocker l(&mtx); saved = group(group_name); transient = saved; + emit reloaded(); } std::shared_ptr make(const QString& name) { @@ -128,33 +142,46 @@ namespace options { } void store(const QString& name, const QVariant& datum) { + QMutexLocker l(&mtx); if (!transient.contains(name) || datum != transient.get(name)) { modified = true; transient.put(name, datum); + emit bundleChanged(); } } bool contains(const QString& name) { + QMutexLocker l(&mtx); return transient.contains(name); } template - T get(QString& name) { + T get(const QString& name) { + QMutexLocker l(&mtx); return transient.get(name); } void save() { + QMutexLocker l(&mtx); modified = false; saved = transient; transient.save(); } void revert() { + QMutexLocker l(&mtx); modified = false; transient = saved; + emit bundleChanged(); } - bool modifiedp() const { return modified; } + bool modifiedp() { + QMutexLocker l(&mtx); + return modified; + } + signals: + void bundleChanged(); + void reloaded(); }; typedef std::shared_ptr pbundle; @@ -162,7 +189,18 @@ namespace options { class base_value : public QObject { Q_OBJECT public: + base_value(pbundle b, const QString& name) : b(b), self_name(name) { + connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); + } virtual QVariant operator=(const QVariant& datum) = 0; + protected: + pbundle b; + QString self_name; + public slots: + void reread_value() + { + this->operator=(b->get(self_name)); + } public slots: #define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } DEFINE_SLOT(double) @@ -179,13 +217,11 @@ namespace options { template class value : public base_value { - private: - QString self_name; - pbundle b; + private: T def; public: - value(pbundle& b, const QString& name, T def) : - self_name(name), - b(b) + static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; + value(pbundle b, const QString& name, T def) : + base_value(b, name), def(def) { if (!b->contains(name)) { @@ -196,15 +232,9 @@ namespace options { operator T() { return b->get(self_name); } QVariant operator=(const QVariant& datum) { b->store(self_name, datum); - switch (datum.type()) - { -#define BRANCH_ON(e, m) case QVariant::e: return valueChanged(datum.m()), datum - BRANCH_ON(Int, toInt); - BRANCH_ON(Double, toDouble); - BRANCH_ON(String, toString); - BRANCH_ON(Bool, toBool); - default: abort(); - } + auto foo = qcruft_to_t(datum); + emit valueChanged(foo); + return datum; } }; @@ -214,56 +244,56 @@ namespace options { template<> inline void tie_setting(value& v, QComboBox* cb) { - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int))); + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); cb->setCurrentIndex(v); } template<> inline void tie_setting(value& v, QComboBox* cb) { - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString))); + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); cb->setCurrentText(v); } template<> inline void tie_setting(value& v, QCheckBox* cb) { - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); cb->setChecked(v); } template<> inline void tie_setting(value& v, QDoubleSpinBox* dsb) { - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); dsb->setValue(v); } template<> inline void tie_setting(value& v, QSpinBox* sb) { - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); sb->setValue(v); } template<> inline void tie_setting(value& v, QSlider* sl) { - base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); sl->setValue(v); } template<> inline void tie_setting(value& v, QLineEdit* le) { - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString))); - base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString))); + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); le->setText(v); } -- cgit v1.2.3 From 54892e5f6a15c1ce0aba364039174eda3d1a6b8b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:40:27 +0100 Subject: main: use settings framework --- facetracknoir/curve-config.cpp | 161 +++--------- facetracknoir/facetracknoir.cpp | 397 ++++++++++-------------------- facetracknoir/facetracknoir.h | 38 +-- facetracknoir/ftnoir_curves.ui | 4 +- facetracknoir/ftnoir_keyboardshortcuts.ui | 53 +--- facetracknoir/main.cpp | 7 +- facetracknoir/shortcuts.cpp | 148 ++--------- facetracknoir/shortcuts.h | 9 +- facetracknoir/tracker.cpp | 25 +- facetracknoir/tracker.h | 51 ++-- 10 files changed, 224 insertions(+), 669 deletions(-) diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 2e731892..4b07a165 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -14,7 +14,23 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); + + tie_setting(mainApp->s.a_x.altp, ui.tx_altp); + tie_setting(mainApp->s.a_y.altp, ui.ty_altp); + tie_setting(mainApp->s.a_z.altp, ui.tz_altp); + tie_setting(mainApp->s.a_yaw.altp, ui.rx_altp); + tie_setting(mainApp->s.a_pitch.altp, ui.ry_altp); + tie_setting(mainApp->s.a_roll.altp, ui.rz_altp); + + tie_setting(mainApp->s.tcomp_p, ui.tcomp_enable); + tie_setting(mainApp->s.tcomp_tz, ui.tcomp_rz); + + tie_setting(mainApp->s.a_x.zero, ui.pos_tx); + tie_setting(mainApp->s.a_y.zero, ui.pos_ty); + tie_setting(mainApp->s.a_z.zero, ui.pos_tz); + tie_setting(mainApp->s.a_yaw.zero, ui.pos_rx); + tie_setting(mainApp->s.a_pitch.zero, ui.pos_ry); + tie_setting(mainApp->s.a_roll.zero, ui.pos_rz); // Load the settings from the current .INI-file loadSettings(); @@ -47,7 +63,7 @@ void CurveConfigurationDialog::doCancel() { // // Ask if changed Settings should be saved // - if (settingsDirty) { + if (settingsDirty || mainApp->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 ); qDebug() << "doCancel says: answer =" << ret; @@ -58,6 +74,7 @@ void CurveConfigurationDialog::doCancel() { this->close(); break; case QMessageBox::Discard: + mainApp->s.b->revert(); this->close(); break; case QMessageBox::Cancel: @@ -77,67 +94,6 @@ void CurveConfigurationDialog::doCancel() { // Load the current Settings from the currently 'active' INI-file. // void CurveConfigurationDialog::loadSettings() { - qDebug() << "CurveConfigurationDialog::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() << "CurveConfigurationDialog::loadSettings says: iniFile = " << currentFile; - - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt" - }; - - iniFile.beginGroup("Tracking"); - - ui.tcomp_rz->setChecked(iniFile.value("tcomp-rz", false).toBool()); - ui.checkBox->setChecked(iniFile.value("compensate", true).toBool()); - - for (int i = 0; i < 6; i++) - mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); - - QCheckBox* widgets[] = { - ui.tx_altp, - ui.ty_altp, - ui.tz_altp, - ui.rx_altp, - ui.ry_altp, - ui.rz_altp - }; - - for (int i = 0; i < 6; i++) - widgets[i]->setChecked(mainApp->axis(i).altp); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - - for (int i = 0; i < 6; i++) - widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); - - iniFile.endGroup(); - QFunctionConfigurator* configs[6] = { ui.txconfig, ui.tyconfig, @@ -156,23 +112,10 @@ void CurveConfigurationDialog::loadSettings() { ui.rzconfig_alt }; - QCheckBox* checkboxes[6] = { - ui.rx_altp, - ui.ry_altp, - ui.rz_altp, - ui.tx_altp, - ui.ty_altp, - ui.tz_altp - }; - - QDoubleSpinBox* widgets3[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; + QSettings settings("opentrack"); + QString currentFile = settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ) + .toString(); for (int i = 0; i < 6; i++) { @@ -182,8 +125,6 @@ void CurveConfigurationDialog::loadSettings() { alt_configs[i]->loadSettings(currentFile); connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); - connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); - mainApp->axis(i).zero = widgets3[i]->value(); } settingsDirty = false; @@ -196,9 +137,11 @@ void CurveConfigurationDialog::save() { qDebug() << "save() says: started"; - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings settings("opentrack"); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ) + .toString(); ui.rxconfig->saveSettings(currentFile); ui.ryconfig->saveSettings(currentFile); @@ -214,53 +157,5 @@ void CurveConfigurationDialog::save() { ui.ryconfig_alt->saveSettings(currentFile); ui.rzconfig_alt->saveSettings(currentFile); - bool tcomp_rz = false, compensate = true; - - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup("Tracking"); - - iniFile.setValue("tcomp-rz", tcomp_rz = ui.tcomp_rz->checkState() != Qt::Unchecked); - iniFile.setValue("compensate", compensate = (bool) !!ui.checkBox->isChecked()); - - if (mainApp->tracker) - { - mainApp->tracker->compensate = compensate; - mainApp->tracker->tcomp_rz = tcomp_rz; - } - - iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); - iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - { - iniFile.setValue(names2[i], widgets2[i]->value()); - mainApp->axis(i).zero = widgets2[i]->value(); - } - - iniFile.endGroup(); - settingsDirty = false; } diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 75ac737d..b98c6085 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -95,6 +95,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : keyCenter(this), keyToggle(this), #endif + b(bundle("opentrack-ui")), + s(b), + pose(std::vector{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}), timUpdateHeadPose(this), pTrackerDialog(NULL), pSecondTrackerDialog(NULL), @@ -111,6 +114,16 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : tracker = 0; + CurveConfigurationDialog* ccd; + + if (!_curve_config) + { + ccd = new CurveConfigurationDialog( this, this ); + _curve_config = ccd; + } else { + ccd = dynamic_cast(_curve_config); + } + QDir::setCurrent(QCoreApplication::applicationDirPath()); connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); @@ -124,18 +137,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); - connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); - connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); - connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); - connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); - connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - - GetCameraNameDX(); - ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); dlopen_filters.push_back((DynamicLibrary*) NULL); ui.iconcomboFilter->addItem(QIcon(), "None"); @@ -144,11 +145,25 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); + tie_setting(s.a_yaw.invert, ui.chkInvertYaw); + tie_setting(s.a_pitch.invert, ui.chkInvertPitch); + tie_setting(s.a_roll.invert, ui.chkInvertRoll); + tie_setting(s.a_x.invert, ui.chkInvertX); + tie_setting(s.a_y.invert, ui.chkInvertY); + tie_setting(s.a_z.invert, ui.chkInvertZ); + tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); + tie_setting(s.tracker2_dll, ui.cbxSecondTrackerSource); + tie_setting(s.protocol_dll, ui.iconcomboProtocol); + tie_setting(s.filter_dll, ui.iconcomboFilter); + + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + + GetCameraNameDX(); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - loadSettings(); - #ifndef _WIN32 connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); @@ -156,6 +171,8 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); kbd_quit.setEnabled(true); + + fill_profile_cbx(); } FaceTrackNoIR::~FaceTrackNoIR() { @@ -250,45 +267,14 @@ void FaceTrackNoIR::open() { } void FaceTrackNoIR::save() { - QSettings settings("opentrack"); + b->save(); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup ( "Tracking" ); - - iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); - iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); - iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); - iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); - iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); - iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "GameProtocol" ); - { - DynamicLibrary* proto = dlopen_protocols.value( ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", proto == NULL ? "" : proto->filename); - } - iniFile.endGroup (); - - iniFile.beginGroup ( "TrackerSource" ); - { - DynamicLibrary* tracker = dlopen_trackers.value( ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", tracker == NULL ? "" : tracker->filename); - } - { - DynamicLibrary* tracker = dlopen_trackers.value( ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - iniFile.setValue ( "2ndDLL", tracker == NULL ? "" : tracker->filename); - } - iniFile.endGroup (); + QSettings settings("opentrack"); - iniFile.beginGroup ( "Filter" ); - { - DynamicLibrary* filter = dlopen_filters.value( ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename); - } - iniFile.endGroup (); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini") + .toString(); #if defined(__unix) || defined(__linux) QByteArray bytes = QFile::encodeName(currentFile); @@ -308,8 +294,7 @@ void FaceTrackNoIR::saveAs() QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), oldFile, -// QCoreApplication::applicationDirPath() + "/settings", - tr("Settings file (*.ini);;All Files (*)")); + tr("Settings file (*.ini);;All Files (*)")); if (!fileName.isEmpty()) { QFileInfo newFileInfo ( fileName ); @@ -325,117 +310,40 @@ void FaceTrackNoIR::saveAs() } settings.setValue ("SettingsFile", fileName); - save(); - - loadSettings(); - } + save(); + } } void FaceTrackNoIR::loadSettings() { - if (looping) - return; - looping = true; - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - qDebug() << "Config file now" << currentFile; - QSettings iniFile( currentFile, QSettings::IniFormat ); - - QFileInfo pathInfo ( currentFile ); - setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); - - QDir settingsDir( pathInfo.dir() ); - QStringList filters; - filters << "*.ini"; - iniFileList.clear(); - iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - ui.iconcomboProfile->clear(); - for ( int i = 0; i < iniFileList.size(); i++) { - ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); - ui.iconcomboProfile->setCurrentIndex( i ); - } - } - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Tracking" ); - ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); - ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); - ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); - ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); - ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); - ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); - iniFile.endGroup (); - - iniFile.beginGroup ( "GameProtocol" ); - QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_protocols.size(); i++) { - if (dlopen_protocols.at(i)->filename.compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboProtocol->setCurrentIndex( i ); - break; - } - } - - iniFile.beginGroup ( "TrackerSource" ); - QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "loadSettings says: selectedTrackerName = " << selectedTrackerName; - QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); - qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_trackers.size(); i++) { - DynamicLibrary* foo = dlopen_trackers.at(i); - if (foo && foo->filename.compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboTrackerSource->setCurrentIndex( i ); - } - if (foo && foo->filename.compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { - ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); - } - } - - iniFile.beginGroup ( "Filter" ); - QString selectedFilterName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_filters.size(); i++) { - DynamicLibrary* foo = dlopen_filters.at(i); - if (foo && foo->filename.compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboFilter->setCurrentIndex( i ); - break; - } - } - - CurveConfigurationDialog* ccd; - - if (!_curve_config) - { - ccd = new CurveConfigurationDialog( this, this ); - _curve_config = ccd; - } else { - ccd = dynamic_cast(_curve_config); - } - - ccd->loadSettings(); + b->reload(); + (dynamic_cast(_curve_config))->loadSettings(); +} - looping = false; +void FaceTrackNoIR::updateButtonState(bool running) +{ + bool e = !running; + ui.iconcomboProfile->setEnabled ( e ); + ui.btnLoad->setEnabled ( e ); + ui.btnSaveAs->setEnabled ( e ); + ui.btnShowFilterControls->setEnabled ( e ); + ui.btnStartTracker->setEnabled ( e ); + ui.btnStopTracker->setEnabled ( running ); + + ui.iconcomboTrackerSource->setEnabled ( e ); + ui.cbxSecondTrackerSource->setEnabled ( e ); + ui.iconcomboProtocol->setEnabled ( e ); + ui.btnShowServerControls->setEnabled ( e ); + ui.iconcomboFilter->setEnabled ( e ); + + ui.btnStartTracker->setEnabled(e); + ui.btnStopTracker->setEnabled(running); } -void FaceTrackNoIR::startTracker( ) { +void FaceTrackNoIR::startTracker( ) { + b->save(); + loadSettings(); bindKeyboardShortcuts(); - ui.iconcomboProfile->setEnabled ( false ); - ui.btnLoad->setEnabled ( false ); - ui.btnSave->setEnabled ( false ); - ui.btnSaveAs->setEnabled ( false ); - ui.btnShowFilterControls->setEnabled ( true ); - if (Libraries) delete Libraries; Libraries = new SelectedLibraries(this); @@ -457,54 +365,19 @@ void FaceTrackNoIR::startTracker( ) { delete tracker; } - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - for (int i = 0; i < 6; i++) { - axis(i).curve.loadSettings(iniFile); - axis(i).curveAlt.loadSettings(iniFile); - } + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt", - }; - - static const char* invert_names[] = { - "invertX", - "invertY", - "invertZ", - "invertYaw", - "invertPitch", - "invertRoll" - }; - - iniFile.beginGroup("Tracking"); - - for (int i = 0; i < 6; i++) { - axis(i).altp = iniFile.value(names[i], false).toBool(); - axis(i).invert = iniFile.value(invert_names[i], false).toBool() ? 1 : -1; + for (int i = 0; i < 6; i++) + { + axis(i).curve.loadSettings(iniFile); + axis(i).curveAlt.loadSettings(iniFile); + } } - tracker = new Tracker ( this ); - - tracker->compensate = iniFile.value("compensate", true).toBool(); - tracker->tcomp_rz = iniFile.value("tcomp-rz", false).toBool(); - - iniFile.endGroup(); - - tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); - tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); - tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); - tracker->setInvertAxis(TX, ui.chkInvertX->isChecked() ); - tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() ); - tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() ); + tracker = new Tracker ( this, s ); if (pTrackerDialog && Libraries->pTracker) { pTrackerDialog->registerTracker( Libraries->pTracker ); @@ -517,21 +390,12 @@ void FaceTrackNoIR::startTracker( ) { ui.video_frame->show(); - ui.btnStartTracker->setEnabled ( false ); - ui.btnStopTracker->setEnabled ( true ); - - ui.iconcomboTrackerSource->setEnabled ( false ); - ui.cbxSecondTrackerSource->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( false ); - ui.btnShowServerControls->setEnabled ( false ); - ui.iconcomboFilter->setEnabled ( false ); - - GetCameraNameDX(); - timUpdateHeadPose.start(50); + + updateButtonState(true); } -void FaceTrackNoIR::stopTracker( ) { +void FaceTrackNoIR::stopTracker( ) { ui.game_name->setText("Not connected"); #if defined(_WIN32) if (keybindingWorker) @@ -555,39 +419,16 @@ void FaceTrackNoIR::stopTracker( ) { pFilterDialog->unregisterFilter(); if ( tracker ) { - qDebug() << "Done with tracking"; tracker->should_quit = true; tracker->wait(); - - qDebug() << "stopTracker says: Deleting tracker!"; delete tracker; - qDebug() << "stopTracker says: Tracker deleted!"; tracker = 0; if (Libraries) { delete Libraries; Libraries = NULL; } } - ui.btnStartTracker->setEnabled ( true ); - ui.btnStopTracker->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( true ); - ui.iconcomboTrackerSource->setEnabled ( true ); - ui.cbxSecondTrackerSource->setEnabled ( true ); - ui.iconcomboFilter->setEnabled ( true ); - - ui.btnShowServerControls->setEnabled ( true ); - ui.video_frame->hide(); - - ui.iconcomboProfile->setEnabled ( true ); - ui.btnLoad->setEnabled ( true ); - ui.btnSave->setEnabled ( true ); - ui.btnSaveAs->setEnabled ( true ); - ui.btnShowFilterControls->setEnabled ( true ); -} - -void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { - if (tracker) - tracker->setInvertAxis (axis, (invert != 0)?true:false ); + updateButtonState(false); } void FaceTrackNoIR::showHeadPose() { @@ -625,7 +466,6 @@ void FaceTrackNoIR::showHeadPose() { } } -/** toggles Engine Controls Dialog **/ void FaceTrackNoIR::showTrackerSettings() { if (pTrackerDialog) { delete pTrackerDialog; @@ -641,7 +481,7 @@ void FaceTrackNoIR::showTrackerSettings() { foo->setFixedSize(foo->size()); if (Libraries && Libraries->pTracker) pTrackerDialog->registerTracker(Libraries->pTracker); - pTrackerDialog->Initialize(this); + dynamic_cast(pTrackerDialog)->show(); } } } @@ -661,7 +501,7 @@ void FaceTrackNoIR::showSecondTrackerSettings() { foo->setFixedSize(foo->size()); if (Libraries && Libraries->pSecondTracker) pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker); - pSecondTrackerDialog->Initialize(this); + dynamic_cast(pSecondTrackerDialog)->show(); } } } @@ -679,7 +519,7 @@ void FaceTrackNoIR::showServerControls() { if (pProtocolDialog) { auto foo = dynamic_cast(pProtocolDialog); foo->setFixedSize(foo->size()); - pProtocolDialog->Initialize(this); + dynamic_cast(pProtocolDialog)->show(); } } } @@ -697,9 +537,9 @@ void FaceTrackNoIR::showFilterControls() { if (pFilterDialog) { auto foo = dynamic_cast(pFilterDialog); foo->setFixedSize(foo->size()); - pFilterDialog->Initialize(this); if (Libraries && Libraries->pFilter) pFilterDialog->registerFilter(Libraries->pFilter); + dynamic_cast(pFilterDialog)->show(); } } } @@ -730,34 +570,61 @@ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); } -void FaceTrackNoIR::profileSelected(int index) +void FaceTrackNoIR::fill_profile_cbx() { if (looping) return; + looping = true; + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + qDebug() << "Config file now" << currentFile; + QFileInfo pathInfo ( currentFile ); + setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); + QDir settingsDir( pathInfo.dir() ); + QStringList filters; + filters << "*.ini"; + auto iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + ui.iconcomboProfile->clear(); + for ( int i = 0; i < iniFileList.size(); i++) { + ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); + if (iniFileList.at(i) == pathInfo.fileName()) { + ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); + ui.iconcomboProfile->setCurrentIndex( i ); + } + } + looping = false; +} + +void FaceTrackNoIR::profileSelected(int index) +{ QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QFileInfo pathInfo ( currentFile ); - - settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(index, "")); + settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); loadSettings(); + if (looping) + return; + looping = true; + fill_profile_cbx(); + looping = false; } #if !defined(_WIN32) -void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile) +void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k) { - const int idx = iniFile.value("Key_index_" + label, 0).toInt(); key.setShortcut(QKeySequence::fromString("")); key.setDisabled(); - QString seq(global_key_sequences.value(idx, "")); + const int idx = k.key_index; if (idx > 0) { + QString seq(global_key_sequences.value(idx, "")); if (!seq.isEmpty()) { - if (iniFile.value(QString("Shift_%1").arg(label), false).toBool()) + if (k.shift) seq = "Shift+" + seq; - if (iniFile.value(QString("Alt_%1").arg(label), false).toBool()) + if (k.alt) seq = "Alt+" + seq; - if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool()) + if (k.ctrl) seq = "Ctrl+" + seq; key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText)); key.setEnabled(); @@ -767,39 +634,31 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString } } #else -static void bind_keyboard_shortcut(Key& key, const QString label, QSettings& iniFile) +static void bind_keyboard_shortcut(Key& key, const key& k) { - const int idx = iniFile.value("Key_index_" + label, 0).toInt(); + const int idx = k.key_index; if (idx > 0) { key.keycode = 0; key.shift = key.alt = key.ctrl = 0; if (idx < global_windows_key_sequences.size()) key.keycode = global_windows_key_sequences[idx]; - key.shift = iniFile.value(QString("Shift_%1").arg(label), false).toBool(); - key.alt = iniFile.value(QString("Alt_%1").arg(label), false).toBool(); - key.ctrl = iniFile.value(QString("Ctrl_%1").arg(label), false).toBool(); + key.shift = k.shift; + key.alt = k.alt; + key.ctrl = k.ctrl; } } #endif void FaceTrackNoIR::bindKeyboardShortcuts() { - QSettings settings("opentrack"); - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - iniFile.beginGroup ( "KB_Shortcuts" ); - #if !defined(_WIN32) - bind_keyboard_shortcut(keyCenter, "Center", iniFile); - bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); + bind_keyboard_shortcut(keyCenter, s.center_key); + bind_keyboard_shortcut(keyToggle, s.toggle_key); #else - bind_keyboard_shortcut(keyCenter, "Center", iniFile); - bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); + bind_keyboard_shortcut(keyCenter, s.center_key); + bind_keyboard_shortcut(keyToggle, s.toggle_key); #endif - iniFile.endGroup (); - if (tracker) /* running already */ { #if defined(_WIN32) @@ -822,9 +681,7 @@ void FaceTrackNoIR::shortcutRecentered() qDebug() << "Center"; if (tracker) - { tracker->do_center = true; - } } void FaceTrackNoIR::shortcutToggled() @@ -832,7 +689,5 @@ void FaceTrackNoIR::shortcutToggled() QApplication::beep(); qDebug() << "Toggle"; if (tracker) - { tracker->enabled = !tracker->enabled; - } } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 72ccebd8..b1279697 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -39,6 +39,7 @@ #include #include #include +#include #if !defined(_WIN32) # include "qxt-mini/QxtGlobalShortcut" #else @@ -50,6 +51,11 @@ #include "ui_facetracknoir.h" +#include "facetracknoir/options.hpp" +using namespace options; + +#include "facetracknoir/main-settings.hpp" + #include "global-settings.h" #include "tracker.h" #include "facetracknoir/shortcuts.h" @@ -100,6 +106,8 @@ public: QxtGlobalShortcut keyCenter; QxtGlobalShortcut keyToggle; #endif + pbundle b; + main_settings s; public slots: void shortcutRecentered(); void shortcutToggled(); @@ -108,7 +116,6 @@ private: HeadPoseData pose; Ui::OpentrackUI ui; QTimer timUpdateHeadPose; // Timer to display headpose - QStringList iniFileList; // List of INI-files, that are present in the Settings folder ITrackerDialog* pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) ITrackerDialog* pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) @@ -122,6 +129,7 @@ private: void GetCameraNameDX(); void loadSettings(); + void updateButtonState(bool); QList dlopen_filters; QList dlopen_trackers; @@ -129,18 +137,18 @@ private: QShortcut kbd_quit; #ifndef _WIN32 - void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile); + void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k); #endif - volatile bool looping; + bool looping; + + void fill_profile_cbx(); private slots: - //file menu void open(); void save(); void saveAs(); void exit(); - // void setIcon(int index); void profileSelected(int index); void showTrackerSettings(); @@ -151,30 +159,10 @@ private slots: void showKeyboardShortcuts(); void showCurveConfiguration(); - void setInvertAxis( Axis axis, int invert ); - void setInvertYaw(int invert) { - setInvertAxis(Yaw, invert); - } - void setInvertPitch(int invert) { - setInvertAxis(Pitch, invert); - } - void setInvertRoll(int invert) { - setInvertAxis(Roll, invert); - } - void setInvertX(int invert) { - setInvertAxis(TX, invert); - } - void setInvertY(int invert) { - setInvertAxis(TY, invert); - } - void setInvertZ(int invert) { - setInvertAxis(TZ, invert); - } void showHeadPose(); void startTracker(); void stopTracker(); - }; #endif // FaceTrackNoIR_H diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 77df9a20..f96df044 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -761,7 +761,7 @@ - + 0 @@ -816,7 +816,7 @@ tx_altp ty_altp tz_altp - checkBox + tcomp_enable tabWidget pos_tx buttonBox diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 565c0e77..1477d56d 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -6,8 +6,8 @@ 0 0 - 335 - 120 + 360 + 124 @@ -191,53 +191,10 @@ - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 5ba3fcd5..3143a093 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #if defined(_WIN32) && defined(_MSC_VER) # include @@ -61,11 +62,9 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); - FaceTrackNoIR w; - QDesktopWidget desktop; + auto w = std::make_shared(); - w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); - w.show(); + w->show(); app.exec(); return 0; diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 6a972aa3..2f117ea4 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -12,63 +12,55 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget * mainApp = ftnoir; // Preserve a pointer to FTNoIR // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); for ( int i = 0; i < global_key_sequences.size(); i++) { ui.cbxCenterKey->addItem(global_key_sequences.at(i)); ui.cbxToggleKey->addItem(global_key_sequences.at(i)); } - loadSettings(); -} + tie_setting(mainApp->s.center_key.key_index, ui.cbxCenterKey); + tie_setting(mainApp->s.center_key.alt, ui.chkCenterAlt); + tie_setting(mainApp->s.center_key.shift, ui.chkCenterShift); + tie_setting(mainApp->s.center_key.ctrl, ui.chkCenterCtrl); -// -// Destructor for server-dialog -// -KeyboardShortcutDialog::~KeyboardShortcutDialog() { - qDebug() << "~KeyboardShortcutDialog() says: started"; + tie_setting(mainApp->s.toggle_key.key_index, ui.cbxToggleKey); + tie_setting(mainApp->s.toggle_key.alt, ui.chkToggleAlt); + tie_setting(mainApp->s.toggle_key.shift, ui.chkToggleShift); + tie_setting(mainApp->s.toggle_key.ctrl, ui.chkToggleCtrl); } // // OK clicked on server-dialog // void KeyboardShortcutDialog::doOK() { - save(); + mainApp->b->save(); this->close(); if (mainApp->tracker) mainApp->bindKeyboardShortcuts(); } -void KeyboardShortcutDialog::showEvent ( QShowEvent * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void KeyboardShortcutDialog::doCancel() { // // Ask if changed Settings should be saved // - 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 ); + if (mainApp->b->modifiedp()) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); qDebug() << "doCancel says: answer =" << ret; switch (ret) { case QMessageBox::Save: - save(); + mainApp->b->save(); this->close(); break; case QMessageBox::Discard: - this->close(); + mainApp->b->revert(); + close(); break; case QMessageBox::Cancel: - // Cancel was clicked - break; default: - // should never be reached break; } } @@ -77,114 +69,6 @@ void KeyboardShortcutDialog::doCancel() { } } -void KeyboardShortcutDialog::loadSettings() { - 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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "KB_Shortcuts" ); - - const char* names[] = { - "Center", "Toggle" - }; - - QComboBox* comboboxen[] = { - ui.cbxCenterKey, - ui.cbxToggleKey - }; - - QCheckBox* boxen[2][3] = { - { - ui.chkCenterShift, - ui.chkCenterCtrl, - ui.chkCenterAlt - }, - { - ui.chkToggleShift, - ui.chkToggleCtrl, - ui.chkToggleAlt - } - }; - - const char* modnames[] = { - "Shift", "Ctrl", "Alt" - }; - - const char* keynames[] = { - "Center", "Toggle" - }; - - const int KEY_COUNT = 2; - const int MODIFIERS = 3; - - for (int i = 0; i < KEY_COUNT; i++) - { - for (int m = 0; m < MODIFIERS; m++) - { - boxen[i][m]->setChecked (iniFile.value ( QString("%1_%2").arg(modnames[m], keynames[i]), 0).toBool()); - } - comboboxen[i]->setCurrentIndex(iniFile.value(QString("Key_index_%1").arg(names[i]), 0).toInt()); - } - - iniFile.endGroup (); - - settingsDirty = false; -} - -void KeyboardShortcutDialog::save() { - const char* keynames[] = { - "Center", "Toggle" - }; - - QComboBox* comboboxen[] = { - ui.cbxCenterKey, - ui.cbxToggleKey - }; - - const char* modnames[] = { - "Shift", "Ctrl", "Alt" - }; - - QCheckBox* boxen[2][3] = { - { - ui.chkCenterShift, - ui.chkCenterCtrl, - ui.chkCenterAlt - }, - { - ui.chkToggleShift, - ui.chkToggleCtrl, - ui.chkToggleAlt - } - }; - - const int MODIFIERS = 3; - const int KEY_COUNT = 2; - - 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) - - iniFile.beginGroup ( "KB_Shortcuts" ); - - for (int i = 0; i < KEY_COUNT; i++) - { - for (int m = 0; m < MODIFIERS; m++) - { - iniFile.setValue(QString("%1_%2").arg(modnames[m], keynames[i]), boxen[i][m]->isChecked()); - } - iniFile.setValue(QString("Key_index_%1").arg(keynames[i]), comboboxen[i]->currentIndex()); - } - - iniFile.endGroup(); - - settingsDirty = false; -} - #if defined(_WIN32) #include diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index a98211a8..f8c34be7 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -15,16 +15,9 @@ class KeyboardShortcutDialog: public QWidget Q_OBJECT public: - explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); - virtual ~KeyboardShortcutDialog(); - void showEvent (QShowEvent *); - + KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); private: Ui::UICKeyboardShortcutDialog ui; - void loadSettings(); - void save(); - - bool settingsDirty; FaceTrackNoIR *mainApp; private slots: diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 590d44bf..ae4398ff 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -22,14 +22,13 @@ # include #endif -Tracker::Tracker( FaceTrackNoIR *parent ) : +Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : + mainApp(parent), + s(s), should_quit(false), do_center(false), - enabled(true), - compensate(true), - tcomp_rz(false) + enabled(true) { - mainApp = parent; } Tracker::~Tracker() @@ -37,18 +36,18 @@ Tracker::~Tracker() } static void get_curve(double pos, double& out, THeadPoseDOF& axis) { - bool altp = (pos < 0) && axis.altp; + bool altp = (pos < 0) && axis.opts.altp; if (altp) { - out = axis.invert * axis.curveAlt.getValue(pos); + out = (axis.opts.invert ? -1 : 1) * axis.curveAlt.getValue(pos); axis.curve.setTrackingActive( false ); axis.curveAlt.setTrackingActive( true ); } else { - out = axis.invert * axis.curve.getValue(pos); + out = (axis.opts.invert ? -1 : 1) * axis.curve.getValue(pos); axis.curve.setTrackingActive( true ); axis.curveAlt.setTrackingActive( false ); } - out += axis.zero; + out += axis.opts.zero; } static void t_compensate(double* input, double* output, bool rz) @@ -131,7 +130,7 @@ void Tracker::run() { do_center = false; if (Libraries->pFilter) - Libraries->pFilter->Initialize(); + Libraries->pFilter->reset(); } T6DOF target_camera, target_camera2, new_camera; @@ -154,8 +153,8 @@ void Tracker::run() { get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); } - if (compensate) - t_compensate(output_camera.axes, output_camera.axes, tcomp_rz); + if (mainApp->s.tcomp_p) + t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); if (Libraries->pProtocol) { Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); // degrees & centimeters @@ -188,5 +187,3 @@ void Tracker::getOutputHeadPose( double *data ) { for (int i = 0; i < 6; i++) data[i] = output_camera.axes[i]; } - -void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert? -1.0 : 1.0; } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 987b5a24..b671ac7c 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -12,53 +12,43 @@ #include #include "global-settings.h" #include +#include #include #include "tracker_types.h" +#include "facetracknoir/main-settings.hpp" +#include "facetracknoir/options.hpp" +using namespace options; class FaceTrackNoIR; // pre-define parent-class to avoid circular includes class THeadPoseDOF { private: - THeadPoseDOF(const THeadPoseDOF &) {} - THeadPoseDOF& operator=(const THeadPoseDOF&) { return *this; } + THeadPoseDOF(const THeadPoseDOF &) = delete; + THeadPoseDOF& operator=(const THeadPoseDOF&) = delete; public: - THeadPoseDOF() : - headPos(0), - invert(0), - altp(false), - zero(0) - { - } - THeadPoseDOF(QString primary, QString secondary, int maxInput1, int maxOutput1, int maxInput2, - int maxOutput2) : + int maxOutput2, + axis_opts* opts) : headPos(0), - invert(1), curve(primary, maxInput1, maxOutput1), curveAlt(secondary, maxInput2, maxOutput2), - zero(0) + opts(*opts) { QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); curve.loadSettings(iniFile); curveAlt.loadSettings(iniFile); - - iniFile.beginGroup("Tracking"); - altp = iniFile.value(secondary).toBool(); - iniFile.endGroup(); } volatile double headPos; - volatile float invert; FunctionConfig curve; FunctionConfig curveAlt; - volatile bool altp; - volatile double zero; + axis_opts& opts; }; class Tracker : public QThread { @@ -67,24 +57,21 @@ class Tracker : public QThread { private: FaceTrackNoIR *mainApp; QMutex mtx; + main_settings& s; protected: void run(); public: - Tracker( FaceTrackNoIR *parent ); + Tracker( FaceTrackNoIR *parent, main_settings& s); ~Tracker(); - void setInvertAxis(Axis axis, bool invert); - void getHeadPose(double *data); void getOutputHeadPose(double *data); volatile bool should_quit; volatile bool do_center; volatile bool enabled; - volatile bool compensate; - volatile bool tcomp_rz; T6DOF output_camera; }; @@ -92,14 +79,14 @@ public: class HeadPoseData { public: THeadPoseDOF* axes[6]; - HeadPoseData() + HeadPoseData(std::vector opts) { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100); - axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180); - axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90); - axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180); + axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100, opts[TX]); + axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100, opts[TY]); + axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100, opts[TZ]); + axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]); + axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]); + axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]); } ~HeadPoseData() { -- 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(-) 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 From 379137fcf8fda2fd480d467f82bf072523e707aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:42:51 +0100 Subject: qfc: delete copy ctor --- qfunctionconfigurator/functionconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index a8bb3371..d809259b 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -30,7 +30,7 @@ private: volatile bool _tracking_active; int _max_Input; int _max_Output; - FunctionConfig(const FunctionConfig&) {} + FunctionConfig(const FunctionConfig&) = delete; public: // // Contructor(s) and destructor -- cgit v1.2.3 From d498588f59c5b33a30bd63cd5d7f55ef8d209ecd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:43:02 +0100 Subject: add forgotten settings file for main ui --- facetracknoir/main-settings.hpp | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 facetracknoir/main-settings.hpp diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp new file mode 100644 index 00000000..05c75398 --- /dev/null +++ b/facetracknoir/main-settings.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include +#include "facetracknoir/options.hpp" +using namespace options; + +struct key_opts { + value key_index; + value ctrl, alt, shift; + key_opts(pbundle b, const QString& name) : + key_index(b, QString("key-index-%1").arg(name), 0), + ctrl(b, QString("key-ctrl-%1").arg(name), 0), + alt(b, QString("key-alt-%1").arg(name), 0), + shift(b, QString("key-shift-%1").arg(name), 0) + {} +}; + +struct axis_opts { + value zero; + value invert, altp; + axis_opts(pbundle b, QString pfx) : + zero(b, n(pfx, "zero-pos"), 0), + invert(b, n(pfx, "invert-axis"), false), + altp(b, n(pfx, "alt-axis-sign"), false) + {} +private: + static inline QString n(QString pfx, QString name) { + return QString("%1-%2").arg(pfx, name); + } +}; + +struct main_settings { + pbundle b; + key_opts center_key; + key_opts toggle_key; + value tracker_dll, tracker2_dll, filter_dll, protocol_dll; + axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; + value tcomp_p, tcomp_tz; + main_settings(pbundle b) : + b(b), + center_key(b, "center"), + toggle_key(b, "toggle"), + tracker_dll(b, "tracker-dll", ""), + tracker2_dll(b, "tracker2-dll", ""), + filter_dll(b, "filter-dll", ""), + protocol_dll(b, "protocol-dll", ""), + a_x(b, "x"), + a_y(b, "y"), + a_z(b, "z"), + a_yaw(b, "yaw"), + a_pitch(b, "pitch"), + a_roll(b, "roll"), + tcomp_p(b, "compensate-translation", true), + tcomp_tz(b, "compensate-translation-disable-z-axis", false) + {} +}; -- cgit v1.2.3 From f32f731518ffe2a2b3f7463eda6cf01b7e09eab3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:43:51 +0100 Subject: resize and cleanup aruco ui --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 256 ++++++++++++-------------- 1 file changed, 122 insertions(+), 134 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 710a33e1..3bf141de 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -9,12 +9,12 @@ 0 0 - 704 - 339 + 630 + 315 - + 0 0 @@ -32,78 +32,8 @@ -1 - - - - Horizontal FOV - - - - - - - Enable axes - - - - -1 - - - 6 - - - 0 - - - 6 - - - 0 - - - - - RX - - - - - - - TX - - - - - - - RY - - - - - - - TY - - - - - - - RZ - - - - - - - TZ - - - - - + + @@ -112,9 +42,6 @@ - - - @@ -131,6 +58,20 @@ + + + + Recommended! + + + + + + + Camera name + + + @@ -155,13 +96,6 @@ - - - - Resolution - - - @@ -193,13 +127,6 @@ - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -224,39 +151,109 @@ - - + + - Camera name + Red channel only - - + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + - Red channel only + Horizontal FOV - - + + - Recommended! + Resolution - + + + + Enable axes + + + + -1 + + + 6 + + + 0 + + + 6 + + + 0 + + + + + RX + + + + + + + TX + + + + + + + RY + + + + + + + TY + + + + + + + RZ + + + + + + + TZ + + + + + + + - Head centroid position + Head position Qt::AlignCenter - - - Qt::AlignHCenter|Qt::AlignTop - + @@ -266,6 +263,12 @@ + + + 0 + 0 + + -200.000000000000000 @@ -283,6 +286,12 @@ + + + 0 + 0 + + -200.000000000000000 @@ -300,6 +309,12 @@ + + + 0 + 0 + + -200.000000000000000 @@ -308,32 +323,6 @@ - - - - Pitch - - - - - - - ° - - - 2 - - - -60.000000000000000 - - - 60.000000000000000 - - - 0.000000000000000 - - - @@ -347,7 +336,6 @@ cx cy cz - pitch_deg rx ry rz -- cgit v1.2.3 From faec4fed35fc7e30ba50143a4f7cdbbd68fb0508 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:57:39 +0100 Subject: ewma use settings framework --- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 39 +-------- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 45 ++++------ ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 99 +++------------------- ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 18 ---- 4 files changed, 32 insertions(+), 169 deletions(-) diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 77596b71..4f07443a 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -37,42 +37,13 @@ // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -FTNoIR_Filter::FTNoIR_Filter() +FTNoIR_Filter::FTNoIR_Filter() : first_run(true), alpha_smoothing(0.02) { - first_run = true; - alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later - loadSettings(); // Load the Settings } -void FTNoIR_Filter::receiveSettings(double smin, double smax, double sexpt) +void FTNoIR_Filter::receiveSettings() { - QMutexLocker foo(&mutex); - - kMinSmoothing = smin; - kMaxSmoothing = smax; - kSmoothingScaleCurve = sexpt; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Filter::loadSettings() { - qDebug() << "FTNoIR_Filter::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_Filter::loadSettings says: iniFile = " << currentFile; - - // - // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR - // - iniFile.beginGroup ( "Tracking" ); - kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt(); - kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt(); - kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt(); - iniFile.endGroup (); + s.b->reload(); } void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, @@ -93,15 +64,13 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, return; } - QMutexLocker foo(&mutex); - for (int i=0;i<6;i++) { // Calculate the delta. delta=target_camera_position[i]-current_camera_position[i]; // Normalise the delta. delta=std::min(std::max(fabs(delta)/scale[i],0.0),1.0); // Calculate the new alpha from the normalized delta. - new_alpha=1.0/(kMinSmoothing+((1.0-pow(delta,kSmoothingScaleCurve))*(kMaxSmoothing-kMinSmoothing))); + new_alpha=1.0/(s.kMinSmoothing+((1.0-pow(delta,s.kSmoothingScaleCurve))*(s.kMaxSmoothing-s.kMinSmoothing))); // Update the smoothed alpha. alpha[i]=(alpha_smoothing*new_alpha)+((1.0-alpha_smoothing)*alpha[i]); } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 7c98b2cb..6e9a7f9a 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -31,35 +31,35 @@ #include "ui_ftnoir_ewma_filtercontrols.h" #include #include +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value kMinSmoothing, kMaxSmoothing, kSmoothingScaleCurve; + settings() : + b(bundle("ewma-filter")), + kMinSmoothing(b, "min-smoothing", 15), + kMaxSmoothing(b, "max-smoothing", 50), + kSmoothingScaleCurve(b, "smoothing-scale-curve", 10) + {} +}; + -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); void reset() {} - void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position); - void receiveSettings(double smin, double smax, double sexpt); - + void receiveSettings(); private: - void loadSettings(); // Load the settings from the INI-file - double newHeadPose; // Structure with new headpose - bool first_run; double alpha_smoothing; double alpha[6]; - - double kMinSmoothing; - double kMaxSmoothing; - double kSmoothingScaleCurve; double current_camera_position[6]; - QMutex mutex; + settings s; }; //******************************************************************************************************* @@ -71,26 +71,19 @@ class FilterControls: public QWidget, public IFilterDialog { Q_OBJECT public: - explicit FilterControls(); - void showEvent (QShowEvent *); + FilterControls(); void registerFilter(IFilter* flt); void unregisterFilter(); private: Ui::UICFilterControls ui; - void loadSettings(); void save(); - - /** helper **/ - bool settingsDirty; - + settings s; FTNoIR_Filter* pFilter; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged( int ) { settingsDirty = true; } }; //******************************************************************************************************* @@ -99,8 +92,6 @@ private slots: class FTNoIR_FilterDll : public Metadata { public: - FTNoIR_FilterDll(); - ~FTNoIR_FilterDll(); void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); } void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); } void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index eb414340..e452c6f0 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -28,35 +28,17 @@ #include "facetracknoir/global-settings.h" #include "ui_ftnoir_ewma_filtercontrols.h" -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// FilterControls::FilterControls() : QWidget(), pFilter(NULL) { - ui.setupUi( this ); + ui.setupUi( this ); - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Connect sliders for reduction factor - connect(ui.minSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.maxSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.powCurve, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - qDebug() << "FilterControls() says: started"; - - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.kMaxSmoothing, ui.maxSmooth); + tie_setting(s.kMinSmoothing, ui.minSmooth); + tie_setting(s.kSmoothingScaleCurve, ui.powCurve); } void FilterControls::registerFilter(IFilter* flt) @@ -69,34 +51,23 @@ void FilterControls::unregisterFilter() pFilter = NULL; } -// -// OK clicked on server-dialog -// void FilterControls::doOK() { save(); this->close(); } -// override show event -void FilterControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void FilterControls::doCancel() { // // Ask if changed Settings should be saved // - 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 ); qDebug() << "doCancel says: answer =" << ret; switch (ret) { case QMessageBox::Save: - save(); + save(); this->close(); break; case QMessageBox::Discard: @@ -115,62 +86,12 @@ void FilterControls::doCancel() { } } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FilterControls::loadSettings() { - qDebug() << "FilterControls::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() << "FilterControls::loadSettings says: iniFile = " << currentFile; - - // - // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR - // - iniFile.beginGroup ( "Tracking" ); - ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt()); - ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt()); - ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// void FilterControls::save() { - 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) - - double smooth_min, smooth_max, smooth_expt; - - iniFile.beginGroup ( "Tracking" ); - iniFile.setValue ( "minSmooth", smooth_min = ui.minSmooth->value() ); - iniFile.setValue ( "powCurve", smooth_expt = ui.powCurve->value() ); - iniFile.setValue ( "maxSmooth", smooth_max = ui.maxSmooth->value() ); - iniFile.endGroup (); - - settingsDirty = false; - + s.b->save(); if (pFilter) - pFilter->receiveSettings(smooth_min, smooth_max, smooth_expt); + pFilter->receiveSettings(); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog( ) { return new FilterControls; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp index 087ede1b..6ef7768e 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #include "ftnoir_filter_ewma2.h" -#include #include "facetracknoir/global-settings.h" -FTNoIR_FilterDll::FTNoIR_FilterDll() { -} - -FTNoIR_FilterDll::~FTNoIR_FilterDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") - extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_FilterDll; -- cgit v1.2.3 From 2c88cc23a4b68261a43895ecc5197658bbe20884 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 09:02:29 +0100 Subject: ewma: discard settings on cancel --- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index e452c6f0..7ab2b09c 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -61,7 +61,7 @@ void FilterControls::doCancel() { // Ask if changed Settings should be saved // 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 ); + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); qDebug() << "doCancel says: answer =" << ret; @@ -71,13 +71,11 @@ void FilterControls::doCancel() { 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; } } -- cgit v1.2.3 From 754c2e6ce637698d8aaf16d5bf05e8185e17b9ef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 09:05:35 +0100 Subject: kalman: remove (all) settings not hooked up --- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 16 +-- .../ftnoir_kalman_filtercontrols.ui | 120 --------------------- ftnoir_filter_kalman/kalman.cpp | 47 +------- 3 files changed, 4 insertions(+), 179 deletions(-) diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 9e0d817d..8f5bcd8b 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -21,13 +21,13 @@ #include #include #include +#include "facetracknoir/options.hpp" +using namespace options; class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - ~FTNoIR_Filter() virt_override { - } void reset() virt_override; void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) virt_override; @@ -39,9 +39,6 @@ public: qint64 timedelta; }; -void kalman_load_settings(FTNoIR_Filter&); -void kalman_save_settings(FTNoIR_Filter&); - class FTNOIR_FILTER_BASE_EXPORT FTNoIR_FilterDll : public Metadata { public: @@ -55,7 +52,7 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi { Q_OBJECT public: - explicit FilterControls() : settingsDirty(false) { + FilterControls() { ui.setupUi(this); QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -68,19 +65,12 @@ public: connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); } - void showEvent ( QShowEvent * ) virt_override { - show(); - } - bool settingsDirty; Ui::KalmanUICFilterControls ui; virtual void registerFilter(IFilter*) virt_override {} virtual void unregisterFilter() virt_override {} public slots: void doOK(); void doCancel(); - void settingsChanged(double) { - settingsDirty = true; - } }; #endif diff --git a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui index 7b71712a..d1cff81e 100644 --- a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui +++ b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui @@ -63,126 +63,6 @@ Cancel - - - - 9 - 30 - 169 - 16 - - - - process-noise-covariance - - - - - - 180 - 26 - 150 - 22 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 14 - - - 1.000000000000000 - - - 0.000001000000000 - - - 0.500000000000000 - - - - - - 180 - 6 - 150 - 22 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 14 - - - 1.000000000000000 - - - 0.000001000000000 - - - 0.500000000000000 - - - - - - 9 - 10 - 165 - 16 - - - - post-error-matrix - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 0 - - - - - - 9 - 55 - 109 - 16 - - - - accel-coefficient - - - - - - 181 - 47 - 150 - 22 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 6 - - - 1000000000.000000000000000 - - - 0.000001000000000 - - - 1.000000000000000 - - diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index 743eb3d4..bef6ddad 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -9,28 +9,7 @@ #include #include -void kalman_load_settings(FTNoIR_Filter&) { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - iniFile.beginGroup("ftnoir-filter-kalman"); - iniFile.endGroup(); -} - -void kalman_save_settings(FilterControls&) { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - iniFile.beginGroup("ftnoir-filter-kalman"); - iniFile.endGroup(); -} - FTNoIR_Filter::FTNoIR_Filter() { - kalman_load_settings(*this); reset(); } @@ -135,35 +114,11 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, } void FilterControls::doOK() { - kalman_save_settings(*this); close(); } void FilterControls::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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - kalman_save_settings(*this); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + close(); } extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -- cgit v1.2.3 From 7bd962db428e403b7e53f9671af313b835f4b858 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 09:25:47 +0100 Subject: fgfs: use settings framework --- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 321 +++++++---------------- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 41 +-- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 52 ++-- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 168 +++--------- ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 17 -- 5 files changed, 151 insertions(+), 448 deletions(-) diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index fd0df6b0..f3b54486 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -9,8 +9,8 @@ 0 0 - 518 - 208 + 404 + 112 @@ -26,239 +26,101 @@ false - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Qt::RightToLeft - - - Local PC only - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - + + + + + IP-address remote PC + + - - - - Qt::Vertical + + + + + 60 + 16777215 + + + + 255 - + + 1 + + + + + + - 20 - 40 + 60 + 16777215 - + + 255 + + + 1 + + - - - - - - If FlightGear is on the same PC as FaceTrackNoIR, tick the 'Local PC only' box. - - - - - - - Otherwise: enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - + + + + + 60 + 16777215 + + + + 255 + + + 1 + + - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + @@ -268,9 +130,6 @@ spinIPThirdNibble spinIPFourthNibble spinPortNumber - btnOK - btnCancel - chkLocalPC diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 08e7370b..0ef6b50f 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -26,41 +26,14 @@ * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ #include "ftnoir_protocol_fg.h" -#include #include "facetracknoir/global-settings.h" #include // For Todd and Arda Kutlu -FTNoIR_Protocol::FTNoIR_Protocol() +void FTNoIR_Protocol::reloadSettings() { - loadSettings(); -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ -} - -void FTNoIR_Protocol::loadSettings() { - 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) - - iniFile.beginGroup ( "FG" ); - - bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool(); - if (blnLocalPC) { - destIP = QHostAddress::LocalHost; - } - else { - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - } - destPort = iniFile.value ( "PortNumber", 5542 ).toInt(); - - iniFile.endGroup (); - + s.b->reload(); } void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { @@ -71,13 +44,15 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { FlightData.h = headpose[Yaw]; FlightData.r = headpose[Roll]; FlightData.status = 1; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + int destPort = s.port; (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(destPort)); } -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 0a255d84..13aaeab4 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -26,9 +26,6 @@ * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ #pragma once -#ifndef INCLUDED_FGSERVER_H -#define INCLUDED_FGSERVER_H - #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ui_ftnoir_fgcontrols.h" #include "fgtypes.h" @@ -36,23 +33,36 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value ip1, ip2, ip3, ip4; + value port; + settings() : + b(bundle("flightgear-proto")), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 5542) + {} +}; class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { return "FlightGear"; } + void reloadSettings(); private: + settings s; TFlightGearData FlightData; - QUdpSocket outSocket; // Send to FligthGear - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); + QUdpSocket outSocket; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -60,47 +70,27 @@ class FGControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FGControls(); + FGControls(); void registerProtocol(IProtocol *protocol) { theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol } void unRegisterProtocol() { theProtocol = NULL; // Reset the pointer } - private: Ui::UICFGControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; FTNoIR_Protocol *theProtocol; - + settings s; private slots: void doOK(); void doCancel(); - void chkLocalPCOnlyChanged(); - void settingChanged() { settingsDirty = true; } }; -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); } void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); } void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); } - void getIcon(QIcon *icon) { *icon = QIcon(":/images/flightgear.png"); } }; - - -#endif//INCLUDED_FGSERVER_H -//END diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index cb11ace6..887020c5 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -37,155 +37,51 @@ // // Constructor for server-settings-dialog // -FGControls::FGControls() : -QWidget() +FGControls::FGControls() : theProtocol(nullptr) { ui.setupUi( this ); - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} + tie_setting(s.ip1, ui.spinIPFirstNibble); + tie_setting(s.ip2, ui.spinIPSecondNibble); + tie_setting(s.ip3, ui.spinIPThirdNibble); + tie_setting(s.ip4, ui.spinIPFourthNibble); + tie_setting(s.port, ui.spinPortNumber); - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); - connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); } -// -// OK clicked on server-dialog -// void FGControls::doOK() { - save(); + s.b->save(); this->close(); + if (theProtocol) + theProtocol->reloadSettings(); } -// -// Cancel clicked on server-dialog -// void FGControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + 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 ); + switch (ret) { + case QMessageBox::Save: + s.b->save(); + if (theProtocol) + theProtocol->reloadSettings(); + this->close(); + break; + case QMessageBox::Discard: + s.b->revert(); + close(); + break; + case QMessageBox::Cancel: + default: + break; + } + } + else { + this->close(); + } } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FGControls::loadSettings() { -// qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FG" ); - ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); - - ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5542 ).toInt() ); - iniFile.endGroup (); - - chkLocalPCOnlyChanged(); - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FGControls::save() { - 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) - - iniFile.beginGroup ( "FG" ); - iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); - iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Handle change of the checkbox. -// -void FGControls::chkLocalPCOnlyChanged() { - - if ( ui.chkLocalPC->isChecked() ) { - ui.spinIPFirstNibble->setValue( 127 ); - ui.spinIPFirstNibble->setEnabled ( false ); - ui.spinIPSecondNibble->setValue( 0 ); - ui.spinIPSecondNibble->setEnabled ( false ); - ui.spinIPThirdNibble->setValue( 0 ); - ui.spinIPThirdNibble->setEnabled ( false ); - ui.spinIPFourthNibble->setValue( 1 ); - ui.spinIPFourthNibble->setEnabled ( false ); - } - else { - ui.spinIPFirstNibble->setEnabled ( true ); - ui.spinIPSecondNibble->setEnabled ( true ); - ui.spinIPThirdNibble->setEnabled ( true ); - ui.spinIPFourthNibble->setEnabled ( true ); - } - - settingsDirty = true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) { return new FGControls; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp index 6c7e7c52..3125f136 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -26,23 +26,6 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_ProtocolDll; -- cgit v1.2.3 From a93c86a81574d4d8410448c46b6de3a7ce06505a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:21:25 +0100 Subject: fix qt being broken as usual, by cleanup --- CMakeLists.txt | 189 +++++++++++---------------------------------------------- 1 file changed, 37 insertions(+), 152 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b36cb27..aa551885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ if(GIT_FOUND) git_describe(OPENTRACK__COMMIT --tags --always) endif() +include_directories(${CMAKE_SOURCE_DIR}) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_COMPILER_IS_GNUCC TRUE) set(CMAKE_COMPILER_IS_GNUCXX TRUE) @@ -39,6 +41,7 @@ SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOMOC_RELAXED_MODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API -DIN_OPENTRACK) @@ -174,171 +177,53 @@ else() include_directories("qxt-mini/") endif() endif() -# main app -file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp") -file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") +# qt being broken as usual +set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h") -file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") -file(GLOB opentrack-bin-h "facetracknoir/*.h" "facetracknoir/*.hpp") -file(GLOB opentrack-bin-ui "facetracknoir/*.ui") -file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") -QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) -QT5_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc}) +macro(opentrack_module n dir) + file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" ${EXTRA-MOCS}) + file(GLOB ${n}-ui "${dir}/*.ui") + file(GLOB ${n}-rc "${dir}/*.qrc") + QT5_WRAP_UI(${n}-uih ${${n}-ui}) + QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) +endmacro() -file(GLOB opentrack-pose-widget-c "ftnoir_posewidget/*.cpp") -file(GLOB opentrack-pose-widget-h "ftnoir_posewidget/*.h") -file(GLOB opentrack-pose-widget-rc "ftnoir_posewidget/*.qrc") -QT5_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc}) +file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp") +file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") -file(GLOB opentrack-spline-widget-c "qfunctionconfigurator/*.cpp") -file(GLOB opentrack-spline-widget-h "qfunctionconfigurator/*.h") +opentrack_module(opentrack-bin facetracknoir) +opentrack_module(opentrack-pose-widget ftnoir_posewidget) +opentrack_module(opentrack-spline-widget qfunctionconfigurator) # filters -file(GLOB opentrack-filter-accela-c "ftnoir_filter_accela/*.cpp") -file(GLOB opentrack-filter-accela-h "ftnoir_filter_accela/*.h") -file(GLOB opentrack-filter-accela-ui "ftnoir_filter_accela/*.ui") -file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc") -QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) -QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) - -file(GLOB opentrack-filter-kalman-c "ftnoir_filter_kalman/*.cpp") -file(GLOB opentrack-filter-kalman-h "ftnoir_filter_kalman/*.h") -file(GLOB opentrack-filter-kalman-ui "ftnoir_filter_kalman/*.ui") -file(GLOB opentrack-filter-kalman-rc "ftnoir_filter_kalman/*.qrc") -QT5_WRAP_UI(opentrack-filter-kalman-uih ${opentrack-filter-kalman-ui}) -QT5_ADD_RESOURCES(opentrack-filter-kalman-rcc ${opentrack-filter-kalman-rc}) - -file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp") -file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h") -file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui") -file(GLOB opentrack-filter-ewma-rc "ftnoir_filter_ewma2/*.qrc") -QT5_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui}) -QT5_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc}) +opentrack_module(opentrack-filter-accela ftnoir_filter_accela) +opentrack_module(opentrack-filter-kalman ftnoir_filter_kalman) +opentrack_module(opentrack-filter-ewma ftnoir_filter_ewma2) # protocols -file(GLOB opentrack-proto-fgfs-c "ftnoir_protocol_fg/*.cpp") -file(GLOB opentrack-proto-fgfs-h "ftnoir_protocol_fg/*.h") -file(GLOB opentrack-proto-fgfs-ui "ftnoir_protocol_fg/*.ui") -file(GLOB opentrack-proto-fgfs-rc "ftnoir_protocol_fg/*.qrc") -QT5_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui}) -QT5_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc}) - -file(GLOB opentrack-proto-fsuipc-c "ftnoir_protocol_fsuipc/*.cpp") -file(GLOB opentrack-proto-fsuipc-h "ftnoir_protocol_fsuipc/*.h") -file(GLOB opentrack-proto-fsuipc-ui "ftnoir_protocol_fsuipc/*.ui") -file(GLOB opentrack-proto-fsuipc-rc "ftnoir_protocol_fsuipc/*.qrc") -QT5_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui}) -QT5_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc}) - -file(GLOB opentrack-proto-freetrack-c "ftnoir_protocol_ft/*.cpp") -file(GLOB opentrack-proto-freetrack-h "ftnoir_protocol_ft/*.h") -file(GLOB opentrack-proto-freetrack-ui "ftnoir_protocol_ft/*.ui") -file(GLOB opentrack-proto-freetrack-rc "ftnoir_protocol_ft/*.qrc") -QT5_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui}) -QT5_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc}) - -file(GLOB opentrack-proto-udp-c "ftnoir_protocol_ftn/*.cpp") -file(GLOB opentrack-proto-udp-h "ftnoir_protocol_ftn/*.h") -file(GLOB opentrack-proto-udp-ui "ftnoir_protocol_ftn/*.ui") -file(GLOB opentrack-proto-udp-rc "ftnoir_protocol_ftn/*.qrc") -QT5_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui}) -QT5_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc}) - -file(GLOB opentrack-proto-wine-c "ftnoir_protocol_wine/*.cpp") -file(GLOB opentrack-proto-wine-h "ftnoir_protocol_wine/*.h") -file(GLOB opentrack-proto-wine-ui "ftnoir_protocol_wine/*.ui") -file(GLOB opentrack-proto-wine-rc "ftnoir_protocol_wine/*.qrc") -QT5_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui}) -QT5_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc}) - -file(GLOB opentrack-proto-win32-mouse-c "ftnoir_protocol_mouse/*.cpp") -file(GLOB opentrack-proto-win32-mouse-h "ftnoir_protocol_mouse/*.h") -file(GLOB opentrack-proto-win32-mouse-ui "ftnoir_protocol_mouse/*.ui") -file(GLOB opentrack-proto-win32-mouse-rc "ftnoir_protocol_mouse/*.qrc") -QT5_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui}) -QT5_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc}) - -file(GLOB opentrack-proto-simconnect-c "ftnoir_protocol_sc/*.cpp" "ftnoir_protocol_sc/ftnoir-protocol-sc.rc") -file(GLOB opentrack-proto-simconnect-h "ftnoir_protocol_sc/*.h") -file(GLOB opentrack-proto-simconnect-ui "ftnoir_protocol_sc/*.ui") -file(GLOB opentrack-proto-simconnect-rc "ftnoir_protocol_sc/*.qrc") -QT5_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) -QT5_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) - -file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp") -file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h") -file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui") -file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc") -QT5_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) -QT5_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) - -file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp") -file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h") -file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui") -file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc") -QT5_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) -QT5_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) +opentrack_module(opentrack-proto-fgfs ftnoir_protocol_fg) +opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) +opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft) +opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn) +opentrack_module(opentrack-proto-wine ftnoir_protocol_wine) +opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) +opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc) +opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy) +opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev) # trackers -file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") -file(GLOB opentrack-tracker-ht-h "ftnoir_tracker_ht/*.h") -file(GLOB opentrack-tracker-ht-ui "ftnoir_tracker_ht/*.ui") -file(GLOB opentrack-tracker-ht-rc "ftnoir_tracker_ht/*.qrc") -QT5_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc}) - -file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp") -file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") -file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") -file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") -QT5_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) - -file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") -file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h") -file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui") -file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc") -QT5_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) - -file(GLOB opentrack-tracker-udp-c "ftnoir_tracker_udp/*.cpp") -file(GLOB opentrack-tracker-udp-h "ftnoir_tracker_udp/*.h") -file(GLOB opentrack-tracker-udp-ui "ftnoir_tracker_udp/*.ui") -file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc") -QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) - -file(GLOB opentrack-tracker-joystick-c "ftnoir_tracker_joystick/*.cpp") -file(GLOB opentrack-tracker-joystick-h "ftnoir_tracker_joystick/*.h") -file(GLOB opentrack-tracker-joystick-ui "ftnoir_tracker_joystick/*.ui") -file(GLOB opentrack-tracker-joystick-rc "ftnoir_tracker_joystick/*.qrc") -QT5_WRAP_UI(opentrack-tracker-joystick-uih ${opentrack-tracker-joystick-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-joystick-rcc ${opentrack-tracker-joystick-rc}) - -file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp") -file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h") -file(GLOB opentrack-tracker-rift-ui "ftnoir_tracker_rift/*.ui") -file(GLOB opentrack-tracker-rift-rc "ftnoir_tracker_rift/*.qrc") -QT5_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc}) - -file(GLOB opentrack-tracker-hydra-c "ftnoir_tracker_hydra/*.cpp") -file(GLOB opentrack-tracker-hydra-h "ftnoir_tracker_hydra/*.h") -file(GLOB opentrack-tracker-hydra-ui "ftnoir_tracker_hydra/*.ui") -file(GLOB opentrack-tracker-hydra-rc "ftnoir_tracker_hydra/*.qrc") -QT5_WRAP_UI(opentrack-tracker-hydra-uih ${opentrack-tracker-hydra-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-hydra-rcc ${opentrack-tracker-hydra-rc}) - -file(GLOB opentrack-tracker-hatire-c "ftnoir_tracker_hatire/*.cpp") -file(GLOB opentrack-tracker-hatire-h "ftnoir_tracker_hatire/*.h") -file(GLOB opentrack-tracker-hatire-ui "ftnoir_tracker_hatire/*.ui") -file(GLOB opentrack-tracker-hatire-rc "ftnoir_tracker_hatire/*.qrc") -QT5_WRAP_UI(opentrack-tracker-hatire-uih ${opentrack-tracker-hatire-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-hatire-rcc ${opentrack-tracker-hatire-rc}) +opentrack_module(opentrack-tracker-ht ftnoir_tracker_ht) +opentrack_module(opentrack-tracker-aruco ftnoir_tracker_aruco) +opentrack_module(opentrack-tracker-pt FTNoIR_Tracker_PT) +opentrack_module(opentrack-tracker-udp ftnoir_tracker_udp) +opentrack_module(opentrack-tracker-joystick ftnoir_tracker_joystick) +opentrack_module(opentrack-tracker-rift ftnoir_tracker_rift) +opentrack_module(opentrack-tracker-hydra ftnoir_tracker_hydra) +opentrack_module(opentrack-tracker-hatire ftnoir_tracker_hatire) file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp") -- cgit v1.2.3 From 647b9c58e437fa2c3f0464f630001e1c0b53927a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:39:58 +0100 Subject: cmake: clean up unreferenced globs --- CMakeLists.txt | 61 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa551885..2033a597 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,8 +189,7 @@ macro(opentrack_module n dir) QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) endmacro() -file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp") -file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") +file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/global-settings.h") opentrack_module(opentrack-bin facetracknoir) opentrack_module(opentrack-pose-widget ftnoir_posewidget) @@ -225,11 +224,11 @@ opentrack_module(opentrack-tracker-rift ftnoir_tracker_rift) opentrack_module(opentrack-tracker-hydra ftnoir_tracker_hydra) opentrack_module(opentrack-tracker-hatire ftnoir_tracker_hatire) -file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp") +file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp" "ftnoir_csv/*.h") # compat lib for POSIX/win32 -file(GLOB opentrack-compat-c "compat/*.cpp") +file(GLOB opentrack-compat-c "compat/*.cpp" "compat/*.h") # x-plane plugin file(GLOB opentrack-xplane-plugin-c "x-plane-plugin/*.c") @@ -271,7 +270,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") endif() -add_library(opentrack-compat SHARED ${opentrack-compat-c} ${opentrack-compat-h}) +add_library(opentrack-compat SHARED ${opentrack-compat-c}) if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() @@ -298,18 +297,18 @@ else() ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${maybe-hatire} ${my-qt-deps}) endif() -add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) +add_library(opentrack-csv SHARED ${opentrack-csv-c}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) -add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${opentrack-pose-widget-moc} ${opentrack-pose-widget-rcc}) +add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-rcc}) target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) -add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c} ${opentrack-spline-widget-h} ${opentrack-spline-widget-moc}) +add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c}) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) -add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) +add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) -add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-h} ${opentrack-filter-kalman-moc} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) +add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) @@ -322,7 +321,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) +add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-rcc}) target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) @@ -330,7 +329,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) +add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-fgfs @@ -339,7 +338,7 @@ endif() if(WIN32 AND SDK_VJOY) include_directories(${SDK_VJOY}) - add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-h} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) if(MSVC) target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") else() @@ -352,7 +351,7 @@ if(WIN32 AND SDK_VJOY) endif() if(UNIX AND SDK_ENABLE_LIBEVDEV) - add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) + add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-libevdev @@ -363,7 +362,7 @@ endif() if(WIN32) if(SDK_FSUIPC) - add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-h} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) + add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") if(MSVC) set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") @@ -373,24 +372,24 @@ if(WIN32) endif() if(SDK_SIMCONNECT) - add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-h} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) + add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) include_directories("${SDK_SIMCONNECT}/inc") target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") endif() - add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-h} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) + add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) - add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) + add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) - add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) + add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup -fno-lto -Wl,-kill-at" PREFIX "" COMPILE_FLAGS "-fno-lto") endif() endif() -add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) +add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-udp @@ -398,7 +397,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) endif() if(WIN32) - add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) + add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-joystick @@ -407,7 +406,7 @@ if(WIN32) endif() if(NOT WIN32 AND SDK_WINE_PREFIX) - add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) + add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-wine @@ -439,7 +438,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) +add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-ht @@ -448,7 +447,7 @@ endif() if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) - add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) + add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-aruco @@ -463,7 +462,7 @@ if(SDK_ARUCO_LIBPATH) endif() if(SDK_HATIRE) - add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-h} ${opentrack-tracker-hatire-moc} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc}) + add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc}) target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS}) install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) @@ -484,7 +483,7 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) +add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) if(APPLE) @@ -504,7 +503,7 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) +add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-udp @@ -514,7 +513,7 @@ endif() if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") - add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) + add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) @@ -546,7 +545,7 @@ if(SDK_RIFT) if(SDK_HYDRA) include_directories("${SDK_HYDRA}/include") include_directories("${SDK_HYDRA}/include/sixense_utils") - add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-h} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) + add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) target_link_libraries(opentrack-tracker-hydra @@ -594,7 +593,7 @@ if(UNIX OR APPLE) target_link_libraries(opentrack-qxt-mini X11) endif() endif() -add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-h} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc}) +add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-uih} ${opentrack-bin-rcc}) set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") set(OPENTRACK_COMMIT_VERSION \"${OPENTRACK__COMMIT}\") configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/opentrack-version.h" @ONLY NEWLINE_STYLE UNIX) @@ -603,7 +602,7 @@ if(APPLE) SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") endif() -add_library(opentrack-api SHARED ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) +add_library(opentrack-api SHARED ${opentrack-lib-c}) target_link_libraries(opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-api PROPERTIES -- cgit v1.2.3 From f460f501d169df9e21825ebe31c9c21fb2692dfa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:40:10 +0100 Subject: rename --- facetracknoir/options.h | 303 ++++++++++++++++++++++++++++++++++++++++++++++ facetracknoir/options.hpp | 303 ---------------------------------------------- 2 files changed, 303 insertions(+), 303 deletions(-) create mode 100644 facetracknoir/options.h delete mode 100644 facetracknoir/options.hpp diff --git a/facetracknoir/options.h b/facetracknoir/options.h new file mode 100644 index 00000000..1305bd0a --- /dev/null +++ b/facetracknoir/options.h @@ -0,0 +1,303 @@ +/* Copyright (c) 2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# define ov override +#else +# define ov +#endif + +namespace options { + template + inline T qcruft_to_t (const QVariant& t); + + template<> + inline int qcruft_to_t(const QVariant& t) + { + return t.toInt(); + } + + template<> + inline QString qcruft_to_t(const QVariant& t) + { + return t.toString(); + } + + template<> + inline bool qcruft_to_t(const QVariant& t) + { + return t.toBool(); + } + + template<> + inline double qcruft_to_t(const QVariant& t) + { + return t.toDouble(); + } + + template<> + inline QVariant qcruft_to_t(const QVariant& t) + { + return t; + } + + // snapshot of qsettings group at given time + class group { + private: + QMap map; + QString name; + public: + group(const QString& name) : name(name) + { + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile(currentFile, QSettings::IniFormat); + iniFile.beginGroup(name); + for (auto& k : iniFile.childKeys()) + map[k] = iniFile.value(k); + iniFile.endGroup(); + } + static constexpr const char* org = "opentrack"; + void save() { + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings s(currentFile, QSettings::IniFormat); + s.beginGroup(name); + for (auto& k : map.keys()) + s.setValue(k, map[k]); + s.endGroup(); + } + template + T get(const QString& k) { + return qcruft_to_t(map.value(k)); + } + + void put(const QString& s, const QVariant& d) + { + map[s] = d; + } + bool contains(const QString& s) + { + return map.contains(s); + } + }; + + class impl_bundle : public QObject { + Q_OBJECT + private: + QMutex mtx; + const QString group_name; + group saved; + group transient; + impl_bundle(const impl_bundle&) = delete; + impl_bundle& operator=(const impl_bundle&) = delete; + bool modified; + public: + impl_bundle(const QString& group_name) : + mtx(QMutex::Recursive), + group_name(group_name), + saved(group_name), + transient(saved), + modified(false) + { + } + /* keep in mind doesn't fire signals */ + void reload() { + QMutexLocker l(&mtx); + saved = group(group_name); + transient = saved; + emit reloaded(); + } + + std::shared_ptr make(const QString& name) { + return std::make_shared(name); + } + void store(const QString& name, const QVariant& datum) + { + QMutexLocker l(&mtx); + if (!transient.contains(name) || datum != transient.get(name)) + { + modified = true; + transient.put(name, datum); + emit bundleChanged(); + } + } + bool contains(const QString& name) + { + QMutexLocker l(&mtx); + return transient.contains(name); + } + template + T get(const QString& name) { + QMutexLocker l(&mtx); + return transient.get(name); + } + void save() + { + QMutexLocker l(&mtx); + modified = false; + saved = transient; + transient.save(); + } + void revert() + { + QMutexLocker l(&mtx); + modified = false; + transient = saved; + emit bundleChanged(); + } + + bool modifiedp() { + QMutexLocker l(&mtx); + return modified; + } + signals: + void bundleChanged(); + void reloaded(); + }; + + typedef std::shared_ptr pbundle; + + class base_value : public QObject { + Q_OBJECT + public: + base_value(pbundle b, const QString& name) : b(b), self_name(name) { + connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); + } + virtual QVariant operator=(const QVariant& datum) = 0; + protected: + pbundle b; + QString self_name; + public slots: + void reread_value() + { + this->operator=(b->get(self_name)); + } + public slots: +#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } + DEFINE_SLOT(double) + DEFINE_SLOT(int) + DEFINE_SLOT(QString) + DEFINE_SLOT(bool) + signals: +#define DEFINE_SIGNAL(t) void valueChanged(t); + DEFINE_SIGNAL(double) + DEFINE_SIGNAL(int) + DEFINE_SIGNAL(QString) + DEFINE_SIGNAL(bool) + }; + + template + class value : public base_value { + private: T def; + public: + static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; + value(pbundle b, const QString& name, T def) : + base_value(b, name), def(def) + { + if (!b->contains(name)) + { + QVariant cruft(def); + b->store(self_name, cruft); + } + } + operator T() { return b->get(self_name); } + QVariant operator=(const QVariant& datum) { + b->store(self_name, datum); + auto foo = qcruft_to_t(datum); + emit valueChanged(foo); + return datum; + } + }; + + template + inline void tie_setting(value&, Q*); + + template<> + inline void tie_setting(value& v, QComboBox* cb) + { + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); + cb->setCurrentIndex(v); + } + + template<> + inline void tie_setting(value& v, QComboBox* cb) + { + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); + cb->setCurrentText(v); + } + + template<> + inline void tie_setting(value& v, QCheckBox* cb) + { + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); + cb->setChecked(v); + } + + template<> + inline void tie_setting(value& v, QDoubleSpinBox* dsb) + { + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); + dsb->setValue(v); + } + + template<> + inline void tie_setting(value& v, QSpinBox* sb) + { + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); + sb->setValue(v); + } + + template<> + inline void tie_setting(value& v, QSlider* sl) + { + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); + sl->setValue(v); + } + + template<> + inline void tie_setting(value& v, QLineEdit* le) + { + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); + le->setText(v); + } + + inline pbundle bundle(const QString& group) { + return std::make_shared(group); + } +} diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp deleted file mode 100644 index 1305bd0a..00000000 --- a/facetracknoir/options.hpp +++ /dev/null @@ -1,303 +0,0 @@ -/* Copyright (c) 2013 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -# define ov override -#else -# define ov -#endif - -namespace options { - template - inline T qcruft_to_t (const QVariant& t); - - template<> - inline int qcruft_to_t(const QVariant& t) - { - return t.toInt(); - } - - template<> - inline QString qcruft_to_t(const QVariant& t) - { - return t.toString(); - } - - template<> - inline bool qcruft_to_t(const QVariant& t) - { - return t.toBool(); - } - - template<> - inline double qcruft_to_t(const QVariant& t) - { - return t.toDouble(); - } - - template<> - inline QVariant qcruft_to_t(const QVariant& t) - { - return t; - } - - // snapshot of qsettings group at given time - class group { - private: - QMap map; - QString name; - public: - group(const QString& name) : name(name) - { - QSettings settings(group::org); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile(currentFile, QSettings::IniFormat); - iniFile.beginGroup(name); - for (auto& k : iniFile.childKeys()) - map[k] = iniFile.value(k); - iniFile.endGroup(); - } - static constexpr const char* org = "opentrack"; - void save() { - QSettings settings(group::org); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings s(currentFile, QSettings::IniFormat); - s.beginGroup(name); - for (auto& k : map.keys()) - s.setValue(k, map[k]); - s.endGroup(); - } - template - T get(const QString& k) { - return qcruft_to_t(map.value(k)); - } - - void put(const QString& s, const QVariant& d) - { - map[s] = d; - } - bool contains(const QString& s) - { - return map.contains(s); - } - }; - - class impl_bundle : public QObject { - Q_OBJECT - private: - QMutex mtx; - const QString group_name; - group saved; - group transient; - impl_bundle(const impl_bundle&) = delete; - impl_bundle& operator=(const impl_bundle&) = delete; - bool modified; - public: - impl_bundle(const QString& group_name) : - mtx(QMutex::Recursive), - group_name(group_name), - saved(group_name), - transient(saved), - modified(false) - { - } - /* keep in mind doesn't fire signals */ - void reload() { - QMutexLocker l(&mtx); - saved = group(group_name); - transient = saved; - emit reloaded(); - } - - std::shared_ptr make(const QString& name) { - return std::make_shared(name); - } - void store(const QString& name, const QVariant& datum) - { - QMutexLocker l(&mtx); - if (!transient.contains(name) || datum != transient.get(name)) - { - modified = true; - transient.put(name, datum); - emit bundleChanged(); - } - } - bool contains(const QString& name) - { - QMutexLocker l(&mtx); - return transient.contains(name); - } - template - T get(const QString& name) { - QMutexLocker l(&mtx); - return transient.get(name); - } - void save() - { - QMutexLocker l(&mtx); - modified = false; - saved = transient; - transient.save(); - } - void revert() - { - QMutexLocker l(&mtx); - modified = false; - transient = saved; - emit bundleChanged(); - } - - bool modifiedp() { - QMutexLocker l(&mtx); - return modified; - } - signals: - void bundleChanged(); - void reloaded(); - }; - - typedef std::shared_ptr pbundle; - - class base_value : public QObject { - Q_OBJECT - public: - base_value(pbundle b, const QString& name) : b(b), self_name(name) { - connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); - } - virtual QVariant operator=(const QVariant& datum) = 0; - protected: - pbundle b; - QString self_name; - public slots: - void reread_value() - { - this->operator=(b->get(self_name)); - } - public slots: -#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } - DEFINE_SLOT(double) - DEFINE_SLOT(int) - DEFINE_SLOT(QString) - DEFINE_SLOT(bool) - signals: -#define DEFINE_SIGNAL(t) void valueChanged(t); - DEFINE_SIGNAL(double) - DEFINE_SIGNAL(int) - DEFINE_SIGNAL(QString) - DEFINE_SIGNAL(bool) - }; - - template - class value : public base_value { - private: T def; - public: - static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; - value(pbundle b, const QString& name, T def) : - base_value(b, name), def(def) - { - if (!b->contains(name)) - { - QVariant cruft(def); - b->store(self_name, cruft); - } - } - operator T() { return b->get(self_name); } - QVariant operator=(const QVariant& datum) { - b->store(self_name, datum); - auto foo = qcruft_to_t(datum); - emit valueChanged(foo); - return datum; - } - }; - - template - inline void tie_setting(value&, Q*); - - template<> - inline void tie_setting(value& v, QComboBox* cb) - { - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); - cb->setCurrentIndex(v); - } - - template<> - inline void tie_setting(value& v, QComboBox* cb) - { - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); - cb->setCurrentText(v); - } - - template<> - inline void tie_setting(value& v, QCheckBox* cb) - { - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); - cb->setChecked(v); - } - - template<> - inline void tie_setting(value& v, QDoubleSpinBox* dsb) - { - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); - dsb->setValue(v); - } - - template<> - inline void tie_setting(value& v, QSpinBox* sb) - { - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); - sb->setValue(v); - } - - template<> - inline void tie_setting(value& v, QSlider* sl) - { - base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); - sl->setValue(v); - } - - template<> - inline void tie_setting(value& v, QLineEdit* le) - { - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); - le->setText(v); - } - - inline pbundle bundle(const QString& group) { - return std::make_shared(group); - } -} -- cgit v1.2.3 From 85129ee6fcabee8821e301ae64fec81f12df788d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:40:55 +0100 Subject: fix doze --- facetracknoir/facetracknoir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index b98c6085..2006f831 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -634,9 +634,9 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k) } } #else -static void bind_keyboard_shortcut(Key& key, const key& k) +static void bind_keyboard_shortcut(Key& key, key_opts& k) { - const int idx = k.key_index; + int idx = k.key_index; if (idx > 0) { key.keycode = 0; -- cgit v1.2.3 From 77412f01c387ffce47d42bcaad3cf26816591350 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:41:12 +0100 Subject: finish rename --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 2 +- facetracknoir/facetracknoir.h | 2 +- facetracknoir/main-settings.hpp | 2 +- facetracknoir/tracker.h | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 8c590db2..a828ea48 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -11,7 +11,7 @@ #include #include "point_tracker.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index b1279697..53b83754 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -51,7 +51,7 @@ #include "ui_facetracknoir.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; #include "facetracknoir/main-settings.hpp" diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp index 05c75398..c9b5ff66 100644 --- a/facetracknoir/main-settings.hpp +++ b/facetracknoir/main-settings.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct key_opts { diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index b671ac7c..404a8f24 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -17,7 +17,7 @@ #include #include "tracker_types.h" #include "facetracknoir/main-settings.hpp" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; class FaceTrackNoIR; // pre-define parent-class to avoid circular includes diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 1aaa039f..e8f077c3 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -10,7 +10,7 @@ #define ACCELA_SECOND_ORDER_ALPHA 100.0 #define ACCELA_THIRD_ORDER_ALPHA 180.0 -#include "facetracknoir/options.hpp" +#include using namespace options; struct settings { diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 6e9a7f9a..e50a4284 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -31,7 +31,7 @@ #include "ui_ftnoir_ewma_filtercontrols.h" #include #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 8f5bcd8b..25f0a0ad 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -21,7 +21,7 @@ #include #include #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 13aaeab4..dca1f245 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -33,7 +33,7 @@ #include #include #include "facetracknoir/global-settings.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 23598f4d..2ff40c77 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -18,7 +18,7 @@ #include #include #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h index 8739394f..4c0fcb8d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -8,7 +8,7 @@ #pragma once #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" #include using namespace options; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index b3c89136..583249dc 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -15,7 +15,7 @@ #include "ht_video_widget.h" #include "compat/compat.h" #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 8d91dfbb..e569efab 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -5,7 +5,7 @@ #include #include #include "facetracknoir/global-settings.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index b1f96bf2..dd673308 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -8,7 +8,7 @@ #include "facetracknoir/global-settings.h" #include "OVR.h" #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { -- cgit v1.2.3 From e1d96c01dc5d7707c7e3a260f49881e6bded832e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:54:31 +0100 Subject: kalman: remove qsettings cruft --- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 25f0a0ad..f2a1b4ec 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -54,13 +54,6 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi public: FilterControls() { ui.setupUi(this); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - iniFile.beginGroup("ftnoir-filter-kalman"); - iniFile.endGroup(); connect(ui.btnOk, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); -- cgit v1.2.3 From edcdcaadb5920cebc9aaa34572cba74de5637241 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:54:42 +0100 Subject: udp: update to settings framework --- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 79 ++-------------- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 46 ++++----- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 105 +++------------------ ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp | 18 ---- 4 files changed, 41 insertions(+), 207 deletions(-) diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index 80cbfa0a..e93a751e 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -32,86 +32,23 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - loadSettings(); - outSocket = 0; } -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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) - - iniFile.beginGroup ( "FTN" ); - - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); - - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose) { - int no_bytes; - double test_data[6]; - // - // Copy the Raw measurements directly to the client. - // - for (int i = 0; i < 6; i++) - test_data[i] = headpose[i]; - // - // Try to send an UDP-message to the receiver - // - - //! [1] - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) test_data, sizeof( test_data ), destIP, destPort); - if ( no_bytes > 0) { -// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; - } - } + int destPort = s.port; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + outSocket.writeDatagram((const char *) headpose, sizeof( double[6] ), destIP, destPort); } -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - return true; + return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index acccc9e7..d5dc2cfe 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -26,8 +26,6 @@ * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ #pragma once -#ifndef INCLUDED_FTNSERVER_H -#define INCLUDED_FTNSERVER_H #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ftnoir_tracker_base/ftnoir_tracker_base.h" @@ -38,23 +36,34 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value ip1, ip2, ip3, ip4, port; + settings() : + b(bundle("udp-proto")), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 4242) + {} +}; class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { return "UDP Tracker"; } - private: - QUdpSocket *outSocket; // Send to FaceTrackNoIR - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); + QUdpSocket outSocket; + settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -62,40 +71,23 @@ class FTNControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FTNControls(); + FTNControls(); void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} - private: Ui::UICFTNControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } }; -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); } void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); } void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("opentrack UDP protocol"); } void getIcon(QIcon *icon) { *icon = QIcon(":/images/facetracknoir.png"); } }; - -#endif//INCLUDED_FTNSERVER_H -//END diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index 72c30051..ce4b3cb0 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -23,44 +23,28 @@ * * ********************************************************************************/ #include "ftnoir_protocol_ftn.h" -#include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// FTNControls::FTNControls() : -QWidget() + QWidget() { - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} + ui.setupUi( this ); - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + tie_setting(s.ip1, ui.spinIPFirstNibble); + tie_setting(s.ip2, ui.spinIPSecondNibble); + tie_setting(s.ip3, ui.spinIPThirdNibble); + tie_setting(s.ip4, ui.spinIPFourthNibble); + tie_setting(s.port, ui.spinPortNumber); - // Load the settings from the current .INI-file - loadSettings(); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); } // // OK clicked on server-dialog // void FTNControls::doOK() { - save(); + s.b->save(); this->close(); } @@ -68,27 +52,19 @@ void FTNControls::doOK() { // Cancel clicked on server-dialog // void FTNControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - + 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); 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; } } @@ -97,59 +73,6 @@ void FTNControls::doCancel() { } } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNControls::loadSettings() { -// qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTN" ); - ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTNControls::save() { - 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) - - iniFile.beginGroup ( "FTN" ); - iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) { return new FTNControls; diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp index acd3b990..99689432 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #include "ftnoir_protocol_ftn.h" -#include #include "facetracknoir/global-settings.h" -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_ProtocolDll; -- cgit v1.2.3 From 4411f8aa4508f2759c29181b668ebf949dc3bc8c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:06:30 +0100 Subject: udp: use settings framework --- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 119 +++-------------------- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 58 +++++------ ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 105 +++----------------- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 21 ---- 4 files changed, 52 insertions(+), 251 deletions(-) diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index e70bfdc7..02ae21f0 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -25,18 +25,8 @@ #include "ftnoir_tracker_udp.h" #include "facetracknoir/global-settings.h" -FTNoIR_Tracker::FTNoIR_Tracker() +FTNoIR_Tracker::FTNoIR_Tracker() : should_quit(false) { - inSocket = 0; - outSocket = 0; - - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; - portAddress = 5551; should_quit = false; for (int i = 0; i < 6; i++) @@ -47,127 +37,46 @@ FTNoIR_Tracker::~FTNoIR_Tracker() { should_quit = true; wait(); - if (inSocket) { - inSocket->close(); - delete inSocket; - } - - if (outSocket) { - outSocket->close(); - delete outSocket; - } } /** QThread run @override **/ void FTNoIR_Tracker::run() { - -QHostAddress sender; -quint16 senderPort; - - // - // Read the data that was received. - // forever { if (should_quit) break; - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - + while (inSocket.hasPendingDatagrams()) { + QMutexLocker foo(&mutex); QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - mutex.lock(); - inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort); - mutex.unlock(); - } - } - else { - break; - } - + datagram.resize(sizeof(newHeadPose)); + inSocket.readDatagram((char * ) newHeadPose, sizeof(double[6])); + } usleep(10000); } } void FTNoIR_Tracker::StartTracker(QFrame*) { - loadSettings(); - // - // Create UDP-sockets if they don't exist already. - // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run()) - // - if (inSocket == 0) { - qDebug() << "FTNoIR_Tracker::Initialize() creating insocket"; - inSocket = new QUdpSocket(); - // Connect the inSocket to the port, to receive messages - - if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - } - } + (void) inSocket.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); start(); - return; } void FTNoIR_Tracker::GetHeadPoseData(double *data) { - mutex.lock(); - if (bEnableX) { + QMutexLocker foo(&mutex); + if (s.enable_x) data[TX] = newHeadPose[TX]; - } - if (bEnableX) { + if (s.enable_y) data[TY] = newHeadPose[TY]; - } - if (bEnableX) { + if (s.enable_z) data[TZ] = newHeadPose[TZ]; - } - if (bEnableYaw) { + if (s.enable_yaw) data[Yaw] = newHeadPose[Yaw]; - } - if (bEnablePitch) { + if (s.enable_pitch) data[Pitch] = newHeadPose[Pitch]; - } - if (bEnableRoll) { + if (s.enable_roll) data[Roll] = newHeadPose[Roll]; - } - mutex.unlock(); } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_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 ( "FTNClient" ); - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); - portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); - 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 FTNoIR_Tracker; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 7157f064..140a935d 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -8,37 +8,43 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value port; + value enable_roll, enable_pitch, enable_yaw, + enable_x, enable_y, enable_z; + settings() : + b(bundle("udp-tracker")), + port(b, "port", 4242), + enable_roll(b, "enable-roll", true), + enable_pitch(b, "enable-pitch", true), + enable_yaw(b, "enable-yaw", true), + enable_x(b, "enable-x", true), + enable_y(b, "enable-y", true), + enable_z(b, "enable-y", true) + {} +}; class FTNoIR_Tracker : public ITracker, public QThread { public: FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - + ~FTNoIR_Tracker(); void StartTracker(QFrame *); void GetHeadPoseData(double *data); - void loadSettings(); volatile bool should_quit; protected: void run(); // qthread override run method - private: - // UDP socket-variables - QUdpSocket *inSocket; // Receive from ... - QUdpSocket *outSocket; // Send to ... - QHostAddress destIP; // Destination IP-address - QHostAddress srcIP; // Source IP-address - - double newHeadPose[6]; // Structure with new headpose - - float portAddress; // Port-number - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; + QUdpSocket inSocket; + QHostAddress destIP; + QHostAddress srcIP; + double newHeadPose[6]; QMutex mutex; + settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -48,23 +54,14 @@ class TrackerControls: public QWidget, public ITrackerDialog public: explicit TrackerControls(); - ~TrackerControls(); void registerTracker(ITracker *) {} void unRegisterTracker() {} - private: Ui::UICFTNClientControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; }; //******************************************************************************************************* @@ -73,9 +70,6 @@ private slots: class FTNoIR_TrackerDll : public Metadata { public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 707abf37..59026288 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -25,61 +25,38 @@ #include "ftnoir_tracker_udp.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// TrackerControls::TrackerControls() : QWidget() { ui.setupUi( this ); - // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - - // Load the settings from the current .INI-file - loadSettings(); -} -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; + tie_setting(s.enable_x, ui.chkEnableX); + tie_setting(s.enable_y, ui.chkEnableY); + tie_setting(s.enable_z, ui.chkEnableZ); + tie_setting(s.enable_yaw, ui.chkEnableYaw); + tie_setting(s.enable_pitch, ui.chkEnablePitch); + tie_setting(s.enable_roll, ui.chkEnableRoll); + tie_setting(s.port, ui.spinPortNumber); } void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } void TrackerControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - + 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); switch (ret) { case QMessageBox::Save: - save(); + s.b->save(); this->close(); break; case QMessageBox::Discard: + s.b->revert(); this->close(); break; case QMessageBox::Cancel: @@ -95,64 +72,6 @@ void TrackerControls::doCancel() { } } - -// -// Load the current Settings from the currently 'active' INI-file. -// -void TrackerControls::loadSettings() { - -// qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTNClient" ); - ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); - ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); - ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::save() { - 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) - - iniFile.beginGroup ( "FTNClient" ); - iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); - iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); - iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) { return new TrackerControls; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index 7d7b7c81..6732b599 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -26,18 +26,6 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "UDP"; - trackerShortName = "UDP"; - trackerDescription = "opentrack UDP client"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { *strToBeFilled = trackerFullName; @@ -58,15 +46,6 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/facetracknoir.png"); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_TrackerDll; -- cgit v1.2.3 From ef92acc3d03d46818317118655bac8574dfb9340 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:51:44 +0100 Subject: add qlabel one-way transfer option --- facetracknoir/options.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 1305bd0a..e77988c7 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #ifdef __GNUC__ @@ -297,6 +298,13 @@ namespace options { le->setText(v); } + template<> + inline void tie_setting(value& v, QLabel* lb) + { + base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.CONNTYPE); + lb->setText(v); + } + inline pbundle bundle(const QString& group) { return std::make_shared(group); } -- cgit v1.2.3 From 5ec8d2bb1b36510988b112cf1b830208ce6910a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:51:55 +0100 Subject: fsuipc: decruft, use settings framework --- ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui | 277 +++++++-------------- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 88 ++----- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 58 ++--- .../ftnoir_protocol_fsuipc_dialog.cpp | 151 ++++------- .../ftnoir_protocol_fsuipc_dll.cpp | 18 -- 5 files changed, 177 insertions(+), 415 deletions(-) diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui index 9ccfa119..1ce77862 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui +++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui @@ -9,8 +9,8 @@ 0 0 - 541 - 139 + 512 + 100 @@ -26,198 +26,101 @@ false - - - - - - - - 0 - 0 - - - - Location of FSUIPC.dll: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - - 35 - 16777215 - - - - ... - - - - + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + The DLL should be located in the Modules/ directory of MS FS 2004 + + - - - - Qt::Vertical + + + + + 0 + 0 + - + - 20 - 40 + 100 + 0 - - - - - - - - The DLL should be placed in the Modules folder of MS Flight Simulator - - - - + + + 100 + 16777215 + + + + OK + + - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + + + + + 35 + 16777215 + + + + ... + + diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 986ccc65..7ca990af 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -30,32 +30,22 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - loadSettings(); - ProgramName = "Microsoft FS2004"; - - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; + prevPosX = 0.0; + prevPosY = 0.0; + prevPosZ = 0.0; + prevRotX = 0.0; + prevRotY = 0.0; + prevRotZ = 0.0; } -/** destructor **/ FTNoIR_Protocol::~FTNoIR_Protocol() { - // - // Free the DLL - // - FSUIPCLib.unload(); + FSUIPCLib.unload(); } -// -// Scale the measured value to the Joystick values -// int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; + double y; + double local_x; local_x = x; if (local_x > max_x) { @@ -69,40 +59,20 @@ double local_x; return (int) y; } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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) - - iniFile.beginGroup ( "FSUIPC" ); - LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); - qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL; - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { -DWORD result; -TFSState pitch; -TFSState yaw; -TFSState roll; -WORD FSZoom; + DWORD result; + TFSState pitch; + TFSState yaw; + TFSState roll; + WORD FSZoom; -float virtPosX; -float virtPosY; -float virtPosZ; + float virtPosX; + float virtPosY; + float virtPosZ; -float virtRotX; -float virtRotY; -float virtRotZ; - -// qDebug() << "FSUIPCServer::run() says: started!"; + float virtRotX; + float virtRotY; + float virtRotZ; virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; @@ -112,17 +82,11 @@ float virtRotZ; virtPosY = 0.0f; virtPosZ = headpose[TZ]; - // - // Init. the FSUIPC offsets (derived from Free-track...) - // pitch.Control = 66503; yaw.Control = 66504; roll.Control = 66505; - // - // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { // // Open the connection @@ -178,7 +142,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // // Load the DLL. // - FSUIPCLib.setFileName( LocationOfDLL ); + FSUIPCLib.setFileName( s.LocationOfDLL ); if (FSUIPCLib.load() != true) { qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL"; return false; @@ -190,14 +154,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -/////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) { diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 9f5e3b6f..a099df36 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -41,12 +41,20 @@ #include #include #include +#include "facetracknoir/options.h" +using namespace options; #define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" -// -// Define the structures necessary for the FSUIPC_Write calls -// +struct settings { + pbundle b; + value LocationOfDLL; + settings() : + b(bundle("proto-fsuipc")), + LocationOfDLL(b, "dll-location", FSUIPC_FILENAME) + {} +}; + #pragma pack(push,1) // All fields in structure must be byte aligned. typedef struct { @@ -59,50 +67,32 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol() virt_override; bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { return "Microsoft Flight Simulator X"; } private: - // Private properties - QString ProgramName; QLibrary FSUIPCLib; - QString LocationOfDLL; - float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - + double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + settings s; static int scale2AnalogLimits( float x, float min_x, float max_x ); - void loadSettings(); }; -// Widget that has controls for FTNoIR protocol client-settings. class FSUIPCControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FSUIPCControls(); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + FSUIPCControls(); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} private: Ui::UICFSUIPCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; }; void getLocationOfDLL(); }; @@ -112,14 +102,10 @@ private slots: class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/fs9.png"); }; + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); } + void getIcon(QIcon *icon) { *icon = QIcon(":/images/fs9.png"); } }; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index b2f28ba1..9ef4ad67 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -25,131 +25,66 @@ #include "ftnoir_protocol_fsuipc.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// FSUIPCControls::FSUIPCControls() : -QWidget() + QWidget() { - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); + ui.setupUi( this ); - theProtocol = NULL; + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.LocationOfDLL, ui.txtLocationOfDLL); } void FSUIPCControls::doOK() { - save(); - this->close(); + s.b->save(); + this->close(); } void FSUIPCControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FSUIPCControls::loadSettings() { - - qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FSUIPC" ); - ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); - iniFile.endGroup (); - - settingsDirty = false; + // + // Ask if changed Settings should be saved + // + 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 ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + s.b->save(); + this->close(); + break; + case QMessageBox::Discard: + s.b->revert(); + this->close(); + break; + case QMessageBox::Cancel: + default: + break; + } + } + else { + this->close(); + } } -// -// Save the current Settings to the currently 'active' INI-file. -// -void FSUIPCControls::save() { - - qDebug() << "save() says: started"; - - 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) - - iniFile.beginGroup ( "FSUIPC" ); - iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Show the Dialog to set the DLL's location -// void FSUIPCControls::getLocationOfDLL() { - // - // Get the new filename of the INI-file. - // - QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), - ui.txtLocationOfDLL->text(), - tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); - if (!fileName.isEmpty()) { - ui.txtLocationOfDLL->setText( fileName ); - settingsDirty = true; - } + // + // Get the new filename of the INI-file. + // + QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), + ui.txtLocationOfDLL->text(), + tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); + if (!fileName.isEmpty()) { + s.LocationOfDLL = fileName; + } } - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog(void) { return new FSUIPCControls; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp index b0ca2eee..57b174c5 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #include "ftnoir_protocol_fsuipc.h" -#include #include "facetracknoir/global-settings.h" -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata(void) { return new FTNoIR_ProtocolDll; -- cgit v1.2.3 From c750ecd74d9e356b762c9b81b5c105f1ec3f997a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:12:25 +0100 Subject: cmake: how did this ever get here? --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2033a597..d7495ab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,12 +264,6 @@ if(QT_USE_FILE) INCLUDE(${QT_USE_FILE}) endif() -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of dll's.") - SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") - SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") -endif() - add_library(opentrack-compat SHARED ${opentrack-compat-c}) if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) -- cgit v1.2.3 From d74a275e6f81d17911972c0c627fb56479e272a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:12:43 +0100 Subject: cmake: add missing version script; fix lto build --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7495ab2..93649fa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,6 +374,10 @@ if(WIN32) add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + SET_TARGET_PROPERTIES(opentrack-proto-freetrack + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") + endif() add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) -- cgit v1.2.3 From 4b5bd9d5e8f2b239da4979e33f42a4ca5f5498db Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:52:21 +0100 Subject: cmake: cleanup copypasta --- CMakeLists.txt | 298 +++++++++++++++++---------------------------------------- 1 file changed, 90 insertions(+), 208 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93649fa7..a88e6995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) +include(CMakeParseArguments) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") include(GetGitRevisionDescription) find_package(Git QUIET) @@ -41,7 +43,6 @@ SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOMOC_RELAXED_MODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API -DIN_OPENTRACK) @@ -189,6 +190,21 @@ macro(opentrack_module n dir) QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) endmacro() +macro(opentrack_library n) + cmake_parse_arguments(lib- "" "LINK COMPILE" "" ${ARGN}) + add_library(${n} SHARED ${${n}-c} ${${n}-uih} ${${n}-rcc}) + target_link_libraries(${n} ${MY_QT_LIBS}) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + SET_TARGET_PROPERTIES(${n} PROPERTIES + LINK_FLAGS "${lib-LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" + COMPILE_FLAGS "${lib-COMPILE}" + ) + else() + set_target_properties(${n} PROPERTIES LINK_FLAGS "${lib-LINK}" COMPILE_FLAGS "${lib-COMPILE}") + endif() + install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) +endmacro() + file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/global-settings.h") opentrack_module(opentrack-bin facetracknoir) @@ -208,7 +224,9 @@ opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft) opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn) opentrack_module(opentrack-proto-wine ftnoir_protocol_wine) -opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) +if(WIN32) + opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) +endif() opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc) opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy) opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev) @@ -299,117 +317,65 @@ target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c}) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) -add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) -target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) - -add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) -target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS}) - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-filter-kalman - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-filter-accela - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-filter-accela) +opentrack_library(opentrack-filter-kalman) +opentrack_library(opentrack-filter-ewma) -add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-rcc}) -target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) +target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-filter-ewma - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - -add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) -target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-proto-fgfs) -if(WIN32 AND SDK_VJOY) +if(SDK_VJOY) include_directories(${SDK_VJOY}) - add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + opentrack_library(opentrack-proto-vjoy) if(MSVC) target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") else() target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-vjoy - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt -Wl,--enable-stdcall-fixup") - endif() endif() -if(UNIX AND SDK_ENABLE_LIBEVDEV) - add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) - target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-libevdev - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() - install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION . LIBRARY DESTINATION . ) +if(SDK_ENABLE_LIBEVDEV) + opentrack_library(opentrack-proto-libevdev) + target_link_libraries(opentrack-proto-libevdev evdev) endif() -if(WIN32) - if(SDK_FSUIPC) - add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) - target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") - if(MSVC) - set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") - else() - set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "-Wl,--exclude-all-symbols") - endif() +if(SDK_FSUIPC) + if(MSVC) + set(link-flags "/NODEFAULTLIB:libc") endif() + opentrack_library(opentrack-proto-fsuipc LINK "${link-flags}") + target_link_libraries(opentrack-proto-fsuipc "${SDK_FSUIPC}/FSUIPC_User.lib") +endif() - if(SDK_SIMCONNECT) - add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) - target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) - include_directories("${SDK_SIMCONNECT}/inc") - target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") - endif() +if(SDK_SIMCONNECT) + opentrack_library(opentrack-proto-simconnect) + include_directories("${SDK_SIMCONNECT}/inc") + target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") +endif() - add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) - target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-freetrack - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() +if(WIN32) + opentrack_library(opentrack-proto-freetrack) + target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) +endif() - add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) - target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) +opentrack_library(opentrack-proto-win32-mouse) + +if(WIN32) add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup -fno-lto -Wl,-kill-at" PREFIX "" COMPILE_FLAGS "-fno-lto") endif() endif() -add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) -target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-proto-udp) if(WIN32) - add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) - target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-joystick - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() + opentrack_library(opentrack-tracker-joystick) endif() -if(NOT WIN32 AND SDK_WINE_PREFIX) - add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) - target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-wine - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() +if(SDK_WINE_PREFIX) + opentrack_library(opentrack-proto-wine) if(NOT SDK_WINE_NO_WRAPPER) set(my-rt -lrt) if(APPLE) @@ -431,26 +397,13 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - -add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) -target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-ht - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-tracker-ht) +target_link_libraries(opentrack-tracker-ht opentrack-compat) if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) - add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) - target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-aruco - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() + opentrack_library(opentrack-tracker-aruco) + target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) if(WIN32 AND MSVC) target_link_libraries(opentrack-tracker-aruco "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" @@ -459,15 +412,7 @@ if(SDK_ARUCO_LIBPATH) endif() endif() -if(SDK_HATIRE) - add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc}) - target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS}) - install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-hatire - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() -endif() +opentrack_library(opentrack-tracker-hatire) if(WIN32) target_link_libraries(opentrack-tracker-ht @@ -481,18 +426,8 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) -target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) - -if(APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11") -endif() - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-pt - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - +opentrack_library(opentrack-tracker-pt) +target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) if(WIN32) target_link_libraries(opentrack-tracker-pt @@ -501,50 +436,44 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) -target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-tracker-udp) if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") - add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) - target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) - if(MSVC) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) - set_target_properties(opentrack-tracker-rift PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") + set(link-flags) + if(APPLE) + set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") + else() + if(MSVC) + set(link-flags "/NODEFAULTLIB:LIBCMT") + endif() + endif() + if(NOT MSVC) + set(c-flags -fno-strict-aliasing) + else() + set(c-flags) + endif() + opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") + if(MSVC) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) + else() + if(WIN32) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm setupapi) + else() + if(NOT APPLE) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) else() - if(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib) - else() - if(NOT APPLE) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) - else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") - endif() - endif() + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-rift - PROPERTIES - LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" - COMPILE_FLAGS "-fno-strict-aliasing" - ) - endif() - if(APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-rift - PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") endif() endif() +endif() if(SDK_HYDRA) include_directories("${SDK_HYDRA}/include") include_directories("${SDK_HYDRA}/include/sixense_utils") - add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) - target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) + opentrack_library(opentrack-tracker-hydra) if(WIN32) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" @@ -572,10 +501,6 @@ if(SDK_HYDRA) ) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-hydra - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() endif() if(WIN32 AND NOT SDK_CONSOLE_DEBUG) @@ -655,11 +580,13 @@ install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) if(SDK_XPLANE) install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() + if(WIN32) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) install(TARGETS freetrackclient RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() - install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) + +install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) @@ -667,69 +594,24 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetr if(NOT WIN32 AND SDK_WINE_PREFIX) install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) - install(TARGETS opentrack-proto-wine RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION . ) - -if(SDK_ARUCO_LIBPATH) - install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() install(TARGETS - opentrack-proto-fgfs - opentrack-proto-udp opentrack-api opentrack-compat opentrack-csv opentrack-pose-widget opentrack-spline-widget - opentrack-filter-accela - opentrack-filter-kalman - opentrack-filter-ewma - opentrack-tracker-ht - opentrack-tracker-udp RUNTIME DESTINATION . LIBRARY DESTINATION . ) -install(TARGETS - opentrack - DESTINATION . -) +install(TARGETS opentrack DESTINATION .) -if(WIN32) - install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -if(WIN32 AND SDK_VJOY) - install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION . LIBRARY DESTINATION . ) +if(SDK_VJOY) install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) endif() -if(SDK_RIFT) - install(TARGETS opentrack-tracker-rift RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -if(SDK_HYDRA) - install( - TARGETS opentrack-tracker-hydra - RUNTIME DESTINATION . LIBRARY DESTINATION . - ) -endif() - if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) - if(SDK_SIMCONNECT) - install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . ) - endif() - install(TARGETS - opentrack-proto-freetrack - opentrack-proto-win32-mouse - RUNTIME DESTINATION . LIBRARY DESTINATION . - ) - if(SDK_FSUIPC) - install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION . LIBRARY DESTINATION .) - endif() - endif() if(MSVC) -- cgit v1.2.3 From 4abd0ca3b5090018a7db05e8c2e0f478d861d978 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:52:50 +0100 Subject: ft: use settings framework --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 102 +++--------- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 100 +++++------- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 194 ++++++++--------------- ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp | 18 +-- 4 files changed, 124 insertions(+), 290 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 84d1d20b..5c086c10 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -24,78 +24,30 @@ * FTServer FTServer is the Class, that communicates headpose-data * * to games, using the FreeTrackClient.dll. * ********************************************************************************/ -#include #include "ftnoir_protocol_ft.h" #include "ftnoir_csv/csv.h" -/** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() : shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap)) { pMemData = (FTMemMap*) shm.mem; - useTIRViews = false; - useDummyExe = false; - intUsedInterface = 0; - - loadSettings(); - - ProgramName = ""; - intGameID = 0; - - viewsStart = 0; - viewsStop = 0; + ProgramName = ""; + intGameID = 0; + viewsStart = 0; + viewsStop = 0; } -/** destructor **/ FTNoIR_Protocol::~FTNoIR_Protocol() { - - qDebug()<< "~FTNoIR_Protocol: Destructor started."; - - // - // Stop if started - // - if (viewsStop != NULL) { - qDebug()<< "~FTNoIR_Protocol: Stopping TIRViews."; - viewsStop(); - FTIRViewsLib.unload(); - } - dummyTrackIR.terminate(); + if (viewsStop != NULL) { + viewsStop(); + FTIRViewsLib.unload(); + } + dummyTrackIR.terminate(); dummyTrackIR.kill(); dummyTrackIR.waitForFinished(50); - } -// -// Read the game-data from CSV -// - - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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) - - iniFile.beginGroup ( "FT" ); - intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt(); - iniFile.endGroup (); - - // - // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there. - // - iniFile.beginGroup ( "FTIR" ); - useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool(); - useDummyExe = iniFile.value ( "useDummyExe", 0 ).toBool(); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { float virtPosX; float virtPosY; @@ -112,7 +64,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { float headRotX; float headRotY; float headRotZ; - headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (useDummyExe ? 2.0 : 1.0); + headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (s.useDummyExe ? 2.0 : 1.0); headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]); headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]); headPosX = virtPosX = headpose[TX] * 10; @@ -149,13 +101,6 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { pMemData->data.Y3 = 0; pMemData->data.Y4 = 0; - // - // Check if the handle that was sent to the Game, was changed (on x64, this will be done by the ED-API) - // If the "Report Program Name" command arrives (which is a '1', for now), raise the event from here! - // - // - // The game-ID was changed? - // if (intGameID != pMemData->GameID) { QString gamename; @@ -167,8 +112,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { } pMemData->data.DataID += 1; - - shm.unlock(); + shm.unlock(); } void FTNoIR_Protocol::start_tirviews() { @@ -212,6 +156,10 @@ bool FTNoIR_Protocol::checkServerInstallationOK() QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) QString aLocation; // Location of Client DLL + + if (!shm.success()) + return false; + qDebug() << "checkServerInstallationOK says: Starting Function"; // @@ -219,8 +167,8 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // aLocation = QCoreApplication::applicationDirPath() + "/"; - qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; - switch (intUsedInterface) { + qDebug() << "checkServerInstallationOK says: used interface = " << s.intUsedInterface; + switch (s.intUsedInterface) { case 0: // Use both interfaces settings.setValue( "Path" , aLocation ); settingsTIR.setValue( "Path" , aLocation ); @@ -241,20 +189,17 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // // TIRViews must be started first, or the NPClient DLL will never be loaded. // - if (useTIRViews) { + if (s.useTIRViews) { start_tirviews(); } // // Check if TIRViews or dummy TrackIR.exe is required for this game // - if (useDummyExe) { + if (s.useDummyExe) { start_dummy(); } - if (!shm.success()) - return false; - pMemData->data.DataID = 1; pMemData->data.CamWidth = 100; pMemData->data.CamHeight = 250; @@ -264,15 +209,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index 56316ec4..8f27b071 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -25,9 +25,6 @@ * to games, using the FreeTrackClient.dll. * ********************************************************************************/ #pragma once -#ifndef INCLUDED_FTSERVER_H -#define INCLUDED_FTSERVER_H - #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ui_ftnoir_ftcontrols.h" #include "facetracknoir/global-settings.h" @@ -43,7 +40,20 @@ #include #include #include "compat/compat.h" -//#include "math.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value intUsedInterface; + value useTIRViews, useDummyExe; + settings() : + b(bundle("proto-freetrack")), + intUsedInterface(b, "used-interfaces", 0), + useTIRViews(b, "use-memory-hacks", false), + useDummyExe(b, "ezca-mode", false) + {} +}; //typedef char *(WINAPI *importProvider)(void); typedef void (WINAPI *importTIRViewsStart)(void); @@ -52,87 +62,59 @@ typedef void (WINAPI *importTIRViewsStop)(void); class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol(); + FTNoIR_Protocol(); virtual ~FTNoIR_Protocol(); - bool checkServerInstallationOK( ); + bool checkServerInstallationOK( ); void sendHeadposeToGame( const double *headpose ); QString getGameName() { QMutexLocker foo(&game_name_mutex); return connected_game; } - private: - importTIRViewsStart viewsStart; // Functions inside TIRViews.dll - importTIRViewsStop viewsStop; + importTIRViewsStart viewsStart; // Functions inside TIRViews.dll + importTIRViewsStop viewsStop; - FTMemMap *pMemData; + FTMemMap *pMemData; QString game_name; PortableLockedShm shm; - // Private properties - QString ProgramName; - QLibrary FTIRViewsLib; - QProcess dummyTrackIR; - int intGameID; - int intUsedInterface; // Determine which interface to use (or to hide from the game) - bool useTIRViews; // Needs to be in the Settings dialog - bool useDummyExe; - float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } - void loadSettings(); + // Private properties + QString ProgramName; + QLibrary FTIRViewsLib; + QProcess dummyTrackIR; + static inline double getRadsFromDegrees ( double degrees ) + { + return degrees * 0.017453; + } + int intGameID; void start_tirviews(); void start_dummy(); - QString connected_game; QMutex game_name_mutex; + settings s; }; -// Widget that has controls for FTNoIR protocol client-settings. class FTControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FTControls(); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + explicit FTControls(); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} private: - Ui::UICFTControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICFTControls ui; + settings s; private slots: - void selectDLL(); - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } + void selectDLL(); + void doOK(); + void doCancel(); }; -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); } - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); } + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); } + void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); } }; - - -#endif//INCLUDED_FTSERVER_H -//END diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 0b29db6e..b414561d 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -34,155 +34,87 @@ // Constructor for server-settings-dialog // FTControls::FTControls() : -QWidget() + QWidget() { - QString aFileName; // File Path and Name + QString aFileName; // File Path and Name - ui.setupUi( this ); + ui.setupUi( this ); - // Connect Qt signals to member-functions + // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); - connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - - ui.cbxSelectInterface->addItem("Enable both"); - ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); - ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); - - - aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( !QFile::exists( aFileName ) ) { - ui.chkTIRViews->setChecked( false ); - ui.chkTIRViews->setEnabled ( false ); - - // - // Best do this save() last, or it will continually reset the settings... :-( - // - save(); - } - else { - ui.chkTIRViews->setEnabled ( true ); - } - - + connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); + + tie_setting(s.intUsedInterface, ui.cbxSelectInterface); + tie_setting(s.useDummyExe, ui.chkStartDummy); + tie_setting(s.useTIRViews, ui.chkTIRViews); + + ui.cbxSelectInterface->addItem("Enable both"); + ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); + ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); + + aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( !QFile::exists( aFileName ) ) { + ui.chkTIRViews->setChecked( false ); + ui.chkTIRViews->setEnabled ( false ); + } + else { + ui.chkTIRViews->setEnabled ( true ); + } } void FTControls::doOK() { - save(); - this->close(); + s.b->save(); + this->close(); } void FTControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTControls::loadSettings() { - qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FT" ); - ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "FTIR" ); - ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); - ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 0 ).toBool()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTControls::save() { - 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) - - iniFile.beginGroup ( "FT" ); - iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex()); - iniFile.endGroup (); - - iniFile.beginGroup ( "FTIR" ); - iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); - iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; + // + // Ask if changed Settings should be saved + // + 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); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::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; + } + } + else { + this->close(); + } } -// -// Select a NPClient.dll file, to repair the Location in the Registry. -// Several program distribute their own version of this file. -// void FTControls::selectDLL() { QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); - // - // Write the location of the file in the required Registry-key. - // - if (! fileName.isEmpty() ) { - if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL - - settingsTIR.setValue( "Path" , aLocation ); - } - } + // + // Write the location of the file in the required Registry-key. + // + if (! fileName.isEmpty() ) { + if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) + QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL + + settingsTIR.setValue( "Path" , aLocation ); + } + } } - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) { return new FTControls; diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp index f4e4a40e..38f11211 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp @@ -23,24 +23,8 @@ * * ********************************************************************************/ #include "ftnoir_protocol_ft.h" -#include -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_ProtocolDll; -} \ No newline at end of file +} -- cgit v1.2.3 From 40f4c6944799bd696ccf358c5378b230ecc7f52b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:10:17 +0100 Subject: sc: settings framework --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 173 ++++------------------- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 62 +++----- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 96 +++---------- ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 17 --- 4 files changed, 75 insertions(+), 273 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 8449f6ce..9fb48527 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -50,15 +50,12 @@ float FTNoIR_Protocol::prevSCRotZ = 0.0f; static QLibrary SCClientLib; -/** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - ProgramName = "Microsoft FSX"; blnSimConnectActive = false; hSimConnect = 0; } -/** destructor **/ FTNoIR_Protocol::~FTNoIR_Protocol() { qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect; @@ -69,18 +66,8 @@ FTNoIR_Protocol::~FTNoIR_Protocol() qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED"; } } -// SCClientLib.unload(); Generates crash when tracker is ended... } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { virtSCRotX = -headpose[Pitch]; // degrees virtSCRotY = -headpose[Yaw]; @@ -90,14 +77,8 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { virtSCPosY = headpose[TY]/100.f; virtSCPosZ = -headpose[TZ]/100.f; - // - // It's only useful to send data, if the connection was made. - // if (!blnSimConnectActive) { if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!"; - - //set up the events we want to listen for HRESULT hr; simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); @@ -105,39 +86,11 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); - ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT); - ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON); - blnSimConnectActive = true; } } - else { - // - // Write the 6DOF-data to FSX -// // -// // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. -// // -// if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || -// (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { -//// if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) { -//// qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; -//// } -// } -// -// prevPosX = virtPosX; -// prevPosY = virtPosY; -// prevPosZ = virtPosZ; -// prevRotX = virtRotX; -// prevRotY = virtRotY; -// prevRotZ = virtRotZ; - - if (SUCCEEDED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL))) { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Dispatching"; - } - else { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Error Dispatching!"; - } - } + else + (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL)); } class ActivationContext { @@ -176,30 +129,16 @@ private: HANDLE hactctx; }; -// -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { if (!SCClientLib.isLoaded()) { - qDebug() << "SCCheckClientDLL says: Starting Function"; - - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "FSX" ); - int act = iniFile.value("version", 0).toInt(); - iniFile.endGroup(); - - ActivationContext ctx(142 + act); + ActivationContext ctx(142 + static_cast(s.sxs_manifest)); if (!SCClientLib.load()) { qDebug() << "SC load" << SCClientLib.errorString(); return false; } - } else { - qDebug() << "SimConnect already loaded"; } // @@ -260,97 +199,47 @@ bool FTNoIR_Protocol::checkServerInstallationOK() void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) { -// HRESULT hr; - switch(pData->dwID) { - case SIMCONNECT_RECV_ID_EVENT: - { - SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData; - - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: SimConnect active!"; - //switch(evt->uEventID) - //{ - // //case EVENT_CAMERA_RIGHT: - - // // cameraBank = normalize180( cameraBank + 5.0f); - - // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, - // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); - - // // printf("\nCamera Bank = %f", cameraBank); - // // break; - - // //case EVENT_CAMERA_LEFT: - // // - // // cameraBank = normalize180( cameraBank - 5.0f); - - // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, - // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); - // // - // // printf("\nCamera Bank = %f", cameraBank); - // // break; - - // //default: - // // break; - //} - //break; + default: + break; + case SIMCONNECT_RECV_ID_EVENT_FRAME: + { + if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || + (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { + (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); } - case SIMCONNECT_RECV_ID_EVENT_FRAME: - { -// qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Frame event!"; - if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || - (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { - if (S_OK == simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY)) { - // qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; - } - } - prevSCPosX = virtSCPosX; - prevSCPosY = virtSCPosY; - prevSCPosZ = virtSCPosZ; - prevSCRotX = virtSCRotX; - prevSCRotY = virtSCRotY; - prevSCRotZ = virtSCRotZ; - } + prevSCPosX = virtSCPosX; + prevSCPosY = virtSCPosY; + prevSCPosZ = virtSCPosZ; + prevSCRotX = virtSCRotX; + prevSCRotY = virtSCRotY; + prevSCRotZ = virtSCRotZ; + } + case SIMCONNECT_RECV_ID_EXCEPTION: + { + SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; - case SIMCONNECT_RECV_ID_EXCEPTION: + switch (except->dwException) { - SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; - - switch (except->dwException) - { - case SIMCONNECT_EXCEPTION_ERROR: - printf("\nCamera error"); - break; - - default: - printf("\nException"); - break; - } + case SIMCONNECT_EXCEPTION_ERROR: + qDebug() << "Camera error"; break; - } - case SIMCONNECT_RECV_ID_QUIT: - { - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!"; -// quit = 1; + default: + qDebug() << "Exception"; break; } + break; + } - default: - break; + case SIMCONNECT_RECV_ID_QUIT: + { + break; + } } } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 7917c532..a13c0097 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -27,8 +27,6 @@ * must be treated as such... * ********************************************************************************/ #pragma once -#ifndef INCLUDED_SCSERVER_H -#define INCLUDED_SCSERVER_H #undef _WIN32_WINNT #define _WIN32_WINNT 0x0502 #include "facetracknoir/global-settings.h" @@ -48,7 +46,8 @@ #include #include #include -//#include "math.h" +#include "facetracknoir/options.h" +using namespace options; typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); @@ -77,6 +76,15 @@ enum INPUT_ID INPUT0=0, }; +struct settings { + pbundle b; + value sxs_manifest; + settings() : + b(bundle("proto-simconnect")), + sxs_manifest(b, "sxs-manifest-version", 0) + {} +}; + class FTNoIR_Protocol : public IProtocol { public: @@ -87,11 +95,7 @@ public: QString getGameName() { return "FS2004/FSX"; } - private: - // Private properties - QString ProgramName; - static float virtSCPosX; static float virtSCPosY; static float virtSCPosZ; @@ -121,7 +125,7 @@ private: static HANDLE hSimConnect; // Handle to SimConnect static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); - void loadSettings(); + settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -129,28 +133,15 @@ class SCControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit SCControls(); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + SCControls(); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} private: - Ui::UICSCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICSCControls ui; + settings s; private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; + void doOK(); + void doCancel(); }; //******************************************************************************************************* @@ -159,15 +150,8 @@ private slots: class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); }; + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); } + void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); } }; - -#endif//INCLUDED_SCSERVER_H -//END diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index eb15ca69..6af87285 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -26,13 +26,6 @@ #include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// SCControls::SCControls() : QWidget() { @@ -41,85 +34,38 @@ QWidget() // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - //connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); - - theProtocol = NULL; - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.sxs_manifest, ui.comboBox); } void SCControls::doOK() { - save(); + s.b->save(); this->close(); } void SCControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} + 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); -// -// Load the current Settings from the currently 'active' INI-file. -// -void SCControls::loadSettings() { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "FSX" ); - int act = iniFile.value("version", 0).toInt(); - iniFile.endGroup(); - ui.comboBox->setCurrentIndex(act); - settingsDirty = false; + switch (ret) { + case QMessageBox::Save: + s.b->save(); + this->close(); + break; + case QMessageBox::Discard: + s.b->revert(); + this->close(); + break; + case QMessageBox::Cancel: + default: + break; + } + } + else { + this->close(); + } } -// -// Save the current Settings to the currently 'active' INI-file. -// -void SCControls::save() { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "FSX" ); - iniFile.setValue("version", ui.comboBox->currentIndex()); - iniFile.endGroup(); - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) { return new SCControls; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index 59a921b8..0a52fa96 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -26,23 +26,6 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_ProtocolDll; -- cgit v1.2.3 From e437f501a6b7a6a9ac90eec6d91ebf022aa09ff8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:16:01 +0100 Subject: fsuipc: decruft more --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 35 +++++++++++++--------- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 7 ++--- .../ftnoir_protocol_fsuipc_dialog.cpp | 9 ------ 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 7ca990af..632d502a 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -30,22 +30,25 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - prevPosX = 0.0; - prevPosY = 0.0; - prevPosZ = 0.0; - prevRotX = 0.0; - prevRotY = 0.0; - prevRotZ = 0.0; + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; } FTNoIR_Protocol::~FTNoIR_Protocol() { - FSUIPCLib.unload(); + FSUIPCLib.unload(); } +// +// Scale the measured value to the Joystick values +// int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { - double y; - double local_x; +double y; +double local_x; local_x = x; if (local_x > max_x) { @@ -74,6 +77,8 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { float virtRotY; float virtRotZ; +// qDebug() << "FSUIPCServer::run() says: started!"; + virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; virtRotZ = headpose[Roll]; @@ -82,11 +87,17 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { virtPosY = 0.0f; virtPosZ = headpose[TZ]; + // + // Init. the FSUIPC offsets (derived from Free-track...) + // pitch.Control = 66503; yaw.Control = 66504; roll.Control = 66505; - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + // + // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. + // + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { // // Open the connection @@ -132,9 +143,6 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { prevRotZ = virtRotZ; } -// -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { qDebug() << "checkServerInstallationOK says: Starting Function"; @@ -154,7 +162,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index a099df36..ff8d3b7f 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -76,8 +76,8 @@ public: private: QLibrary FSUIPCLib; double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - settings s; static int scale2AnalogLimits( float x, float min_x, float max_x ); + settings s; }; class FSUIPCControls: public QWidget, public IProtocolDialog @@ -85,7 +85,7 @@ class FSUIPCControls: public QWidget, public IProtocolDialog Q_OBJECT public: FSUIPCControls(); - void registerProtocol(IProtocol *protocol) {} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: Ui::UICFSUIPCControls ui; @@ -96,9 +96,6 @@ private slots: void getLocationOfDLL(); }; -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* class FTNoIR_ProtocolDll : public Metadata { public: diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 9ef4ad67..bae3d5df 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -29,8 +29,6 @@ FSUIPCControls::FSUIPCControls() : QWidget() { ui.setupUi( this ); - - // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); @@ -43,11 +41,7 @@ void FSUIPCControls::doOK() { this->close(); } - void FSUIPCControls::doCancel() { - // - // Ask if changed Settings should be saved - // 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 ); @@ -74,9 +68,6 @@ void FSUIPCControls::doCancel() { void FSUIPCControls::getLocationOfDLL() { - // - // Get the new filename of the INI-file. - // QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), ui.txtLocationOfDLL->text(), tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); -- cgit v1.2.3 From afaeec72c57a368eb3db072b9157eb1089c37fc1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:30:09 +0100 Subject: reindent cmake --- CMakeLists.txt | 78 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a88e6995..a3162637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,54 +114,54 @@ if(MINGW) set(Qt5Gui_gdi32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libgdi32.a) endif() - find_package(OpenCV REQUIRED) - set(maybe-serial-port) - if(SDK_HATIRE) - set(maybe-serial-port SerialPort) - endif() +find_package(OpenCV REQUIRED) +set(maybe-serial-port) +if(SDK_HATIRE) + set(maybe-serial-port SerialPort) +endif() - find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui ${maybe-serial-port} QUIET) - cmake_policy(SET CMP0020 NEW) - include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) - add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) +find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui ${maybe-serial-port} QUIET) +cmake_policy(SET CMP0020 NEW) +include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) +add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ftnoir_posewidget) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ftnoir_posewidget) - set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library") +set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library") - SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked") - if(WIN32) - set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK") - set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK") - set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC") - if(SDK_DIRECTX) - include_directories("${SDK_DIRECTX}/Include") - link_directories("${SDK_DIRECTX}/Lib") - endif() +SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked") +if(WIN32) + set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK") + set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK") + set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC") + if(SDK_DIRECTX) + include_directories("${SDK_DIRECTX}/Include") + link_directories("${SDK_DIRECTX}/Lib") endif() +endif() - if(NOT WIN32) - set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed") - set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app") - endif() - IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE) - set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") - endif() +if(NOT WIN32) + set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed") + set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app") +endif() +IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE) + set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") +endif() - if(SDK_XPLANE) - INCLUDE_DIRECTORIES("${SDK_XPLANE}/CHeaders" "${SDK_XPLANE}/CHeaders/XPLM") - endif() +if(SDK_XPLANE) + INCLUDE_DIRECTORIES("${SDK_XPLANE}/CHeaders" "${SDK_XPLANE}/CHeaders/XPLM") +endif() - if(WIN32) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) - SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") - endif() - ENABLE_LANGUAGE(RC) - endif(WIN32) +if(WIN32) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) + SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") + endif() + ENABLE_LANGUAGE(RC) +endif(WIN32) if(SDK_FSUIPC AND WIN32) include_directories("${SDK_FSUIPC}") -- cgit v1.2.3 From 823fdc531192ca4a7e831dbfc0c3755f65e17cd6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:38:22 +0100 Subject: duh, braino --- CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3162637..100cad67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,9 +224,7 @@ opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft) opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn) opentrack_module(opentrack-proto-wine ftnoir_protocol_wine) -if(WIN32) - opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) -endif() +opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc) opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy) opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev) @@ -357,10 +355,9 @@ endif() if(WIN32) opentrack_library(opentrack-proto-freetrack) target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) + opentrack_library(opentrack-proto-win32-mouse) endif() -opentrack_library(opentrack-proto-win32-mouse) - if(WIN32) add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) -- cgit v1.2.3 From cb24e0d1dc2917691db6f30c063f2add323ca70b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 17:14:45 +0100 Subject: web host gone away, long live the new web host --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b1fa53a..67fa3df8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Windows binary builds are available at +Windows binary builds are available at Source code access available at -- cgit v1.2.3 From 4a9c157caa350f0e333cba8444793ddae840bf12 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 10:33:12 +0100 Subject: settings for mouse --- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 56 ++----- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 78 ++++----- .../ftnoir_protocol_mouse_dialog.cpp | 180 ++++++--------------- .../ftnoir_protocol_mouse_dll.cpp | 18 --- 4 files changed, 86 insertions(+), 246 deletions(-) diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 64e010a8..cc8aa11e 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -29,38 +29,12 @@ #include "ftnoir_protocol_mouse.h" #include "facetracknoir/global-settings.h" -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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) - - iniFile.beginGroup ( "Mouse" ); - Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 0 ).toInt()); - Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 0 ).toInt()); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { - float fMouse_X = 0; - float fMouse_Y = 0; + double fMouse_X = 0; + double fMouse_Y = 0; + + int Mouse_X = s.Mouse_X; + int Mouse_Y = s.Mouse_Y; if (Mouse_X > 0 && Mouse_X <= 6) fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180); @@ -77,24 +51,16 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { } } -// -// Returns 'true' if all seems OK. -// +void FTNoIR_Protocol::reload() +{ + s.b->reload(); +} + bool FTNoIR_Protocol::checkServerInstallationOK() { - - return true; + return true; } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 1ce72f69..01f283d3 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -41,37 +41,34 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value Mouse_X, Mouse_Y; + settings() : + b(bundle("mouse-proto")), + Mouse_X(b, "mouse-x", 0), + Mouse_Y(b, "mouse-y", 0) + {} +}; #define MOUSE_AXIS_MIN 0 #define MOUSE_AXIS_MAX 65535 -enum FTN_AngleName { - FTN_YAW = Yaw, - FTN_PITCH = Pitch, - FTN_ROLL = Roll, - FTN_X = TX, - FTN_Y = TY, - FTN_Z = TZ -}; - class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); + FTNoIR_Protocol() {} bool checkServerInstallationOK(); void sendHeadposeToGame( const double *headpose); QString getGameName() { return "Mouse tracker"; } + void reload(); private: - HANDLE h; - INPUT MouseStruct; - - FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction - FTN_AngleName Mouse_Y; - FTN_AngleName Mouse_Wheel; - void loadSettings(); + struct settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -79,31 +76,20 @@ class MOUSEControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit MOUSEControls(); - virtual ~MOUSEControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + MOUSEControls(); + void registerProtocol(IProtocol *protocol) { + _proto = (FTNoIR_Protocol *) protocol; + } + void unRegisterProtocol() { + _proto = NULL; + } private: - Ui::UICMOUSEControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICMOUSEControls ui; + settings s; + FTNoIR_Protocol* _proto; private slots: - void doOK(); - void doCancel(); - void settingChanged( int setting ) { settingsDirty = true; } + void doOK(); + void doCancel(); }; //******************************************************************************************************* @@ -112,13 +98,9 @@ private slots: class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); } - + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); } void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); } }; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index c8d62a58..cc62b004 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -23,158 +23,68 @@ * * ********************************************************************************/ #include "ftnoir_protocol_mouse.h" -#include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -MOUSEControls::MOUSEControls() : -QWidget() +MOUSEControls::MOUSEControls() : _proto(nullptr) { - ui.setupUi( this ); - ui.cbxSelectMouse_X->addItem("None"); + ui.setupUi( this ); + ui.cbxSelectMouse_X->addItem("None"); ui.cbxSelectMouse_X->addItem("X"); - ui.cbxSelectMouse_X->addItem("Y"); - ui.cbxSelectMouse_X->addItem("Z"); - ui.cbxSelectMouse_X->addItem("Yaw"); + ui.cbxSelectMouse_X->addItem("Y"); + ui.cbxSelectMouse_X->addItem("Z"); + ui.cbxSelectMouse_X->addItem("Yaw"); ui.cbxSelectMouse_X->addItem("Pitch"); - ui.cbxSelectMouse_X->addItem("Roll"); + ui.cbxSelectMouse_X->addItem("Roll"); - ui.cbxSelectMouse_Y->addItem("None"); - ui.cbxSelectMouse_Y->addItem("X"); - ui.cbxSelectMouse_Y->addItem("Y"); - ui.cbxSelectMouse_Y->addItem("Z"); + ui.cbxSelectMouse_Y->addItem("None"); + ui.cbxSelectMouse_Y->addItem("X"); + ui.cbxSelectMouse_Y->addItem("Y"); + ui.cbxSelectMouse_Y->addItem("Z"); ui.cbxSelectMouse_Y->addItem("Yaw"); - ui.cbxSelectMouse_Y->addItem("Pitch"); - ui.cbxSelectMouse_Y->addItem("Roll"); - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - theProtocol = NULL; - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -MOUSEControls::~MOUSEControls() { - qDebug() << "~MOUSEControls() says: started"; -} + ui.cbxSelectMouse_Y->addItem("Pitch"); + ui.cbxSelectMouse_Y->addItem("Roll"); -// -// Initialize tracker-client-dialog -// -void MOUSEControls::Initialize(QWidget *parent) { + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); + tie_setting(s.Mouse_X, ui.cbxSelectMouse_X); + tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y); } -// -// OK clicked on server-dialog -// void MOUSEControls::doOK() { - save(); - this->close(); -} - -// override show event -void MOUSEControls::showEvent ( QShowEvent * event ) { - loadSettings(); + s.b->save(); + if (_proto) + _proto->reload(); + this->close(); } -// -// Cancel clicked on server-dialog -// void MOUSEControls::doCancel() { - // - // Ask if changed Settings should be saved - // - 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 ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void MOUSEControls::loadSettings() { - qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Mouse" ); - ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 0 ).toInt() ); - ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 0 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; + 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); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + s.b->save(); + this->close(); + if (_proto) + _proto->reload(); + break; + case QMessageBox::Discard: + s.b->revert(); + this->close(); + break; + case QMessageBox::Cancel: + default: + break; + } + } + else { + this->close(); + } } -// -// Save the current Settings to the currently 'active' INI-file. -// -void MOUSEControls::save() { - qDebug() << "save() says: started"; - - 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) - - iniFile.beginGroup ( "Mouse" ); - iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() ); - iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) { return new MOUSEControls; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp index d142934d..54f6b307 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #include "ftnoir_protocol_mouse.h" -#include #include "facetracknoir/global-settings.h" -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_ProtocolDll; -- cgit v1.2.3 From 46807a9feea303144884f2865ac37f55c54fdb5a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 10:48:33 +0100 Subject: joystick: don't be a phonebook --- .../ftnoir_tracker_joystick.cpp | 22 +--- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 49 +++++--- .../ftnoir_tracker_joystick_dialog.cpp | 134 ++++++--------------- .../ftnoir_tracker_joystick_dll.cpp | 29 +---- 4 files changed, 71 insertions(+), 163 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 5be6b3db..28fc034a 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -10,24 +10,24 @@ static BOOL CALLBACK EnumJoysticksCallback2( const DIDEVICEINSTANCE* pdidInstanc self->def = *pdidInstance; - return self->iter++ == self->joyid ? DIENUM_STOP : DIENUM_CONTINUE; + return self->iter++ == self->s.joyid ? DIENUM_STOP : DIENUM_CONTINUE; } FTNoIR_Tracker::FTNoIR_Tracker() : g_pDI(nullptr), g_pJoystick(nullptr), - joyid(-1), iter(-1), mtx(QMutex::Recursive) { for (int i = 0; i < 6; i++) - axes[i] = min_[i] = max_[i] = 0; + *s.axes[i] = min_[i] = max_[i] = 0; GUID bar = {0}; preferred = bar; } void FTNoIR_Tracker::reload() { + s.b->reload(); QMutexLocker foo(&mtx); if (g_pJoystick) { @@ -100,7 +100,6 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) QMutexLocker foo(&mtx); this->frame = frame; iter = 0; - loadSettings(); auto hr = CoInitialize( nullptr ); DI_ENUM_CONTEXT enumContext = {0}; @@ -218,7 +217,7 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) for (int i = 0; i < 6; i++) { - auto idx = axes[i] - 1; + auto idx = *s.axes[i] - 1; if (idx < 0 || idx > 7) { data[i] = 0; @@ -234,19 +233,6 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) } } -void FTNoIR_Tracker::loadSettings() { - - QMutexLocker foo(&mtx); - 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) - iniFile.beginGroup ( "tracker-joy" ); - joyid = iniFile.value("joyid", -1).toInt(); - for (int i = 0; i < 6; i++) - axes[i] = iniFile.value(QString("axis-%1").arg(i), 0).toInt() - 1; - iniFile.endGroup (); -} - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Tracker; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 67291e6f..162cbe48 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -24,10 +24,12 @@ #include #include #include -//#include #include #include +#include "facetracknoir/options.h" +using namespace options; + struct DI_ENUM_CONTEXT { GUID preferred_instance; @@ -35,29 +37,48 @@ struct DI_ENUM_CONTEXT LPDIRECTINPUT8 g_pDI; }; +struct settings { + pbundle b; + value axis_0; + value axis_1; + value axis_2; + value axis_3; + value axis_4; + value axis_5; + value joyid; + value* axes[6]; + settings() : + b(bundle("tracker-joystick")), + axis_0(b, "axis-0", 0), + axis_1(b, "axis-1", 0), + axis_2(b, "axis-2", 0), + axis_3(b, "axis-3", 0), + axis_4(b, "axis-4", 0), + axis_5(b, "axis-5", 0), + joyid(b, "joy-id", 0), + axes{&axis_0, &axis_1, &axis_2, &axis_3, &axis_4, &axis_5} + {} +}; + class FTNoIR_Tracker : public ITracker { public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void StartTracker(QFrame *frame); void GetHeadPoseData(double *data); - void loadSettings(); + void reload(); LPDIRECTINPUT8 g_pDI; LPDIRECTINPUTDEVICE8 g_pJoystick; - int axes[6]; int min_[8], max_[8]; GUID preferred; - int joyid; QMutex mtx; QFrame* frame; DIDEVICEINSTANCE def; - void reload(); int iter; // XXX bad style + settings s; }; -// Widget that has controls for FTNoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT @@ -71,32 +92,20 @@ public: } QList guids; Ui::UIJoystickControls ui; - void loadSettings(); - void save(); - bool settingsDirty; FTNoIR_Tracker* tracker; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } }; -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* class FTNoIR_TrackerDll : public Metadata { public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); - private: QString trackerFullName; // Trackers' name and description QString trackerShortName; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 42ca8689..812ad454 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -11,22 +11,21 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance return DIENUM_CONTINUE; } -TrackerControls::TrackerControls() : - QWidget(), tracker(nullptr), settingsDirty(false) +TrackerControls::TrackerControls() : tracker(nullptr) { - ui.setupUi( this ); + ui.setupUi( this ); - // Connect Qt signals to member-functions + // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.joylist, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + tie_setting(s.joyid, ui.joylist); + tie_setting(s.axis_0, ui.comboBox); + tie_setting(s.axis_1, ui.comboBox_2); + tie_setting(s.axis_2, ui.comboBox_3); + tie_setting(s.axis_3, ui.comboBox_4); + tie_setting(s.axis_4, ui.comboBox_5); + tie_setting(s.axis_5, ui.comboBox_6); { auto hr = CoInitialize( nullptr ); @@ -46,107 +45,42 @@ fin: if (g_pDI) g_pDI->Release(); } - - loadSettings(); } void TrackerControls::doOK() { - save(); - this->close(); + s.b->save(); + if (tracker) + tracker->reload(); + this->close(); } 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 ); + 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 ); switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -void TrackerControls::loadSettings() { - - 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) - - QComboBox* boxen[] = { - ui.comboBox_4, - ui.comboBox_5, - ui.comboBox_6, - ui.comboBox, - ui.comboBox_2, - ui.comboBox_3, - }; - - iniFile.beginGroup ( "tracker-joy" ); - for (int i = 0; i < 6; i++) - { - boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt()); - } - ui.joylist->setCurrentIndex(iniFile.value("joyid", -1).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -void TrackerControls::save() { - 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) - - QComboBox* boxen[] = { - ui.comboBox_4, - ui.comboBox_5, - ui.comboBox_6, - ui.comboBox, - ui.comboBox_2, - ui.comboBox_3, - }; - - iniFile.beginGroup ( "tracker-joy" ); - for (int i = 0; i < 6; i++) - { - iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex()); + case QMessageBox::Save: + s.b->save(); + if (tracker) + tracker->reload(); + this->close(); + break; + case QMessageBox::Discard: + s.b->reload(); + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; } - iniFile.setValue("joyid", ui.joylist->currentIndex()); - iniFile.endGroup (); } - - if(tracker) - { - tracker->reload(); + else { + this->close(); } - - settingsDirty = false; } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) { diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp index c5ee4e5f..325d24a4 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp @@ -2,31 +2,19 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "Joystick"; - trackerShortName = "Joystick"; - trackerDescription = "joystick"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { - *strToBeFilled = trackerFullName; + *strToBeFilled = "Joystick"; } void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = trackerShortName; + *strToBeFilled = "Joystick"; } void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = trackerDescription; + *strToBeFilled = "Joystick"; } void FTNoIR_TrackerDll::getIcon(QIcon *icon) @@ -34,16 +22,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/facetracknoir.png"); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { - return new FTNoIR_TrackerDll; + return new FTNoIR_TrackerDll; } -- cgit v1.2.3 From 8744ae5baea83ed068a432d2dcc1c13fc347b8b2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:22:19 +0100 Subject: fix build --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 100cad67..f7459e0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,16 +191,19 @@ macro(opentrack_module n dir) endmacro() macro(opentrack_library n) - cmake_parse_arguments(lib- "" "LINK COMPILE" "" ${ARGN}) + cmake_parse_arguments(foolib "" "LINK;COMPILE" "" ${ARGN}) + if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ") + message(FATAL_ERROR "opentrack_library bad formals") + endif() add_library(${n} SHARED ${${n}-c} ${${n}-uih} ${${n}-rcc}) target_link_libraries(${n} ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(${n} PROPERTIES - LINK_FLAGS "${lib-LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" - COMPILE_FLAGS "${lib-COMPILE}" + LINK_FLAGS "${foolib_LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" + COMPILE_FLAGS "${foolib_COMPILE}" ) else() - set_target_properties(${n} PROPERTIES LINK_FLAGS "${lib-LINK}" COMPILE_FLAGS "${lib-COMPILE}") + set_target_properties(${n} PROPERTIES LINK_FLAGS "${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") endif() install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endmacro() @@ -373,6 +376,7 @@ endif() if(SDK_WINE_PREFIX) opentrack_library(opentrack-proto-wine) + target_link_libraries(opentrack-proto-wine opentrack-compat opentrack-csv) if(NOT SDK_WINE_NO_WRAPPER) set(my-rt -lrt) if(APPLE) -- cgit v1.2.3 From b4cd90ce91322830a6b08d6f18440cd92987f166 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:28:44 +0100 Subject: libovr doesn't require strict aliasing anymore --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 100cad67..2092aee3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,12 +446,7 @@ if(SDK_RIFT) set(link-flags "/NODEFAULTLIB:LIBCMT") endif() endif() - if(NOT MSVC) - set(c-flags -fno-strict-aliasing) - else() - set(c-flags) - endif() - opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") + opentrack_library(opentrack-tracker-rift LINK "${link-flags}") if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) else() -- cgit v1.2.3 From c2e56bd21ee40501dab53b3647c8bdd1f370dba3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:28:59 +0100 Subject: don't reference QSettings anymore --- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 1 - ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h | 1 - ftnoir_protocol_wine/ftnoir_protocol_wine.h | 1 - ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 1 - ftnoir_tracker_ht/stdafx.h | 1 - ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 1 - ftnoir_tracker_rift/ftnoir_tracker_rift.h | 1 - ftnoir_tracker_udp/ftnoir_tracker_udp.h | 1 - 8 files changed, 8 deletions(-) diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index d5dc2cfe..99e6c6a1 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include "facetracknoir/global-settings.h" #include "facetracknoir/options.h" diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index 5df59919..f92bb7bb 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -9,7 +9,6 @@ #include "ui_ftnoir_libevdev_controls.h" #include -#include #include "facetracknoir/global-settings.h" extern "C" { diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index e84dbd69..50d2bc0c 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -33,7 +33,6 @@ #include "ftnoir_csv/csv.h" #include "ui_ftnoir_winecontrols.h" #include -#include #include #include #include diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index 57ead58d..0dbc4c8c 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -16,7 +16,6 @@ #include #include #include -#include #define VER_FILEVERSION_STR "Version 2.0.7\0" diff --git a/ftnoir_tracker_ht/stdafx.h b/ftnoir_tracker_ht/stdafx.h index 0e532c9f..6f1539b7 100644 --- a/ftnoir_tracker_ht/stdafx.h +++ b/ftnoir_tracker_ht/stdafx.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index e569efab..05a8b076 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -1,7 +1,6 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_hydra_clientcontrols.h" #include -#include #include #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index dd673308..7162b7ca 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -2,7 +2,6 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_rift_clientcontrols.h" #include -#include #include #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 140a935d..20d4f742 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 495b518b4b4127ed3656c8da817c1f9744abee9e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:31:21 +0100 Subject: empty default config. should have sane defaults by now --- bin/settings/default.ini | 130 ----------------------------------------------- 1 file changed, 130 deletions(-) diff --git a/bin/settings/default.ini b/bin/settings/default.ini index 05ce3af4..e69de29b 100644 --- a/bin/settings/default.ini +++ b/bin/settings/default.ini @@ -1,130 +0,0 @@ -[Curves-rx] -point-count=4 -point-0-x=0 -point-0-y=0 -point-1-x=5 -point-1-y=14 -point-2-x=12.222222328186 -point-2-y=75 -point-3-x=19 -point-3-y=158 - -[Curves-ry] -point-count=1 -point-0-x=19 -point-0-y=90 - -[Curves-ry_alt] -point-count=4 -point-0-x=0 -point-0-y=0 -point-1-x=4.88888883590698 -point-1-y=16 -point-2-x=8.88888931274414 -point-2-y=36 -point-3-x=12 -point-3-y=69 - -[Curves-rz] -point-count=1 -point-0-x=60 -point-0-y=60 - -[Curves-tx] -point-count=1 -point-0-x=59.8888893127441 -point-0-y=165 - -[Curves-ty] -point-count=1 -point-0-x=60 -point-0-y=165 - -[Curves-tz] -point-count=1 -point-0-x=60 -point-0-y=200 - -[Tracking] -Smooth=1 -invertYaw=false -invertPitch=false -invertRoll=false -invertX=false -invertY=false -invertZ=false -rx_alt=false -ry_alt=true -rz_alt=false -tx_alt=false -ty_alt=false -tz_alt=false - -[GameProtocol] -DLL=FTNoIR_Protocol_FT.dll - -[KB_Shortcuts] -Keycode_Center=199 -Shift_Center=false -Ctrl_Center=false -Alt_Center=false -Keycode_StartStop=207 -Shift_StartStop=false -Ctrl_StartStop=false -Alt_StartStop=false - -[PPJoy] -Selection=1 - -[FSUIPC] -LocationOfDLL=C:/Program Files/Microsoft Games/Flight Simulator 9/Modules/FSUIPC.dll - -[TrackerSource] -Selection=0 -DLL=FTNoIR_Tracker_SM.dll -2ndDLL=None - -[Filter] -DLL=FTNoIR_Filter_Accela.dll - -[SMTracker] -FilterLevel=1 -EnableRoll=true -EnablePitch=true -EnableYaw=true -EnableX=true -EnableY=true -EnableZ=true - -[Accela] -Reduction=1000 -zoom-slowness=5 -smoothing-factor=1.5 - -[Curves-Accela-Scaling-Rotation] -point-count=6 -point-0-x=0 -point-0-y=0 -point-1-x=0.535433053970337 -point-1-y=0.29824560880661 -point-2-x=0.992125988006592 -point-2-y=0.736842095851898 -point-3-x=1.33070862293243 -point-3-y=1.59649121761322 -point-4-x=1.4960629940033 -point-4-y=3.29824566841125 -point-5-x=1.58267712593079 -point-5-y=8 - -[Curves-Accela-Scaling-Translation] -point-count=5 -point-0-x=0 -point-0-y=0 -point-1-x=0.346456706523895 -point-1-y=1 -point-2-x=0.559055089950562 -point-2-y=3.15789484977722 -point-3-x=0.700787425041199 -point-3-y=5.54385948181152 -point-4-x=0.795275568962097 -point-4-y=8 \ No newline at end of file -- cgit v1.2.3 From a154845c21a58891f9368c560cfe26602b19ff10 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:35:35 +0100 Subject: UDP: fill in description strings --- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 5 ----- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 20d4f742..62eb67df 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -73,10 +73,5 @@ public: void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; }; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index 6732b599..22dc7daa 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -28,17 +28,17 @@ void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { - *strToBeFilled = trackerFullName; + *strToBeFilled = "UDP"; } void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = trackerShortName; + *strToBeFilled = "UDP"; } void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = trackerDescription; + *strToBeFilled = "UDP"; } void FTNoIR_TrackerDll::getIcon(QIcon *icon) -- cgit v1.2.3 From 478923fa291949af2ce1f307f9dd592f451508df Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:13:25 +0100 Subject: fix qvariant saying invalid when they're not --- facetracknoir/options.h | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/facetracknoir/options.h b/facetracknoir/options.h index e77988c7..7ecf6280 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -32,6 +32,8 @@ # define ov #endif +#include + namespace options { template inline T qcruft_to_t (const QVariant& t); @@ -193,8 +195,8 @@ namespace options { base_value(pbundle b, const QString& name) : b(b), self_name(name) { connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); } - virtual QVariant operator=(const QVariant& datum) = 0; protected: + virtual QVariant operator=(const QVariant& datum) = 0; pbundle b; QString self_name; public slots: @@ -203,7 +205,7 @@ namespace options { this->operator=(b->get(self_name)); } public slots: -#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } +#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); } DEFINE_SLOT(double) DEFINE_SLOT(int) DEFINE_SLOT(QString) @@ -218,24 +220,29 @@ namespace options { template class value : public base_value { - private: T def; + private: + T def; + protected: + QVariant operator=(const QVariant& datum) { + auto foo = qcruft_to_t(datum); + b->store(self_name, qVariantFromValue(foo)); + emit valueChanged(foo); + return datum; + } public: static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; value(pbundle b, const QString& name, T def) : base_value(b, name), def(def) { - if (!b->contains(name)) + if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) { - QVariant cruft(def); - b->store(self_name, cruft); + this->operator=(qVariantFromValue(def)); } } operator T() { return b->get(self_name); } - QVariant operator=(const QVariant& datum) { - b->store(self_name, datum); - auto foo = qcruft_to_t(datum); - emit valueChanged(foo); - return datum; + QVariant operator=(const T& datum) + { + return this->operator =(qVariantFromValue(datum)); } }; -- cgit v1.2.3 From e18f6c36733b206167470619bf97040fa4a3b99f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:24:25 +0100 Subject: reload profile combobox at appropriate time and place --- facetracknoir/facetracknoir.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2006f831..6e97080d 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -262,6 +262,7 @@ void FaceTrackNoIR::open() { QSettings settings("opentrack"); settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); } + fill_profile_cbx(); loadSettings(); } } @@ -587,10 +588,6 @@ void FaceTrackNoIR::fill_profile_cbx() ui.iconcomboProfile->clear(); for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); - ui.iconcomboProfile->setCurrentIndex( i ); - } } looping = false; } @@ -602,11 +599,6 @@ void FaceTrackNoIR::profileSelected(int index) QFileInfo pathInfo ( currentFile ); settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); loadSettings(); - if (looping) - return; - looping = true; - fill_profile_cbx(); - looping = false; } #if !defined(_WIN32) -- cgit v1.2.3 From ec3fe4414268acb83c04194247087389c3d1f7f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:35:58 +0100 Subject: reload profile list when saving a new one --- facetracknoir/facetracknoir.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 6e97080d..08cd9dfa 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -313,6 +313,8 @@ void FaceTrackNoIR::saveAs() settings.setValue ("SettingsFile", fileName); save(); } + + fill_profile_cbx(); } void FaceTrackNoIR::loadSettings() { -- cgit v1.2.3 From 36ca50cb9a5d575d3fb6ea1b5062c2f96a906b4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:36:43 +0100 Subject: load right profile when using multiple ones (duh) --- facetracknoir/facetracknoir.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 08cd9dfa..2bb36a78 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -590,6 +590,10 @@ void FaceTrackNoIR::fill_profile_cbx() ui.iconcomboProfile->clear(); for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); + if (iniFileList.at(i) == pathInfo.fileName()) { + ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); + ui.iconcomboProfile->setCurrentIndex( i ); + } } looping = false; } -- cgit v1.2.3 From e38d6ab7472e9adb6bac0550fdffebb748ac4353 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:41:29 +0100 Subject: get rid of useless active profile icon --- facetracknoir/facetracknoir.cpp | 1 - facetracknoir/images/settingsopen16.png | Bin 686 -> 0 bytes facetracknoir/main-facetracknoir.qrc | 1 - 3 files changed, 2 deletions(-) delete mode 100644 facetracknoir/images/settingsopen16.png diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2bb36a78..309a4a93 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -591,7 +591,6 @@ void FaceTrackNoIR::fill_profile_cbx() for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); ui.iconcomboProfile->setCurrentIndex( i ); } } diff --git a/facetracknoir/images/settingsopen16.png b/facetracknoir/images/settingsopen16.png deleted file mode 100644 index 5bf65f0d..00000000 Binary files a/facetracknoir/images/settingsopen16.png and /dev/null differ diff --git a/facetracknoir/main-facetracknoir.qrc b/facetracknoir/main-facetracknoir.qrc index eb5ad991..6cb2e300 100644 --- a/facetracknoir/main-facetracknoir.qrc +++ b/facetracknoir/main-facetracknoir.qrc @@ -2,7 +2,6 @@ uielements/tools.png images/settings16.png - images/settingsopen16.png uielements/curves.png images/facetracknoir.png -- cgit v1.2.3 From 9f0ba65825054b182d9a9c2b53dad955a90d4df1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:40:41 +0100 Subject: base spline widget size on config size --- facetracknoir/ftnoir_curves.ui | 12 ++++++------ qfunctionconfigurator/functionconfig.h | 2 ++ qfunctionconfigurator/qfunctionconfigurator.cpp | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index f96df044..9b5c8d07 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -325,7 +325,7 @@ 100 - 7 + 28 2 @@ -374,7 +374,7 @@ 100 - 7 + 28 2 @@ -415,7 +415,7 @@ 100 - 7 + 28 2 @@ -464,7 +464,7 @@ 100 - 7 + 28 2 @@ -505,7 +505,7 @@ 100 - 7 + 28 2 @@ -554,7 +554,7 @@ 100 - 7 + 28 2 diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index d809259b..ab2d0d0c 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,6 +32,8 @@ private: int _max_Output; FunctionConfig(const FunctionConfig&) = delete; public: + const int maxInput() const { return _max_Input; } + const int maxOutput() const { return _max_Output; } // // Contructor(s) and destructor // diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 4ad0a9a4..5a02a826 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -31,8 +31,7 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) // // Defaults, for when the widget has no values different from the domXML() // - MaxInput = 50; // Maximum input limit - MaxOutput = 180; // Maximum output limit + pPerEGU_Output = 1; // Number of pixels, per EGU pPerEGU_Input = 4; // Number of pixels, per EGU gDistEGU_Input = 5; // Distance of gridlines @@ -74,6 +73,10 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi setCaption(config->getTitle()); _draw_function = _draw_background = true; + + setmaxInputEGU(config->maxInput()); + setmaxOutputEGU(config->maxOutput()); + this->update(); } -- cgit v1.2.3 From 44162ed05648e68bd07dfcb35e86b6a18b3d3372 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:50:44 +0100 Subject: one const too many --- qfunctionconfigurator/functionconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index ab2d0d0c..4d771dfd 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,8 +32,8 @@ private: int _max_Output; FunctionConfig(const FunctionConfig&) = delete; public: - const int maxInput() const { return _max_Input; } - const int maxOutput() const { return _max_Output; } + int maxInput() const { return _max_Input; } + int maxOutput() const { return _max_Output; } // // Contructor(s) and destructor // -- cgit v1.2.3 From 2d5bdc9d7211d68e619b9d255b46f551d50ef515 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:53:17 +0100 Subject: fix rift build --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93e0b415..e6efa07d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -443,14 +443,18 @@ if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") set(link-flags) + set(c-flags) if(APPLE) set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") + set(c-flags "-fno-strict-aliasing") else() if(MSVC) set(link-flags "/NODEFAULTLIB:LIBCMT") + else() + set(c-flags "-fno-strict-aliasing") endif() endif() - opentrack_library(opentrack-tracker-rift LINK "${link-flags}") + opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) else() -- cgit v1.2.3 From 04709d458eb5449739648fedb6aa8e60fc9cf7f1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 14:00:38 +0100 Subject: don't gray out the wrong buttons when tracking --- facetracknoir/facetracknoir.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 309a4a93..85207b53 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -328,15 +328,13 @@ void FaceTrackNoIR::updateButtonState(bool running) ui.iconcomboProfile->setEnabled ( e ); ui.btnLoad->setEnabled ( e ); ui.btnSaveAs->setEnabled ( e ); - ui.btnShowFilterControls->setEnabled ( e ); ui.btnStartTracker->setEnabled ( e ); ui.btnStopTracker->setEnabled ( running ); - - ui.iconcomboTrackerSource->setEnabled ( e ); - ui.cbxSecondTrackerSource->setEnabled ( e ); ui.iconcomboProtocol->setEnabled ( e ); ui.btnShowServerControls->setEnabled ( e ); ui.iconcomboFilter->setEnabled ( e ); + ui.iconcomboTrackerSource->setEnabled(e); + ui.cbxSecondTrackerSource->setEnabled(e); ui.btnStartTracker->setEnabled(e); ui.btnStopTracker->setEnabled(running); -- cgit v1.2.3 From 53d7258c0151893e95f569cf7f9386d269618672 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 14:37:15 +0100 Subject: remove outdated comment --- facetracknoir/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 7ecf6280..bc53a456 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -132,7 +132,6 @@ namespace options { modified(false) { } - /* keep in mind doesn't fire signals */ void reload() { QMutexLocker l(&mtx); saved = group(group_name); -- cgit v1.2.3 From 63e130f42c2ad329aba3da9e3121323914fac3fc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 06:25:30 +0100 Subject: fix win32 native build by reordering headers --- FTNoIR_Tracker_PT/camera.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 5f6db57c..754533c5 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -5,6 +5,11 @@ * copyright notice and this permission notice appear in all copies. */ + #if defined(OPENTRACK_API) && defined(_WIN32) +#include +#include +#endif + #include "camera.h" #include #include @@ -15,11 +20,6 @@ using namespace cv; #include #endif -#if defined(OPENTRACK_API) && defined(_WIN32) -#include -#include -#endif - #ifdef OPENTRACK_API void get_camera_device_names(std::vector& device_names) { # if defined(_WIN32) -- cgit v1.2.3 From a4eb9e8d6d727516e77bf370c2b0838850e52f81 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 06:25:53 +0100 Subject: fix header/lib mismatch on windows --- CMakeLists.txt | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6efa07d..0d2c0006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,20 @@ endif() # qt being broken as usual set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h") +function(link_with_dinput8 n) + if(WIN32) + if(MSVC) + target_link_libraries(${n} + "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) + else() + target_link_libraries(${n} dinput8 dxguid strmiids) + endif() + endif() +endfunction() + macro(opentrack_module n dir) file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" ${EXTRA-MOCS}) file(GLOB ${n}-ui "${dir}/*.ui") @@ -413,29 +427,17 @@ if(SDK_ARUCO_LIBPATH) endif() endif() -opentrack_library(opentrack-tracker-hatire) - -if(WIN32) - target_link_libraries(opentrack-tracker-ht - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - target_link_libraries(opentrack-tracker-joystick - "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) +if(SDK_HATIRE) + opentrack_library(opentrack-tracker-hatire) endif() +link_with_dinput8(opentrack-tracker-ht) +link_with_dinput8(opentrack-tracker-joystick) + opentrack_library(opentrack-tracker-pt) target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) -if(WIN32) - target_link_libraries(opentrack-tracker-pt - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) -endif() +link_with_dinput8(opentrack-tracker-pt) opentrack_library(opentrack-tracker-udp) @@ -547,14 +549,8 @@ if(UNIX OR APPLE) install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() -if(WIN32) - target_link_libraries(opentrack "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - winmm - uuid - ) -endif() +link_with_dinput8(opentrack) + if(MSVC) SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() -- cgit v1.2.3 From f998dc6ce88d8439e5e6ec9e506bd82255ef71f7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 07:17:45 +0100 Subject: add missing resolution forcing --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index a0a11ed2..651f7dbf 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -441,6 +441,7 @@ TrackerControls::TrackerControls() ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); tie_setting(s.camera_index, ui.cameraName); + tie_setting(s.resolution, ui.resolution); tie_setting(s.force_fps, ui.cameraFPS); tie_setting(s.fov, ui.cameraFOV); tie_setting(s.eyaw, ui.rx); -- cgit v1.2.3 From fba587185e077cf6ed4b37d213553f87e3b859cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:07:03 +0100 Subject: fix bad fps copy-paste-o --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 651f7dbf..ff7821fd 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -146,16 +146,16 @@ void Tracker::run() { default: case 0: - fps = 0; + fps = 30; break; - case 30: - fps = 1; + case 1: + fps = 60; break; - case 60: - fps = 2; + case 2: + fps = 120; break; - case 120: - fps = 3; + case 3: + fps = 0; break; } camera = cv::VideoCapture(s.camera_index); -- cgit v1.2.3 From 58a8a9eeaf85f017f38741a2b7c3c46a22431a88 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:10:45 +0100 Subject: add .rc files to build following cmake debloatification --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d2c0006..776473b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,7 @@ function(link_with_dinput8 n) endfunction() macro(opentrack_module n dir) - file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" ${EXTRA-MOCS}) + file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.rc" ${EXTRA-MOCS}) file(GLOB ${n}-ui "${dir}/*.ui") file(GLOB ${n}-rc "${dir}/*.qrc") QT5_WRAP_UI(${n}-uih ${${n}-ui}) -- cgit v1.2.3 From b2a79761e49b847e1ba30915045404e4a218fd86 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:12:28 +0100 Subject: delete msvc cruft --- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj | 212 ----------------------- 1 file changed, 212 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj deleted file mode 100644 index b777077b..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - FTNoIR_Tracker_PT - {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D} - FTNoIR_Tracker_PT - Qt4VSv1.0 - - - - DynamicLibrary - - - DynamicLibrary - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\bin\ - $(SolutionDir)\$(Configuration)\ - $(SolutionDir)/bin_dbg\ - $(SolutionDir)\$(Configuration)\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - MaxSpeed - .;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories) - UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions) - MultiThreadedDLL - false - - - - - qtmain.lib;QtCore4.lib;QtGui4.lib;QtOpenGL4.lib;opengl32.lib;glu32.lib;opencv_core242.lib;opencv_imgproc242.lib;opencv_calib3d242.lib;videoInput_vc10.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName).dll - $(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories) - atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries) - false - Windows - - - - - Disabled - .;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories) - UNICODE;WIN32;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - ProgramDatabase - - - qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtOpenGLd4.lib;opengl32.lib;glu32.lib;opencv_core242d.lib;opencv_imgproc242d.lib;opencv_calib3d242d.lib;videoInput_vc10.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName).dll - $(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories) - atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries) - true - Windows - - - - - - - - - - - - - - - - - - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - %(AdditionalInputs) - %(Outputs) - - - - - %(AdditionalInputs) - %(Outputs) - - - Moc%27ing ftnoir_tracker_pt_dialog.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - Moc%27ing ftnoir_tracker_pt_dialog.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - - - - - - - - - - Moc%27ing video_widget.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - Moc%27ing video_widget.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - - - - - - Uic%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" - - $(QTDIR)\bin\uic.exe;%(AdditionalInputs) - .\GeneratedFiles\ui_%(Filename).h;%(Outputs) - Uic%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" - - $(QTDIR)\bin\uic.exe;%(AdditionalInputs) - .\GeneratedFiles\ui_%(Filename).h;%(Outputs) - - - Rcc%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp - - %(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs) - .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) - Rcc%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp - - %(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs) - .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3 From dd41c425229716c82b4b4b4444e04f644c7a22f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:12:34 +0100 Subject: fix build --- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc | 61 ---------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc deleted file mode 100644 index 11c5d52f..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc +++ /dev/null @@ -1,61 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - -- cgit v1.2.3 From 1a95a291666f82d15fc1fe6e91803d3a71816883 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 16:35:45 +0100 Subject: align offsets with combobox entries --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ff7821fd..b4f35c6f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -146,16 +146,16 @@ void Tracker::run() { default: case 0: - fps = 30; + fps = 0; break; case 1: - fps = 60; + fps = 30; break; case 2: - fps = 120; + fps = 60; break; case 3: - fps = 0; + fps = 120; break; } camera = cv::VideoCapture(s.camera_index); -- cgit v1.2.3 From 12dd00394b62d26d892cbd320fcb5652df6635e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 10:35:14 +0100 Subject: Fix FSX manifest. Ouch! --- ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 1 + ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 8 +++++++- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 11 ++++++++--- ftnoir_protocol_sc/scserver-acceleration.manifest | 13 +++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 ftnoir_protocol_sc/scserver-acceleration.manifest diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc index 693aa12e..80b6c12c 100644 --- a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc +++ b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc @@ -1,3 +1,4 @@ #include 142 RT_MANIFEST scserver.manifest 143 RT_MANIFEST scserver-sp2.manifest +144 RT_MANIFEST scserver-acceleration.manifest \ No newline at end of file diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 9fb48527..2714e980 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -102,7 +102,12 @@ public: actx.cbSize = sizeof(ACTCTXA); actx.lpResourceName = MAKEINTRESOURCEA(resid); actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; - QString path = QCoreApplication::applicationDirPath() + "/opentrack-proto-simconnect.dll"; +#ifdef _MSC_VER +# define PREFIX "" +#else +# define PREFIX "lib" +#endif + QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; QByteArray name = QFile::encodeName(path); actx.lpSource = name.constData(); hactctx = CreateActCtxA(&actx); @@ -135,6 +140,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() { ActivationContext ctx(142 + static_cast(s.sxs_manifest)); + SCClientLib.setFileName("SimConnect.dll"); if (!SCClientLib.load()) { qDebug() << "SC load" << SCClientLib.errorString(); return false; diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 17e94c4b..430b3912 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -9,8 +9,8 @@ 0 0 - 258 - 61 + 290 + 79 @@ -38,7 +38,7 @@ - Acceleration + SP1 @@ -46,6 +46,11 @@ SP2 + + + Acceleration + + diff --git a/ftnoir_protocol_sc/scserver-acceleration.manifest b/ftnoir_protocol_sc/scserver-acceleration.manifest new file mode 100644 index 00000000..06459587 --- /dev/null +++ b/ftnoir_protocol_sc/scserver-acceleration.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.2.3 From 519434cd1abb8991635487c6d84bc0d85367fc42 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 10:57:02 +0100 Subject: How about an octopus instead? --- facetracknoir/facetracknoir.ico | Bin 23558 -> 67134 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/facetracknoir/facetracknoir.ico b/facetracknoir/facetracknoir.ico index 5115066c..5cac8da1 100644 Binary files a/facetracknoir/facetracknoir.ico and b/facetracknoir/facetracknoir.ico differ -- cgit v1.2.3