summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-05 20:25:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-05 20:25:40 +0200
commitf78f4b73325a9df11c80bc191f735650006bd635 (patch)
treef67f3f92a5fd75e0e64f28f58e30902c43ed6176
parentf4754d23984126de847279f4abad4ae713d9e386 (diff)
retab only
-rw-r--r--qfunctionconfigurator/functionconfig.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp
index f39562c1..7c4aaaab 100644
--- a/qfunctionconfigurator/functionconfig.cpp
+++ b/qfunctionconfigurator/functionconfig.cpp
@@ -35,51 +35,51 @@ float Map::getValue(float x) {
QMutexLocker foo(&_mutex);
int x2 = (int) (std::min<float>(std::max<float>(x, -360), 360) * MEMOIZE_PRECISION);
float ret = getValueInternal(x2);
- last_input_value.setX(x);
- last_input_value.setY(ret);
- return ret;
+ last_input_value.setX(x);
+ last_input_value.setY(ret);
+ return ret;
}
bool Map::getLastPoint(QPointF& point ) {
QMutexLocker foo(&_mutex);
- point = last_input_value;
- return activep;
+ point = last_input_value;
+ return activep;
}
float Map::getValueInternal(int x) {
float sign = x < 0 ? -1 : 1;
- x = x < 0 ? -x : x;
+ x = x < 0 ? -x : 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 if (x < 0)
+ ret = 0;
+ else if (x < sz && x >= 0)
+ ret = data[x];
+ else
+ ret = data[sz - 1];
+ 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];
+ 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() {
- if (input.size())
- qStableSort(input.begin(), input.end(), sortFn);
+ if (input.size())
+ qStableSort(input.begin(), input.end(), sortFn);
- if (input.size()) {
+ if (input.size()) {
data = std::vector<float>(MEMOIZE_PRECISION * input[input.size() - 1].x());
const int sz = data.size();
@@ -87,7 +87,7 @@ void Map::reload() {
for (int i = 0; i < sz; i++)
data[i] = -1;
- for (int k = 0; k < input[0].x() * MEMOIZE_PRECISION; k++) {
+ for (int k = 0; k < input[0].x() * MEMOIZE_PRECISION; k++) {
if (k < sz)
data[k] = input[0].y() * k / (input[0].x() * MEMOIZE_PRECISION);
}
@@ -120,7 +120,7 @@ void Map::reload() {
if (x >= 0 && x < sz)
data[x] = y;
}
- }
+ }
float last = 0;
for (int i = 0; i < sz; i++)
@@ -129,7 +129,7 @@ void Map::reload() {
data[i] = last;
last = data[i];
}
- }
+ }
}
void Map::removePoint(int i) {
@@ -143,8 +143,8 @@ void Map::removePoint(int i) {
void Map::addPoint(QPointF pt) {
QMutexLocker foo(&_mutex);
- input.append(pt);
- reload();
+ input.append(pt);
+ reload();
}
void Map::movePoint(int idx, QPointF pt) {
@@ -159,42 +159,42 @@ void Map::movePoint(int idx, QPointF pt) {
const QList<QPointF> Map::getPoints() {
QMutexLocker foo(&_mutex);
// NB can't pass by reference
- return input;
+ return input;
}
void Map::loadSettings(QSettings& settings, const QString& title) {
QMutexLocker foo(&_mutex);
QPointF newPoint;
- QList<QPointF> points;
- settings.beginGroup(QString("Curves-%1").arg(title));
-
+ QList<QPointF> points;
+ settings.beginGroup(QString("Curves-%1").arg(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);
- }
+ 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);
+ }
settings.endGroup();
- input = points;
- reload();
+ input = points;
+ reload();
}
void Map::saveSettings(QSettings& settings, const QString& title) {
QMutexLocker foo(&_mutex);
- settings.beginGroup(QString("Curves-%1").arg(title));
- int max = input.size();
- settings.setValue("point-count", max);
- for (int i = 0; i < max; i++) {
- settings.setValue(QString("point-%1-x").arg(i), input[i].x());
- settings.setValue(QString("point-%1-y").arg(i), input[i].y());
+ settings.beginGroup(QString("Curves-%1").arg(title));
+ int max = input.size();
+ settings.setValue("point-count", max);
+ for (int i = 0; i < max; i++) {
+ settings.setValue(QString("point-%1-x").arg(i), input[i].x());
+ settings.setValue(QString("point-%1-y").arg(i), input[i].y());
}
for (int i = max; true; i++)
@@ -205,5 +205,5 @@ void Map::saveSettings(QSettings& settings, const QString& title) {
settings.remove(x);
settings.remove(QString("point-%1-y").arg(i));
}
- settings.endGroup();
+ settings.endGroup();
}