From 8303597a865400a363ae574ccde819302495f498 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 2 Apr 2013 18:41:01 +0200 Subject: Just put everything new in. Conflict resolution will be later --- ftnoir_filter_accela/default-points.cpp | 38 ++ .../ftnoir_accela_filtercontrols.ui | 451 +++++++++++++++++++++ ftnoir_filter_accela/ftnoir_filter_accela.cpp | 31 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 65 +-- .../ftnoir_filter_accela_dialog.cpp | 23 +- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 9 +- 6 files changed, 544 insertions(+), 73 deletions(-) create mode 100644 ftnoir_filter_accela/default-points.cpp create mode 100644 ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui (limited to 'ftnoir_filter_accela') diff --git a/ftnoir_filter_accela/default-points.cpp b/ftnoir_filter_accela/default-points.cpp new file mode 100644 index 00000000..2cebff6c --- /dev/null +++ b/ftnoir_filter_accela/default-points.cpp @@ -0,0 +1,38 @@ +#include +#include + +static QList EmptyList() { + return QList(); +} + +extern const QList defScaleRotation, defScaleTranslation; + +const QList defScaleRotation = + EmptyList() + << QPointF(0, 0) + << QPointF(0.308900523560209, 0.0666666666666667) + << QPointF(0.565445026178011, 0.226666666666667) + << QPointF(0.769633507853403, 0.506666666666667) + << QPointF(0.994764397905759, 1) + << QPointF(1.23560209424084, 1.61333333333333) + << QPointF(1.47643979057592, 2.37333333333333) + << QPointF(1.66492146596859, 3.12) + << QPointF(1.80628272251309, 3.92) + << QPointF(1.91623036649215, 4.70666666666667) + << QPointF(2.00523560209424, 5.44) + << QPointF(2.07329842931937, 6) +; + +const QList defScaleTranslation = + EmptyList() + << QPointF(0, 0) + << QPointF(0.282722513089005, 0.08) + << QPointF(0.492146596858639, 0.306666666666667) + << QPointF(0.764397905759162, 0.84) + << QPointF(1.00523560209424, 1.62666666666667) + << QPointF(1.17277486910995, 2.78666666666667) + << QPointF(1.25130890052356, 3.6) + << QPointF(1.31937172774869, 4.29333333333333) + << QPointF(1.38219895287958, 4.90666666666667) + << QPointF(1.43455497382199, 5.65333333333333) +; diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui new file mode 100644 index 00000000..9be0356b --- /dev/null +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -0,0 +1,451 @@ + + + AccelaUICFilterControls + + + Qt::ApplicationModal + + + + 0 + 0 + 880 + 673 + + + + Filter settings + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + + + + true + + + + 0 + 0 + + + + + 850 + 574 + + + + + 300 + 574 + + + + 0 + + + + Rotation + + + + + 20 + 20 + 819 + 510 + + + + 4 + + + 6 + + + 191 + + + 75 + + + 1 + + + 1 + + + + 255 + 170 + 0 + + + + + 192 + 192 + 192 + + + + Input + + + Output + + + Translation + + + + + + Translation + + + + + 20 + 20 + 819 + 510 + + + + 4 + + + 6 + + + 191 + + + 75 + + + 1 + + + 1 + + + + 85 + 255 + 0 + + + + + 192 + 192 + 192 + + + + Input + + + Output + + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Reduction factor: + + + + + + + + 50 + 15 + + + + 1 + + + 100 + + + 5 + + + 100 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 35 + 22 + + + + background:none; + + + false + + + 1 + + + 100 + + + 100 + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Zoom slowness: + + + + + + + + 50 + 15 + + + + 0 + + + 200 + + + 1 + + + 100 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 35 + 22 + + + + background:none; + + + false + + + 0 + + + 200 + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + QFunctionConfigurator + QWidget +
qfunctionconfigurator/qfunctionconfigurator.h
+
+
+ + + + slideReduction + valueChanged(int) + spinReduction + setValue(int) + + + 219 + 620 + + + 310 + 622 + + + + + spinReduction + valueChanged(int) + slideReduction + setValue(int) + + + 315 + 613 + + + 170 + 621 + + + + + slideZoom + valueChanged(int) + spinZoom + setValue(int) + + + 547 + 602 + + + 667 + 602 + + + + + spinZoom + valueChanged(int) + slideZoom + setValue(int) + + + 663 + 602 + + + 537 + 602 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 3e4c3bf6..cb9fb0f5 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -10,11 +10,15 @@ Additional changes: I have added two parameters to the constructor of FunctionConfig and renamed 3 member-functions (getFilterFullName is now called getFullName). */ -#include "ftnoir_filter_Accela.h" +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include "math.h" #include -#include #include +#include "facetracknoir/global-settings.h" + +#if !defined(_WIN32) && !defined(__WIN32) +# define _isnan isnan +#endif FTNoIR_Filter::FTNoIR_Filter() : functionConfig("Accela-Scaling-Rotation", 4, 6), @@ -32,8 +36,6 @@ FTNoIR_Filter::~FTNoIR_Filter() void FTNoIR_Filter::Initialize() { - loadSettings(); - return; } void FTNoIR_Filter::loadSettings() { @@ -45,24 +47,29 @@ void FTNoIR_Filter::loadSettings() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleRotation); i++) { // Get the default points (hardcoded!) + for (int i = 0; i < defScaleRotation.size(); i++) { // Get the default points (hardcoded!) defPoints.append(defScaleRotation[i]); } functionConfig.loadSettings(iniFile, defPoints); defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleTranslation); i++) { // Get the default points (hardcoded!) + for (int i = 0; i < defScaleTranslation.size(); i++) { // Get the default points (hardcoded!) defPoints.append(defScaleTranslation[i]); } translationFunctionConfig.loadSettings(iniFile, defPoints); iniFile.beginGroup ( "Accela" ); kMagicNumber = iniFile.value ( "Reduction", 100 ).toFloat(); + kZoomSlowness = iniFile.value("zoom-slowness", 0).toFloat(); iniFile.endGroup (); } -void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) +void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, + THeadPoseData *target_camera_position, + THeadPoseData *new_camera_position, + THeadPoseData *last_post_filter_values, + bool newTarget) { double target[6]; double prev_output[6]; @@ -130,10 +137,7 @@ void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, T // useful for filtering, as skipping them would result in jerky output. // the magic "100" is the amount of calls to the filter by FTNOIR per sec. // WVR: Added kMagicNumber for Patrick - double velocity = foo / 100.0; - if (kMagicNumber > 0.0f) { - double velocity = foo / kMagicNumber; - } + double velocity = foo / (kMagicNumber > 0 ? kMagicNumber : 100.0) * (1 / std::max(1.0, 1 + kZoomSlowness * -last_post_filter_values->z / 100)); double sum = start + velocity * sign; bool done = (sign > 0 ? sum >= e2 : sum <= e2); if (done) { @@ -168,9 +172,8 @@ void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, T // GetFilter - Undecorated name, which can be easily used with GetProcAddress // Win32 API function. // _GetFilter@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilter=_GetFilter@0") -FTNOIR_FILTER_BASE_EXPORT IFilterPtr __stdcall GetFilter() +extern "C" FTNOIR_FILTER_BASE_EXPORT void* CALLING_CONVENTION GetConstructor() { - return new FTNoIR_Filter; + return (IFilter*) new FTNoIR_Filter; } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 77aa59ea..32cebf99 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -26,39 +26,16 @@ #ifndef INCLUDED_FTN_FILTER_H #define INCLUDED_FTN_FILTER_H -#include "..\ftnoir_filter_base\ftnoir_filter_base.h" -#include "ui_FTNoIR_FilterControls.h" -#include +#undef FTNOIR_TRACKER_BASE_LIB +#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -const QPointF defScaleRotation[] = -{ - QPointF(0, 0), - QPointF(0.308900523560209, 0.0666666666666667), - QPointF(0.565445026178011, 0.226666666666667), - QPointF(0.769633507853403, 0.506666666666667), - QPointF(0.994764397905759, 1), - QPointF(1.23560209424084, 1.61333333333333), - QPointF(1.47643979057592, 2.37333333333333), - QPointF(1.66492146596859, 3.12), - QPointF(1.80628272251309, 3.92), - QPointF(1.91623036649215, 4.70666666666667), - QPointF(2.00523560209424, 5.44), - QPointF(2.07329842931937, 6) -}; +#include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "ui_ftnoir_accela_filtercontrols.h" +#include +#include "facetracknoir/global-settings.h" -const QPointF defScaleTranslation[] = -{ - QPointF(0, 0), - QPointF(0.282722513089005, 0.08), - QPointF(0.492146596858639, 0.306666666666667), - QPointF(0.764397905759162, 0.84), - QPointF(1.00523560209424, 1.62666666666667), - QPointF(1.17277486910995, 2.78666666666667), - QPointF(1.25130890052356, 3.6), - QPointF(1.31937172774869, 4.29333333333333), - QPointF(1.38219895287958, 4.90666666666667), - QPointF(1.43455497382199, 5.65333333333333) -}; +extern const QList defScaleRotation; +extern const QList defScaleTranslation; // // Macro to determine array-size @@ -68,16 +45,14 @@ const QPointF defScaleTranslation[] = //******************************************************************************************************* // FaceTrackNoIR Filter class. //******************************************************************************************************* -class FTNoIR_Filter : public IFilter +class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); ~FTNoIR_Filter(); - void Release(); void Initialize(); - void StartFilter(); - void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); + void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, THeadPoseData *last_post_filter_values, bool newTarget); private: void loadSettings(); // Load the settings from the INI-file @@ -86,7 +61,7 @@ private: bool first_run; double kFactor, kFactorTranslation; double kSensitivity, kSensitivityTranslation; - double kMagicNumber; // Stanislaws' magic number (should be 100 according to him...) + double kMagicNumber, kZoomSlowness; // Stanislaws' magic number (should be 100 according to him...) FunctionConfig functionConfig; FunctionConfig translationFunctionConfig; @@ -97,7 +72,7 @@ private: //******************************************************************************************************* // Widget that has controls for FTNoIR protocol filter-settings. -class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog +class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, Ui::AccelaUICFilterControls, public IFilterDialog { Q_OBJECT public: @@ -107,17 +82,17 @@ public: void showEvent ( QShowEvent * event ); void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent, IFilterPtr ptr); + void Initialize(QWidget *parent, IFilter *ptr); private: - Ui::UICFilterControls ui; + Ui::AccelaUICFilterControls ui; void loadSettings(); void save(); /** helper **/ bool settingsDirty; - IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance + IFilter* pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance FunctionConfig functionConfig; FunctionConfig translationFunctionConfig; @@ -131,17 +106,17 @@ private slots: //******************************************************************************************************* // FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter //******************************************************************************************************* -class FTNoIR_FilterDll : public IFilterDll +class FTNoIR_FilterDll : public Metadata { public: FTNoIR_FilterDll(); ~FTNoIR_FilterDll(); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk2"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk2"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk2"); }; + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk2"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk2"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk2"); } - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } }; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index c230eed8..9970e962 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -26,9 +26,10 @@ Modifications (last one on top): 20130102 - WVR: Added 'reduction factor' to accommodate Patrick's need for speed. */ -#include "ftnoir_filter_Accela.h" +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include "math.h" #include +#include "facetracknoir/global-settings.h" //******************************************************************************************************* // FaceTrackNoIR Filter Settings-dialog. @@ -51,7 +52,7 @@ FilterControls::FilterControls() : connect(ui.translationScalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); // Connect slider for reduction - connect(ui.slideReduction, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + //connect(ui.slideReduction, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); qDebug() << "FilterControls() says: started"; } @@ -71,7 +72,7 @@ void FilterControls::Release() // // Initialize tracker-client-dialog // -void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { +void FilterControls::Initialize(QWidget *parent, IFilter* ptr) { // // The dialog can be opened, while the Tracker is running. @@ -79,6 +80,7 @@ void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... // pFilter = ptr; + loadSettings(); QPoint offsetpos(100, 100); if (parent) { @@ -100,7 +102,6 @@ void FilterControls::doOK() { // override show event void FilterControls::showEvent ( QShowEvent * event ) { - loadSettings(); } // @@ -150,16 +151,16 @@ QList defPoints; qDebug() << "FTNoIR_Filter::loadSettings2 says: iniFile = " << currentFile; - qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); + //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleRotation); i++) { // Get the default points (hardcoded!) + for (int i = 0; i < defScaleRotation.size(); i++) { // Get the default points (hardcoded!) defPoints.append(defScaleRotation[i]); } functionConfig.loadSettings(iniFile, defPoints); defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleTranslation); i++) { // Get the default points (hardcoded!) + for (int i = 0; i < defScaleTranslation.size(); i++) { // Get the default points (hardcoded!) defPoints.append(defScaleTranslation[i]); } translationFunctionConfig.loadSettings(iniFile, defPoints); @@ -169,6 +170,7 @@ QList defPoints; iniFile.beginGroup ( "Accela" ); ui.slideReduction->setValue (iniFile.value ( "Reduction", 100 ).toInt()); + ui.slideZoom->setValue(iniFile.value("zoom-slowness", 0).toInt()); iniFile.endGroup (); settingsDirty = false; @@ -187,6 +189,7 @@ void FilterControls::save() { iniFile.beginGroup ( "Accela" ); iniFile.setValue ( "Reduction", ui.slideReduction->value() ); + iniFile.setValue("zoom-slowness", ui.slideZoom->value()); iniFile.endGroup (); functionConfig.saveSettings(iniFile); @@ -202,9 +205,9 @@ void FilterControls::save() { // 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") +//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") -FTNOIR_FILTER_BASE_EXPORT IFilterDialogPtr __stdcall GetFilterDialog( ) +extern "C" FTNOIR_FILTER_BASE_EXPORT void* CALLING_CONVENTION GetDialog() { - return new FilterControls; + return (IFilterDialog*) new FilterControls; } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp index e1452bf2..3ae273df 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -30,8 +30,9 @@ The FilterDll class solves this. The functions to get the name(s) and icon were removed from the two other classes. */ -#include "ftnoir_filter_Accela.h" +#include "ftnoir_filter_accela.h" #include +#include "facetracknoir/global-settings.h" FTNoIR_FilterDll::FTNoIR_FilterDll() { } @@ -48,9 +49,9 @@ FTNoIR_FilterDll::~FTNoIR_FilterDll() // 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") +//#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") -FTNOIR_FILTER_BASE_EXPORT IFilterDllPtr __stdcall GetFilterDll() +extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { - return new FTNoIR_FilterDll; + return new FTNoIR_FilterDll; } -- cgit v1.2.3