From 7eb9227aab7b18c9ab6fe31775f1d0b85cc5b7d0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 7 Oct 2015 20:52:44 +0200 Subject: qfc: revert to floats as in rc15 Issue: #248 Issue: #231 --- qfunctionconfigurator/functionconfig.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'qfunctionconfigurator/functionconfig.h') diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 886ce06a..25e072d2 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -19,19 +19,16 @@ class Map { private: - static constexpr int value_count = 5000; - using num = double; - using integral = std::uint32_t; - static constexpr integral integral_max = std::numeric_limits::max(); + static constexpr int value_count = 10000; struct State { QList input; - std::vector data; + std::vector data; }; int precision() const; void reload(); - num getValueInternal(int x); + float getValueInternal(int x); MyMutex _mutex; QPointF last_input_value; @@ -52,7 +49,7 @@ public: lazy_reload = true; } - num getValue(num x); + float getValue(float x); bool getLastPoint(QPointF& point); void removePoint(int i); void removeAllPoints() { -- cgit v1.2.3 From 790a9cff9a25def2370186e2a56ed30fbdbf0195 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 7 Oct 2015 21:28:00 +0200 Subject: qfc: no need to load lazily, it's received immediately --- qfunctionconfigurator/functionconfig.cpp | 20 +++++++------------- qfunctionconfigurator/functionconfig.h | 5 ++--- 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'qfunctionconfigurator/functionconfig.h') diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index f2e81b17..b93a4cbf 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -19,18 +19,12 @@ Map::Map() : _mutex(QMutex::Recursive), activep(false), max_x(0), - max_y(0), - lazy_reload(true) + max_y(0) { } float Map::getValue(float x) { QMutexLocker foo(&_mutex); - if (lazy_reload) - { - lazy_reload = false; - reload(); - } float q = x * precision(); int xi = (int)q; float yi = getValueInternal(xi); @@ -151,14 +145,14 @@ void Map::removePoint(int i) { if (i >= 0 && i < cur.input.size()) { cur.input.removeAt(i); - lazy_reload = true; + reload(); } } void Map::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); cur.input.append(pt); - lazy_reload = true; + reload(); qStableSort(cur.input.begin(), cur.input.end(), sortFn); } @@ -167,8 +161,8 @@ void Map::movePoint(int idx, QPointF pt) { if (idx >= 0 && idx < cur.input.size()) { cur.input[idx] = pt; - lazy_reload = true; - // we don't allow points to be reodered, so no sort here + reload(); + // we don't allow points to be reordered, so no sort here } } @@ -181,7 +175,7 @@ void Map::invalidate_unsaved_settings() { QMutexLocker foo(&_mutex); cur = saved; - lazy_reload = true; + reload(); } void Map::loadSettings(QSettings& settings, const QString& title) { @@ -210,7 +204,7 @@ void Map::loadSettings(QSettings& settings, const QString& title) { points.append(QPointF(maxInput(), maxOutput())); cur.input = points; - lazy_reload = true; + reload(); saved = cur; } diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 25e072d2..31aebdf6 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -37,7 +37,6 @@ private: double max_y; State cur, saved; - bool lazy_reload; public: double maxInput() const { return max_x; } double maxOutput() const { return max_y; } @@ -46,7 +45,7 @@ public: { setMaxInput(maxx); setMaxOutput(maxy); - lazy_reload = true; + reload(); } float getValue(float x); @@ -55,7 +54,7 @@ public: void removeAllPoints() { QMutexLocker foo(&_mutex); cur.input.clear(); - lazy_reload = true; + reload(); } void addPoint(QPointF pt); -- cgit v1.2.3