From 44828b42ec40330e2e98033202d76ea29dd219e6 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Fri, 24 Sep 2010 17:09:20 +0000 Subject: Curves added (1st try) git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@18 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 2 +- FaceTrackNoIR/FaceTrackNoIR.cpp | 226 ++++++++++++++++++++- FaceTrackNoIR/FaceTrackNoIR.h | 27 +++ FaceTrackNoIR/FaceTrackNoIR.ui | 7 + FaceTrackNoIR/FaceTrackNoIR.vcproj | 34 +++- FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp | 2 +- .../GeneratedFiles/ui_FTNoIR_ppjoycontrols.h | 2 +- FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h | 8 +- FaceTrackNoIR/Release/BuildLog.htm | Bin 14636 -> 10028 bytes FaceTrackNoIR/Release/mt.dep | 2 +- 10 files changed, 301 insertions(+), 9 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui index 435f22ee..321a1af5 100644 --- a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui +++ b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui @@ -11,7 +11,7 @@ - PPJoy settings FaceTrackNoIR + FaceTrackNoIR keyboard shortcuts diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 30ad25ef..cac13715 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -36,10 +36,17 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { cameraDetected = false; + + // + // Initialize Widget handles, to prevent memory-access errors. + // _engine_controls = 0; _server_controls = 0; _keyboard_shortcuts = 0; _preferences = 0; + _keyboard_shortcuts = 0; + _curve_config = 0; + tracker = 0; _display = 0; l = 0; @@ -64,6 +71,7 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); connect(ui.actionKeyboard_Shortcuts, SIGNAL(triggered()), this, SLOT(showKeyboardShortcuts())); + connect(ui.actionCurve_Configuration, SIGNAL(triggered()), this, SLOT(showCurveConfiguration())); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); @@ -707,7 +715,7 @@ void FaceTrackNoIR::showPreferences() { } } -/** toggles Server Controls Dialog **/ +/** toggles Keyboard Shortcut Dialog **/ void FaceTrackNoIR::showKeyboardShortcuts() { // Create if new @@ -723,6 +731,22 @@ void FaceTrackNoIR::showKeyboardShortcuts() { } } +/** toggles Curve Configuration Dialog **/ +void FaceTrackNoIR::showCurveConfiguration() { + + // Create if new + if (!_curve_config) + { + _curve_config = new CurveConfigurationDialog( this, Qt::Dialog ); + } + + // Show if already created + if (_curve_config) { + _curve_config->show(); + _curve_config->raise(); + } +} + /** exit application **/ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); @@ -954,8 +978,10 @@ void PreferencesDialog::save() { settingsDirty = false; } +//**************************************************************************************************// +//**************************************************************************************************// // -// Constructor for server-settings-dialog +// Constructor for Keyboard-shortcuts-dialog // KeyboardShortcutDialog::KeyboardShortcutDialog( QWidget *parent, Qt::WindowFlags f ) : QWidget( parent , f) @@ -1248,3 +1274,199 @@ void KeyboardShortcutDialog::save() { settingsDirty = false; } + +//**************************************************************************************************// +//**************************************************************************************************// +// +// Constructor for Curve-configuration-dialog +// +CurveConfigurationDialog::CurveConfigurationDialog( QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + connect(ui.curveRoll, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +CurveConfigurationDialog::~CurveConfigurationDialog() { + qDebug() << "~CurveConfigurationDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void CurveConfigurationDialog::doOK() { + save(); + this->close(); +} + +// override show event +void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void CurveConfigurationDialog::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 CurveConfigurationDialog::loadSettings() { +int NeutralZone; +int sensRoll; +QPointF point; + + qDebug() << "loadSettings says: Starting "; + 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) + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Tracking" ); + NeutralZone = iniFile.value ( "NeutralZone", 5 ).toInt(); + sensRoll = iniFile.value ( "sensRoll", 100 ).toInt(); + iniFile.endGroup (); + + iniFile.beginGroup ( "Curves" ); + + // + // If Point 1 exists, read it from the file. + // If not: get the y-coord from the global (deprecated) NeutralZone setting. + // Any case: set the x-coord to '0', to keep it on the Y-axis + // + if (iniFile.contains("Roll_point1")) { + point = iniFile.value ( "Roll_point1", 0 ).toPoint(); + } + else { + point.setY(NeutralZone); + } + point.setX(0); + ui.curveRoll->setPointOne( point ); + + // + // If Point 4 exists, read it from the file. + // If not: derive the x-coord from the (deprecated) 'Sensitivity' setting and set y to max. + // + if (iniFile.contains("Roll_point4")) { + point = iniFile.value ( "Roll_point4", 0 ).toPoint(); + } + else { + point.setY(50); // Max. Input for rotations + if (sensRoll < 360) { + point.setX((sensRoll/100.0f) * 50); + } + else { + point.setX(180); + } + } + ui.curveRoll->setPointFour( point ); + + // + // If Point 2 exists, read it from the file. + // If not: derive it from the (deprecated) 'Sensitivity' setting. + // + if (iniFile.contains("Roll_point2")) { + point = iniFile.value ( "Roll_point2", 0 ).toPoint(); + } + else { + point.setY(0.333f * 50); // Set the Point at 1/3 of Max. Input + if (sensRoll < 360) { + point.setX(0.333f * (sensRoll/100.0f) * 50); + + } + else { + point.setX(60); + } + } + ui.curveRoll->setPointTwo( point ); + + // + // If Point 3 exists, read it from the file. + // If not: derive it from the (deprecated) 'Sensitivity' setting. + // + if (iniFile.contains("Roll_point3")) { + point = iniFile.value ( "Roll_point3", 0 ).toPoint(); + } + else { + point.setY(0.666f * 50); // Set the Point at 2/3 of Max. Input + if (sensRoll < 360) { + point.setX(0.666f * (sensRoll/100.0f) * 50); + + } + else { + point.setX(120); + } + } + ui.curveRoll->setPointThree( point ); + iniFile.endGroup (); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void CurveConfigurationDialog::save() { + + qDebug() << "save() says: started"; + + 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 ( "Curves" ); + iniFile.setValue ("Roll_point1", ui.curveRoll->getPointOne() ); + iniFile.setValue ("Roll_point2", ui.curveRoll->getPointTwo() ); + iniFile.setValue ("Roll_point3", ui.curveRoll->getPointThree() ); + iniFile.setValue ("Roll_point4", ui.curveRoll->getPointFour() ); + iniFile.endGroup (); + + settingsDirty = false; +} diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 93160c48..e1bdc5cb 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -37,6 +37,7 @@ #include "ui_FaceTrackNoIR.h" #include "ui_FTNoIR_KeyboardShortcuts.h" #include "ui_FTNoIR_Preferences.h" +#include "ui_FTNoIR_Curves.h" #include #include @@ -67,6 +68,7 @@ private: QWidget *_server_controls; QWidget *_preferences; QWidget *_keyboard_shortcuts; + QWidget *_curve_config; /** QT objects **/ QDialog aboutDialog; @@ -109,6 +111,7 @@ private: void showServerControls(); void showPreferences(); void showKeyboardShortcuts(); + void showCurveConfiguration(); // sensibility sliders void setSensYaw( int sens ); @@ -196,5 +199,29 @@ private slots: void keyChanged( int index ) { settingsDirty = true; }; }; +// Widget that has controls for Keyboard shortcuts. +class CurveConfigurationDialog: public QWidget, public Ui::UICCurveConfigurationDialog +{ + Q_OBJECT +public: + + explicit CurveConfigurationDialog( QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~CurveConfigurationDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICCurveConfigurationDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void curveChanged( bool change ) { settingsDirty = true; }; +}; + #endif // FaceTrackNoIR_H diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 16c91108..b0889c31 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -2205,6 +2205,8 @@ background:none; + + @@ -2355,6 +2357,11 @@ background:none; Preferences + + + Curve Configuration + + diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj index b35e07b9..cb75ed3b 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj @@ -68,7 +68,7 @@ /> + + + + + + + + @@ -592,6 +618,10 @@ RelativePath=".\GeneratedFiles\ui_FaceTrackNoIR.h" > + + diff --git a/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp b/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp index 363370e6..cb1a03ee 100644 --- a/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Resource object code ** -** Created: Fri 3. Sep 13:27:15 2010 +** Created: Fri 24. Sep 11:22:09 2010 ** by: The Resource Compiler for Qt version 4.6.2 ** ** WARNING! All changes made in this file will be lost! diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h b/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h index bb1e60c8..198683a3 100644 --- a/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h +++ b/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'FTNoIR_ppjoycontrols.ui' ** -** Created: Fri 3. Sep 13:27:15 2010 +** Created: Fri 24. Sep 11:22:05 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h index 32f64a21..1c9582fd 100644 --- a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h +++ b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'FaceTrackNoIR.ui' ** -** Created: Fri 3. Sep 13:27:15 2010 +** Created: Fri 24. Sep 11:22:07 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! @@ -54,6 +54,7 @@ public: QAction *actionSave_As; QAction *actionKeyboard_Shortcuts; QAction *actionPreferences; + QAction *actionCurve_Configuration; QWidget *centralWidget; QVBoxLayout *verticalLayout_2; QWidget *widgetTop; @@ -286,6 +287,8 @@ public: actionKeyboard_Shortcuts->setObjectName(QString::fromUtf8("actionKeyboard_Shortcuts")); actionPreferences = new QAction(FaceTrackNoIRClass); actionPreferences->setObjectName(QString::fromUtf8("actionPreferences")); + actionCurve_Configuration = new QAction(FaceTrackNoIRClass); + actionCurve_Configuration->setObjectName(QString::fromUtf8("actionCurve_Configuration")); centralWidget = new QWidget(FaceTrackNoIRClass); centralWidget->setObjectName(QString::fromUtf8("centralWidget")); centralWidget->setMinimumSize(QSize(800, 500)); @@ -1143,6 +1146,8 @@ public: menuView->addAction(actionHeadPoseWidget); menuOptions->addAction(actionPreferences); menuOptions->addAction(actionKeyboard_Shortcuts); + menuOptions->addSeparator(); + menuOptions->addAction(actionCurve_Configuration); retranslateUi(FaceTrackNoIRClass); QObject::connect(sensYaw, SIGNAL(valueChanged(int)), spinSensYaw, SLOT(setValue(int))); @@ -1212,6 +1217,7 @@ public: actionSave_As->setText(QApplication::translate("FaceTrackNoIRClass", "Save As", 0, QApplication::UnicodeUTF8)); actionKeyboard_Shortcuts->setText(QApplication::translate("FaceTrackNoIRClass", "Keyboard Shortcuts", 0, QApplication::UnicodeUTF8)); actionPreferences->setText(QApplication::translate("FaceTrackNoIRClass", "Preferences", 0, QApplication::UnicodeUTF8)); + actionCurve_Configuration->setText(QApplication::translate("FaceTrackNoIRClass", "Curve Configuration", 0, QApplication::UnicodeUTF8)); headRotYLine->setText(QApplication::translate("FaceTrackNoIRClass", "N/A", 0, QApplication::UnicodeUTF8)); headRotXLine->setText(QApplication::translate("FaceTrackNoIRClass", "N/A", 0, QApplication::UnicodeUTF8)); headRotZLine->setText(QApplication::translate("FaceTrackNoIRClass", "N/A", 0, QApplication::UnicodeUTF8)); diff --git a/FaceTrackNoIR/Release/BuildLog.htm b/FaceTrackNoIR/Release/BuildLog.htm index 995147bd..27fcb281 100644 Binary files a/FaceTrackNoIR/Release/BuildLog.htm and b/FaceTrackNoIR/Release/BuildLog.htm differ diff --git a/FaceTrackNoIR/Release/mt.dep b/FaceTrackNoIR/Release/mt.dep index d9624085..f8da41f8 100644 --- a/FaceTrackNoIR/Release/mt.dep +++ b/FaceTrackNoIR/Release/mt.dep @@ -1 +1 @@ -Manifest resource last updated at 13:08:32.52 on vr 10-09-2010 +Manifest resource last updated at 19:03:49.66 on vr 24-09-2010 -- cgit v1.2.3