summaryrefslogtreecommitdiffhomepage
path: root/qfunctionconfigurator/functionconfig.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-05 20:37:09 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-05 20:37:22 +0200
commit921853c7443060d21e18909ba806a859f8af86a5 (patch)
treed867b313037158e98d375e8f73009c03c439a834 /qfunctionconfigurator/functionconfig.cpp
parentf78f4b73325a9df11c80bc191f735650006bd635 (diff)
mapping was set to nonsense when exceeded spline bounds
Diffstat (limited to 'qfunctionconfigurator/functionconfig.cpp')
-rw-r--r--qfunctionconfigurator/functionconfig.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp
index 7c4aaaab..99b6d871 100644
--- a/qfunctionconfigurator/functionconfig.cpp
+++ b/qfunctionconfigurator/functionconfig.cpp
@@ -14,8 +14,9 @@
#include <QtAlgorithms>
#include <QtAlgorithms>
#include <QSettings>
-#include <cmath>
#include <QPixmap>
+#include <cmath>
+#include <algorithm>
void Map::setTrackingActive(bool blnActive)
{
@@ -48,18 +49,14 @@ bool Map::getLastPoint(QPointF& point ) {
float Map::getValueInternal(int x) {
float sign = x < 0 ? -1 : 1;
- x = x < 0 ? -x : x;
+ x = fabs(x);
float ret;
int sz = data.size();
- if (sz == 0)
- ret = 0;
- else if (x < 0)
- ret = 0;
- else if (x < sz && x >= 0)
- ret = data[x];
- else
- ret = data[sz - 1];
- return ret * sign;
+ if (sz == 0)
+ ret = 0;
+ else
+ ret = std::max(std::min(x, sz-1), 0);
+ return ret * sign;
}
static __inline QPointF ensureInBounds(QList<QPointF> points, int i) {