diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-24 13:49:37 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-24 13:49:37 +0200 |
commit | 6baa8ca1070612e5d7cbae7aa62cbe4a9e51ad40 (patch) | |
tree | caab7af5c2fe22dcfbd32ff009b61698ac671837 | |
parent | f6d3db98a2aac3b3e41014dc7a6c050c8ca79761 (diff) | |
parent | 948fb5ef0ffd6a83675763d80053a433e09aea06 (diff) |
Merge branch 'unstable' into trackhat-ui
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 10 | ||||
-rw-r--r-- | qfunctionconfigurator/functionconfig.cpp | 38 | ||||
-rw-r--r-- | qfunctionconfigurator/functionconfig.h | 14 | ||||
-rw-r--r-- | qfunctionconfigurator/qfunctionconfigurator.cpp | 13 |
4 files changed, 37 insertions, 38 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 31534ad3..95b90a46 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -10,15 +10,13 @@ #include <QDebug> #include <QMutexLocker> #include "opentrack/plugin-api.hpp" -using namespace std; static constexpr double rot_gains[][2] = { { 2.66, 110 }, - { 2.33, 80 }, - { 2, 50 }, - { 1.66, 30 }, + { 2.0, 50 }, + { 1.66, 29 }, { 1.33, 15 }, - { 1, 5 }, + { 1, 6 }, { .66, 1.4 }, { .33, .4 }, { 0, 0 }, @@ -96,7 +94,7 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double vec = in - last_output[i]; const double dz = i >= 3 ? rot_dz : trans_dz; - const double vec_ = max(0., fabs(vec) - dz); + const double vec_ = std::max(0., fabs(vec) - dz); const double thres = i >= 3 ? rot_t : trans_t; const double val = m.getValue(vec_ / thres); const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val; diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 264097ab..2b9d3a07 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -54,17 +54,17 @@ float Map::getValueInternal(int x) { return ret * sign; } -static __inline QPointF ensureInBounds(QList<QPointF> points, int i) { - int siz = points.size(); - if (siz == 0 || i < 0) - return QPointF(0, 0); - if (siz > i) - return points[i]; - return points[siz - 1]; +static QPointF ensureInBounds(QList<QPointF> points, int i) { + int siz = points.size(); + if (siz == 0 || i < 0) + return QPointF(0, 0); + if (siz > i) + return points[i]; + return points[siz - 1]; } static bool sortFn(const QPointF& one, const QPointF& two) { - return one.x() < two.x(); + return one.x() < two.x(); } void Map::reload() { @@ -149,8 +149,8 @@ void Map::removePoint(int i) { void Map::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); - cur.input.append(pt); - reload(); + cur.input.append(pt); + reload(); } void Map::movePoint(int idx, QPointF pt) { @@ -182,15 +182,15 @@ void Map::loadSettings(QSettings& settings, const QString& title) { int max = settings.value("point-count", 0).toInt(); for (int i = 0; i < max; i++) { - newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(), - settings.value(QString("point-%1-y").arg(i), 0).toFloat()); - if (newPoint.x() > max_x) { - newPoint.setX(max_x); - } - if (newPoint.y() > max_y) { - newPoint.setY(max_y); - } - points.append(newPoint); + newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(), + settings.value(QString("point-%1-y").arg(i), 0).toFloat()); + if (newPoint.x() > max_x) { + newPoint.setX(max_x); + } + if (newPoint.y() > max_y) { + newPoint.setY(max_y); + } + points.append(newPoint); } settings.endGroup(); diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index f7930cb2..7ead2c5d 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,15 +32,15 @@ private: MyMutex _mutex; QPointF last_input_value; volatile bool activep; - int max_x; - int max_y; + double max_x; + double max_y; State cur, saved; public: - int maxInput() const { return max_x; } - int maxOutput() const { return max_y; } + double maxInput() const { return max_x; } + double maxOutput() const { return max_y; } Map(); - Map(int maxx, int maxy) + Map(double maxx, double maxy) { setMaxInput(maxx); setMaxOutput(maxy); @@ -58,10 +58,10 @@ public: void addPoint(QPointF pt); void movePoint(int idx, QPointF pt); const QList<QPointF> getPoints(); - void setMaxInput(int MaxInput) { + void setMaxInput(double MaxInput) { max_x = MaxInput; } - void setMaxOutput(int MaxOutput) { + void setMaxOutput(double MaxOutput) { max_y = MaxOutput; } diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 3d86216e..d3525c1d 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -22,7 +22,8 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : void QFunctionConfigurator::setConfig(Map* config, const QString& name) { mem<QSettings> iniFile = group::ini_file(); - config->loadSettings(*iniFile, name); + if (name != "") + config->loadSettings(*iniFile, name); _config = config; _draw_function = true; update_range(); @@ -49,8 +50,8 @@ void QFunctionConfigurator::drawBackground() QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine); const int xstep = 10, ystep = 10; - const int maxx = _config->maxInput(); - const int maxy = _config->maxOutput(); + const double maxx = _config->maxInput(); + const double maxy = _config->maxOutput(); // horizontal grid for (int i = 0; i < maxy; i += xstep) @@ -68,7 +69,7 @@ void QFunctionConfigurator::drawBackground() } { - const int i = maxy; + const double i = maxy; double y = pixel_bounds.height() - i * c.y() + pixel_bounds.y(); drawLine(&painter, QPointF(pixel_bounds.x(), y), @@ -97,7 +98,7 @@ void QFunctionConfigurator::drawBackground() text); } { - const int i = maxx; + const double i = maxx; double x = pixel_bounds.x() + i * c.x(); drawLine(&painter, QPointF(x, pixel_bounds.y()), @@ -132,7 +133,7 @@ void QFunctionConfigurator::drawFunction() QPen pen(spline_color, 1.2, Qt::SolidLine); const double max = _config->maxInput(); - const double step = std::max(1e-2, max / 500.); + const double step = std::max(1e-3, max / 1000.); QPointF prev = point_to_pixel(QPointF(0, 0)); for (double i = 0; i < max; i += step) { |