diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-21 17:41:35 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-23 00:05:15 +0200 |
commit | e82b071bf96b9b514c575c87d261d28d7321c80f (patch) | |
tree | 59d5b5af9d81376ffae3217c93981ef4223ef656 /filter-accela | |
parent | 9b3fc73ba6d6c3b25e33b400ce0baa7226d2e32e (diff) |
filter/accela: move control points .cpp from static to settings constexpr
Now the debug spline can display in dialog without connecting to running
filter instance.
Diffstat (limited to 'filter-accela')
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 58 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.h | 27 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela_dialog.cpp | 28 |
3 files changed, 61 insertions, 52 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 526b2da6..a5127cb3 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -11,47 +11,18 @@ #include <QMutexLocker> #include "api/plugin-api.hpp" -static constexpr double rot_gains[][2] = { - { 6, 200 }, - { 2.66, 50 }, - { 1.66, 17 }, - { 1, 4 }, - { .5, .53 }, - { 0, 0 }, - { -1, 0 } -}; - -static constexpr double trans_gains[][2] = { - { 2.33, 40 }, - { 1.66, 13 }, - { 1.33, 5 }, - { .66, 1 }, - { .33, .5 }, - { 0, 0 }, - { -1, 0 } -}; - constexpr double settings_accela::mult_rot; constexpr double settings_accela::mult_trans; constexpr double settings_accela::mult_rot_dz; constexpr double settings_accela::mult_trans_dz; constexpr double settings_accela::mult_ewma; +constexpr double settings_accela::rot_gains[][2]; +constexpr double settings_accela::trans_gains[][2]; + FTNoIR_Filter::FTNoIR_Filter() : first_run(true) { - rot.setMaxInput(rot_gains[0][0]); - trans.setMaxInput(trans_gains[0][0]); - rot.setMaxOutput(rot_gains[0][1]); - trans.setMaxOutput(trans_gains[0][1]); - - for (int i = 0; rot_gains[i][0] >= 0; i++) - { - rot.addPoint(QPointF(rot_gains[i][0], rot_gains[i][1])); - } - for (int i = 0; trans_gains[i][0] >= 0; i++) - { - trans.addPoint(QPointF(trans_gains[i][0], trans_gains[i][1])); - } + s.make_splines(rot, trans); } void FTNoIR_Filter::filter(const double* input, double *output) @@ -98,10 +69,29 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double out = i >= 3 && std::fabs(rot_nl - 1) > 5e-3 && vec_ < s.max_rot_nl ? (std::pow(out_/s.max_rot_nl, rot_nl) * s.max_rot_nl) : out_; - const double val = m.getValue(float(out)); + const double val = double(m.getValue(out)); last_output[i] = output[i] = last_output[i] + signum(vec) * dt * val; } } + + +void settings_accela::make_splines(spline& rot, spline& trans) +{ + rot = spline(); + trans = spline(); + + rot.setMaxInput(rot_gains[0][0]); + trans.setMaxInput(trans_gains[0][0]); + rot.setMaxOutput(rot_gains[0][1]); + trans.setMaxOutput(trans_gains[0][1]); + + for (int i = 0; rot_gains[i][0] >= 0; i++) + rot.addPoint(QPointF(rot_gains[i][0], rot_gains[i][1])); + + for (int i = 0; trans_gains[i][0] >= 0; i++) + trans.addPoint(QPointF(trans_gains[i][0], trans_gains[i][1])); +} + OPENTRACK_DECLARE_FILTER(FTNoIR_Filter, FilterControls, FTNoIR_FilterDll) diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index d3156429..fb2d78b2 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -18,6 +18,28 @@ using namespace options; struct settings_accela : opts { + static constexpr double rot_gains[][2] = { + { 6, 200 }, + { 2.66, 50 }, + { 1.66, 17 }, + { 1, 4 }, + { .5, .53 }, + { 0, 0 }, + { -1, 0 } + }; + + static constexpr double trans_gains[][2] = { + { 2.33, 40 }, + { 1.66, 13 }, + { 1.33, 5 }, + { .66, 1 }, + { .33, .5 }, + { 0, 0 }, + { -1, 0 } + }; + + static void make_splines(spline& rot, spline& trans); + value<int> rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone; value<slider_value> rot_nonlinearity; static constexpr double mult_rot = 4. / 100.; @@ -75,12 +97,11 @@ class FilterControls: public IFilterDialog Q_OBJECT public: FilterControls(); - void register_filter(IFilter* filter); - void unregister_filter(); + void register_filter(IFilter*) override {} + void unregister_filter() override {} private: Ui::AccelaUICFilterControls ui; void save(); - FTNoIR_Filter* accela_filter; settings_accela s; private slots: void doOK(); diff --git a/filter-accela/ftnoir_filter_accela_dialog.cpp b/filter-accela/ftnoir_filter_accela_dialog.cpp index 83114b20..89ad80aa 100644 --- a/filter-accela/ftnoir_filter_accela_dialog.cpp +++ b/filter-accela/ftnoir_filter_accela_dialog.cpp @@ -13,8 +13,7 @@ #include "spline-widget/spline-widget.hpp" #include <QDialog> -FilterControls::FilterControls() : - accela_filter(nullptr) +FilterControls::FilterControls() { ui.setupUi(this); @@ -42,30 +41,29 @@ FilterControls::FilterControls() : update_rot_dz_display(ui.rot_dz_slider->value()); update_trans_dz_display(ui.trans_dz_slider->value()); update_rot_nl_slider(s.rot_nonlinearity); -} -void FilterControls::register_filter(IFilter* filter) -{ - accela_filter = static_cast<FTNoIR_Filter*>(filter); + { //#define SPLINE_ROT_DEBUG #if defined(SPLINE_ROT_DEBUG) || defined(SPLINE_TRANS_DEBUG) + spline rot, trans; + s.make_splines(rot, trans); QDialog d; - QFunctionConfigurator r(&d); + + spline_widget r(&d); + r.set_preview_only(true); + r.setEnabled(false); r.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + #if defined(SPLINE_TRANS_DEBUG) - r.setConfig(&accela_filter->trans, ""); + r.setConfig(&trans); #else - r.setConfig(&accela_filter->rot, ""); + r.setConfig(&rot); #endif - r.setFixedSize(800, 600); + r.setFixedSize(1024, 600); d.show(); d.exec(); #endif -} - -void FilterControls::unregister_filter() -{ - accela_filter = nullptr; + } } void FilterControls::doOK() |