diff options
Diffstat (limited to 'facetracknoir/curve-config.cpp')
-rw-r--r-- | facetracknoir/curve-config.cpp | 187 |
1 files changed, 82 insertions, 105 deletions
diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 2bff009a..57cea7a4 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,117 +1,94 @@ -#include "facetracknoir/facetracknoir.h" -#include "facetracknoir/curve-config.h" -#include <QDebug> -#include <QCheckBox> -CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : - QWidget( parent, Qt::Dialog ), mainApp(ftnoir) +#include "./facetracknoir.h" +#include "./curve-config.h" +#include "./main-settings.hpp" +MapWidget::MapWidget(Mappings& m, main_settings& s, QWidget *parent) : + QWidget(parent, Qt::Dialog), + m(m) { - ui.setupUi( this ); - setFont(qApp->font()); + ui.setupUi( this ); + + // rest of mapping settings taken care of by options::value<t> + m.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; + Mapping& axis = m(qfcs[i].axis); + Map* 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); + this->move(parent->pos() + offsetpos); - // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - 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); - - tie_setting(mainApp->s.a_yaw.invert, ui.chkInvertYaw); - tie_setting(mainApp->s.a_pitch.invert, ui.chkInvertPitch); - tie_setting(mainApp->s.a_roll.invert, ui.chkInvertRoll); - tie_setting(mainApp->s.a_x.invert, ui.chkInvertX); - tie_setting(mainApp->s.a_y.invert, ui.chkInvertY); - tie_setting(mainApp->s.a_z.invert, ui.chkInvertZ); - - // Load the settings from the current .INI-file - loadSettings(); -} - -void CurveConfigurationDialog::doOK() { - save(); - this->close(); + tie_setting(s.a_x.altp, ui.tx_altp); + tie_setting(s.a_y.altp, ui.ty_altp); + tie_setting(s.a_z.altp, ui.tz_altp); + tie_setting(s.a_yaw.altp, ui.rx_altp); + tie_setting(s.a_pitch.altp, ui.ry_altp); + tie_setting(s.a_roll.altp, ui.rz_altp); + + tie_setting(s.tcomp_p, ui.tcomp_enable); + tie_setting(s.tcomp_tz, ui.tcomp_rz); + + tie_setting(s.a_x.zero, ui.pos_tx); + tie_setting(s.a_y.zero, ui.pos_ty); + tie_setting(s.a_z.zero, ui.pos_tz); + tie_setting(s.a_yaw.zero, ui.pos_rx); + tie_setting(s.a_pitch.zero, ui.pos_ry); + tie_setting(s.a_roll.zero, ui.pos_rz); + + tie_setting(s.a_yaw.invert, ui.invert_yaw); + tie_setting(s.a_pitch.invert, ui.invert_pitch); + tie_setting(s.a_roll.invert, ui.invert_roll); + tie_setting(s.a_x.invert, ui.invert_x); + tie_setting(s.a_y.invert, ui.invert_y); + tie_setting(s.a_z.invert, ui.invert_z); + + tie_setting(s.a_yaw.src, ui.src_yaw); + tie_setting(s.a_pitch.src, ui.src_pitch); + tie_setting(s.a_roll.src, ui.src_roll); + tie_setting(s.a_x.src, ui.src_x); + tie_setting(s.a_y.src, ui.src_y); + tie_setting(s.a_z.src, ui.src_z); } -void CurveConfigurationDialog::doCancel() { - mainApp->b->revert(); - loadSettings(); - close(); +void MapWidget::doOK() { + m.save_mappings(); + this->close(); } -// -// Load the current Settings from the currently 'active' INI-file. -// -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 - }; - - QSettings settings("opentrack"); - QString currentFile = settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ) - .toString(); - - for (int i = 0; i < 6; i++) - { - configs[i]->setConfig(&mainApp->axis(i).curve); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt); - } -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void CurveConfigurationDialog::save() { - - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ) - .toString(); - - ui.rxconfig->saveSettings(currentFile); - ui.ryconfig->saveSettings(currentFile); - ui.rzconfig->saveSettings(currentFile); - ui.txconfig->saveSettings(currentFile); - ui.tyconfig->saveSettings(currentFile); - ui.tzconfig->saveSettings(currentFile); - - ui.txconfig_alt->saveSettings(currentFile); - ui.tyconfig_alt->saveSettings(currentFile); - ui.tzconfig_alt->saveSettings(currentFile); - ui.rxconfig_alt->saveSettings(currentFile); - ui.ryconfig_alt->saveSettings(currentFile); - ui.rzconfig_alt->saveSettings(currentFile); +void MapWidget::doCancel() { + m.invalidate_unsaved(); + this->close(); } |