diff options
-rw-r--r-- | facetracknoir/curve-config.cpp | 109 | ||||
-rw-r--r-- | facetracknoir/curve-config.h | 2 | ||||
-rw-r--r-- | facetracknoir/facetracknoir.cpp | 57 | ||||
-rw-r--r-- | facetracknoir/facetracknoir.h | 4 | ||||
-rw-r--r-- | qfunctionconfigurator/qfunctionconfigurator.cpp | 7 | ||||
-rw-r--r-- | qfunctionconfigurator/qfunctionconfigurator.h | 2 |
6 files changed, 79 insertions, 102 deletions
diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 535655c2..81383688 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -4,10 +4,50 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { ui.setupUi( this ); + + // rest of mapping settings taken care of by options::value<t> + mainApp->load_mappings(); + + { + struct { + QFunctionConfigurator* qfc; + Axis axis; + bool altp; + } qfcs[] = + { + { ui.rxconfig, Yaw, false }, + { ui.ryconfig, Pitch, false}, + { ui.rzconfig, Roll, false }, + { ui.txconfig, TX, false }, + { ui.tyconfig, TY, false }, + { ui.tzconfig, TZ, false }, + + { ui.rxconfig_alt, Yaw, true }, + { ui.ryconfig_alt, Pitch, true}, + { ui.rzconfig_alt, Roll, true }, + { ui.txconfig_alt, TX, true }, + { ui.tyconfig_alt, TY, true }, + { ui.tzconfig_alt, TZ, true }, + { nullptr, Yaw, false } + }; + + for (int i = 0; qfcs[i].qfc; i++) + { + const bool altp = qfcs[i].altp; + THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); + FunctionConfig* conf = altp ? &axis.curveAlt : &axis.curve; + const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; + + qfcs[i].qfc->setConfig(conf, name); + } + } + setFont(qApp->font()); - QPoint offsetpos(120, 30); this->move(parent->pos() + offsetpos); + + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -42,8 +82,6 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge tie_setting(mainApp->s.a_x.src, ui.src_x); tie_setting(mainApp->s.a_y.src, ui.src_y); tie_setting(mainApp->s.a_z.src, ui.src_z); - - loadSettings(); } void CurveConfigurationDialog::doOK() { @@ -52,69 +90,10 @@ void CurveConfigurationDialog::doOK() { } void CurveConfigurationDialog::doCancel() { - mainApp->b->revert(); - loadSettings(); - close(); -} - -void CurveConfigurationDialog::loadSettings() { - QFunctionConfigurator* configs[6] = { - ui.txconfig, - ui.tyconfig, - ui.tzconfig, - ui.rxconfig, - ui.ryconfig, - ui.rzconfig - }; - - QFunctionConfigurator* alt_configs[6] = { - ui.txconfig_alt, - ui.tyconfig_alt, - ui.tzconfig_alt, - ui.rxconfig_alt, - ui.ryconfig_alt, - ui.rzconfig_alt - }; - - for (int i = 0; i < 6; i++) - { - configs[i]->setConfig(&mainApp->axis(i).curve, mainApp->axis(i).name1); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, mainApp->axis(i).name2); - } + mainApp->load_mappings(); + this->close(); } void CurveConfigurationDialog::save() { - QSettings settings("opentrack"); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ) - .toString(); - - struct { - QFunctionConfigurator* qfc; - Axis axis; - bool altp; - } qfcs[] = - { - { ui.rxconfig, Yaw, false }, - { ui.ryconfig, Pitch, false}, - { ui.rzconfig, Roll, false }, - { ui.txconfig, TX, false }, - { ui.tyconfig, TY, false }, - { ui.tzconfig, TZ, false }, - - { ui.rxconfig_alt, Yaw, true }, - { ui.ryconfig_alt, Pitch, true}, - { ui.rzconfig_alt, Roll, true }, - { ui.txconfig_alt, TX, true }, - { ui.tyconfig_alt, TY, true }, - { ui.tzconfig_alt, TZ, true }, - { nullptr, Yaw, false } - }; - - for (int i = 0; qfcs[i].qfc; i++) - { - THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); - qfcs[i].qfc->saveSettings(currentFile, qfcs[i].altp ? axis.name2 : axis.name1); - } + mainApp->save_mappings(); } diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 0949cdc4..49aba7bd 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -10,12 +10,10 @@ class CurveConfigurationDialog: public QWidget Q_OBJECT public: CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); - void loadSettings(); private: Ui::UICCurveConfigurationDialog ui; void save(); FaceTrackNoIR *mainApp; - private slots: void doOK(); void doCancel(); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index da8fae61..dfa13577 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -259,16 +259,26 @@ void FaceTrackNoIR::open() { } } -void FaceTrackNoIR::save() { - b->save(); - +void FaceTrackNoIR::save_mappings() { 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.saveSettings(iniFile, axis(i).name1); + axis(i).curveAlt.saveSettings(iniFile, axis(i).name2); + } +} +void FaceTrackNoIR::save() { + b->save(); + save_mappings(); + #if defined(__unix) || defined(__linux) QByteArray bytes = QFile::encodeName(currentFile); const char* filename_as_asciiz = bytes.constData(); @@ -311,9 +321,21 @@ void FaceTrackNoIR::saveAs() fill_profile_cbx(); } +void FaceTrackNoIR::load_mappings() { + 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).name1); + axis(i).curveAlt.loadSettings(iniFile, axis(i).name2); + } +} + void FaceTrackNoIR::loadSettings() { b->reload(); - (dynamic_cast<CurveConfigurationDialog*>(_curve_config))->loadSettings(); + load_mappings(); } void FaceTrackNoIR::updateButtonState(bool running) @@ -359,18 +381,6 @@ 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).name1); - axis(i).curveAlt.loadSettings(iniFile, axis(i).name2); - } - } - tracker = new Tracker ( this, s ); if (pTrackerDialog && Libraries->pTracker) { @@ -559,17 +569,12 @@ void FaceTrackNoIR::showKeyboardShortcuts() { _keyboard_shortcuts->show(); _keyboard_shortcuts->raise(); } -void FaceTrackNoIR::showCurveConfiguration() { - - if (!_curve_config) - { +void FaceTrackNoIR::showCurveConfiguration() { + if (!_curve_config) _curve_config = new CurveConfigurationDialog( this, this ); - } - - if (_curve_config) { - _curve_config->show(); - _curve_config->raise(); - } + + _curve_config->show(); + _curve_config->raise(); } void FaceTrackNoIR::exit() { diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index dc37ad37..f6f4afdf 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -152,4 +152,8 @@ private slots: void startTracker(); void stopTracker(); + +public: + void save_mappings(); + void load_mappings(); }; diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 3f94f094..70f68285 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -49,13 +49,6 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, const QString& nam update(); } -void QFunctionConfigurator::saveSettings(QString settingsFile, const QString& name) { - QSettings iniFile(settingsFile, QSettings::IniFormat); - - if (_config) - _config->saveSettings(iniFile, name); -} - void QFunctionConfigurator::drawBackground() { if (!_config) diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 4643f0d5..bb2f09ce 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -23,8 +23,6 @@ public: FunctionConfig* config(); void setConfig(FunctionConfig* config, const QString &name); - void saveSettings(QString settingsFile, const QString &name); - QColor colorBezier() const { return spline_color; |