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